[英]is there a way of getting the vcpu amount of a vm in azure python sdk api?
how to get in python azure sdk ComputeManagementClient
object the number of VCPU it has ? 如何获取python azure sdk
ComputeManagementClient
对象中具有的VCPU数量? code example : 代码示例:
from azure.mgmt.compute import ComputeManagementClient
compute_client = ComputeManagementClient(self.credentials, SUBSCRIPTION_ID)
vm = compute_client.virtual_machines.get(resource_group, name, expand='instanceView')
vm.hardware_profile.vm_size # here i have the vm type in a string
The short answer is yes. 简短的答案是肯定的。 After you get the VM size, then you can get the VCPU number from the exact size.
获取虚拟机大小后,即可从确切大小中获取VCPU号。 The example code here:
此处的示例代码:
vm = compute_client.virtual_machines.get(resource_group, name, expand='instanceView')
sizeList = compute_client.virtual_machine_sizes.list(vm.location)
print(sizeList)
for size in sizeList:
if size.name == vm.hardware_profile.vm_size:
print(size.number_of_cores)
For more details, see VirtualMachineSizesOperations class . 有关更多详细信息,请参见VirtualMachineSizesOperations类 。 Hope it helps.
希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.