Exemple #1
0
def main():
    '''Main routine.'''
    # check for single command argument
    if len(sys.argv) != 2:
        region = 'all'
    else:
        region = sys.argv[1]

    # Load Azure app defaults
    try:
        with open('azurermconfig.json') as config_file:
            config_data = json.load(config_file)
    except FileNotFoundError:
        sys.exit('Error: Expecting azurermconfig.json in current folder')

    tenant_id = config_data['tenantId']
    app_id = config_data['appId']
    app_secret = config_data['appSecret']
    sub_id = config_data['subscriptionId']

    access_token = azurerm.get_access_token(tenant_id, app_id, app_secret)

    # print quota
    if region == 'all':
        # list locations
        locations = azurerm.list_locations(access_token, sub_id)
        for location in locations['value']:
            print_region_quota(access_token, sub_id, location['name'])
    else:
        print_region_quota(access_token, sub_id, region)
Exemple #2
0
 def getRegion(self):
     try:
         location = azurerm.list_locations(self.access_token,
                                           self.subscription)
         array = []
         for locale in location['value']:
             array2 = []
             array2.append(locale['displayName'])
             array2.append(locale['name'])
             array.append(array2)
         return array
     except ValueError:
         print("Fail to get Locations list")
         return False
    def test_subscriptions(self):
        # list subscriptions
        print('Listing subscriptions..')
        response = azurerm.list_subscriptions(self.access_token)
        # print(json.dumps(response, sort_keys=False, indent=2, separators=(',', ': ')))
        self.assertTrue(len(response['value']) > 0)

        # list locations
        print('Listing locations..')
        response = azurerm.list_locations(self.access_token,
                                          self.subscription_id)
        # print(json.dumps(response, sort_keys=False, indent=2, separators=(',', ': ')))
        self.assertTrue(len(response['value']) > 0)

        # list tenants
        print('Listing tenants..')
        response = azurerm.list_tenants(self.access_token)
        # print(json.dumps(response, sort_keys=False, indent=2, separators=(',', ': ')))
        self.assertTrue(len(response['value']) > 0)
Exemple #4
0
def main():
    '''Main routine.'''
    # Load Azure app defaults
    try:
        with open('azurermconfig.json') as config_file:
            config_data = json.load(config_file)
    except FileNotFoundError:
        sys.exit("Error: Expecting azurermconfig.json in current folder")

    tenant_id = config_data['tenantId']
    app_id = config_data['appId']
    app_secret = config_data['appSecret']
    subscription_id = config_data['subscriptionId']

    access_token = azurerm.get_access_token(tenant_id, app_id, app_secret)

    # list locations
    locations = azurerm.list_locations(access_token, subscription_id)

    for location in locations['value']:
        print(location['name'] + ', Display Name: ' + location['displayName'] +
              ', Coords: ' + location['latitude'] + ', ' +
              location['longitude'])
Exemple #5
0
import azurerm
import json

# Load Azure app defaults
try:
   with open('azurermconfig.json') as configFile:    
      configData = json.load(configFile)
except FileNotFoundError:
   print("Error: Expecting vmssConfig.json in current folder")
   sys.exit()
   
tenant_id = configData['tenantId']
app_id = configData['appId']
app_secret = configData['appSecret']
subscription_id = configData['subscriptionId']

access_token = azurerm.get_access_token(tenant_id, app_id, app_secret)

# list locations
locations = azurerm.list_locations(access_token, subscription_id)

for location in locations['value']:
    print(location['name']
          + ', Display Name: ' + location['displayName']
          + ', Coords: ' + location['latitude']
          + ', ' + location['longitude'])

Exemple #6
0
# Load Azure app defaults
try:
   with open('azurermconfig.json') as configFile:    
      configData = json.load(configFile)
except FileNotFoundError:
   print("Error: Expecting vmssConfig.json in current folder")
   sys.exit()
   
tenant_id = configData['tenantId']
app_id = configData['appId']
app_secret = configData['appSecret']
subscription_id = configData['subscriptionId']

access_token = azurerm.get_access_token(tenant_id, app_id, app_secret)

# list locations
locations = azurerm.list_locations(access_token, subscription_id)

for location in locations['value']:
    print(location['name']
          + ', Display Name: ' + location['displayName']
          + ', Coords: ' + location['latitude']
          + ', ' + location['longitude'])