Skip to content

Commit bc56712

Browse files
committed
Adding preview tag for commands, moving migration to a seperate folder & update help text.
1 parent ffc8eac commit bc56712

File tree

10 files changed

+116
-269
lines changed

10 files changed

+116
-269
lines changed

src/migrate/azext_migrate/_help.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,3 +540,61 @@
540540
--name myJobName \\
541541
--subscription-id "12345678-1234-1234-1234-123456789012"
542542
"""
543+
544+
helps['migrate local start-migration'] = """
545+
type: command
546+
short-summary: Start migration for a replicating server to Azure Local.
547+
long-summary: |
548+
Initiates the migration (failover) process for a server that
549+
has been configured for replication to Azure Local or Azure Stack HCI.
550+
This command triggers the final migration step, which creates
551+
the virtual machine on the target Azure Local/Stack HCI environment.
552+
553+
The protected item must be in a healthy replication state
554+
before migration can be initiated.
555+
You can optionally specify whether to turn off the source server
556+
after migration completes.
557+
558+
Note: This command uses a preview API version
559+
and may experience breaking changes in future releases.
560+
parameters:
561+
- name: --protected-item-id --id
562+
short-summary: Full ARM resource ID of the protected item to migrate.
563+
long-summary: >
564+
The complete ARM resource ID of the replicating server.
565+
This ID can be obtained from the 'az migrate local replication list'
566+
or 'az migrate local replication get' commands.
567+
Required parameter.
568+
- name: --turn-off-source-server
569+
short-summary: Turn off the source server after migration.
570+
long-summary: >
571+
Specifies whether the source server should be powered off
572+
after the migration completes successfully.
573+
Default is False. Use this option to automatically shut down
574+
the source server to prevent conflicts.
575+
- name: --subscription-id
576+
short-summary: Azure subscription ID.
577+
long-summary: >
578+
The subscription containing the migration resources.
579+
Uses the current subscription if not specified.
580+
examples:
581+
- name: Start migration for a protected item
582+
text: |
583+
az migrate local start-migration \\
584+
--protected-item-id "/subscriptions/xxxx/resourceGroups/myRG/providers/Microsoft.DataReplication/replicationVaults/myVault/protectedItems/myItem"
585+
- name: Start migration and turn off source server
586+
text: |
587+
az migrate local start-migration \\
588+
--protected-item-id "/subscriptions/xxxx/resourceGroups/myRG/providers/Microsoft.DataReplication/replicationVaults/myVault/protectedItems/myItem" \\
589+
--turn-off-source-server
590+
- name: Start migration using short parameter names
591+
text: |
592+
az migrate local start-migration \\
593+
--id "/subscriptions/xxxx/resourceGroups/myRG/providers/Microsoft.DataReplication/replicationVaults/myVault/protectedItems/myItem" \\
594+
--turn-off-source-server
595+
- name: Start migration with specific subscription
596+
text: |
597+
az migrate local start-migration \\
598+
--protected-item-id "/subscriptions/xxxx/resourceGroups/myRG/providers/Microsoft.DataReplication/replicationVaults/myVault/protectedItems/myItem" \\
599+
--subscription-id "12345678-1234-1234-1234-123456789012"
600+
"""

src/migrate/azext_migrate/_params.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,3 +255,18 @@ def load_arguments(self, _):
255255
options_list=['--job-name', '--name'],
256256
help='Job identifier.')
257257
c.argument('subscription_id', subscription_id_type)
258+
259+
with self.argument_context('migrate local start-migration') as c:
260+
c.argument(
261+
'protected_item_id',
262+
options_list=['--protected-item-id', '--id'],
263+
help='The full ARM resource ID of the protected item to migrate. '
264+
'This can be obtained from the list or get replication commands.',
265+
required=True)
266+
c.argument(
267+
'turn_off_source_server',
268+
options_list=['--turn-off-source-server'],
269+
arg_type=get_three_state_flag(),
270+
help='Specifies whether the source server should be turned off '
271+
'after migration completes. Default is False.')
272+
c.argument('subscription_id', subscription_id_type)

src/migrate/azext_migrate/commands.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66

77
def load_command_table(self, _):
88
# Azure Local Migration Commands
9-
with self.command_group('migrate') as g:
9+
with self.command_group('migrate', is_preview=True) as g:
1010
g.custom_command('get-discovered-server', 'get_discovered_server')
1111

12-
with self.command_group('migrate local replication') as g:
12+
with self.command_group('migrate local replication', is_preview=True) as g:
1313
g.custom_command('init', 'initialize_replication_infrastructure')
1414
g.custom_command('new', 'new_local_server_replication')
1515
g.custom_command('list', 'list_local_server_replications')
1616
g.custom_command('get', 'get_local_server_replication')
1717
g.custom_command('remove', 'remove_local_server_replication')
1818
g.custom_command('get-job', 'get_local_replication_job')
1919

20-
with self.command_group('migrate local') as g:
20+
with self.command_group('migrate local', is_preview=True) as g:
2121
g.custom_command('start-migration', 'start_local_server_migration')

src/migrate/azext_migrate/custom.py

Lines changed: 2 additions & 232 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,6 @@ def get_discovered_server(cmd,
2020
subscription_id=None,
2121
name=None,
2222
appliance_name=None):
23-
"""
24-
Retrieve discovered servers from the Azure Migrate project.
25-
26-
Args:
27-
cmd: The CLI command context
28-
project_name (str): Specifies the migrate project name (required)
29-
resource_group (str): Specifies the resource group name
30-
(required)
31-
display_name (str, optional): Specifies the source machine
32-
display name
33-
source_machine_type (str, optional): Specifies the source machine
34-
type (VMware, HyperV)
35-
subscription_id (str, optional): Specifies the subscription id
36-
name (str, optional): Specifies the source machine name
37-
(internal name)
38-
appliance_name (str, optional): Specifies the appliance name
39-
(maps to site)
40-
41-
Returns:
42-
dict: The discovered server data from the API response
43-
44-
Raises:
45-
CLIError: If required parameters are missing or the API request
46-
fails
47-
"""
4823
from azext_migrate.helpers._utils import APIVersion
4924
from azext_migrate.helpers._server import (
5025
validate_get_discovered_server_params,
@@ -112,37 +87,6 @@ def initialize_replication_infrastructure(cmd,
11287
cache_storage_account_id=None,
11388
subscription_id=None,
11489
pass_thru=False):
115-
"""
116-
Initialize Azure Migrate local replication infrastructure.
117-
118-
This function is based on a preview API version and may experience
119-
breaking changes in future releases.
120-
121-
Args:
122-
cmd: The CLI command context
123-
resource_group (str): Specifies the Resource Group of the
124-
Azure Migrate Project (required)
125-
project_name (str): Specifies the name of the Azure Migrate
126-
project to be used for server migration (required)
127-
source_appliance_name (str): Specifies the source appliance name
128-
for the AzLocal scenario (required)
129-
target_appliance_name (str): Specifies the target appliance name
130-
for the AzLocal scenario (required)
131-
cache_storage_account_id (str, optional): Specifies the Storage
132-
Account ARM Id to be used for private endpoint scenario
133-
subscription_id (str, optional): Azure Subscription ID. Uses
134-
current subscription if not provided
135-
pass_thru (bool, optional): Returns True when the command
136-
succeeds
137-
138-
Returns:
139-
bool: True if the operation succeeds (when pass_thru is True),
140-
otherwise None
141-
142-
Raises:
143-
CLIError: If required parameters are missing or the API request
144-
fails
145-
"""
14690
from azure.cli.core.commands.client_factory import \
14791
get_subscription_id
14892
from azext_migrate.helpers.replication.init._execute_init import (
@@ -197,63 +141,6 @@ def new_local_server_replication(cmd,
197141
nic_to_include=None,
198142
os_disk_id=None,
199143
subscription_id=None):
200-
"""
201-
Create a new replication for an Azure Local server.
202-
203-
This cmdlet is based on a preview API version and may experience
204-
breaking changes in future releases.
205-
206-
Args:
207-
cmd: The CLI command context
208-
target_storage_path_id (str): Specifies the storage path ARM ID
209-
where the VMs will be stored (required)
210-
target_resource_group_id (str): Specifies the target resource
211-
group ARM ID where the migrated VM resources will reside
212-
(required)
213-
target_vm_name (str): Specifies the name of the VM to be created
214-
(required)
215-
source_appliance_name (str): Specifies the source appliance name
216-
for the AzLocal scenario (required)
217-
target_appliance_name (str): Specifies the target appliance name
218-
for the AzLocal scenario (required)
219-
machine_id (str, optional): Specifies the machine ARM ID of the
220-
discovered server to be migrated (required if machine_index
221-
not provided)
222-
machine_index (int, optional): Specifies the index of the
223-
discovered server from the list (1-based, required if
224-
machine_id not provided)
225-
project_name (str, optional): Specifies the migrate project name
226-
(required when using machine_index)
227-
resource_group (str, optional): Specifies the resource group
228-
name (required when using machine_index)
229-
target_vm_cpu_core (int, optional): Specifies the number of CPU
230-
cores
231-
target_virtual_switch_id (str, optional): Specifies the logical
232-
network ARM ID that the VMs will use (required for default
233-
user mode)
234-
target_test_virtual_switch_id (str, optional): Specifies the test
235-
logical network ARM ID that the VMs will use
236-
is_dynamic_memory_enabled (str, optional): Specifies if RAM is
237-
dynamic or not. Valid values: 'true', 'false'
238-
target_vm_ram (int, optional): Specifies the target RAM size in
239-
MB
240-
disk_to_include (list, optional): Specifies the disks on the
241-
source server to be included for replication (power user
242-
mode)
243-
nic_to_include (list, optional): Specifies the NICs on the source
244-
server to be included for replication (power user mode)
245-
os_disk_id (str, optional): Specifies the operating system disk
246-
for the source server to be migrated (required for default
247-
user mode)
248-
subscription_id (str, optional): Azure Subscription ID. Uses
249-
current subscription if not provided
250-
251-
Returns:
252-
dict: The job model from the API response
253-
254-
Raises:
255-
CLIError: If required parameters are missing or validation fails
256-
"""
257144
from azext_migrate.helpers._utils import SiteTypes
258145
from azext_migrate.helpers.replication.new._validate import (
259146
validate_server_parameters,
@@ -482,29 +369,6 @@ def get_local_replication_job(cmd,
482369
project_name=None,
483370
job_name=None,
484371
subscription_id=None):
485-
"""
486-
Retrieve the status of an Azure Migrate job.
487-
488-
This cmdlet is based on a preview API version and may experience
489-
breaking changes in future releases.
490-
491-
Args:
492-
cmd: The CLI command context
493-
job_id (str, optional): Specifies the job ARM ID for which
494-
the details need to be retrieved
495-
resource_group (str, optional): The name of the resource
496-
group where the recovery services vault is present
497-
project_name (str, optional): The name of the migrate project
498-
job_name (str, optional): Job identifier/name
499-
subscription_id (str, optional): Azure Subscription ID. Uses
500-
current subscription if not provided
501-
502-
Returns:
503-
dict or list: Job details (single job or list of jobs)
504-
505-
Raises:
506-
CLIError: If required parameters are missing or the job is not found
507-
"""
508372
from azure.cli.core.commands.client_factory import \
509373
get_subscription_id
510374
from azext_migrate.helpers.replication.job._parse import (
@@ -554,26 +418,6 @@ def list_local_server_replications(cmd,
554418
resource_group=None,
555419
project_name=None,
556420
subscription_id=None):
557-
"""
558-
List all protected items (replicating servers) in an Azure Migrate project.
559-
560-
This cmdlet is based on a preview API version and may experience
561-
breaking changes in future releases.
562-
563-
Args:
564-
cmd: The CLI command context
565-
resource_group (str, optional): The name of the resource group where
566-
the migrate project is present (required)
567-
project_name (str, optional): The name of the migrate project (required)
568-
subscription_id (str, optional): Azure Subscription ID. Uses
569-
current subscription if not provided
570-
571-
Returns:
572-
list: List of protected items with their replication status
573-
574-
Raises:
575-
CLIError: If required parameters are missing or the vault is not found
576-
"""
577421
from azure.cli.core.commands.client_factory import \
578422
get_subscription_id
579423
from azext_migrate.helpers.replication.list._execute_list import (
@@ -605,31 +449,6 @@ def get_local_server_replication(cmd,
605449
resource_group=None,
606450
project_name=None,
607451
subscription_id=None):
608-
"""
609-
Get details of a specific replicating server.
610-
611-
This cmdlet is based on a preview API version and may experience
612-
breaking changes in future releases.
613-
614-
Args:
615-
cmd: The CLI command context
616-
protected_item_name (str, optional): The name of the protected item
617-
protected_item_id (str, optional): The full ARM resource ID of the
618-
protected item
619-
resource_group (str, optional): The name of the resource group where
620-
the migrate project is present (required if using protected_item_name)
621-
project_name (str, optional): The name of the migrate project
622-
(required if using protected_item_name)
623-
subscription_id (str, optional): Azure Subscription ID. Uses
624-
current subscription if not provided
625-
626-
Returns:
627-
dict: Detailed information about the protected item
628-
629-
Raises:
630-
CLIError: If required parameters are missing or the protected item
631-
is not found
632-
"""
633452
from azure.cli.core.commands.client_factory import \
634453
get_subscription_id
635454
from azext_migrate.helpers.replication.get._execute_get import (
@@ -664,28 +483,6 @@ def remove_local_server_replication(cmd,
664483
target_object_id,
665484
force_remove=False,
666485
subscription_id=None):
667-
"""
668-
Stop replication for a migrated server.
669-
670-
This cmdlet is based on a preview API version and may experience
671-
breaking changes in future releases.
672-
673-
Args:
674-
cmd: The CLI command context
675-
target_object_id (str): Specifies the replicating server ARM ID
676-
for which replication needs to be disabled (required)
677-
force_remove (bool, optional): Specifies whether the replication
678-
needs to be force removed. Default is False
679-
subscription_id (str, optional): Azure Subscription ID. Uses
680-
current subscription if not provided
681-
682-
Returns:
683-
dict: The job model from the API response
684-
685-
Raises:
686-
CLIError: If the protected item is not found or cannot be
687-
removed in its current state
688-
"""
689486
from azure.cli.core.commands.client_factory import \
690487
get_subscription_id
691488
from azext_migrate.helpers.replication.remove._parse import (
@@ -720,39 +517,12 @@ def start_local_server_migration(cmd,
720517
protected_item_id=None,
721518
turn_off_source_server=False,
722519
subscription_id=None):
723-
"""
724-
Start migration for a local server.
725-
726-
This cmdlet is based on a preview API version and may experience
727-
breaking changes in future releases.
728-
729-
Args:
730-
cmd: The CLI command context
731-
protected_item_name (str, optional): The name of the protected item
732-
protected_item_id (str, optional): The full ARM resource ID of the
733-
protected item
734-
resource_group (str, optional): The name of the resource group where
735-
the migrate project is present (required if using protected_item_name)
736-
project_name (str, optional): The name of the migrate project
737-
(required if using protected_item_name)
738-
turn_off_source_server (bool, optional): Specifies whether the source
739-
server should be turned off post migration. Default is False
740-
subscription_id (str, optional): Azure Subscription ID. Uses
741-
current subscription if not provided
742-
743-
Returns:
744-
dict: Job model representing the migration operation
745-
746-
Raises:
747-
CLIError: If required parameters are missing or the protected item
748-
is not found or cannot be migrated
749-
"""
750520
from azure.cli.core.commands.client_factory import \
751521
get_subscription_id
752-
from azext_migrate.helpers.replication.migrate._parse import (
522+
from azext_migrate.helpers.migration.start._parse import (
753523
parse_protected_item_id
754524
)
755-
from azext_migrate.helpers.replication.migrate._execute_migrate import (
525+
from azext_migrate.helpers.migration.start._execute_migrate import (
756526
execute_migration
757527
)
758528

src/migrate/azext_migrate/helpers/replication/migrate/__init__.py renamed to src/migrate/azext_migrate/helpers/migration/__init__.py

File renamed without changes.

0 commit comments

Comments
 (0)