Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Commit(AAZCommand):
cannot be reversed with `abort`.

:example: Commit the migration of a Network Virtual Appliance to the new internal load balancer (ILB) architecture.
az network virtual-appliance migration commit -n MyName -g MyRG --migration-type MigrateToNewILBArchitecture
az network virtual-appliance migration commit -n MyName -g MyRG
"""

_aaz_info = {
Expand Down Expand Up @@ -65,8 +65,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
_args_schema.migration_type = AAZStrArg(
options=["--migration-type"],
arg_group="Properties",
help="The type of migration workflow to commit for the Network Virtual Appliance. Must match the type used in the prepare and execute phases.",
required=True,
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.",
enum={"MigrateToNewILBArchitecture": "MigrateToNewILBArchitecture", "MigrateToNewOSVersion": "MigrateToNewOSVersion"},
)
return cls._args_schema
Expand Down Expand Up @@ -177,7 +176,7 @@ def content(self):

properties = _builder.get(".properties")
if properties is not None:
properties.set_prop("migrationType", AAZStrType, ".migration_type", typ_kwargs={"flags": {"required": True}})
properties.set_prop("migrationType", AAZStrType, ".migration_type")

return self.serialize_content(_content_value)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Execute(AAZCommand):
completes, run `commit` to finalize the migration or `abort` to roll it back.

:example: Execute the migration of a Network Virtual Appliance to the new internal load balancer (ILB) architecture.
az network virtual-appliance migration execute -n MyName -g MyRG --migration-type MigrateToNewILBArchitecture
az network virtual-appliance migration execute -n MyName -g MyRG
"""

_aaz_info = {
Expand Down Expand Up @@ -65,8 +65,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
_args_schema.migration_type = AAZStrArg(
options=["--migration-type"],
arg_group="Properties",
help="The type of migration workflow to execute for the Network Virtual Appliance. Must match the type used in the prepare phase.",
required=True,
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.",
enum={"MigrateToNewILBArchitecture": "MigrateToNewILBArchitecture", "MigrateToNewOSVersion": "MigrateToNewOSVersion"},
)
return cls._args_schema
Expand Down Expand Up @@ -177,7 +176,7 @@ def content(self):

properties = _builder.get(".properties")
if properties is not None:
properties.set_prop("migrationType", AAZStrType, ".migration_type", typ_kwargs={"flags": {"required": True}})
properties.set_prop("migrationType", AAZStrType, ".migration_type")

return self.serialize_content(_content_value)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Prepare(AAZCommand):
stages the resources required to perform it.

:example: Prepare a Network Virtual Appliance for migration to the new internal load balancer (ILB) architecture.
az network virtual-appliance migration prepare -n MyName -g MyRG --migration-type MigrateToNewILBArchitecture
az network virtual-appliance migration prepare -n MyName -g MyRG
"""

_aaz_info = {
Expand Down Expand Up @@ -65,8 +65,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
_args_schema.migration_type = AAZStrArg(
options=["--migration-type"],
arg_group="Properties",
help="The type of migration workflow to prepare for the Network Virtual Appliance.",
required=True,
help="The type of migration workflow to prepare for the Network Virtual Appliance. If omitted, the migration defaults to MigrateToNewILBArchitecture.",
enum={"MigrateToNewILBArchitecture": "MigrateToNewILBArchitecture", "MigrateToNewOSVersion": "MigrateToNewOSVersion"},
)
_args_schema.marketplace_version = AAZStrArg(
Expand Down Expand Up @@ -183,7 +182,7 @@ def content(self):
properties = _builder.get(".properties")
if properties is not None:
properties.set_prop("marketPlaceVersion", AAZStrType, ".marketplace_version")
properties.set_prop("migrationType", AAZStrType, ".migration_type", typ_kwargs={"flags": {"required": True}})
properties.set_prop("migrationType", AAZStrType, ".migration_type")

return self.serialize_content(_content_value)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8859,7 +8859,6 @@ def test_network_virtual_appliance_migration(self, resource_group):
'nva_name': 'clivirtualappliancemigration', # NVA name
'rg': resource_group,
'subscription': subscriptionId,
'migration_type': 'MigrateToNewILBArchitecture',
})

# Add the required extension
Expand Down Expand Up @@ -8895,7 +8894,7 @@ def test_network_virtual_appliance_migration(self, resource_group):
])

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

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

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

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

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

# Ensure that the provisioning state is 'Succeeded' after committing the migration
provisioning_state = self.cmd('network virtual-appliance show -g {rg} -n {nva_name}').get_output_in_json()['provisioningState']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,39 @@ def test_application_gateway_subresource_preserves_hsm_schema(self):
self.assertIsNotNone(hsm.key_id)
self.assertIsNotNone(hsm.public_cert_data)

def test_virtual_appliance_ilb_migration_allows_null_body(self):
from azure.cli.core.aaz._command_ctx import AAZCommandCtx
from azure.cli.core.mock import DummyCli
from azure.cli.command_modules.network.aaz.latest.network.virtual_appliance.migration import (
Commit, Execute, Prepare)

commands = (
(Prepare, Prepare.NetworkVirtualAppliancesPrepareMigration),
(Execute, Execute.NetworkVirtualAppliancesExecuteMigration),
(Commit, Commit.NetworkVirtualAppliancesCommitMigration),
)
for command, operation_type in commands:
schema = command._build_arguments_schema()
self.assertFalse(schema.migration_type.to_cmd_arg('migration_type').type.settings['required'])

with self.subTest(command=command.__name__, body='null'):
ctx = AAZCommandCtx(DummyCli(), schema, {})
operation = object.__new__(operation_type)
operation.ctx = ctx
self.assertIsNone(operation.content)

with self.subTest(command=command.__name__, body='explicit'):
ctx = AAZCommandCtx(DummyCli(), schema, {
'migration_type': 'MigrateToNewOSVersion',
})
operation = object.__new__(operation_type)
operation.ctx = ctx
self.assertEqual(operation.content, {
'properties': {
'migrationType': 'MigrateToNewOSVersion',
}
})

def test_network_get_nic_ip_config(self):
from azure.cli.command_modules.network.custom import _get_nic_ip_config

Expand Down
Loading