Skip to content

Commit ab10e2b

Browse files
author
Saif Al-Din Ali
committed
Process project name
1 parent f17cbe1 commit ab10e2b

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

src/migrate/azext_migrate/custom.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def new_local_server_replication(cmd,
172172
subscription_id = get_subscription_id(cmd.cli_ctx)
173173
print(f"Selected Subscription Id: '{subscription_id}'")
174174

175-
rg_uri, machine_id, subscription_id = validate_server_parameters(
175+
rg_uri, machine_id, subscription_id, project_name = validate_server_parameters(
176176
cmd,
177177
machine_id,
178178
machine_index,
@@ -239,7 +239,7 @@ def new_local_server_replication(cmd,
239239
"Please verify your appliance setup and provided "
240240
"-machine_id.")
241241

242-
amh_solution, migrate_project, machine_props = process_amh_solution(
242+
amh_solution, migrate_project, machine_props, project_name = process_amh_solution(
243243
cmd,
244244
machine,
245245
site_object,

src/migrate/azext_migrate/helpers/replication/new/_process_inputs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def process_amh_solution(cmd,
228228
f"'{resource_group_name}' and project '{project_name}'. "
229229
"Please verify your appliance setup."
230230
)
231-
return amh_solution, migrate_project, machine_props
231+
return amh_solution, migrate_project, machine_props, project_name
232232

233233

234234
def process_replication_vault(cmd,

src/migrate/azext_migrate/helpers/replication/new/_validate.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ def validate_server_parameters( # pylint: disable=too-many-locals,too-many-bran
206206
# machine_id was provided directly
207207
# Check if it's in Microsoft.Migrate format and needs to be resolved
208208
if "/Microsoft.Migrate/MigrateProjects/" in machine_id or "/Microsoft.Migrate/migrateprojects/" in machine_id:
209+
# Extract project_name from the Microsoft.Migrate machine ID
210+
migrate_id_parts = machine_id.split("/")
211+
if len(migrate_id_parts) >= 9 and not project_name:
212+
project_name = migrate_id_parts[8]
213+
209214
# This is a Migrate Project machine ID, need to resolve to OffAzure machine ID
210215
migrate_machine = get_resource_by_id(
211216
cmd, machine_id, APIVersion.Microsoft_Migrate.value)
@@ -257,7 +262,7 @@ def validate_server_parameters( # pylint: disable=too-many-locals,too-many-bran
257262
f"/subscriptions/{subscription_id}/"
258263
f"resourceGroups/{resource_group_name}")
259264

260-
return rg_uri, machine_id, subscription_id
265+
return rg_uri, machine_id, subscription_id, project_name
261266

262267

263268
def validate_required_parameters(machine_id,

src/migrate/azext_migrate/tests/latest/test_migrate_commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3246,7 +3246,7 @@ def test_process_amh_solution_project_from_discovery(self, mock_get_resource):
32463246

32473247
mock_get_resource.side_effect = [mock_project, mock_amh]
32483248

3249-
amh, project, props = process_amh_solution(
3249+
amh, _, _, _ = process_amh_solution(
32503250
mock_cmd, mock_machine, mock_site, None, 'rg1', 'machine1',
32513251
'/subscriptions/sub1/resourceGroups/rg1'
32523252
)

0 commit comments

Comments
 (0)