Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/azure-cli/azure/cli/command_modules/storage/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,17 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
help='Look into sub-directories recursively.')
sas_help = 'The permissions the SAS grants. Allowed values: {}. Do not use if a stored access policy is ' \
'referenced with --id that specifies this value. Can be combined.'
t_routing_choice = self.get_models('RoutingChoice', resource_type=ResourceType.MGMT_STORAGE)
routing_choice_type = CLIArgumentType(
arg_group='Routing Preference', arg_type=get_enum_type(t_routing_choice),
help='Routing Choice defines the kind of network routing opted by the user.',
is_preview=True, min_api='2019-06-01')
publish_microsoft_endpoints_type = CLIArgumentType(
arg_group='Routing Preference', arg_type=get_three_state_flag(), is_preview=True, min_api='2019-06-01',
help='A boolean flag which indicates whether microsoft routing storage endpoints are to be published.')
publish_internet_endpoints_type = CLIArgumentType(
arg_group='Routing Preference', arg_type=get_three_state_flag(), is_preview=True, min_api='2019-06-01',
help='A boolean flag which indicates whether internet routing storage endpoints are to be published.')

with self.argument_context('storage') as c:
c.argument('container_name', container_name_type)
Expand Down Expand Up @@ -189,6 +200,9 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
'with account-scoped encryption key. "Service": Queue will always be encrypted with '
'service-scoped keys. Currently the default encryption key type is "Service".',
min_api='2019-06-01', options_list=['--encryption-key-type-for-queue', '-q'])
c.argument('routing_choice', routing_choice_type)
c.argument('publish_microsoft_endpoints', publish_microsoft_endpoints_type)
c.argument('publish_internet_endpoints', publish_internet_endpoints_type)

with self.argument_context('storage account update', resource_type=ResourceType.MGMT_STORAGE) as c:
c.register_common_storage_account_options()
Expand All @@ -208,6 +222,9 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
c.argument('domain_guid', domain_guid_type)
c.argument('domain_sid', domain_sid_type)
c.argument('azure_storage_sid', azure_storage_sid_type)
c.argument('routing_choice', routing_choice_type)
c.argument('publish_microsoft_endpoints', publish_microsoft_endpoints_type)
c.argument('publish_internet_endpoints', publish_internet_endpoints_type)

with self.argument_context('storage account update', arg_group='Customer managed key', min_api='2017-06-01') as c:
c.extra('encryption_key_name', help='The name of the KeyVault key', )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,21 @@
logger = get_logger(__name__)


def str2bool(v):
if v is not None:
return v.lower() == "true"
return v


# pylint: disable=too-many-locals, too-many-statements
def create_storage_account(cmd, resource_group_name, account_name, sku=None, location=None, kind=None,
tags=None, custom_domain=None, encryption_services=None, access_tier=None, https_only=None,
enable_files_aadds=None, bypass=None, default_action=None, assign_identity=False,
enable_large_file_share=None, enable_files_adds=None, domain_name=None,
net_bios_domain_name=None, forest_name=None, domain_guid=None, domain_sid=None,
azure_storage_sid=None, enable_hierarchical_namespace=None,
encryption_key_type_for_table=None, encryption_key_type_for_queue=None):
encryption_key_type_for_table=None, encryption_key_type_for_queue=None,
routing_choice=None, publish_microsoft_endpoints=None, publish_internet_endpoints=None):
StorageAccountCreateParameters, Kind, Sku, CustomDomain, AccessTier, Identity, Encryption, NetworkRuleSet = \
cmd.get_models('StorageAccountCreateParameters', 'Kind', 'Sku', 'CustomDomain', 'AccessTier', 'Identity',
'Encryption', 'NetworkRuleSet')
Expand Down Expand Up @@ -99,6 +106,14 @@ def create_storage_account(cmd, resource_group_name, account_name, sku=None, loc
queue_encryption_service = EncryptionService(enabled=True, key_type=encryption_key_type_for_queue)
params.encryption.services.queue = queue_encryption_service

if any([routing_choice, publish_microsoft_endpoints, publish_internet_endpoints]):
RoutingPreference = cmd.get_models('RoutingPreference')
params.routing_preference = RoutingPreference(
routing_choice=routing_choice,
publish_microsoft_endpoints=str2bool(publish_microsoft_endpoints),
publish_internet_endpoints=str2bool(publish_internet_endpoints)
)

return scf.storage_accounts.create(resource_group_name, account_name, params)


Expand Down Expand Up @@ -171,10 +186,11 @@ def update_storage_account(cmd, instance, sku=None, tags=None, custom_domain=Non
access_tier=None, https_only=None, enable_files_aadds=None, assign_identity=False,
bypass=None, default_action=None, enable_large_file_share=None, enable_files_adds=None,
domain_name=None, net_bios_domain_name=None, forest_name=None, domain_guid=None,
domain_sid=None, azure_storage_sid=None):
domain_sid=None, azure_storage_sid=None, routing_choice=None,
publish_microsoft_endpoints=None, publish_internet_endpoints=None):
StorageAccountUpdateParameters, Sku, CustomDomain, AccessTier, Identity, Encryption, NetworkRuleSet = \
cmd.get_models('StorageAccountUpdateParameters', 'Sku', 'CustomDomain', 'AccessTier', 'Identity',
'Encryption', 'NetworkRuleSet')
cmd.get_models('StorageAccountUpdateParameters', 'Sku', 'CustomDomain', 'AccessTier', 'Identity', 'Encryption',
'NetworkRuleSet')

domain = instance.custom_domain
if custom_domain is not None:
Expand Down Expand Up @@ -285,6 +301,18 @@ def update_storage_account(cmd, instance, sku=None, tags=None, custom_domain=Non
raise CLIError('incorrect usage: --default-action ACTION [--bypass SERVICE ...]')
params.network_rule_set = acl

if hasattr(params, 'routing_preference') and any([routing_choice, publish_microsoft_endpoints,
publish_internet_endpoints]):
if params.routing_preference is None:
RoutingPreference = cmd.get_models('RoutingPreference')
params.routing_preference = RoutingPreference()
if routing_choice is not None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

routing_choice [](start = 11, length = 14)

This is just a question, if customer specify --routing-choice without a value, is routing_choice an empty string like "" or none?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be none.

params.routing_preference.routing_choice = routing_choice
if publish_microsoft_endpoints is not None:
params.routing_preference.publish_microsoft_endpoints = str2bool(publish_microsoft_endpoints)
if publish_internet_endpoints is not None:
params.routing_preference.publish_internet_endpoints = str2bool(publish_internet_endpoints)

return params


Expand Down
Loading