Skip to content

Commit ee21251

Browse files
saifaldin14Saif Al-Din AliCopilot
authored
[MIGRATE] Split custom.py to separate files and folder for easier maintainability (#9421)
* Create extension * Update src/migrate/azext_migrate/__init__.py Co-authored-by: Copilot <[email protected]> * Fix import issues * Update src/migrate/setup.py Co-authored-by: Copilot <[email protected]> * Small * Small lint * Small * disable lint for this check * Add json * Fix licesnse issue * fix small * Small * Get rid of unused variables * Add service name and code owner * New version * Style * Small * Update * Follow standard * Add suggestions * Small * Not preview * Add flag to become experimental * Update history * Fix * small * Create get job and remove replication commands * Add better error handling for jobs command * Add better messages to remove protected item * Return job id in remove command * Move helpers * Rename get discovered server helper * Refactor _initialize_replication_infrastructure_helpers * Refactor new replication * Refactor jobs * Refactor delete protected item * Fix lint issues * Change release version * Fix lint issues * Add fix * Updae correct version * Put beta version before * Fix * Update --------- Co-authored-by: Saif Al-Din Ali <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent ef668ae commit ee21251

26 files changed

+3684
-2342
lines changed

src/migrate/HISTORY.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33
Release History
44
===============
55

6-
1.0.0
6+
3.0.0b1
77
+++++++++++++++
8-
* Initial release.
8+
* Refactor codebase for improved readability and maintainability.
9+
10+
2.0.1b1
11+
+++++++++++++++
12+
* Switch to experimental version.
913

1014
2.0.0
1115
+++++++++++++++
1216
* New version.
1317

14-
2.0.1b1
18+
1.0.0
1519
+++++++++++++++
16-
* Switch to experimental version.
20+
* Initial release.

src/migrate/azext_migrate/_help.py

Lines changed: 121 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,31 +71,31 @@
7171
text: |
7272
az migrate local get-discovered-server \\
7373
--project-name myMigrateProject \\
74-
--resource-group-name myRG
74+
--resource-group myRG
7575
- name: Get a specific discovered server by name
7676
text: |
7777
az migrate local get-discovered-server \\
7878
--project-name myMigrateProject \\
79-
--resource-group-name myRG \\
79+
--resource-group myRG \\
8080
--name machine-12345
8181
- name: Filter discovered servers by display name
8282
text: |
8383
az migrate local get-discovered-server \\
8484
--project-name myMigrateProject \\
85-
--resource-group-name myRG \\
85+
--resource-group myRG \\
8686
--display-name "web-server"
8787
- name: List VMware servers discovered by a specific appliance
8888
text: |
8989
az migrate local get-discovered-server \\
9090
--project-name myMigrateProject \\
91-
--resource-group-name myRG \\
91+
--resource-group myRG \\
9292
--appliance-name myVMwareAppliance \\
9393
--source-machine-type VMware
9494
- name: Get a specific server from a specific appliance
9595
text: |
9696
az migrate local get-discovered-server \\
9797
--project-name myMigrateProject \\
98-
--resource-group-name myRG \\
98+
--resource-group myRG \\
9999
--appliance-name myAppliance \\
100100
--name machine-12345 \\
101101
--source-machine-type HyperV
@@ -152,14 +152,14 @@
152152
- name: Initialize replication infrastructure
153153
text: |
154154
az migrate local replication init \\
155-
--resource-group-name myRG \\
155+
--resource-group myRG \\
156156
--project-name myMigrateProject \\
157157
--source-appliance-name myVMwareAppliance \\
158158
--target-appliance-name myAzStackHCIAppliance
159159
- name: Initialize and return success status
160160
text: |
161161
az migrate local replication init \\
162-
--resource-group-name myRG \\
162+
--resource-group myRG \\
163163
--project-name myMigrateProject \\
164164
--source-appliance-name mySourceAppliance \\
165165
--target-appliance-name myTargetAppliance \\
@@ -268,7 +268,7 @@
268268
az migrate local replication new \\
269269
--machine-index 1 \\
270270
--project-name myMigrateProject \\
271-
--resource-group-name myRG \\
271+
--resource-group myRG \\
272272
--target-storage-path-id "XZXZ" \\
273273
--target-resource-group-id "YZYZ" \\
274274
--target-vm-name migratedVM01 \\
@@ -303,3 +303,116 @@
303303
--target-test-virtual-switch-id "XYXY" \\
304304
--os-disk-id "disk-0"
305305
"""
306+
307+
helps['migrate local replication remove'] = """
308+
type: command
309+
short-summary: Stop replication for a migrated server.
310+
long-summary: |
311+
Stops the replication for a migrated server and removes
312+
the replication configuration.
313+
This command disables protection for the specified server.
314+
315+
Note: This command uses a preview API version
316+
and may experience breaking changes in future releases.
317+
parameters:
318+
- name: --target-object-id --id
319+
short-summary: Replicating server ARM ID to disable replication.
320+
long-summary: >
321+
Specifies the ARM resource ID of the replicating server
322+
for which replication needs to be disabled.
323+
The ID should be retrieved using a get or list command
324+
for replication items.
325+
- name: --force-remove --force
326+
short-summary: Force remove the replication.
327+
long-summary: >
328+
Specifies whether the replication needs to be
329+
force removed. Default is false.
330+
Use this option to remove replication even if
331+
the cleanup process encounters errors.
332+
- name: --subscription-id
333+
short-summary: Azure subscription ID.
334+
long-summary: >
335+
The subscription containing the replication resources.
336+
Uses the current subscription if not specified.
337+
examples:
338+
- name: Stop replication for a migrated server
339+
text: |
340+
az migrate local replication remove \\
341+
--target-object-id "XXXX"
342+
- name: Force remove replication for a server
343+
text: |
344+
az migrate local replication remove \\
345+
--target-object-id "XXXX" \\
346+
--force-remove true
347+
- name: Stop replication using short parameter names
348+
text: |
349+
az migrate local replication remove \\
350+
--id "XXXX" \\
351+
--force
352+
"""
353+
354+
helps['migrate local replication get-job'] = """
355+
type: command
356+
short-summary: Retrieve the status of an Azure Migrate job.
357+
long-summary: |
358+
Get the status and details of an Azure Migrate replication job.
359+
You can retrieve a specific job by its ARM ID or name,
360+
or list all jobs in a migrate project.
361+
362+
Note: This command uses a preview API version
363+
and may experience breaking changes in future releases.
364+
parameters:
365+
- name: --job-id --id
366+
short-summary: Job ARM ID for which details need to be retrieved.
367+
long-summary: >
368+
Specifies the full ARM resource ID of the job.
369+
When provided, retrieves the specific job details.
370+
- name: --resource-group -g
371+
short-summary: Resource group name where the vault is present.
372+
long-summary: >
373+
The name of the resource group containing
374+
the recovery services vault.
375+
Required when using --project-name.
376+
- name: --project-name
377+
short-summary: Name of the migrate project.
378+
long-summary: >
379+
The name of the Azure Migrate project.
380+
Required when using --resource-group.
381+
- name: --job-name --name
382+
short-summary: Job identifier/name.
383+
long-summary: >
384+
The name of the specific job to retrieve.
385+
If not provided, lists all jobs in the project.
386+
- name: --subscription-id
387+
short-summary: Azure subscription ID.
388+
long-summary: >
389+
The subscription containing the migrate project.
390+
Uses the current subscription if not specified.
391+
examples:
392+
- name: Get a specific job by ARM ID
393+
text: |
394+
az migrate local replication get-job \\
395+
--job-id "/subscriptions/{sub-id}/resourceGroups/{rg}/providers/Microsoft.DataReplication/replicationVaults/{vault}/jobs/{job-name}"
396+
- name: Get a specific job by name
397+
text: |
398+
az migrate local replication get-job \\
399+
--resource-group myRG \\
400+
--project-name myMigrateProject \\
401+
--job-name myJobName
402+
- name: List all jobs in a project
403+
text: |
404+
az migrate local replication get-job \\
405+
--resource-group myRG \\
406+
--project-name myMigrateProject
407+
- name: Get job using short parameter names
408+
text: |
409+
az migrate local replication get-job \\
410+
--id "/subscriptions/{sub-id}/resourceGroups/{rg}/providers/Microsoft.DataReplication/replicationVaults/{vault}/jobs/{job-name}"
411+
- name: Get job with specific subscription
412+
text: |
413+
az migrate local replication get-job \\
414+
-g myRG \\
415+
--project-name myMigrateProject \\
416+
--name myJobName \\
417+
--subscription-id "12345678-1234-1234-1234-123456789012"
418+
"""

0 commit comments

Comments
 (0)