Skip to content

Commit ffc8eac

Browse files
committed
Added migrate command
1 parent 3b19466 commit ffc8eac

26 files changed

+6512
-304
lines changed

src/migrate/HISTORY.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
Release History
44
===============
55

6+
4.0.0b1
7+
+++++++++++++++
8+
* Added replication list, get and start migration commands.
9+
610
3.0.0b1
711
+++++++++++++++
812
* Refactor codebase for improved readability and maintainability.

src/migrate/azext_migrate/_help.py

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,130 @@
304304
--os-disk-id "disk-0"
305305
"""
306306

307+
helps['migrate local replication list'] = """
308+
type: command
309+
short-summary: List all protected items (replicating servers) in a project.
310+
long-summary: |
311+
Lists all servers that have replication enabled
312+
in an Azure Migrate project.
313+
This command shows the replication status, health,
314+
and configuration details for each protected server.
315+
316+
The command returns information including:
317+
- Protection state (e.g., Protected, ProtectedReplicating, EnablingFailed)
318+
- Replication health (Normal, Warning, Critical)
319+
- Source machine name and target VM name
320+
- Replication policy name
321+
- Resource IDs (used for remove command)
322+
- Health errors if any
323+
324+
Note: This command uses a preview API version
325+
and may experience breaking changes in future releases.
326+
parameters:
327+
- name: --resource-group -g
328+
short-summary: Resource group containing the Azure Migrate project.
329+
long-summary: >
330+
The name of the resource group where
331+
the Azure Migrate project is located.
332+
- name: --project-name
333+
short-summary: Name of the Azure Migrate project.
334+
long-summary: >
335+
The Azure Migrate project that contains
336+
the replicating servers.
337+
- name: --subscription-id
338+
short-summary: Azure subscription ID.
339+
long-summary: >
340+
The subscription containing the Azure Migrate project.
341+
Uses the default subscription if not specified.
342+
examples:
343+
- name: List all replicating servers in a project
344+
text: |
345+
az migrate local replication list \\
346+
--resource-group myRG \\
347+
--project-name myMigrateProject
348+
- name: List replicating servers with a specific subscription
349+
text: |
350+
az migrate local replication list \\
351+
--resource-group myRG \\
352+
--project-name myMigrateProject \\
353+
--subscription-id 00000000-0000-0000-0000-000000000000
354+
"""
355+
356+
helps['migrate local replication get'] = """
357+
type: command
358+
short-summary: Get detailed information about a specific replicating server.
359+
long-summary: |
360+
Retrieves comprehensive details about a specific protected item (replicating server)
361+
including its protection state, replication health, configuration settings,
362+
and historical information about failover operations.
363+
364+
You can retrieve the protected item either by:
365+
- Full ARM resource ID (--protected-item-id or --id)
366+
- Name with project context (--protected-item-name with --resource-group and --project-name)
367+
368+
The command returns detailed information including:
369+
- Basic information (name, resource ID, correlation ID)
370+
- Protection status (state, health, resync requirements)
371+
- Configuration (policy, replication extension)
372+
- Failover history (test, planned, unplanned)
373+
- Allowed operations
374+
- Machine details (source and target information)
375+
- Health errors with recommended actions (if any)
376+
377+
Note: This command uses a preview API version
378+
and may experience breaking changes in future releases.
379+
parameters:
380+
- name: --protected-item-id --id
381+
short-summary: Full ARM resource ID of the protected item.
382+
long-summary: >
383+
The complete ARM resource ID of the protected item.
384+
If provided, --resource-group and --project-name are not required.
385+
This ID can be obtained from the 'list' or 'new' commands.
386+
- name: --protected-item-name --name
387+
short-summary: Name of the protected item (replicating server).
388+
long-summary: >
389+
The name of the protected item to retrieve.
390+
When using this option, both --resource-group and --project-name
391+
are required to locate the item.
392+
- name: --resource-group -g
393+
short-summary: Resource group containing the Azure Migrate project.
394+
long-summary: >
395+
The name of the resource group where the Azure Migrate project is located.
396+
Required when using --protected-item-name.
397+
- name: --project-name
398+
short-summary: Name of the Azure Migrate project.
399+
long-summary: >
400+
The Azure Migrate project that contains the replicating server.
401+
Required when using --protected-item-name.
402+
- name: --subscription-id
403+
short-summary: Azure subscription ID.
404+
long-summary: >
405+
The subscription containing the Azure Migrate project.
406+
Uses the default subscription if not specified.
407+
examples:
408+
- name: Get a protected item by its full ARM resource ID
409+
text: |
410+
az migrate local replication get \\
411+
--protected-item-id "/subscriptions/xxxx/resourceGroups/myRG/providers/Microsoft.DataReplication/replicationVaults/myVault/protectedItems/myItem"
412+
- name: Get a protected item by name using project context
413+
text: |
414+
az migrate local replication get \\
415+
--protected-item-name myProtectedItem \\
416+
--resource-group myRG \\
417+
--project-name myMigrateProject
418+
- name: Get a protected item with specific subscription
419+
text: |
420+
az migrate local replication get \\
421+
--name myProtectedItem \\
422+
--resource-group myRG \\
423+
--project-name myMigrateProject \\
424+
--subscription-id 00000000-0000-0000-0000-000000000000
425+
- name: Get a protected item using short parameter names
426+
text: |
427+
az migrate local replication get \\
428+
--id "/subscriptions/xxxx/resourceGroups/myRG/providers/Microsoft.DataReplication/replicationVaults/myVault/protectedItems/myItem"
429+
"""
430+
307431
helps['migrate local replication remove'] = """
308432
type: command
309433
short-summary: Stop replication for a migrated server.

src/migrate/azext_migrate/_params.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,42 @@ def load_arguments(self, _):
184184
required=True)
185185
c.argument('subscription_id', subscription_id_type)
186186

187+
with self.argument_context('migrate local replication list') as c:
188+
c.argument(
189+
'resource_group',
190+
options_list=['--resource-group', '-g'],
191+
help='The name of the resource group where the migrate '
192+
'project is present.',
193+
required=True)
194+
c.argument(
195+
'project_name',
196+
project_name_type,
197+
help='The name of the migrate project.',
198+
required=True)
199+
c.argument('subscription_id', subscription_id_type)
200+
201+
with self.argument_context('migrate local replication get') as c:
202+
c.argument(
203+
'protected_item_name',
204+
options_list=['--protected-item-name', '--name'],
205+
help='The name of the protected item (replicating server).')
206+
c.argument(
207+
'protected_item_id',
208+
options_list=['--protected-item-id', '--id'],
209+
help='The full ARM resource ID of the protected item. '
210+
'If provided, --resource-group and --project-name are not required.')
211+
c.argument(
212+
'resource_group',
213+
options_list=['--resource-group', '-g'],
214+
help='The name of the resource group where the migrate '
215+
'project is present. Required when using --protected-item-name.')
216+
c.argument(
217+
'project_name',
218+
project_name_type,
219+
help='The name of the migrate project. Required when using '
220+
'--protected-item-name.')
221+
c.argument('subscription_id', subscription_id_type)
222+
187223
with self.argument_context('migrate local replication remove') as c:
188224
c.argument(
189225
'target_object_id',

src/migrate/azext_migrate/commands.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,10 @@ def load_command_table(self, _):
1212
with self.command_group('migrate local replication') as g:
1313
g.custom_command('init', 'initialize_replication_infrastructure')
1414
g.custom_command('new', 'new_local_server_replication')
15+
g.custom_command('list', 'list_local_server_replications')
16+
g.custom_command('get', 'get_local_server_replication')
1517
g.custom_command('remove', 'remove_local_server_replication')
1618
g.custom_command('get-job', 'get_local_replication_job')
19+
20+
with self.command_group('migrate local') as g:
21+
g.custom_command('start-migration', 'start_local_server_migration')

0 commit comments

Comments
 (0)