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
14 changes: 12 additions & 2 deletions src/azure-cli/azure/cli/command_modules/rdbms/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
get_enum_type, file_type,
resource_group_name_type,
get_three_state_flag)
from azure.cli.command_modules.rdbms.validators import configuration_value_validator, validate_subnet, \
from azure.cli.command_modules.rdbms.validators import configuration_value_validator, db_renaming_cluster_validator, validate_subnet, \
tls_validator, public_access_validator, maintenance_window_validator, ip_address_validator, \
retention_validator, validate_identity, validate_byok_identity, validate_identities, \
virtual_endpoint_name_validator, node_count_validator, postgres_firewall_rule_name_validator
Expand Down Expand Up @@ -285,6 +285,16 @@ def _flexible_server_params(command_group):
actions=[LocalContextAction.GET, LocalContextAction.SET],
scopes=['{} flexible-server'.format(command_group)]))

database_name_arg_type_cluster = CLIArgumentType(
metavar='NAME',
options_list=['--database-name', '-d'],
help='The default database name for an elastic cluster. Only applicable when --cluster-option is set to ElasticCluster.',
local_context_attribute=LocalContextAttribute(
name='database_name',
actions=[LocalContextAction.GET, LocalContextAction.SET],
scopes=['{} flexible-server'.format(command_group)]),
validator=db_renaming_cluster_validator)

tier_arg_type = CLIArgumentType(
options_list=['--tier'],
help='Compute tier of the server. Accepted values: Burstable, GeneralPurpose, MemoryOptimized '
Expand Down Expand Up @@ -628,7 +638,7 @@ def _flexible_server_params(command_group):
c.argument('cluster_size', default=None, arg_type=create_node_count_arg_type)
c.argument('zonal_resiliency', arg_type=zonal_resiliency_arg_type, default="Disabled")
c.argument('allow_same_zone', arg_type=allow_same_zone_arg_type, default=False)
c.argument('database_name', arg_type=database_name_create_arg_type)
c.argument('database_name', default=None, arg_type=database_name_arg_type_cluster)
elif command_group == 'mysql':
c.argument('tier', default='Burstable', arg_type=tier_arg_type)
c.argument('sku_name', default='Standard_B1ms', arg_type=sku_name_arg_type)
Expand Down
6 changes: 6 additions & 0 deletions src/azure-cli/azure/cli/command_modules/rdbms/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ def node_count_validator(ns):
raise CLIError('incorrect usage: --node-count. Range is 1 to 10 for an elastic cluster.')


def db_renaming_cluster_validator(ns):
if ns.database_name is not None and ns.create_cluster != 'ElasticCluster':
raise ArgumentUsageError('incorrect usage: --database-name can only be '
'used when --cluster-option is set to ElasticCluster.')


# Validates if a subnet id or name have been given by the user. If subnet id is given, vnet-name should not be provided.
def validate_subnet(cmd, namespace):

Expand Down