本文整理汇总了Python中azure.servicemanagement.ServiceManagementService类的典型用法代码示例。如果您正苦于以下问题:Python ServiceManagementService类的具体用法?Python ServiceManagementService怎么用?Python ServiceManagementService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ServiceManagementService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: deprovision
def deprovision(instance_id):
"""
Deprovision an existing instance of this service
DELETE /v2/service_instances/<instance_id>:
<instance_id> is the Cloud Controller provided
value used to provision the instance
return:
As of API 2.3, an empty JSON document
is expected
"""
global subscription_id
global cert
global account_name
global account_key
if account_name and account_key:
blob_service = BlobService(account_name, account_key)
container_name = '{0}-{1}'.format(CONTAINER_NAME_PREFIX, instance_id)
blob_service.delete_container(container_name)
if account_name.startswith(STORAGE_ACCOUNT_NAME_PREFIX):
sms = ServiceManagementService(subscription_id, cert_file)
sms.delete_storage_account(account_name)
return jsonify({})
示例2: main
def main(argv):
config = ConfigParser.ConfigParser()
#config.read([splunkHome + '/etc/apps/oovoo/config/app.conf'])
config.read('/root/oovoo/config/app.conf')
sms = ServiceManagementService(config.get('Azure','subscription_id'),config.get('Azure','certificate'))
services = sms.list_hosted_services()
for oneService in services:
print('Service name:' + oneService.service_name)
print 'Finish...'
示例3: delete_machine
def delete_machine(self, instance_ids, deployment_name=None,
cleanup_service=None, **kwargs):
sms = ServiceManagementService(self.profile.username,
self.cert_path)
for inst in instance_ids:
try:
sms.delete_deployment(service_name=inst,
deployment_name=deployment_name)
if cleanup_service:
sms.delete_hosted_service(service_name=inst)
except Exception, ex:
self.log.exception(ex)
return self.FAIL
示例4: __init__
def __init__(self):
"""Main execution path."""
# Inventory grouped by display group
self.inventory = {}
# Index of deployment name -> host
self.index = {}
# Read settings and parse CLI arguments
self.read_settings()
self.read_environment()
self.parse_cli_args()
# Initialize Azure ServiceManagementService
self.sms = ServiceManagementService(self.subscription_id, self.cert_path)
# Cache
if self.args.refresh_cache:
self.do_api_calls_update_cache()
elif not self.is_cache_valid():
self.do_api_calls_update_cache()
if self.args.list_images:
data_to_print = self.json_format_dict(self.get_images(), True)
elif self.args.list:
# Display list of nodes for inventory
if len(self.inventory) == 0:
data_to_print = self.get_inventory_from_cache()
else:
data_to_print = self.json_format_dict(self.inventory, True)
print data_to_print
示例5: setUp
def setUp(self):
self.sms = ServiceManagementService(credentials.getSubscriptionId(),
credentials.getManagementCertFile())
set_service_options(self.sms)
self.affinity_group_name = getUniqueName('utaffgrp')
self.hosted_service_name = None
self.storage_account_name = None
示例6: setUp
def setUp(self):
proxy_host = credentials.getProxyHost()
proxy_port = credentials.getProxyPort()
self.sms = ServiceManagementService(credentials.getSubscriptionId(), credentials.getManagementCertFile())
if proxy_host:
self.sms.set_proxy(proxy_host, proxy_port)
self.management_certificate_name = getUniqueNameBasedOnCurrentTime('utmgmtcert')
开发者ID:Bunkerbewohner,项目名称:azure-sdk-for-python,代码行数:9,代码来源:test_managementcertificatemanagementservice.py
示例7: setUp
def setUp(self):
self.sms = ServiceManagementService(credentials.getSubscriptionId(),
credentials.getManagementCertFile())
self.sms.set_proxy(credentials.getProxyHost(),
credentials.getProxyPort(),
credentials.getProxyUser(),
credentials.getProxyPassword())
self.storage_account_name = getUniqueNameBasedOnCurrentTime('utstorage')
示例8: setUp
def setUp(self):
self.sms = ServiceManagementService(credentials.getSubscriptionId(),
credentials.getManagementCertFile())
self.sms.set_proxy(credentials.getProxyHost(),
credentials.getProxyPort(),
credentials.getProxyUser(),
credentials.getProxyPassword())
self.certificate_thumbprints = []
示例9: azure_add_endpoints
def azure_add_endpoints(name, portConfigs):
sms = ServiceManagementService(AZURE_SUBSCRIPTION_ID, AZURE_CERTIFICATE)
role = sms.get_role(name, name, name)
network_config = role.configuration_sets[0]
for i, portConfig in enumerate(portConfigs):
network_config.input_endpoints.input_endpoints.append(
ConfigurationSetInputEndpoint(
name=portConfig["service"],
protocol=portConfig["protocol"],
port=portConfig["port"],
local_port=portConfig["local_port"],
load_balanced_endpoint_set_name=None,
enable_direct_server_return=True if portConfig["protocol"] == "udp" else False,
idle_timeout_in_minutes=None if portConfig["protocol"] == "udp" else 4)
)
try:
sms.update_role(name, name, name, network_config=network_config)
except AzureHttpError as e:
debug.warn("Exception opening ports for %s: %r" % (name, e))
示例10: setUp
def setUp(self):
proxy_host = credentials.getProxyHost()
proxy_port = credentials.getProxyPort()
self.sms = ServiceManagementService(credentials.getSubscriptionId(), credentials.getManagementCertFile())
if proxy_host:
self.sms.set_proxy(proxy_host, proxy_port)
self.affinity_group_name = getUniqueNameBasedOnCurrentTime('utaffgrp')
self.hosted_service_name = None
self.storage_account_name = None
示例11: _deleteVirtualMachines
def _deleteVirtualMachines(self, service_name):
"""
Deletes the VMs in the given cloud service.
"""
if self._resource_exists(lambda: self.sms.get_deployment_by_name(service_name, service_name)) == False:
logger.warn("Deployment %s not found: no VMs to delete.", service_name)
else:
logger.info("Attempting to delete deployment %s.", service_name)
# Get set of role instances before we remove them
role_instances = self._getRoleInstances(service_name)
def update_request(request):
"""
A filter to intercept the HTTP request sent by the ServiceManagementService
so we can take advantage of a newer feature ('comp=media') in the delete deployment API
(see http://msdn.microsoft.com/en-us/library/windowsazure/ee460812.aspx)
"""
hdrs = []
for name, value in request.headers:
if 'x-ms-version' == name:
value = '2013-08-01'
hdrs.append((name, value))
request.headers = hdrs
request.path = request.path + '?comp=media'
#pylint: disable=W0212
response = self.sms._filter(request)
return response
svc = ServiceManagementService(self.sms.subscription_id, self.sms.cert_file)
#pylint: disable=W0212
svc._filter = update_request
result = svc.delete_deployment(service_name, service_name)
logger.info("Deployment %s deletion in progress: waiting for delete_deployment operation.", service_name)
self._wait_for_operation_success(result.request_id)
logger.info("Deployment %s deletion in progress: waiting for VM disks to be removed.", service_name)
# Now wait for the disks to disappear
for role_instance_name in role_instances.keys():
disk_name = "{0}.vhd".format(role_instance_name)
self._wait_for_disk_deletion(disk_name)
logger.info("Deployment %s deleted.", service_name)
示例12: __init__
def __init__(self):
"""Main execution path."""
# Inventory grouped by display group
self.inventory = {}
# Index of deployment name -> host
self.index = {}
self.host_metadata = {}
# Cache setting defaults.
# These can be overridden in settings (see `read_settings`).
cache_dir = os.path.expanduser('~')
self.cache_path_cache = os.path.join(cache_dir, '.ansible-azure.cache')
self.cache_path_index = os.path.join(cache_dir, '.ansible-azure.index')
self.cache_max_age = 0
# Read settings and parse CLI arguments
self.read_settings()
self.read_environment()
self.parse_cli_args()
# Initialize Azure ServiceManagementService
self.sms = ServiceManagementService(self.subscription_id, self.cert_path)
# Cache
if self.args.refresh_cache:
self.do_api_calls_update_cache()
elif not self.is_cache_valid():
self.do_api_calls_update_cache()
if self.args.list_images:
data_to_print = self.json_format_dict(self.get_images(), True)
elif self.args.list or self.args.host:
# Display list of nodes for inventory
if len(self.inventory) == 0:
data = json.loads(self.get_inventory_from_cache())
else:
data = self.inventory
if self.args.host:
data_to_print = self.get_host(self.args.host)
else:
# Add the `['_meta']['hostvars']` information.
hostvars = {}
if len(data) > 0:
for host in set([h for hosts in data.values() for h in hosts if h]):
hostvars[host] = self.get_host(host, jsonify=False)
data['_meta'] = {'hostvars': hostvars}
# JSONify the data.
data_to_print = self.json_format_dict(data, pretty=True)
print(data_to_print)
示例13: launch_node
def launch_node(node_id, creds, params, init, ssh_username, ssh_private_key):
# "pip install azure"
sms = ServiceManagementService(
subscription_id='69581868-8a08-4d98-a5b0-1d111c616fc3',
cert_file='/Users/dgriffin/certs/iOSWAToolkit.pem')
for i in sms.list_os_images():
print 'I is ', i.name, ' -- ', i.label, ' -- ', i.location, ' -- ', i.media_link
media_link = \
'http://opdemandstorage.blob.core.windows.net/communityimages/' + \
'b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu_DAILY_BUILD-' + \
'precise-12_04_2-LTS-amd64-server-20130702-en-us-30GB.vhd'
config = LinuxConfigurationSet(user_name="ubuntu", user_password="opdemand")
hard_disk = OSVirtualHardDisk(
'b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu_DAILY_BUILD-' +
'precise-12_04_2-LTS-amd64-server-20130702-en-us-30GB',
media_link, disk_label='opdemandservice')
ret = sms.create_virtual_machine_deployment(
'opdemandservice', 'deploy1', 'production', 'opdemandservice2',
'opdemandservice3', config, hard_disk)
# service_name, deployment_name, deployment_slot, label, role_name
# system_config, os_virtual_hard_disk
print 'Ret ', ret
return sms
示例14: create_machine
def create_machine(self, name, region='West US',
image=None, role_size='Small',
min_count=1, max_count=1,
media='storage_url_blob_cloudrunner',
username='', password='', ssh_pub_key='',
server=CR_SERVER,
cleanup=None, **kwargs):
self.log.info("Registering Azure machine [%s::%s] for [%s]" %
(name, image, CR_SERVER))
try:
sms = ServiceManagementService(self.profile.username,
self._cert_path)
server_config = LinuxConfigurationSet('myhostname', 'myuser',
'mypassword', True)
media_link = "%s__%s" % (media, name)
os_hd = OSVirtualHardDisk(image, media_link)
res = sms.create_virtual_machine_deployment(
service_name=name,
deployment_name=name,
deployment_slot='production',
label=name,
role_name=name,
system_config=server_config,
os_virtual_hard_disk=os_hd,
role_size='Small')
instance_ids = []
meta = {}
if not res:
return self.FAIL, [], {}
meta['deployment_name'] = name
meta['cleanup_service'] = cleanup in ['1', 'True', 'true']
return self.OK, instance_ids, meta
except Exception, ex:
self.log.exception(ex)
return self.FAIL, [], {}
示例15: __init__
def __init__(self, subscription_id=None, key_file=None, **kwargs):
"""
subscription_id contains the Azure subscription id
in the form of GUID key_file contains
the Azure X509 certificate in .pem form
"""
self.subscription_id = subscription_id
self.key_file = key_file
self.sms = ServiceManagementService(subscription_id, key_file)
super(AzureNodeDriver, self).__init__(
self.subscription_id,
self.key_file,
secure=True,
**kwargs)