diff --git a/src/azure-cli/azure/cli/command_modules/netappfiles/custom.py b/src/azure-cli/azure/cli/command_modules/netappfiles/custom.py index 83792bdcdde..242b9664610 100644 --- a/src/azure-cli/azure/cli/command_modules/netappfiles/custom.py +++ b/src/azure-cli/azure/cli/command_modules/netappfiles/custom.py @@ -28,6 +28,14 @@ tib_scale = gib_scale * 1024 +def _get_location_from_resource_group(cli_ctx, resource_group_name): + from azure.cli.core.commands.client_factory import get_mgmt_service_client + from azure.cli.core.profiles import ResourceType + client = get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES) + group = client.resource_groups.get(resource_group_name) + return group.location + + def _update_mapper(existing, new, keys): for key in keys: existing_value = getattr(existing, key) @@ -38,9 +46,8 @@ def _update_mapper(existing, new, keys): # ---- ACCOUNT ---- # pylint: disable=unused-argument # account update - active_directory is amended with subgroup commands -def create_account(client, account_name, resource_group_name, location=None, tags=None, encryption=None): - if location is None: - location = client.resource_groups.get(resource_group_name).location +def create_account(cmd, client, account_name, resource_group_name, location=None, tags=None, encryption=None): + location = location or _get_location_from_resource_group(cmd.cli_ctx, resource_group_name) account_encryption = AccountEncryption(key_source=encryption) if encryption is not None else None body = NetAppAccount(location=location, tags=tags, encryption=account_encryption) return client.begin_create_or_update(resource_group_name, account_name, body) @@ -149,10 +156,9 @@ def list_accounts(client, resource_group_name=None): # ---- POOL ---- # pylint: disable=no-required-location-param -def create_pool(client, account_name, pool_name, resource_group_name, service_level, size, location=None, tags=None, +def create_pool(cmd, client, account_name, pool_name, resource_group_name, service_level, size, location=None, tags=None, qos_type=None, cool_access=None, encryption_type=None): - if location is None: - location = client.resource_groups.get(resource_group_name).location + location = location or _get_location_from_resource_group(cmd.cli_ctx, resource_group_name) body = CapacityPool(service_level=service_level, size=int(size) * tib_scale, location=location, @@ -187,8 +193,7 @@ def create_volume(cmd, client, account_name, pool_name, volume_name, resource_gr allowed_clients=None, ldap_enabled=None, chown_mode=None, cool_access=None, coolness_period=None, unix_permissions=None, is_def_quota_enabled=None, default_user_quota=None, default_group_quota=None, avs_data_store=None, network_features=None, enable_subvolumes=None): - if location is None: - location = client.resource_groups.get(resource_group_name).location + location = location or _get_location_from_resource_group(cmd.cli_ctx, resource_group_name) subs_id = get_subscription_id(cmd.cli_ctx) # default the resource group of the subnet to the volume's rg unless the subnet is specified by id @@ -420,10 +425,9 @@ def remove_export_policy_rule(instance, rule_index): # ---- SNAPSHOTS ---- -def create_snapshot(client, resource_group_name, account_name, pool_name, volume_name, snapshot_name, location=None): - if location is None: - location = client.resource_groups.get(resource_group_name).location +def create_snapshot(cmd, client, resource_group_name, account_name, pool_name, volume_name, snapshot_name, location=None): body = Snapshot(location=location) + location = location or _get_location_from_resource_group(cmd.cli_ctx, resource_group_name) return client.begin_create(resource_group_name, account_name, pool_name, volume_name, snapshot_name, body) @@ -437,14 +441,13 @@ def snapshot_restore_files(client, resource_group_name, account_name, pool_name, # ---- SNAPSHOT POLICIES ---- -def create_snapshot_policy(client, resource_group_name, account_name, snapshot_policy_name, location=None, +def create_snapshot_policy(cmd, client, resource_group_name, account_name, snapshot_policy_name, location=None, hourly_snapshots=None, hourly_minute=None, daily_snapshots=None, daily_minute=None, daily_hour=None, weekly_snapshots=None, weekly_minute=None, weekly_hour=None, weekly_day=None, monthly_snapshots=None, monthly_minute=None, monthly_hour=None, monthly_days=None, enabled=False, tags=None): - if location is None: - location = client.resource_groups.get(resource_group_name).location + location = location or _get_location_from_resource_group(cmd.cli_ctx, resource_group_name) body = SnapshotPolicy( location=location, hourly_schedule=HourlySchedule(snapshots_to_keep=hourly_snapshots, minute=hourly_minute), @@ -458,14 +461,13 @@ def create_snapshot_policy(client, resource_group_name, account_name, snapshot_p return client.create(resource_group_name, account_name, snapshot_policy_name, body) -def patch_snapshot_policy(client, resource_group_name, account_name, snapshot_policy_name, location=None, +def patch_snapshot_policy(cmd, client, resource_group_name, account_name, snapshot_policy_name, location=None, hourly_snapshots=None, hourly_minute=None, daily_snapshots=None, daily_minute=None, daily_hour=None, weekly_snapshots=None, weekly_minute=None, weekly_hour=None, weekly_day=None, monthly_snapshots=None, monthly_minute=None, monthly_hour=None, monthly_days=None, enabled=False): - if location is None: - location = client.resource_groups.get(resource_group_name).location + location = location or _get_location_from_resource_group(cmd.cli_ctx, resource_group_name) body = SnapshotPolicyPatch( location=location, hourly_schedule=HourlySchedule(snapshots_to_keep=hourly_snapshots, minute=hourly_minute), @@ -479,10 +481,9 @@ def patch_snapshot_policy(client, resource_group_name, account_name, snapshot_po # ---- VOLUME BACKUPS ---- -def create_backup(client, resource_group_name, account_name, pool_name, volume_name, backup_name, location=None, +def create_backup(cmd, client, resource_group_name, account_name, pool_name, volume_name, backup_name, location=None, use_existing_snapshot=None): - if location is None: - location = client.resource_groups.get(resource_group_name).location + location = location or _get_location_from_resource_group(cmd.cli_ctx, resource_group_name) body = Backup(location=location, use_existing_snapshot=use_existing_snapshot) return client.begin_create(resource_group_name, account_name, pool_name, volume_name, backup_name, body) @@ -494,10 +495,9 @@ def update_backup(client, resource_group_name, account_name, pool_name, volume_n # ---- BACKUP POLICIES ---- -def create_backup_policy(client, resource_group_name, account_name, backup_policy_name, location=None, +def create_backup_policy(cmd, client, resource_group_name, account_name, backup_policy_name, location=None, daily_backups=None, weekly_backups=None, monthly_backups=None, enabled=False, tags=None): - if location is None: - location = client.resource_groups.get(resource_group_name).location + location = location or _get_location_from_resource_group(cmd.cli_ctx, resource_group_name) body = BackupPolicy( location=location, daily_backups_to_keep=daily_backups, @@ -542,7 +542,7 @@ def patch_subvolume(client, resource_group_name, account_name, pool_name, volume # ---- VOLUME GROUPS ---- def create_volume_group(cmd, client, resource_group_name, account_name, pool_name, volume_group_name, vnet, ppg, - sap_sid, subnet='default', location=None, tags=None, gp_rules=None, memory=100, + sap_sid, location=None, subnet='default', tags=None, gp_rules=None, memory=100, add_snapshot_capacity=50, start_host_id=1, number_of_hots=1, prefix="", system_role="PRIMARY", data_size=None, data_throughput=None, log_size=None, log_throughput=None, shared_size=None, shared_throughput=None, data_backup_size=None, data_backup_throughput=None, @@ -559,6 +559,8 @@ def create_volume_group(cmd, client, resource_group_name, account_name, pool_nam if system_role == "DR" and number_of_hots != 1: raise ValidationError("Number of hosts must be 1 when creating a Disaster Recovery (DR) volume group") + location = location or _get_location_from_resource_group(cmd.cli_ctx, resource_group_name) + if prefix == "": if system_role == "HA": prefix = "HA-" @@ -567,8 +569,6 @@ def create_volume_group(cmd, client, resource_group_name, account_name, pool_nam else: prefix = prefix + "-" - if location is None: - location = client.resource_groups.get(resource_group_name).location rules = [] if gp_rules is not None: for rule in gp_rules: diff --git a/src/azure-cli/azure/cli/command_modules/netappfiles/tests/latest/recordings/test_create_account_with_no_location.yaml b/src/azure-cli/azure/cli/command_modules/netappfiles/tests/latest/recordings/test_create_account_with_no_location.yaml new file mode 100644 index 00000000000..212759c0dee --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/netappfiles/tests/latest/recordings/test_create_account_with_no_location.yaml @@ -0,0 +1,246 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - netappfiles account create + Connection: + - keep-alive + ParameterSetName: + - -g -a + User-Agent: + - AZURECLI/2.37.0 azsdk-python-azure-mgmt-resource/21.1.0b1 Python/3.8.10 (macOS-12.4-x86_64-i386-64bit) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_netappfiles_test_account_000001?api-version=2021-04-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_netappfiles_test_account_000001","name":"cli_netappfiles_test_account_000001","type":"Microsoft.Resources/resourceGroups","location":"eastus","tags":{"owner":"cli_test","CreatedOnDate":"2022-06-08T15:27:10.4857282Z","SkipNRMSNSG":"true"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '363' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 08 Jun 2022 15:27:11 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"location": "eastus"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - netappfiles account create + Connection: + - keep-alive + Content-Length: + - '22' + Content-Type: + - application/json + ParameterSetName: + - -g -a + User-Agent: + - AZURECLI/2.37.0 azsdk-python-mgmt-netapp/7.0.0 Python/3.8.10 (macOS-12.4-x86_64-i386-64bit) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_netappfiles_test_account_000001/providers/Microsoft.NetApp/netAppAccounts/cli-acc-000002?api-version=2021-10-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_netappfiles_test_account_000001/providers/Microsoft.NetApp/netAppAccounts/cli-acc-000002","name":"cli-acc-000002","type":"Microsoft.NetApp/netAppAccounts","etag":"W/\"datetime''2022-06-08T15%3A27%3A16.7772629Z''\"","location":"eastus","tags":{"CreatedOnDate":"2022-06-08T15:27:13.5391571Z"},"properties":{"provisioningState":"Creating"},"systemData":{"createdBy":"c6c4faba-2b22-44d9-80a4-71ff5b71f811","createdAt":"2022-06-08T15:27:16.1528901Z","createdByType":"Application","lastModifiedBy":"c6c4faba-2b22-44d9-80a4-71ff5b71f811","lastModifiedAt":"2022-06-08T15:27:16.1528901Z","lastModifiedByType":"Application"}}' + headers: + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.NetApp/locations/eastus/operationResults/5510d0be-8d03-4bfc-af9d-300bb0c6a110?api-version=2021-10-01 + cache-control: + - no-cache + content-length: + - '691' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 08 Jun 2022 15:27:17 GMT + etag: + - W/"datetime'2022-06-08T15%3A27%3A16.7772629Z'" + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + x-powered-by: + - ASP.NET + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - netappfiles account create + Connection: + - keep-alive + ParameterSetName: + - -g -a + User-Agent: + - AZURECLI/2.37.0 azsdk-python-mgmt-netapp/7.0.0 Python/3.8.10 (macOS-12.4-x86_64-i386-64bit) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.NetApp/locations/eastus/operationResults/5510d0be-8d03-4bfc-af9d-300bb0c6a110?api-version=2021-10-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.NetApp/locations/eastus/operationResults/5510d0be-8d03-4bfc-af9d-300bb0c6a110","name":"5510d0be-8d03-4bfc-af9d-300bb0c6a110","status":"Succeeded","startTime":"2022-06-08T15:27:16.783976Z","endTime":"2022-06-08T15:27:16.8308683Z","percentComplete":100.0,"properties":{"resourceName":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_netappfiles_test_account_000001/providers/Microsoft.NetApp/netAppAccounts/cli-acc-000002"}}' + headers: + cache-control: + - no-cache + content-length: + - '524' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 08 Jun 2022 15:27:47 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - netappfiles account create + Connection: + - keep-alive + ParameterSetName: + - -g -a + User-Agent: + - AZURECLI/2.37.0 azsdk-python-mgmt-netapp/7.0.0 Python/3.8.10 (macOS-12.4-x86_64-i386-64bit) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_netappfiles_test_account_000001/providers/Microsoft.NetApp/netAppAccounts/cli-acc-000002?api-version=2021-10-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_netappfiles_test_account_000001/providers/Microsoft.NetApp/netAppAccounts/cli-acc-000002","name":"cli-acc-000002","type":"Microsoft.NetApp/netAppAccounts","etag":"W/\"datetime''2022-06-08T15%3A27%3A16.8343975Z''\"","location":"eastus","tags":{"CreatedOnDate":"2022-06-08T15:27:13.5391571Z"},"properties":{"encryption":{"keySource":"Microsoft.NetApp"},"provisioningState":"Succeeded"},"systemData":{"createdBy":"c6c4faba-2b22-44d9-80a4-71ff5b71f811","createdAt":"2022-06-08T15:27:16.1528901Z","createdByType":"Application","lastModifiedBy":"c6c4faba-2b22-44d9-80a4-71ff5b71f811","lastModifiedAt":"2022-06-08T15:27:16.1528901Z","lastModifiedByType":"Application"}}' + headers: + cache-control: + - no-cache + content-length: + - '738' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 08 Jun 2022 15:27:48 GMT + etag: + - W/"datetime'2022-06-08T15%3A27%3A16.8343975Z'" + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - netappfiles account show + Connection: + - keep-alive + ParameterSetName: + - --resource-group -a + User-Agent: + - AZURECLI/2.37.0 azsdk-python-mgmt-netapp/7.0.0 Python/3.8.10 (macOS-12.4-x86_64-i386-64bit) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_netappfiles_test_account_000001/providers/Microsoft.NetApp/netAppAccounts/cli-acc-000002?api-version=2021-10-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_netappfiles_test_account_000001/providers/Microsoft.NetApp/netAppAccounts/cli-acc-000002","name":"cli-acc-000002","type":"Microsoft.NetApp/netAppAccounts","etag":"W/\"datetime''2022-06-08T15%3A27%3A16.8343975Z''\"","location":"eastus","tags":{"CreatedOnDate":"2022-06-08T15:27:13.5391571Z"},"properties":{"encryption":{"keySource":"Microsoft.NetApp"},"provisioningState":"Succeeded"},"systemData":{"createdBy":"c6c4faba-2b22-44d9-80a4-71ff5b71f811","createdAt":"2022-06-08T15:27:16.1528901Z","createdByType":"Application","lastModifiedBy":"c6c4faba-2b22-44d9-80a4-71ff5b71f811","lastModifiedAt":"2022-06-08T15:27:16.1528901Z","lastModifiedByType":"Application"}}' + headers: + cache-control: + - no-cache + content-length: + - '738' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 08 Jun 2022 15:27:49 GMT + etag: + - W/"datetime'2022-06-08T15%3A27%3A16.8343975Z'" + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/netappfiles/tests/latest/recordings/test_create_pool_with_no_location.yaml b/src/azure-cli/azure/cli/command_modules/netappfiles/tests/latest/recordings/test_create_pool_with_no_location.yaml new file mode 100644 index 00000000000..3e5ddaca750 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/netappfiles/tests/latest/recordings/test_create_pool_with_no_location.yaml @@ -0,0 +1,441 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - netappfiles account create + Connection: + - keep-alive + ParameterSetName: + - -g -a + User-Agent: + - AZURECLI/2.37.0 azsdk-python-azure-mgmt-resource/21.1.0b1 Python/3.8.10 (macOS-12.4-x86_64-i386-64bit) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_netappfiles_test_account_000001?api-version=2021-04-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_netappfiles_test_account_000001","name":"cli_netappfiles_test_account_000001","type":"Microsoft.Resources/resourceGroups","location":"eastus","tags":{"owner":"cli_test","CreatedOnDate":"2022-06-08T15:28:01.9914753Z","SkipNRMSNSG":"true"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '363' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 08 Jun 2022 15:28:03 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"location": "eastus"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - netappfiles account create + Connection: + - keep-alive + Content-Length: + - '22' + Content-Type: + - application/json + ParameterSetName: + - -g -a + User-Agent: + - AZURECLI/2.37.0 azsdk-python-mgmt-netapp/7.0.0 Python/3.8.10 (macOS-12.4-x86_64-i386-64bit) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_netappfiles_test_account_000001/providers/Microsoft.NetApp/netAppAccounts/cli-acc-000002?api-version=2021-10-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_netappfiles_test_account_000001/providers/Microsoft.NetApp/netAppAccounts/cli-acc-000002","name":"cli-acc-000002","type":"Microsoft.NetApp/netAppAccounts","etag":"W/\"datetime''2022-06-08T15%3A28%3A09.5884448Z''\"","location":"eastus","tags":{"CreatedOnDate":"2022-06-08T15:28:05.9350501Z"},"properties":{"provisioningState":"Creating"},"systemData":{"createdBy":"c6c4faba-2b22-44d9-80a4-71ff5b71f811","createdAt":"2022-06-08T15:28:08.9613126Z","createdByType":"Application","lastModifiedBy":"c6c4faba-2b22-44d9-80a4-71ff5b71f811","lastModifiedAt":"2022-06-08T15:28:08.9613126Z","lastModifiedByType":"Application"}}' + headers: + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.NetApp/locations/eastus/operationResults/c8dabf25-f057-452b-be38-f0c0c7fabb0b?api-version=2021-10-01 + cache-control: + - no-cache + content-length: + - '691' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 08 Jun 2022 15:28:10 GMT + etag: + - W/"datetime'2022-06-08T15%3A28%3A09.5884448Z'" + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + x-powered-by: + - ASP.NET + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - netappfiles account create + Connection: + - keep-alive + ParameterSetName: + - -g -a + User-Agent: + - AZURECLI/2.37.0 azsdk-python-mgmt-netapp/7.0.0 Python/3.8.10 (macOS-12.4-x86_64-i386-64bit) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.NetApp/locations/eastus/operationResults/c8dabf25-f057-452b-be38-f0c0c7fabb0b?api-version=2021-10-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.NetApp/locations/eastus/operationResults/c8dabf25-f057-452b-be38-f0c0c7fabb0b","name":"c8dabf25-f057-452b-be38-f0c0c7fabb0b","status":"Succeeded","startTime":"2022-06-08T15:28:09.5906041Z","endTime":"2022-06-08T15:28:09.6531368Z","percentComplete":100.0,"properties":{"resourceName":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_netappfiles_test_account_000001/providers/Microsoft.NetApp/netAppAccounts/cli-acc-000002"}}' + headers: + cache-control: + - no-cache + content-length: + - '525' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 08 Jun 2022 15:28:40 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - netappfiles account create + Connection: + - keep-alive + ParameterSetName: + - -g -a + User-Agent: + - AZURECLI/2.37.0 azsdk-python-mgmt-netapp/7.0.0 Python/3.8.10 (macOS-12.4-x86_64-i386-64bit) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_netappfiles_test_account_000001/providers/Microsoft.NetApp/netAppAccounts/cli-acc-000002?api-version=2021-10-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_netappfiles_test_account_000001/providers/Microsoft.NetApp/netAppAccounts/cli-acc-000002","name":"cli-acc-000002","type":"Microsoft.NetApp/netAppAccounts","etag":"W/\"datetime''2022-06-08T15%3A28%3A09.6546887Z''\"","location":"eastus","tags":{"CreatedOnDate":"2022-06-08T15:28:05.9350501Z"},"properties":{"encryption":{"keySource":"Microsoft.NetApp"},"provisioningState":"Succeeded"},"systemData":{"createdBy":"c6c4faba-2b22-44d9-80a4-71ff5b71f811","createdAt":"2022-06-08T15:28:08.9613126Z","createdByType":"Application","lastModifiedBy":"c6c4faba-2b22-44d9-80a4-71ff5b71f811","lastModifiedAt":"2022-06-08T15:28:08.9613126Z","lastModifiedByType":"Application"}}' + headers: + cache-control: + - no-cache + content-length: + - '738' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 08 Jun 2022 15:28:40 GMT + etag: + - W/"datetime'2022-06-08T15%3A28%3A09.6546887Z'" + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - netappfiles pool create + Connection: + - keep-alive + ParameterSetName: + - -g -a -p --service-level --size + User-Agent: + - AZURECLI/2.37.0 azsdk-python-azure-mgmt-resource/21.1.0b1 Python/3.8.10 (macOS-12.4-x86_64-i386-64bit) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_netappfiles_test_account_000001?api-version=2021-04-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_netappfiles_test_account_000001","name":"cli_netappfiles_test_account_000001","type":"Microsoft.Resources/resourceGroups","location":"eastus","tags":{"owner":"cli_test","CreatedOnDate":"2022-06-08T15:28:01.9914753Z","SkipNRMSNSG":"true"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '363' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 08 Jun 2022 15:28:40 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"location": "eastus", "properties": {"size": 4398046511104, "serviceLevel": + "Premium"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - netappfiles pool create + Connection: + - keep-alive + Content-Length: + - '88' + Content-Type: + - application/json + ParameterSetName: + - -g -a -p --service-level --size + User-Agent: + - AZURECLI/2.37.0 azsdk-python-mgmt-netapp/7.0.0 Python/3.8.10 (macOS-12.4-x86_64-i386-64bit) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_netappfiles_test_account_000001/providers/Microsoft.NetApp/netAppAccounts/cli-acc-000002/capacityPools/cli-pool-000003?api-version=2021-10-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_netappfiles_test_account_000001/providers/Microsoft.NetApp/netAppAccounts/cli-acc-000002/capacityPools/cli-pool-000003","name":"cli-acc-000002/cli-pool-000003","type":"Microsoft.NetApp/netAppAccounts/capacityPools","etag":"W/\"datetime''2022-06-08T15%3A28%3A46.178498Z''\"","location":"eastus","tags":{"CreatedOnDate":"2022-06-08T15:28:43.4057240Z"},"properties":{"serviceLevel":"Premium","size":4398046511104,"totalThroughputMibps":0.0,"utilizedThroughputMibps":0.0,"provisioningState":"Creating"},"systemData":{"createdBy":"c6c4faba-2b22-44d9-80a4-71ff5b71f811","createdAt":"2022-06-08T15:28:45.3494638Z","createdByType":"Application","lastModifiedBy":"c6c4faba-2b22-44d9-80a4-71ff5b71f811","lastModifiedAt":"2022-06-08T15:28:45.3494638Z","lastModifiedByType":"Application"}}' + headers: + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.NetApp/locations/eastus/operationResults/e26fba89-8cb3-42dd-a0d8-f7bf1bd503cd?api-version=2021-10-01 + cache-control: + - no-cache + content-length: + - '853' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 08 Jun 2022 15:28:46 GMT + etag: + - W/"datetime'2022-06-08T15%3A28%3A46.178498Z'" + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + x-powered-by: + - ASP.NET + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - netappfiles pool create + Connection: + - keep-alive + ParameterSetName: + - -g -a -p --service-level --size + User-Agent: + - AZURECLI/2.37.0 azsdk-python-mgmt-netapp/7.0.0 Python/3.8.10 (macOS-12.4-x86_64-i386-64bit) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.NetApp/locations/eastus/operationResults/e26fba89-8cb3-42dd-a0d8-f7bf1bd503cd?api-version=2021-10-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.NetApp/locations/eastus/operationResults/e26fba89-8cb3-42dd-a0d8-f7bf1bd503cd","name":"e26fba89-8cb3-42dd-a0d8-f7bf1bd503cd","status":"Succeeded","startTime":"2022-06-08T15:28:46.185494Z","endTime":"2022-06-08T15:28:46.4199215Z","percentComplete":100.0,"properties":{"resourceName":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_netappfiles_test_account_000001/providers/Microsoft.NetApp/netAppAccounts/cli-acc-000002/capacityPools/cli-pool-000003"}}' + headers: + cache-control: + - no-cache + content-length: + - '554' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 08 Jun 2022 15:29:16 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - netappfiles pool create + Connection: + - keep-alive + ParameterSetName: + - -g -a -p --service-level --size + User-Agent: + - AZURECLI/2.37.0 azsdk-python-mgmt-netapp/7.0.0 Python/3.8.10 (macOS-12.4-x86_64-i386-64bit) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_netappfiles_test_account_000001/providers/Microsoft.NetApp/netAppAccounts/cli-acc-000002/capacityPools/cli-pool-000003?api-version=2021-10-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_netappfiles_test_account_000001/providers/Microsoft.NetApp/netAppAccounts/cli-acc-000002/capacityPools/cli-pool-000003","name":"cli-acc-000002/cli-pool-000003","type":"Microsoft.NetApp/netAppAccounts/capacityPools","etag":"W/\"datetime''2022-06-08T15%3A28%3A46.4032186Z''\"","location":"eastus","tags":{"CreatedOnDate":"2022-06-08T15:28:43.4057240Z"},"properties":{"poolId":"fc60592b-c3e8-28c8-e341-00a0f84c936a","serviceLevel":"Premium","size":4398046511104,"qosType":"Auto","totalThroughputMibps":262.144,"utilizedThroughputMibps":0.0,"encryptionType":"Single","coolAccess":false,"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '691' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 08 Jun 2022 15:29:17 GMT + etag: + - W/"datetime'2022-06-08T15%3A28%3A46.4032186Z'" + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - netappfiles pool show + Connection: + - keep-alive + ParameterSetName: + - -g -a -p + User-Agent: + - AZURECLI/2.37.0 azsdk-python-mgmt-netapp/7.0.0 Python/3.8.10 (macOS-12.4-x86_64-i386-64bit) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_netappfiles_test_account_000001/providers/Microsoft.NetApp/netAppAccounts/cli-acc-000002/capacityPools/cli-pool-000003?api-version=2021-10-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_netappfiles_test_account_000001/providers/Microsoft.NetApp/netAppAccounts/cli-acc-000002/capacityPools/cli-pool-000003","name":"cli-acc-000002/cli-pool-000003","type":"Microsoft.NetApp/netAppAccounts/capacityPools","etag":"W/\"datetime''2022-06-08T15%3A28%3A46.4032186Z''\"","location":"eastus","tags":{"CreatedOnDate":"2022-06-08T15:28:43.4057240Z"},"properties":{"poolId":"fc60592b-c3e8-28c8-e341-00a0f84c936a","serviceLevel":"Premium","size":4398046511104,"qosType":"Auto","totalThroughputMibps":262.144,"utilizedThroughputMibps":0.0,"encryptionType":"Single","coolAccess":false,"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '691' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 08 Jun 2022 15:29:18 GMT + etag: + - W/"datetime'2022-06-08T15%3A28%3A46.4032186Z'" + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/netappfiles/tests/latest/test_account_commands.py b/src/azure-cli/azure/cli/command_modules/netappfiles/tests/latest/test_account_commands.py index 4040a1faf80..302836bf404 100644 --- a/src/azure-cli/azure/cli/command_modules/netappfiles/tests/latest/test_account_commands.py +++ b/src/azure-cli/azure/cli/command_modules/netappfiles/tests/latest/test_account_commands.py @@ -190,3 +190,13 @@ def test_account_encryption(self): self.check('name', '{acc2_name}'), self.check('encryption.keySource', '{encryption}') ]) + + @ResourceGroupPreparer(name_prefix='cli_netappfiles_test_account_', additional_tags={'owner': 'cli_test'}, location='eastus') + def test_create_account_with_no_location(self): + self.kwargs.update({ + 'acc_name': self.create_random_name(prefix='cli-acc-', length=24) + }) + self.cmd("az netappfiles account create -g {rg} -a {acc_name}") + self.cmd("az netappfiles account show --resource-group {rg} -a {acc_name}", checks=[ + self.check('location', 'eastus') + ]) diff --git a/src/azure-cli/azure/cli/command_modules/netappfiles/tests/latest/test_pool_commands.py b/src/azure-cli/azure/cli/command_modules/netappfiles/tests/latest/test_pool_commands.py index b23c65e5114..54b9fb1401e 100644 --- a/src/azure-cli/azure/cli/command_modules/netappfiles/tests/latest/test_pool_commands.py +++ b/src/azure-cli/azure/cli/command_modules/netappfiles/tests/latest/test_pool_commands.py @@ -130,3 +130,16 @@ def test_pool_parameters(self): pool = self.cmd("az netappfiles pool show --resource-group {rg} -a %s -p %s" % (account_name, pool_name)).get_output_in_json() assert pool['name'] == account_name + '/' + pool_name assert pool['encryptionType'] == "Double" + + @ResourceGroupPreparer(name_prefix='cli_netappfiles_test_account_', additional_tags={'owner': 'cli_test'}, location='eastus') + def test_create_pool_with_no_location(self): + self.kwargs.update({ + 'acc_name': self.create_random_name(prefix='cli-acc-', length=24), + 'pool_name': self.create_random_name(prefix='cli-pool-', length=24), + 'pool_default': POOL_DEFAULT + }) + self.cmd("az netappfiles account create -g {rg} -a {acc_name}") + self.cmd("az netappfiles pool create -g {rg} -a {acc_name} -p {pool_name} {pool_default}") + self.cmd("az netappfiles pool show -g {rg} -a {acc_name} -p {pool_name}", checks=[ + self.check('location', 'eastus') + ]) \ No newline at end of file