Exemplo n.º 1
0
    def test_storage_accounts(self):

        # create storage account
        print("Creating storage account: " + self.storage_account)
        response = azurerm.create_storage_account(
            self.access_token, self.subscription_id, self.rgname, self.storage_account, self.location
        )
        self.assertEqual(response.status_code, 202)

        # get storage account
        print("Get storage account: " + self.storage_account)
        response = azurerm.get_storage_account(
            self.access_token, self.subscription_id, self.rgname, self.storage_account
        )
        self.assertEqual(response["name"], self.storage_account)

        # get storage account keys
        print("Get storage account keys")
        time.sleep(2)  # small delay to allow account keys to be created
        response = azurerm.get_storage_account_keys(
            self.access_token, self.subscription_id, self.rgname, self.storage_account
        )
        keys = json.loads(response.text)
        self.assertTrue("keys" in keys)

        # get storage usage
        print("Get storage usage")
        response = azurerm.get_storage_usage(self.access_token, self.subscription_id)
        self.assertTrue("value" in response)

        # list storage accounts
        print("List storage accounts")
        response = azurerm.list_storage_accounts_rg(self.access_token, self.subscription_id, self.rgname)
        self.assertTrue("value" in response)

        # list storage accounts in subscription
        print("List storage accounts in subscription")
        response = azurerm.list_storage_accounts_sub(self.access_token, self.subscription_id)
        self.assertTrue("value" in response)

        # delete storage account
        print("Delete storage account: " + self.storage_account)
        response = azurerm.delete_storage_account(
            self.access_token, self.subscription_id, self.rgname, self.storage_account
        )
        self.assertEqual(response.status_code, 200)
Exemplo n.º 2
0
    def test_storage_accounts(self):

        # create storage account
        print('Creating storage account: ' + self.storage_account)
        response = azurerm.create_storage_account(self.access_token, self.subscription_id, \
            self.rgname, self.storage_account, self.location)
        self.assertEqual(response.status_code, 202)

        # get storage account
        print('Get storage account: ' + self.storage_account)
        response = azurerm.get_storage_account(self.access_token, self.subscription_id, \
            self.rgname, self.storage_account)
        self.assertEqual(response['name'], self.storage_account)

        # get storage account keys
        print('Get storage account keys')
        time.sleep(2) # small delay to allow account keys to be created
        response = azurerm.get_storage_account_keys(self.access_token, self.subscription_id, \
            self.rgname, self.storage_account) 
        keys = json.loads(response.text)
        self.assertTrue('keys' in keys)

        # get storage usage
        print('Get storage usage')
        response = azurerm.get_storage_usage(self.access_token, self.subscription_id)
        self.assertTrue('value' in response)

        # list storage accounts
        print('List storage accounts')
        response = azurerm.list_storage_accounts_rg(self.access_token, self.subscription_id, \
            self.rgname)
        self.assertTrue('value' in response)

        # list storage accounts in subscription
        print('List storage accounts in subscription')
        response = azurerm.list_storage_accounts_sub(self.access_token, self.subscription_id)
        self.assertTrue('value' in response)

        # delete storage account
        print('Delete storage account: ' + self.storage_account)
        response = azurerm.delete_storage_account(self.access_token, self.subscription_id, \
            self.rgname, self.storage_account)
        self.assertEqual(response.status_code, 200)
Exemplo n.º 3
0
access_token = azurerm.get_access_token(
    tenant_id,
    app_id,
    app_secret
)

# create a storage account 
print('Enter storage account name to create.')
saname = input()
location = 'eastus'
sareturn = azurerm.create_storage_account(access_token, subscription_id, resource_group, saname, location)
print(sareturn)

# list storage accounts per sub
sa_list = azurerm.list_storage_accounts_sub(access_token, subscription_id)
print(sa_list)
#for rg in resource_groups["value"]:
#    print(rg["name"] + ', ' + rg["location"] + ', ' + rg["properties"]["provisioningState"])

print('Press Enter to continue and list accounts in RG.')
input()

# list storage accounts in rg
sa_list = azurerm.list_storage_accounts_rg(access_token, subscription_id, resource_group)
print(json.dumps(sa_list, sort_keys=False, indent=2, separators=(',', ': ')))

print('Storage account details...')

# get storage account details
sa_info = azurerm.get_storage_account(access_token, subscription_id, resource_group, saname)