简体   繁体   中英

Using python code how do i get the disks name and disk state in azure

I am unable to get the disks name and disk state details using python:

credentials = ServicePrincipalCredentials( client_id = CLIENT, secret = KEY, tenant = TENANT_ID )
subscription_id = ''
compute_client = ComputeManagementClient(credentials, subscription_id)
rg = 'shuilinux'
disks = compute_client.disks.list_by_resource_group(rg)
for disk in disks:
    print disk

Answering to you question, below code gives you the disks names and disk state

credentials = ServicePrincipalCredentials( client_id = CLIENT, secret = KEY, tenant = TENANT_ID ) subscription_id = '' compute_client = ComputeManagementClient(credentials, subscription_id) rg = 'shuilinux' disks = compute_client.disks.list_by_resource_group(rg) for disk in disks: print disk.name print disk.disk_state

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM