Skip to content

Commit a94194f

Browse files
committed
Made changes to make it so that the body for NVAs ILB Migration is optional
1 parent 8bead7f commit a94194f

5 files changed

Lines changed: 45 additions & 16 deletions

File tree

‎src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/virtual_appliance/migration/_commit.py‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Commit(AAZCommand):
2222
cannot be reversed with `abort`.
2323
2424
:example: Commit the migration of a Network Virtual Appliance to the new internal load balancer (ILB) architecture.
25-
az network virtual-appliance migration commit -n MyName -g MyRG --migration-type MigrateToNewILBArchitecture
25+
az network virtual-appliance migration commit -n MyName -g MyRG
2626
"""
2727

2828
_aaz_info = {
@@ -65,8 +65,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
6565
_args_schema.migration_type = AAZStrArg(
6666
options=["--migration-type"],
6767
arg_group="Properties",
68-
help="The type of migration workflow to commit for the Network Virtual Appliance. Must match the type used in the prepare and execute phases.",
69-
required=True,
68+
help="The type of migration workflow to commit for the Network Virtual Appliance. If omitted, the migration defaults to MigrateToNewILBArchitecture. Otherwise, it must match the type used in the prepare and execute phases.",
7069
enum={"MigrateToNewILBArchitecture": "MigrateToNewILBArchitecture", "MigrateToNewOSVersion": "MigrateToNewOSVersion"},
7170
)
7271
return cls._args_schema
@@ -177,7 +176,7 @@ def content(self):
177176

178177
properties = _builder.get(".properties")
179178
if properties is not None:
180-
properties.set_prop("migrationType", AAZStrType, ".migration_type", typ_kwargs={"flags": {"required": True}})
179+
properties.set_prop("migrationType", AAZStrType, ".migration_type")
181180

182181
return self.serialize_content(_content_value)
183182

‎src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/virtual_appliance/migration/_execute.py‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Execute(AAZCommand):
2222
completes, run `commit` to finalize the migration or `abort` to roll it back.
2323
2424
:example: Execute the migration of a Network Virtual Appliance to the new internal load balancer (ILB) architecture.
25-
az network virtual-appliance migration execute -n MyName -g MyRG --migration-type MigrateToNewILBArchitecture
25+
az network virtual-appliance migration execute -n MyName -g MyRG
2626
"""
2727

2828
_aaz_info = {
@@ -65,8 +65,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
6565
_args_schema.migration_type = AAZStrArg(
6666
options=["--migration-type"],
6767
arg_group="Properties",
68-
help="The type of migration workflow to execute for the Network Virtual Appliance. Must match the type used in the prepare phase.",
69-
required=True,
68+
help="The type of migration workflow to execute for the Network Virtual Appliance. If omitted, the migration defaults to MigrateToNewILBArchitecture. Otherwise, it must match the type used in the prepare phase.",
7069
enum={"MigrateToNewILBArchitecture": "MigrateToNewILBArchitecture", "MigrateToNewOSVersion": "MigrateToNewOSVersion"},
7170
)
7271
return cls._args_schema
@@ -177,7 +176,7 @@ def content(self):
177176

178177
properties = _builder.get(".properties")
179178
if properties is not None:
180-
properties.set_prop("migrationType", AAZStrType, ".migration_type", typ_kwargs={"flags": {"required": True}})
179+
properties.set_prop("migrationType", AAZStrType, ".migration_type")
181180

182181
return self.serialize_content(_content_value)
183182

‎src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/virtual_appliance/migration/_prepare.py‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Prepare(AAZCommand):
2222
stages the resources required to perform it.
2323
2424
:example: Prepare a Network Virtual Appliance for migration to the new internal load balancer (ILB) architecture.
25-
az network virtual-appliance migration prepare -n MyName -g MyRG --migration-type MigrateToNewILBArchitecture
25+
az network virtual-appliance migration prepare -n MyName -g MyRG
2626
"""
2727

2828
_aaz_info = {
@@ -65,8 +65,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
6565
_args_schema.migration_type = AAZStrArg(
6666
options=["--migration-type"],
6767
arg_group="Properties",
68-
help="The type of migration workflow to prepare for the Network Virtual Appliance.",
69-
required=True,
68+
help="The type of migration workflow to prepare for the Network Virtual Appliance. If omitted, the migration defaults to MigrateToNewILBArchitecture.",
7069
enum={"MigrateToNewILBArchitecture": "MigrateToNewILBArchitecture", "MigrateToNewOSVersion": "MigrateToNewOSVersion"},
7170
)
7271
_args_schema.marketplace_version = AAZStrArg(
@@ -183,7 +182,7 @@ def content(self):
183182
properties = _builder.get(".properties")
184183
if properties is not None:
185184
properties.set_prop("marketPlaceVersion", AAZStrType, ".marketplace_version")
186-
properties.set_prop("migrationType", AAZStrType, ".migration_type", typ_kwargs={"flags": {"required": True}})
185+
properties.set_prop("migrationType", AAZStrType, ".migration_type")
187186

188187
return self.serialize_content(_content_value)
189188

‎src/azure-cli/azure/cli/command_modules/network/tests/latest/test_network_commands.py‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8859,7 +8859,6 @@ def test_network_virtual_appliance_migration(self, resource_group):
88598859
'nva_name': 'clivirtualappliancemigration', # NVA name
88608860
'rg': resource_group,
88618861
'subscription': subscriptionId,
8862-
'migration_type': 'MigrateToNewILBArchitecture',
88638862
})
88648863

88658864
# Add the required extension
@@ -8895,7 +8894,7 @@ def test_network_virtual_appliance_migration(self, resource_group):
88958894
])
88968895

88978896
# Phase 1: prepare the migration to the new ILB architecture
8898-
self.cmd('network virtual-appliance migration prepare -g {rg} -n {nva_name} --migration-type {migration_type}')
8897+
self.cmd('network virtual-appliance migration prepare -g {rg} -n {nva_name}')
88998898

89008899
provisioning_state = self.cmd('network virtual-appliance show -g {rg} -n {nva_name}').get_output_in_json()['provisioningState']
89018900
retry_count = 0
@@ -8907,7 +8906,7 @@ def test_network_virtual_appliance_migration(self, resource_group):
89078906
provisioning_state = self.cmd('network virtual-appliance show -g {rg} -n {nva_name}').get_output_in_json()['provisioningState']
89088907

89098908
# Phase 2: execute the migration
8910-
self.cmd('network virtual-appliance migration execute -g {rg} -n {nva_name} --migration-type {migration_type}')
8909+
self.cmd('network virtual-appliance migration execute -g {rg} -n {nva_name}')
89118910

89128911
provisioning_state = self.cmd('network virtual-appliance show -g {rg} -n {nva_name}').get_output_in_json()['provisioningState']
89138912
retry_count = 0
@@ -8919,7 +8918,7 @@ def test_network_virtual_appliance_migration(self, resource_group):
89198918
provisioning_state = self.cmd('network virtual-appliance show -g {rg} -n {nva_name}').get_output_in_json()['provisioningState']
89208919

89218920
# Phase 3: commit the migration to finalize the new ILB architecture
8922-
self.cmd('network virtual-appliance migration commit -g {rg} -n {nva_name} --migration-type {migration_type}')
8921+
self.cmd('network virtual-appliance migration commit -g {rg} -n {nva_name}')
89238922

89248923
# Ensure that the provisioning state is 'Succeeded' after committing the migration
89258924
provisioning_state = self.cmd('network virtual-appliance show -g {rg} -n {nva_name}').get_output_in_json()['provisioningState']

‎src/azure-cli/azure/cli/command_modules/network/tests/latest/test_network_unit_tests.py‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,39 @@ def test_application_gateway_subresource_preserves_hsm_schema(self):
2424
self.assertIsNotNone(hsm.key_id)
2525
self.assertIsNotNone(hsm.public_cert_data)
2626

27+
def test_virtual_appliance_ilb_migration_allows_null_body(self):
28+
from azure.cli.core.aaz._command_ctx import AAZCommandCtx
29+
from azure.cli.core.mock import DummyCli
30+
from azure.cli.command_modules.network.aaz.latest.network.virtual_appliance.migration import (
31+
Commit, Execute, Prepare)
32+
33+
commands = (
34+
(Prepare, Prepare.NetworkVirtualAppliancesPrepareMigration),
35+
(Execute, Execute.NetworkVirtualAppliancesExecuteMigration),
36+
(Commit, Commit.NetworkVirtualAppliancesCommitMigration),
37+
)
38+
for command, operation_type in commands:
39+
schema = command._build_arguments_schema()
40+
self.assertFalse(schema.migration_type.to_cmd_arg('migration_type').type.settings['required'])
41+
42+
with self.subTest(command=command.__name__, body='null'):
43+
ctx = AAZCommandCtx(DummyCli(), schema, {})
44+
operation = object.__new__(operation_type)
45+
operation.ctx = ctx
46+
self.assertIsNone(operation.content)
47+
48+
with self.subTest(command=command.__name__, body='explicit'):
49+
ctx = AAZCommandCtx(DummyCli(), schema, {
50+
'migration_type': 'MigrateToNewOSVersion',
51+
})
52+
operation = object.__new__(operation_type)
53+
operation.ctx = ctx
54+
self.assertEqual(operation.content, {
55+
'properties': {
56+
'migrationType': 'MigrateToNewOSVersion',
57+
}
58+
})
59+
2760
def test_network_get_nic_ip_config(self):
2861
from azure.cli.command_modules.network.custom import _get_nic_ip_config
2962

0 commit comments

Comments
 (0)