Skip to content

Commit

Permalink
Merge pull request #6 from mjain2/arde/removeDuplicateRGfromMySQL
Browse files Browse the repository at this point in the history
Update Storage to be accepted in GB
  • Loading branch information
mjain2 committed Sep 4, 2020
2 parents 4733f4a + 282d72d commit 74fc67f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

logger = get_logger(__name__)

DEFAULT_LOCATION = 'southeastasia' #'eastus2euap'
DEFAULT_LOCATION = 'northeurope' #'eastus2euap'


def resolve_poller(result, cli_ctx, name):
Expand Down Expand Up @@ -58,6 +58,12 @@ def generate_missing_parameters(cmd, location, resource_group_name, server_name)


def generate_password(administrator_login_password):
'''import string,random
if administrator_login_password is None:
passwordLength = 16
password_character = string.ascii_letters + string.digits + '!@#,?;:$&*' # Allowing limited punctuations to avoid unicode errors
pwd = "".join(random.choice(password_character) for i in range(passwordLength))
'''
if administrator_login_password is None:
administrator_login_password = str(uuid.uuid4())
return administrator_login_password
Expand Down
8 changes: 5 additions & 3 deletions src/azure-cli/azure/cli/command_modules/rdbms/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
tags_type, get_location_type,
get_enum_type,
get_three_state_flag)
from azure.cli.command_modules.rdbms.validators import configuration_value_validator, validate_subnet, retention_validator, tls_validator, public_access_validator
from azure.cli.command_modules.rdbms.validators import configuration_value_validator, validate_subnet, retention_validator, tls_validator, public_access_validator, pg_storage_validator, mysql_storage_validator
from azure.cli.core.commands.validators import get_default_location_from_resource_group
from .randomname.generate import generate_username
from azure.cli.core.local_context import LocalContextAttribute, LocalContextAction
Expand Down Expand Up @@ -206,7 +206,8 @@ def _flexible_server_params(command_group):
help='Compute tier of the server. Accepted values: Burstable, GeneralPurpose, Memory Optimized ')
c.argument('sku_name', default='Standard_D4s_v3', options_list=['--sku-name'],
help='The name of the compute SKU. Follows the convention Standard_{VM name}. Examples: Standard_B1ms, Standard_D4s_v3 ')
c.argument('storage_mb', default='131072', options_list=['--storage-size'], type=int,
c.argument('storage_mb', default='128', options_list=['--storage-size'], type=int,
validator=pg_storage_validator,
help='The storage capacity of the server. Minimum is 32 GiB and max is 16 TiB.')
c.argument('version', default='12', options_list=['--version'],
help='Server major version.')
Expand All @@ -217,7 +218,8 @@ def _flexible_server_params(command_group):
help='Compute tier of the server. Accepted values: Burstable, GeneralPurpose, Memory Optimized ')
c.argument('sku_name', default='Standard_B1MS', options_list=['--sku-name'],
help='The name of the compute SKU. Follows the convention Standard_{VM name}. Examples: Standard_B1ms, Standard_D4s_v3 ')
c.argument('storage_mb', default='10240', options_list=['--storage-size'], type=int,
c.argument('storage_mb', default='10', options_list=['--storage-size'], type=int,
validator=mysql_storage_validator,
help='The storage capacity of the server. Minimum is 5 GiB and increases in 1 GiB increments. Max is 16 TiB.')
c.argument('version', default='5.7', options_list=['--version'],
help='Server major version.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

logger = get_logger(__name__)


# region create without args
def _flexible_server_create(cmd, client,
resource_group_name=None, server_name=None,
Expand Down
16 changes: 16 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 @@ -116,6 +116,22 @@ def validate_private_endpoint_connection_id(cmd, namespace):
del namespace.connection_id


def pg_storage_validator(ns):
if ns.storage_mb:
if str(ns.storage_mb) in ['32', '64', '128', '256', '512', '1024', '2048', '4096', '8192', '16384']:
ns.storage_mb = int(ns.storage_mb) * 1024
else:
raise CLIError('Incorrect Value : Allowed values(in GB) : {32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384}')


def mysql_storage_validator(ns):
if ns.storage_mb:
if 10 <= int(ns.storage_mb) <= 16384:
ns.storage_mb = int(ns.storage_mb) * 1024
else:
raise CLIError('Incorrect Value : Allowed values(in GB) : Integers ranging 10-16384')


def public_access_validator(ns):
if ns.public_access:
val = ns.public_access
Expand Down

0 comments on commit 74fc67f

Please sign in to comment.