本文整理汇总了Python中azure.servicemanagement.ServiceManagementService.delete_storage_account方法的典型用法代码示例。如果您正苦于以下问题:Python ServiceManagementService.delete_storage_account方法的具体用法?Python ServiceManagementService.delete_storage_account怎么用?Python ServiceManagementService.delete_storage_account使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类azure.servicemanagement.ServiceManagementService
的用法示例。
在下文中一共展示了ServiceManagementService.delete_storage_account方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: deprovision
# 需要导入模块: from azure.servicemanagement import ServiceManagementService [as 别名]
# 或者: from azure.servicemanagement.ServiceManagementService import delete_storage_account [as 别名]
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: AffinityGroupManagementServiceTest
# 需要导入模块: from azure.servicemanagement import ServiceManagementService [as 别名]
# 或者: from azure.servicemanagement.ServiceManagementService import delete_storage_account [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: StorageManagementServiceTest
# 需要导入模块: from azure.servicemanagement import ServiceManagementService [as 别名]
# 或者: from azure.servicemanagement.ServiceManagementService import delete_storage_account [as 别名]
class StorageManagementServiceTest(AzureTestCase):
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.storage_account_name = getUniqueNameBasedOnCurrentTime('utstorage')
def tearDown(self):
try:
self.sms.delete_storage_account(self.storage_account_name)
except: pass
#--Helpers-----------------------------------------------------------------
def _wait_for_async(self, request_id):
count = 0
result = self.sms.get_operation_status(request_id)
while result.status == 'InProgress':
count = count + 1
if count > 120:
self.assertTrue(False, 'Timed out waiting for async operation to complete.')
time.sleep(5)
result = self.sms.get_operation_status(request_id)
self.assertEqual(result.status, 'Succeeded')
def _create_storage_account(self, name):
result = self.sms.create_storage_account(name, name + 'description', name + 'label', None, 'West US', False, {'ext1':'val1', 'ext2':42})
self._wait_for_async(result.request_id)
def _storage_account_exists(self, name):
try:
props = self.sms.get_storage_account_properties(name)
return props is not None
except:
return False
#--Test cases for storage accounts -----------------------------------
def test_list_storage_accounts(self):
# Arrange
self._create_storage_account(self.storage_account_name)
# Act
result = self.sms.list_storage_accounts()
# Assert
self.assertIsNotNone(result)
self.assertTrue(len(result) > 0)
storage = None
for temp in result:
if temp.service_name == self.storage_account_name:
storage = temp
break
self.assertIsNotNone(storage)
self.assertIsNotNone(storage.service_name)
self.assertIsNone(storage.storage_service_keys)
self.assertIsNotNone(storage.storage_service_properties)
self.assertIsNotNone(storage.storage_service_properties.affinity_group)
self.assertIsNotNone(storage.storage_service_properties.description)
self.assertIsNotNone(storage.storage_service_properties.geo_primary_region)
self.assertIsNotNone(storage.storage_service_properties.geo_replication_enabled)
self.assertIsNotNone(storage.storage_service_properties.geo_secondary_region)
self.assertIsNotNone(storage.storage_service_properties.label)
self.assertIsNotNone(storage.storage_service_properties.last_geo_failover_time)
self.assertIsNotNone(storage.storage_service_properties.location)
self.assertIsNotNone(storage.storage_service_properties.status)
self.assertIsNotNone(storage.storage_service_properties.status_of_primary)
self.assertIsNotNone(storage.storage_service_properties.status_of_secondary)
self.assertIsNotNone(storage.storage_service_properties.endpoints)
self.assertTrue(len(storage.storage_service_properties.endpoints) > 0)
self.assertIsNotNone(storage.extended_properties)
self.assertTrue(len(storage.extended_properties) > 0)
def test_get_storage_account_properties(self):
# Arrange
self._create_storage_account(self.storage_account_name)
# Act
result = self.sms.get_storage_account_properties(self.storage_account_name)
# Assert
self.assertIsNotNone(result)
self.assertEqual(result.service_name, self.storage_account_name)
self.assertIsNotNone(result.url)
self.assertIsNone(result.storage_service_keys)
self.assertIsNotNone(result.storage_service_properties)
self.assertIsNotNone(result.storage_service_properties.affinity_group)
self.assertIsNotNone(result.storage_service_properties.description)
self.assertIsNotNone(result.storage_service_properties.geo_primary_region)
self.assertIsNotNone(result.storage_service_properties.geo_replication_enabled)
self.assertIsNotNone(result.storage_service_properties.geo_secondary_region)
self.assertIsNotNone(result.storage_service_properties.label)
self.assertIsNotNone(result.storage_service_properties.last_geo_failover_time)
self.assertIsNotNone(result.storage_service_properties.location)
self.assertIsNotNone(result.storage_service_properties.status)
#.........这里部分代码省略.........
示例4: Deployment
# 需要导入模块: from azure.servicemanagement import ServiceManagementService [as 别名]
# 或者: from azure.servicemanagement.ServiceManagementService import delete_storage_account [as 别名]
#.........这里部分代码省略.........
)
network_config = ConfigurationSet()
network_config.configuration_set_type = 'NetworkConfiguration'
ssh_endpoint = ConfigurationSetInputEndpoint(name='SSH',
protocol='TCP',
port=u'22',
local_port=u'22')
network_config.input_endpoints.input_endpoints.append(ssh_endpoint)
result = self.sms.create_virtual_machine_deployment(service_name=service_name,
deployment_name=service_name,
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)):