#!/usr/bin/env python3.6
import os
import sys
from azure.common.credentials import ServicePrincipalCredentials
from azure.mgmt.compute import ComputeManagementClient
#
# Required
#
envars = ["ARM_SUBSCRIPTION_ID", "ARM_CLIENT_ID", "ARM_CLIENT_SECRET", "ARM_TENANT_ID", "ARM_REGION" ]
def check_env():
for e in envars:
if not os.getenv(e):
print ("ERROR: %s must be set in the environmet" % e)
sys.exit(1)
check_env()
subscription_id = os.environ.get('ARM_SUBSCRIPTION_ID')
credentials = ServicePrincipalCredentials(
client_id=os.environ['ARM_CLIENT_ID'],
secret=os.environ['ARM_CLIENT_SECRET'],
tenant=os.environ['ARM_TENANT_ID']
)
region = os.environ['ARM_REGION']
if not region:
print ("ERROR: ARM_REGION not set")
sys.exit(1)
compute_client = ComputeManagementClient(credentials, subscription_id)
async_creation = compute_client.disks.create_or_update(
resource_group,
"/dev/xvda",
{
'location': region,
'disk_size_gb': 50,
'creation_data': {
'create_option': "empty"
}
}
)
disk_resource = async_creation.result()
print ("Disk = ", disk_resource)
===================
Traceback (most recent call last):
File "./broke.py", line 36, in
async_creation = compute_client.disks.create_or_update(
AttributeError: 'ComputeManagementClient' object has no attribute 'disks'
Looks like something changed ... and broke ???
===================
Traceback (most recent call last): File "./broke.py", line 36, in
async_creation = compute_client.disks.create_or_update(
AttributeError: 'ComputeManagementClient' object has no attribute 'disks'