From 736d67ba3478d1a4221dbb5869dd1704383f129f Mon Sep 17 00:00:00 2001 From: zhiyihuang <17182306+calvinhzy@users.noreply.github.com> Date: Mon, 24 Mar 2025 15:57:23 +0800 Subject: [PATCH] `az storage share create`: Add `--enable-snapshot-virtual-directory-access` --- .../cli/command_modules/storage/_params.py | 5 + ...t_storage_file_share_premium_scenario.yaml | 179 ++++++++++++++++++ .../test_storage_file_share_scenarios.py | 16 ++ 3 files changed, 200 insertions(+) create mode 100644 src/azure-cli/azure/cli/command_modules/storage/tests/latest/recordings/test_storage_file_share_premium_scenario.yaml diff --git a/src/azure-cli/azure/cli/command_modules/storage/_params.py b/src/azure-cli/azure/cli/command_modules/storage/_params.py index f1d1a00f2b0..420aef94182 100644 --- a/src/azure-cli/azure/cli/command_modules/storage/_params.py +++ b/src/azure-cli/azure/cli/command_modules/storage/_params.py @@ -1782,6 +1782,11 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem resource_type=ResourceType.DATA_STORAGE_FILESHARE) c.extra('protocols', options_list=['--protocol'], arg_type=get_enum_type(t_share_protocols_type), help='The protocol to enable for the share.') + c.extra('enable_snapshot_virtual_directory_access', + options_list=('--enable-snapshot-virtual-directory-access', '--virtual-dir-access'), + arg_type=get_three_state_flag(), + help='Specifies whether the snapshot virtual directory should be accessible at the root of the ' + 'share mount point when NFS is enabled. If not specified, it will be accessible.') with self.argument_context('storage share url') as c: c.extra('unc', action='store_true', help='Output UNC network path.') diff --git a/src/azure-cli/azure/cli/command_modules/storage/tests/latest/recordings/test_storage_file_share_premium_scenario.yaml b/src/azure-cli/azure/cli/command_modules/storage/tests/latest/recordings/test_storage_file_share_premium_scenario.yaml new file mode 100644 index 00000000000..65f5b09247a --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/storage/tests/latest/recordings/test_storage_file_share_premium_scenario.yaml @@ -0,0 +1,179 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - storage account keys list + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -n -g --query -o + User-Agent: + - AZURECLI/2.70.0 azsdk-python-core/1.31.0 Python/3.12.9 (Windows-11-10.0.26100-SP0) + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest000001/providers/Microsoft.Storage/storageAccounts/share000002/listKeys?api-version=2024-01-01&$expand=kerb + response: + body: + string: '{"keys":[{"creationTime":"2025-03-24T07:54:38.3786395Z","keyName":"key1","value":"veryFakedStorageAccountKey==","permissions":"FULL"},{"creationTime":"2025-03-24T07:54:38.3786395Z","keyName":"key2","value":"veryFakedStorageAccountKey==","permissions":"FULL"}]}' + headers: + cache-control: + - no-cache + content-length: + - '260' + content-type: + - application/json + date: + - Mon, 24 Mar 2025 07:55:03 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=54826b22-38d6-4fb2-bad9-b7b93a3e9c5a,objectId=a7250e3a-0e5e-48e2-9a34-45f1f5e1a91e/southeastasia/f62b3840-5053-420e-a14b-a6678ed31473 + x-ms-ratelimit-remaining-subscription-resource-requests: + - '11999' + x-msedge-ref: + - 'Ref A: 78F7AD4038F74BF3973FAC71662C42DC Ref B: MAA201060515019 Ref C: 2025-03-24T07:55:03Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/xml + Accept-Encoding: + - gzip, deflate + CommandName: + - storage share create + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -n --fail-on-exist --metadata --enable-snapshot-virtual-directory-access --protocol + --account-name --account-key + User-Agent: + - AZURECLI/2.70.0 azsdk-python-storage-file-share/12.21.0 Python/3.12.9 (Windows-11-10.0.26100-SP0) + x-ms-date: + - Mon, 24 Mar 2025 07:55:04 GMT + x-ms-enable-snapshot-virtual-directory-access: + - 'false' + x-ms-enabled-protocols: + - NFS + x-ms-meta: + - '{''foo'': ''bar'', ''cat'': ''hat''}' + x-ms-meta-cat: + - hat + x-ms-meta-foo: + - bar + x-ms-version: + - '2025-05-05' + method: PUT + uri: https://share000002.file.core.windows.net/share000003?restype=share + response: + body: + string: '' + headers: + content-length: + - '0' + date: + - Mon, 24 Mar 2025 07:55:04 GMT + etag: + - '"0x8DD6AA930885461"' + last-modified: + - Mon, 24 Mar 2025 07:55:05 GMT + server: + - Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0 + x-ms-version: + - '2025-05-05' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/xml + Accept-Encoding: + - gzip, deflate + CommandName: + - storage share show + Connection: + - keep-alive + ParameterSetName: + - -n --account-name --account-key + User-Agent: + - AZURECLI/2.70.0 azsdk-python-storage-file-share/12.21.0 Python/3.12.9 (Windows-11-10.0.26100-SP0) + x-ms-date: + - Mon, 24 Mar 2025 07:55:05 GMT + x-ms-version: + - '2025-05-05' + method: GET + uri: https://share000002.file.core.windows.net/share000003?restype=share + response: + body: + string: '' + headers: + content-length: + - '0' + date: + - Mon, 24 Mar 2025 07:55:06 GMT + etag: + - '"0x8DD6AA930885461"' + last-modified: + - Mon, 24 Mar 2025 07:55:05 GMT + server: + - Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0 + x-ms-access-tier: + - Premium + x-ms-enable-snapshot-virtual-directory-access: + - 'false' + x-ms-enabled-protocols: + - NFS + x-ms-has-immutability-policy: + - 'false' + x-ms-has-legal-hold: + - 'false' + x-ms-lease-state: + - available + x-ms-lease-status: + - unlocked + x-ms-meta-cat: + - hat + x-ms-meta-foo: + - bar + x-ms-root-squash: + - NoRootSquash + x-ms-share-next-allowed-quota-downgrade-time: + - Mon, 24 Mar 2025 07:55:05 GMT + x-ms-share-paid-bursting-enabled: + - 'false' + x-ms-share-provisioned-bandwidth-mibps: + - '117' + x-ms-share-provisioned-egress-mbps: + - '117' + x-ms-share-provisioned-ingress-mbps: + - '117' + x-ms-share-provisioned-iops: + - '3032' + x-ms-share-quota: + - '32' + x-ms-version: + - '2025-05-05' + status: + code: 200 + message: OK +version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/storage/tests/latest/test_storage_file_share_scenarios.py b/src/azure-cli/azure/cli/command_modules/storage/tests/latest/test_storage_file_share_scenarios.py index b7ea6feeec5..d9d1ff177c2 100644 --- a/src/azure-cli/azure/cli/command_modules/storage/tests/latest/test_storage_file_share_scenarios.py +++ b/src/azure-cli/azure/cli/command_modules/storage/tests/latest/test_storage_file_share_scenarios.py @@ -73,6 +73,22 @@ def test_storage_file_share_scenario(self, resource_group, storage_account): self.storage_cmd('storage share show --name {}', account_info, share) \ .assert_with_checks(JMESPathCheck('properties.quota', 3)) + @ResourceGroupPreparer(name_prefix='clitest') + @StorageAccountPreparer(name_prefix='share', kind='FileStorage', location='eastus2', sku='Premium_LRS') + def test_storage_file_share_premium_scenario(self, resource_group, storage_account): + + account_info = self.get_account_info(resource_group, storage_account) + share_name = self.create_random_name('share', 24) + + self.storage_cmd('storage share create -n {} --fail-on-exist --metadata foo=bar cat=hat ' + '--enable-snapshot-virtual-directory-access false --protocol nfs', + account_info, share_name) \ + .assert_with_checks(JMESPathCheck('created', True)) + + self.storage_cmd('storage share show -n {}', account_info, share_name) \ + .assert_with_checks(JMESPathCheck('enableSnapshotVirtualDirectoryAccess', False), + JMESPathCheck('protocols', ['NFS'])) + @ResourceGroupPreparer(name_prefix='clitest') @StorageAccountPreparer(name_prefix='share', kind='StorageV2', location='eastus2', sku='Standard_RAGRS') def test_storage_share_metadata_scenario(self, resource_group, storage_account):