本文整理汇总了Python中azure.servicemanagement.ServiceManagementService.list_role_sizes方法的典型用法代码示例。如果您正苦于以下问题:Python ServiceManagementService.list_role_sizes方法的具体用法?Python ServiceManagementService.list_role_sizes怎么用?Python ServiceManagementService.list_role_sizes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类azure.servicemanagement.ServiceManagementService
的用法示例。
在下文中一共展示了ServiceManagementService.list_role_sizes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AzureNodeDriver
# 需要导入模块: from azure.servicemanagement import ServiceManagementService [as 别名]
# 或者: from azure.servicemanagement.ServiceManagementService import list_role_sizes [as 别名]
class AzureNodeDriver(NodeDriver):
name = "Azure Node Provider"
type = Provider.AZURE
website = 'http://windowsazure.com'
sms = None
rolesizes = None
NODE_STATE_MAP = {
'RoleStateUnknown': NodeState.UNKNOWN,
'CreatingVM': NodeState.PENDING,
'StartingVM': NodeState.PENDING,
'CreatingRole': NodeState.PENDING,
'StartingRole': NodeState.PENDING,
'ReadyRole': NodeState.RUNNING,
'BusyRole': NodeState.PENDING,
'StoppingRole': NodeState.PENDING,
'StoppingVM': NodeState.PENDING,
'DeletingVM': NodeState.PENDING,
'StoppedVM': NodeState.STOPPED,
'RestartingRole': NodeState.REBOOTING,
'CyclingRole': NodeState.TERMINATED,
'FailedStartingRole': NodeState.TERMINATED,
'FailedStartingVM': NodeState.TERMINATED,
'UnresponsiveRole': NodeState.TERMINATED,
'StoppedDeallocated': NodeState.TERMINATED,
}
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)
def list_sizes(self):
"""
Lists all sizes from azure
:rtype: ``list`` of :class:`NodeSize`
"""
if self.rolesizes is None:
# refresh rolesizes
data = self.sms.list_role_sizes()
self.rolesizes = [self._to_node_size(i) for i in data]
return self.rolesizes
def list_images(self, location=None):
"""
Lists all sizes from azure
:rtype: ``list`` of :class:`NodeSize`
"""
data = self.sms.list_os_images()
images = [self._to_image(i) for i in data]
if location is not None:
images = [image for image in images
if location in image.extra["location"]]
return images
def list_locations(self):
"""
Lists all Location from azure
:rtype: ``list`` of :class:`NodeLocation`
"""
data = self.sms.list_locations()
locations = [self._to_location(i) for i in data]
return locations
def list_virtual_net(self):
"""
List all VirtualNetworkSites
:rtype: ``list`` of :class:`VirtualNetwork`
"""
data = self.sms.list_virtual_network_sites()
virtualnets = [self._to_virtual_network(i) for i in data]
return virtualnets
def create_node(self,
name,
image,
size,
storage,
service_name,
vm_user,
vm_password,
location=None,
affinity_group=None,
#.........这里部分代码省略.........
示例2: ServiceManagementService
# 需要导入模块: from azure.servicemanagement import ServiceManagementService [as 别名]
# 或者: from azure.servicemanagement.ServiceManagementService import list_role_sizes [as 别名]
)
sms = ServiceManagementService(subscription_id, pem_file)
if not os.path.exists('./azure/data'):
os.mkdir('./azure/data')
result = sms.list_os_images()
process_sms_list(result.images, './azure/data/azure_os_images.csv')
print ('Azure OS images saved in azure_os_images.csv')
result = sms.list_vm_images()
process_sms_list(result.vm_images, './azure/data/azure_vm_images.csv')
print ('Azure VM images saved in azure_vm_images.csv')
result = sms.list_role_sizes()
process_sms_list(result.role_sizes, './azure/data/azure_role_sizes.csv')
print ('Azure Role sizes saved in azure_role_sizes.csv')
result = sms.list_locations()
process_sms_list(result.locations, './azure/data/azure_locations.csv')
print ('Azure Locations saved in azure_locations.csv')
result = sms.list_storage_accounts()
process_sms_list(result.storage_services, './azure/data/azure_storage_accounts.csv')
print ('Azure Storage accounts saved in azure_storage_accounts.csv')
# Put this result always next to for loop!
result = sms.list_hosted_services()
process_sms_list(result.hosted_services, './azure/data/azure_hosted_services.csv')
print ('Azure Hosted services saved in azure_hosted_services.csv')