Skip to content

Commit 1df023c

Browse files
authoredMar 22, 2024
[Mysql] az mysql flexible-server import create: Add support for online migration for single to flex (Azure#28599)
* added online migrate for single to flex * fix style * fix
1 parent 163de3a commit 1df023c

File tree

3 files changed

+46
-35
lines changed

3 files changed

+46
-35
lines changed
 

‎src/azure-cli/azure/cli/command_modules/mysql/_help.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,23 @@
239239
240240
examples:
241241
- name: >
242-
Trigger a Import from azure mysql single server.
242+
Trigger an Import from azure mysql single server.
243243
text: >
244244
az mysql flexible-server import create --data-source-type mysql_single \\
245245
--data-source test-single-server --resource-group test-rg \\
246246
--location northeurope --name testserver \\
247247
--sku-name Standard_B1ms --tier Burstable --public-access 0.0.0.0 \\
248248
--storage-size 32 --tags "key=value" --version 5.7 --high-availability ZoneRedundant \\
249249
--zone 1 --standby-zone 3 --storage-auto-grow Enabled --iops 500
250+
- name: >
251+
Trigger an Online Import from azure mysql single server.
252+
text: >
253+
az mysql flexible-server import create --data-source-type mysql_single \\
254+
--data-source test-single-server --mode "Online" --resource-group test-rg \\
255+
--location northeurope --name testserver \\
256+
--sku-name Standard_B1ms --tier Burstable --public-access 0.0.0.0 \\
257+
--storage-size 32 --tags "key=value" --version 5.7 --high-availability ZoneRedundant \\
258+
--zone 1 --standby-zone 3 --storage-auto-grow Enabled --iops 500
250259
- name: >
251260
Trigger a Import from source backup stored in azure blob container.
252261
text: >

‎src/azure-cli/azure/cli/command_modules/mysql/_params.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ def load_arguments(self, _): # pylint: disable=too-many-statements, too-many-
284284

285285
mode_arg_type = CLIArgumentType(
286286
options_list=['--mode'],
287-
arg_type=get_enum_type(['Offline']),
288-
help='Mode of import. Enum values: [Offline]. Default is Offline. '
287+
arg_type=get_enum_type(['Offline', 'Online']),
288+
help='Mode of import. Enum values: [Offline, Online]. Default is Offline. '
289289
)
290290

291291
with self.argument_context('mysql flexible-server') as c:

‎src/azure-cli/azure/cli/command_modules/mysql/custom.py

+34-32
Original file line numberDiff line numberDiff line change
@@ -491,39 +491,41 @@ def flexible_server_import_create(cmd, client,
491491
create_mode = 'Create'
492492
if data_source_type.lower() == 'mysql_single':
493493
if mode.lower() == 'offline':
494-
# Generating source_server_id from data_source depending on whether it is a server_name or resource_id
495-
if not is_valid_resource_id(data_source):
496-
if len(data_source.split('/')) == 1:
497-
source_server_id = resource_id(
498-
subscription=get_subscription_id(cmd.cli_ctx),
499-
resource_group=resource_group_name,
500-
namespace=provider,
501-
type='servers',
502-
name=data_source)
503-
else:
504-
raise ValidationError('The provided data-source {} is invalid.'.format(data_source))
505-
else:
506-
source_server_id = data_source
507-
508-
single_server_client = cf_mysql_servers(cli_ctx=cmd.cli_ctx, _=None)
509494
create_mode = 'Migrate'
510-
# Mapping the single server configuration to flexible server configuration
511-
(tier, sku_name, location, storage_gb, auto_grow, backup_retention,
512-
geo_redundant_backup, version, tags, public_access, administrator_login) = map_single_server_configuration(single_server_client=single_server_client,
513-
source_server_id=source_server_id,
514-
tier=tier,
515-
sku_name=sku_name,
516-
location=location,
517-
storage_gb=storage_gb,
518-
auto_grow=auto_grow,
519-
backup_retention=backup_retention,
520-
geo_redundant_backup=geo_redundant_backup,
521-
version=version,
522-
tags=tags,
523-
public_access=public_access,
524-
subnet=subnet,
525-
administrator_login=administrator_login,
526-
administrator_login_password=administrator_login_password)
495+
elif mode.lower() == 'online':
496+
create_mode = 'OnlineMigrate'
497+
# Generating source_server_id from data_source depending on whether it is a server_name or resource_id
498+
if not is_valid_resource_id(data_source):
499+
if len(data_source.split('/')) == 1:
500+
source_server_id = resource_id(
501+
subscription=get_subscription_id(cmd.cli_ctx),
502+
resource_group=resource_group_name,
503+
namespace=provider,
504+
type='servers',
505+
name=data_source)
506+
else:
507+
raise ValidationError('The provided data-source {} is invalid.'.format(data_source))
508+
else:
509+
source_server_id = data_source
510+
511+
single_server_client = cf_mysql_servers(cli_ctx=cmd.cli_ctx, _=None)
512+
# Mapping the single server configuration to flexible server configuration
513+
(tier, sku_name, location, storage_gb, auto_grow, backup_retention,
514+
geo_redundant_backup, version, tags, public_access, administrator_login) = map_single_server_configuration(single_server_client=single_server_client,
515+
source_server_id=source_server_id,
516+
tier=tier,
517+
sku_name=sku_name,
518+
location=location,
519+
storage_gb=storage_gb,
520+
auto_grow=auto_grow,
521+
backup_retention=backup_retention,
522+
geo_redundant_backup=geo_redundant_backup,
523+
version=version,
524+
tags=tags,
525+
public_access=public_access,
526+
subnet=subnet,
527+
administrator_login=administrator_login,
528+
administrator_login_password=administrator_login_password)
527529
elif data_source_type.lower() == 'azure_blob':
528530
(tier, sku_name, storage_gb, auto_grow, backup_retention,
529531
geo_redundant_backup, version, administrator_login) = get_default_flex_configuration(tier=tier,

0 commit comments

Comments
 (0)