-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Storage]: Add a new command group az storage share-rm
to use the Microsoft.Storage resource provider for Azure file share management operations.
#11649
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2e1fea8
feat: Use the Microsoft.Storage resource provider for Azure file shar…
jsntcy e4c20b4
add release note to history file
jsntcy fb88474
fix linter errors: errors for help
jsntcy 5e59935
support account id and file share ids
jsntcy e1ae174
update code based on review comments
jsntcy 5407969
add confirmation for delete command
jsntcy 4758f3f
make file share name lower case in help file
jsntcy ca52d1f
update history
jsntcy f928fc7
fix test
jsntcy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,020 changes: 1,020 additions & 0 deletions
1,020
...and_modules/storage/tests/latest/recordings/test_storage_file_using_rm_main_scenario.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
142 changes: 142 additions & 0 deletions
142
...mmand_modules/storage/tests/latest/test_storage_file_using_resource_provider_scenarios.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
import os | ||
from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer, StorageAccountPreparer, api_version_constraint) | ||
from azure.cli.core.profiles import ResourceType | ||
from ..storage_test_util import StorageScenarioMixin | ||
|
||
|
||
@api_version_constraint(ResourceType.MGMT_STORAGE, min_api='2019-04-01') | ||
class StorageFileShareUsingResourceProviderScenarios(StorageScenarioMixin, ScenarioTest): | ||
@ResourceGroupPreparer() | ||
@StorageAccountPreparer() | ||
def test_storage_file_using_rm_main_scenario(self): | ||
# 1. Test create command. | ||
|
||
# Create file share with storage account name and resource group. | ||
share_name_1 = self.create_random_name('share', 24) | ||
initial_quota = 5 | ||
self.kwargs.update({ | ||
'share_name_1': share_name_1, | ||
'initial_quota': initial_quota | ||
}) | ||
|
||
result = self.cmd('storage share-rm create --storage-account {sa} -g {rg} -n {share_name_1} --quota {initial_quota} --metadata key1=value1').get_output_in_json() | ||
self.assertEqual(result['name'], share_name_1) | ||
self.assertEqual(result['shareQuota'], initial_quota) | ||
self.assertEqual(result['metadata']['key1'], 'value1') | ||
|
||
share_id_1 = result['id'] | ||
self.kwargs.update({ | ||
'share_id_1': share_id_1 | ||
}) | ||
|
||
# Create file share with storage account id. | ||
share_name_2 = self.create_random_name('share', 24) | ||
storage_account = self.cmd('storage account show -n {sa}').get_output_in_json() | ||
storage_account_id = storage_account['id'] | ||
self.kwargs.update({ | ||
'share_name_2': share_name_2, | ||
'storage_account_id': storage_account_id | ||
}) | ||
|
||
result = self.cmd('storage share-rm create --storage-account {storage_account_id} -n {share_name_2} --quota {initial_quota} --metadata key1=value1').get_output_in_json() | ||
self.assertEqual(result['name'], share_name_2) | ||
self.assertEqual(result['shareQuota'], initial_quota) | ||
self.assertEqual(result['metadata']['key1'], 'value1') | ||
|
||
share_id_2 = result['id'] | ||
self.kwargs.update({ | ||
'share_id_2': share_id_2 | ||
}) | ||
|
||
# 2. Test exists command (the file share exists). | ||
|
||
# Check existence with storage account name and resource group. | ||
result = self.cmd('storage share-rm exists --storage-account {sa} -g {rg} -n {share_name_1}').get_output_in_json() | ||
self.assertEqual(result['exists'], True) | ||
|
||
# Check existence with storage account id. | ||
result = self.cmd('storage share-rm exists --storage-account {storage_account_id} -n {share_name_1}').get_output_in_json() | ||
self.assertEqual(result['exists'], True) | ||
|
||
# Check existence by file share resource id. | ||
result = self.cmd('storage share-rm exists --ids {share_id_1}').get_output_in_json() | ||
self.assertEqual(result['exists'], True) | ||
|
||
# 3. Test show command (the file share exists). | ||
|
||
# Show properties of a file share with storage account name and resource group. | ||
result = self.cmd('storage share-rm show --storage-account {sa} -g {rg} -n {share_name_1}').get_output_in_json() | ||
self.assertEqual(result['name'], share_name_1) | ||
|
||
# Show properties of a file share with storage account id. | ||
result = self.cmd('storage share-rm show --storage-account {storage_account_id} -n {share_name_1}').get_output_in_json() | ||
self.assertEqual(result['name'], share_name_1) | ||
|
||
# Show properties by file share resource id. | ||
result = self.cmd('storage share-rm show --ids {share_id_1}').get_output_in_json() | ||
self.assertEqual(result['name'], share_name_1) | ||
|
||
# 4. Test show command (the file share doesn't exist). | ||
non_exist_share_name = self.create_random_name('share', 24) | ||
self.kwargs.update({ | ||
'non_exist_share_name': non_exist_share_name | ||
}) | ||
with self.assertRaisesRegexp(SystemExit, '3'): | ||
self.cmd('storage share-rm show --storage-account {sa} -g {rg} -n {non_exist_share_name}') | ||
|
||
# 5. Test update command. | ||
updated_quota = 10 | ||
self.kwargs.update({ | ||
'updated_quota': updated_quota | ||
}) | ||
|
||
# Update file share with storage account name and resource group. | ||
result = self.cmd( | ||
'storage share-rm update --storage-account {sa} -g {rg} -n {share_name_1} --quota {updated_quota} --metadata key2=value2').get_output_in_json() | ||
self.assertEqual(result['shareQuota'], updated_quota) | ||
self.assertEqual(result['metadata']['key2'], 'value2') | ||
self.assertNotIn('key1', result['metadata']) | ||
|
||
# Update file share with storage account id. | ||
result = self.cmd( | ||
'storage share-rm update --storage-account {storage_account_id} -n {share_name_2} --quota {updated_quota} --metadata key2=value2').get_output_in_json() | ||
self.assertEqual(result['shareQuota'], updated_quota) | ||
self.assertEqual(result['metadata']['key2'], 'value2') | ||
self.assertNotIn('key1', result['metadata']) | ||
|
||
# Update file share by resource id | ||
result = self.cmd( | ||
'storage share-rm update --ids {share_id_1} --quota {updated_quota} --metadata key2=value2').get_output_in_json() | ||
self.assertEqual(result['shareQuota'], updated_quota) | ||
self.assertEqual(result['metadata']['key2'], 'value2') | ||
self.assertNotIn('key1', result['metadata']) | ||
|
||
# 6. Test list command. | ||
|
||
# List file shares with storage account name and resource group. | ||
self.assertIn(share_name_1, | ||
self.cmd('storage share-rm list --storage-account {sa} -g {rg} --query "[].name"').get_output_in_json()) | ||
|
||
# List file shares with storage account id. | ||
self.assertIn(share_name_1, | ||
self.cmd('storage share-rm list --storage-account {storage_account_id} --query "[].name"').get_output_in_json()) | ||
|
||
# 7. Test delete command. | ||
|
||
# Delete file shares with storage account name and resource group. | ||
self.cmd('storage share-rm delete --storage-account {sa} -g {rg} -n {share_name_1} -y') | ||
|
||
# Delete file share by resource id. | ||
self.cmd('storage share-rm delete --ids {share_id_2} -y') | ||
|
||
# 8. Test exists command (the file share doesn't exist). | ||
result = self.cmd('storage share-rm exists --storage-account {sa} -g {rg} -n {share_name_1}').get_output_in_json() | ||
self.assertEqual(result['exists'], False) | ||
|
||
result = self.cmd('storage share-rm exists --ids {share_id_2}').get_output_in_json() | ||
self.assertEqual(result['exists'], False) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about "Add a new command group
az storage share-rm
to support manage File share (create/delete/update/show/list) in mgmt plane"? #WontFixThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CLI users should not care if it's mgmt plane or data plane
In reply to: 364247847 [](ancestors = 364247847)