本文整理汇总了Python中azure.servicemanagement.ServiceManagementService.delete_hosted_service方法的典型用法代码示例。如果您正苦于以下问题:Python ServiceManagementService.delete_hosted_service方法的具体用法?Python ServiceManagementService.delete_hosted_service怎么用?Python ServiceManagementService.delete_hosted_service使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类azure.servicemanagement.ServiceManagementService
的用法示例。
在下文中一共展示了ServiceManagementService.delete_hosted_service方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_machine
# 需要导入模块: from azure.servicemanagement import ServiceManagementService [as 别名]
# 或者: from azure.servicemanagement.ServiceManagementService import delete_hosted_service [as 别名]
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
示例2: AffinityGroupManagementServiceTest
# 需要导入模块: from azure.servicemanagement import ServiceManagementService [as 别名]
# 或者: from azure.servicemanagement.ServiceManagementService import delete_hosted_service [as 别名]
class AffinityGroupManagementServiceTest(AzureTestCase):
def setUp(self):
self.sms = ServiceManagementService(credentials.getSubscriptionId(),
credentials.getManagementCertFile())
self.sms.set_proxy(credentials.getProxyHost(),
credentials.getProxyPort(),
credentials.getProxyUser(),
credentials.getProxyPassword())
self.affinity_group_name = getUniqueNameBasedOnCurrentTime('utaffgrp')
self.hosted_service_name = None
self.storage_account_name = None
def tearDown(self):
try:
if self.hosted_service_name is not None:
self.sms.delete_hosted_service(self.hosted_service_name)
except: pass
try:
if self.storage_account_name is not None:
self.sms.delete_storage_account(self.storage_account_name)
except: pass
try:
self.sms.delete_affinity_group(self.affinity_group_name)
except: pass
#--Helpers-----------------------------------------------------------------
def _create_affinity_group(self, name):
result = self.sms.create_affinity_group(name, 'tstmgmtaffgrp', 'West US', 'tstmgmt affinity group')
self.assertIsNone(result)
def _affinity_group_exists(self, name):
try:
props = self.sms.get_affinity_group_properties(name)
return props is not None
except:
return False
#--Test cases for affinity groups ------------------------------------
def test_list_affinity_groups(self):
# Arrange
self._create_affinity_group(self.affinity_group_name)
# Act
result = self.sms.list_affinity_groups()
# Assert
self.assertIsNotNone(result)
self.assertTrue(len(result) > 0)
group = None
for temp in result:
if temp.name == self.affinity_group_name:
group = temp
break
self.assertIsNotNone(group)
self.assertIsNotNone(group.name)
self.assertIsNotNone(group.label)
self.assertIsNotNone(group.description)
self.assertIsNotNone(group.location)
self.assertIsNotNone(group.capabilities)
self.assertTrue(len(group.capabilities) > 0)
def test_get_affinity_group_properties(self):
# Arrange
self.hosted_service_name = getUniqueNameBasedOnCurrentTime('utsvc')
self.storage_account_name = getUniqueNameBasedOnCurrentTime('utstorage')
self._create_affinity_group(self.affinity_group_name)
self.sms.create_hosted_service(self.hosted_service_name, 'affgrptestlabel', 'affgrptestdesc', None, self.affinity_group_name)
self.sms.create_storage_account(self.storage_account_name, self.storage_account_name + 'desc', self.storage_account_name + 'label', self.affinity_group_name)
# Act
result = self.sms.get_affinity_group_properties(self.affinity_group_name)
# Assert
self.assertIsNotNone(result)
self.assertEqual(result.name, self.affinity_group_name)
self.assertIsNotNone(result.label)
self.assertIsNotNone(result.description)
self.assertIsNotNone(result.location)
self.assertIsNotNone(result.hosted_services[0])
self.assertEqual(result.hosted_services[0].service_name, self.hosted_service_name)
self.assertEqual(result.hosted_services[0].hosted_service_properties.affinity_group, self.affinity_group_name)
# not sure why azure does not return any storage service
self.assertTrue(len(result.capabilities) > 0)
def test_create_affinity_group(self):
# Arrange
label = 'tstmgmtaffgrp'
description = 'tstmgmt affinity group'
# Act
result = self.sms.create_affinity_group(self.affinity_group_name, label, 'West US', description)
# Assert
#.........这里部分代码省略.........
示例3: __init__
# 需要导入模块: from azure.servicemanagement import ServiceManagementService [as 别名]
# 或者: from azure.servicemanagement.ServiceManagementService import delete_hosted_service [as 别名]
class AzureServicesManager:
# Storage
container = 'vhds'
windows_blob_url = 'blob.core.windows.net'
# Linux
linux_user = 'azureuser'
linux_pass = 'Test123#'
location = 'West US'
# SSH Keys
def __init__(self, subscription_id, cert_file):
self.subscription_id = subscription_id
self.cert_file = cert_file
self.sms = ServiceManagementService(self.subscription_id, self.cert_file)
@property
def sms(self):
return self.sms
def list_locations(self):
locations = self.sms.list_locations()
for location in locations:
print location
def list_images(self):
return self.sms.list_os_images()
@utils.resource_not_found_handler
def get_hosted_service(self, service_name):
resp = self.sms.get_hosted_service_properties(service_name)
properties = resp.hosted_service_properties
return properties.__dict__
def delete_hosted_service(self, service_name):
res = self.sms.check_hosted_service_name_availability(service_name)
if not res.result:
return
self.sms.delete_hosted_service(service_name)
def create_hosted_service(self, os_user, service_name=None, random=False):
if not service_name:
service_name = self.generate_cloud_service_name(os_user, random)
available = False
while not available:
res = self.sms.check_hosted_service_name_availability(service_name)
if not res.result:
service_name = self.generate_cloud_service_name(os_user,
random)
else:
available = True
self.sms.create_hosted_service(service_name=service_name,
label=service_name,
location='West US')
return service_name
def create_virtual_machine(self, service_name, vm_name, image_name, role_size):
media_link = self._get_media_link(vm_name)
# Linux VM configuration
hostname = '-'.join((vm_name, 'host'))
linux_config = LinuxConfigurationSet(hostname,
self.linux_user,
self.linux_pass,
True)
# Hard disk for the OS
os_hd = OSVirtualHardDisk(image_name, media_link)
# Create vm
result = self.sms.create_virtual_machine_deployment(
service_name=service_name, deployment_name=vm_name,
deployment_slot='production', label=vm_name,
role_name=vm_name, system_config=linux_config,
os_virtual_hard_disk=os_hd,
role_size=role_size
)
request_id = result.request_id
return {
'request_id': request_id,
'media_link': media_link
}
def delete_virtual_machine(self, service_name, vm_name):
resp = self.sms.delete_deployment(service_name, vm_name, True)
self.sms.wait_for_operation_status(resp.request_id)
result = self.sms.delete_hosted_service(service_name)
return result
def generate_cloud_service_name(self, os_user=None, random=False):
if random:
return utils.generate_random_name(10)
return '-'.join((os_user, utils.generate_random_name(6)))
#.........这里部分代码省略.........
示例4: Deployment
# 需要导入模块: from azure.servicemanagement import ServiceManagementService [as 别名]
# 或者: from azure.servicemanagement.ServiceManagementService import delete_hosted_service [as 别名]
#.........这里部分代码省略.........
deployment_slot='Production',
label=vm_hostname,
role_name=vm_hostname,
system_config=linux_config,
os_virtual_hard_disk=os_hd,
network_config=network_config,
availability_set_name=None,
data_virtual_hard_disks=None,
role_size=self.config.getBuildInstanceRoleSize())
self._wait_for_operation_success(result.request_id, timeout=self.config.getAzureOperationTimeout())
self._wait_for_role_instance_status(vm_hostname, service_name, 'ReadyRole',
self.config.getAzureOperationTimeout())
logger.info("Role instance %s has been created.", vm_hostname)
def _deleteStorageAccount(self, name):
"""
Deletes the storage account for the web site.
"""
logger.info("Attempting to delete storage account %s.", name)
if self._resource_exists(lambda: self.sms.get_storage_account_properties(name)) == False:
logger.warn("Storage account %s not found: nothing to delete.", name)
else:
self.sms.delete_storage_account(name)
logger.info("Storage account %s deleted.", name)
def _deleteService(self, name):
"""
Deletes the specified cloud service.
"""
logger.info("Attempting to delete cloud service %s.", name)
if self._resource_exists(lambda: self.sms.get_hosted_service_properties(name)) == False:
logger.warn("Cloud service %s not found: nothing to delete.", name)
else:
self.sms.delete_hosted_service(name)
logger.info("Cloud service %s deleted.", name)
def _deleteAffinityGroup(self):
"""
Deletes the affinity group for the web site.
"""
name = self.config.getAffinityGroupName()
logger.info("Attempting to delete affinity group %s.", name)
if self._resource_exists(lambda: self.sms.get_affinity_group_properties(name)) == False:
logger.warn("Affinity group %s not found: nothing to delete.", name)
else:
self.sms.delete_affinity_group(name)
logger.info("Affinity group %s deleted.", name)
def _ensureServiceBusNamespaceExists(self):
"""
Creates the Azure Service Bus Namespace if it does not exist.
"""
name = self.config.getServiceBusNamespace()
logger.info("Checking for existence of service bus namespace (name=%s).", name)
if self._resource_exists(lambda: self.sbms.get_namespace(name)):
logger.warn("A namespace named %s already exists.", name)
else:
self.sbms.create_namespace(name, self.config.getServiceLocation())
self._wait_for_namespace_active(name)
logger.info("Created namespace %s.", name)
def _ensureServiceBusQueuesExist(self):
"""
Creates Azure service bus queues required by the service.
"""
logger.info("Checking for existence of Service Bus Queues.")