Skip to content

Commit

Permalink
RDBMS: Support storage auto-grow for MySQL, PostgreSQL and MariaDB(#9821
Browse files Browse the repository at this point in the history
)
  • Loading branch information
QingqingYuan2 authored and yugangw-msft committed Jul 9, 2019
1 parent 7c9db0b commit d22d8b8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/azure-cli/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ Release History

**RDBMS**

* Support storage auto-grow for MySQL, PostgreSQL and MariaDB

* Support replication for MariaDB.

**SQL**
Expand Down
2 changes: 2 additions & 0 deletions src/azure-cli/azure/cli/command_modules/rdbms/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def _complex_params(command_group):
c.argument('backup_retention', type=int, options_list=['--backup-retention'], help='The number of days a backup is retained. Range of 7 to 35 days. Default is 7 days.', validator=retention_validator)
c.argument('geo_redundant_backup', arg_type=get_enum_type(['Enabled', 'Disabled']), options_list=['--geo-redundant-backup'], help='Enable or disable geo-redundant backups. Default value is Disabled. Not supported in Basic pricing tier.')
c.argument('storage_mb', options_list=['--storage-size'], type=int, help='The storage capacity of the server (unit is megabytes). Minimum 5120 and increases in 1024 increments. Default is 51200.')
c.argument('auto_grow', arg_type=get_enum_type(['Enabled', 'Disabled']), options_list=['--auto-grow'], help='Enable or disable autogrow of the storage. Default value is Enabled.')

c.argument('location', arg_type=get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group)
c.argument('version', help='Server major version.')
Expand Down Expand Up @@ -84,6 +85,7 @@ def _complex_params(command_group):
c.argument('family', options_list=['--family'], arg_type=get_enum_type(['Gen4', 'Gen5']), help='Hardware generation.')
c.argument('storage_mb', options_list=['--storage-size'], type=int, help='The storage capacity of the server (unit is megabytes). Minimum 5120 and increases in 1024 increments. Default is 51200.')
c.argument('backup_retention', options_list=['--backup-retention'], type=int, help='The number of days a backup is retained. Range of 7 to 35 days. Default is 7 days.', validator=retention_validator)
c.argument('auto_grow', arg_type=get_enum_type(['Enabled', 'Disabled']), options_list=['--auto-grow'], help='Enable or disable autogrow of the storage. Default value is Enabled.')
c.argument('tags', tags_type)

for scope in ['mariadb server-logs', 'mysql server-logs', 'postgres server-logs']:
Expand Down
17 changes: 12 additions & 5 deletions src/azure-cli/azure/cli/command_modules/rdbms/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

def _server_create(cmd, client, resource_group_name, server_name, sku_name, no_wait=False,
location=None, administrator_login=None, administrator_login_password=None, backup_retention=None,
geo_redundant_backup=None, ssl_enforcement=None, storage_mb=None, tags=None, version=None):
geo_redundant_backup=None, ssl_enforcement=None, storage_mb=None, tags=None, version=None, auto_grow='Enabled'):
provider = 'Microsoft.DBforPostgreSQL'
if isinstance(client, MySqlServersOperations):
provider = 'Microsoft.DBforMySQL'
Expand All @@ -38,7 +38,8 @@ def _server_create(cmd, client, resource_group_name, server_name, sku_name, no_w
storage_profile=mysql.models.StorageProfile(
backup_retention_days=backup_retention,
geo_redundant_backup=geo_redundant_backup,
storage_mb=storage_mb)),
storage_mb=storage_mb,
storage_autogrow=auto_grow)),
location=location,
tags=tags)
elif provider == 'Microsoft.DBforPostgreSQL':
Expand All @@ -53,7 +54,8 @@ def _server_create(cmd, client, resource_group_name, server_name, sku_name, no_w
storage_profile=postgresql.models.StorageProfile(
backup_retention_days=backup_retention,
geo_redundant_backup=geo_redundant_backup,
storage_mb=storage_mb)),
storage_mb=storage_mb,
storage_autogrow=auto_grow)),
location=location,
tags=tags)
elif provider == 'Microsoft.DBforMariaDB':
Expand All @@ -68,7 +70,8 @@ def _server_create(cmd, client, resource_group_name, server_name, sku_name, no_w
storage_profile=mariadb.models.StorageProfile(
backup_retention_days=backup_retention,
geo_redundant_backup=geo_redundant_backup,
storage_mb=storage_mb)),
storage_mb=storage_mb,
storage_autogrow=auto_grow)),
location=location,
tags=tags)

Expand Down Expand Up @@ -279,7 +282,8 @@ def _server_update_custom_func(instance,
backup_retention=None,
administrator_login_password=None,
ssl_enforcement=None,
tags=None):
tags=None,
auto_grow=None):
from importlib import import_module
server_module_path = instance.__module__
module = import_module(server_module_path.replace('server', 'server_update_parameters'))
Expand All @@ -299,6 +303,9 @@ def _server_update_custom_func(instance,
if backup_retention:
instance.storage_profile.backup_retention_days = backup_retention

if auto_grow:
instance.storage_profile.storage_autogrow = auto_grow

params = ServerUpdateParameters(sku=instance.sku,
storage_profile=instance.storage_profile,
administrator_login_password=administrator_login_password,
Expand Down

0 comments on commit d22d8b8

Please sign in to comment.