Skip to content

Commit 6663409

Browse files
authored
[Network] az network virtual-appliance: Add --nva-interface-configurations parameter (#32470)
1 parent 48fc08b commit 6663409

File tree

14 files changed

+14314
-77
lines changed

14 files changed

+14314
-77
lines changed

src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/virtual_appliance/_create.py

Lines changed: 115 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
@register_command(
15-
"network virtual-appliance create"
15+
"network virtual-appliance create",
1616
)
1717
class Create(AAZCommand):
1818
"""Create an Azure network virtual appliance.
@@ -22,9 +22,9 @@ class Create(AAZCommand):
2222
"""
2323

2424
_aaz_info = {
25-
"version": "2023-11-01",
25+
"version": "2024-10-01",
2626
"resources": [
27-
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networkvirtualappliances/{}", "2023-11-01"],
27+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networkvirtualappliances/{}", "2024-10-01"],
2828
]
2929
}
3030

@@ -57,6 +57,11 @@ def _build_arguments_schema(cls, *args, **kwargs):
5757
# define Arg Group "Parameters"
5858

5959
_args_schema = cls._args_schema
60+
_args_schema.identity = AAZObjectArg(
61+
options=["--identity"],
62+
arg_group="Parameters",
63+
help="The service principal that has read access to cloud-init and config blob.",
64+
)
6065
_args_schema.location = AAZResourceLocationArg(
6166
arg_group="Parameters",
6267
help="Location. Values from: `az account list-locations`. You can configure the default location using `az configure --defaults location=<location>`.",
@@ -70,23 +75,30 @@ def _build_arguments_schema(cls, *args, **kwargs):
7075
help="Space-separated tags: key[=value] [key[=value] ...]. Use \"\" to clear existing tags.",
7176
)
7277

73-
_args_schema.identity = AAZObjectArg(
74-
options=["--identity"],
75-
arg_group="Parameters",
76-
help="The identity of the Network Virtual Appliance, if configured.",
77-
)
78-
7978
identity = cls._args_schema.identity
79+
identity.mi_system_assigned = AAZStrArg(
80+
options=["system-assigned", "mi-system-assigned"],
81+
help="Set the system managed identity.",
82+
blank="True",
83+
)
8084
identity.type = AAZStrArg(
8185
options=["type"],
82-
help="The type of identity used for the resource. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the Network Virtual Appliance.",
86+
help="The type of identity used for the resource. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine.",
8387
enum={"None": "None", "SystemAssigned": "SystemAssigned", "SystemAssigned, UserAssigned": "SystemAssigned, UserAssigned", "UserAssigned": "UserAssigned"},
8488
)
89+
identity.mi_user_assigned = AAZListArg(
90+
options=["user-assigned", "mi-user-assigned"],
91+
help="Set the user managed identities.",
92+
blank=[],
93+
)
8594
identity.user_assigned_identities = AAZDictArg(
8695
options=["user-assigned-identities"],
8796
help="The list of user identities associated with resource. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.",
8897
)
8998

99+
mi_user_assigned = cls._args_schema.identity.mi_user_assigned
100+
mi_user_assigned.Element = AAZStrArg()
101+
90102
user_assigned_identities = cls._args_schema.identity.user_assigned_identities
91103
user_assigned_identities.Element = AAZObjectArg(
92104
blank={},
@@ -123,10 +135,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
123135
arg_group="Properties",
124136
help="The delegation for the Virtual Appliance",
125137
)
126-
127-
#Manually changed --internet-ingress-public-ips to --internet-ingress-ips to make it lint compliant.
128-
#Will fix in Swagger in next release.
129-
_args_schema.internet_ingress_public_ips = AAZListArg(
138+
_args_schema.internet_ingress_ips = AAZListArg(
130139
options=["--internet-ingress-ips"],
131140
arg_group="Properties",
132141
help="List of Resource Uri of Public IPs for Internet Ingress Scenario.",
@@ -136,6 +145,14 @@ def _build_arguments_schema(cls, *args, **kwargs):
136145
arg_group="Properties",
137146
help="Network Profile containing configurations for Public and Private NIC.",
138147
)
148+
_args_schema.nva_interface_configurations = AAZListArg(
149+
options=["--interface-configs", "--nva-interface-configurations"],
150+
arg_group="Properties",
151+
help="The NVA in VNet interface configurations",
152+
fmt=AAZListArgFormat(
153+
max_length=3,
154+
),
155+
)
139156
_args_schema.asn = AAZIntArg(
140157
options=["--asn"],
141158
arg_group="Properties",
@@ -171,10 +188,10 @@ def _build_arguments_schema(cls, *args, **kwargs):
171188
help="The service name to which the NVA is delegated.",
172189
)
173190

174-
internet_ingress_public_ips = cls._args_schema.internet_ingress_public_ips
175-
internet_ingress_public_ips.Element = AAZObjectArg()
191+
internet_ingress_ips = cls._args_schema.internet_ingress_ips
192+
internet_ingress_ips.Element = AAZObjectArg()
176193

177-
_element = cls._args_schema.internet_ingress_public_ips.Element
194+
_element = cls._args_schema.internet_ingress_ips.Element
178195
_element.id = AAZResourceIdArg(
179196
options=["id"],
180197
help="Resource Uri of Public Ip",
@@ -211,6 +228,37 @@ def _build_arguments_schema(cls, *args, **kwargs):
211228
help="Whether or not this is primary IP configuration of the NIC.",
212229
)
213230

231+
nva_interface_configurations = cls._args_schema.nva_interface_configurations
232+
nva_interface_configurations.Element = AAZObjectArg()
233+
234+
_element = cls._args_schema.nva_interface_configurations.Element
235+
_element.name = AAZStrArg(
236+
options=["name"],
237+
help="Specifies the name of the interface. Maximum length is 70 characters.",
238+
fmt=AAZStrArgFormat(
239+
max_length=70,
240+
),
241+
)
242+
_element.subnet = AAZObjectArg(
243+
options=["subnet"],
244+
help="A subnet resource id where the NIC will be deployed. Each subnet resource uri should be unique.",
245+
)
246+
_element.type = AAZListArg(
247+
options=["type"],
248+
help="Specifies the NIC types for the NVA interface configuration. Allowed values: PrivateNic, PublicNic, AdditionalPrivateNic, AdditionalPublicNic. Only the combination of PrivateNic and PublicNic is currently supported.",
249+
)
250+
251+
subnet = cls._args_schema.nva_interface_configurations.Element.subnet
252+
subnet.id = AAZResourceIdArg(
253+
options=["id"],
254+
help="Resource Uri of Subnet",
255+
)
256+
257+
type = cls._args_schema.nva_interface_configurations.Element.type
258+
type.Element = AAZStrArg(
259+
enum={"AdditionalPrivateNic": "AdditionalPrivateNic", "AdditionalPublicNic": "AdditionalPublicNic", "PrivateNic": "PrivateNic", "PublicNic": "PublicNic"},
260+
)
261+
214262
# define Arg Group "Sku"
215263

216264
_args_schema = cls._args_schema
@@ -321,7 +369,7 @@ def url_parameters(self):
321369
def query_parameters(self):
322370
parameters = {
323371
**self.serialize_query_param(
324-
"api-version", "2023-11-01",
372+
"api-version", "2024-10-01",
325373
required=True,
326374
),
327375
}
@@ -346,29 +394,36 @@ def content(self):
346394
typ=AAZObjectType,
347395
typ_kwargs={"flags": {"required": True, "client_flatten": True}}
348396
)
397+
_builder.set_prop("identity", AAZIdentityObjectType, ".identity")
349398
_builder.set_prop("location", AAZStrType, ".location")
350-
_builder.set_prop("identity", AAZObjectType, ".identity")
351399
_builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}})
352400
_builder.set_prop("tags", AAZDictType, ".tags")
353401

354402
identity = _builder.get(".identity")
355403
if identity is not None:
356404
identity.set_prop("type", AAZStrType, ".type")
357405
identity.set_prop("userAssignedIdentities", AAZDictType, ".user_assigned_identities")
406+
identity.set_prop("userAssigned", AAZListType, ".mi_user_assigned", typ_kwargs={"flags": {"action": "create"}})
407+
identity.set_prop("systemAssigned", AAZStrType, ".mi_system_assigned", typ_kwargs={"flags": {"action": "create"}})
358408

359409
user_assigned_identities = _builder.get(".identity.userAssignedIdentities")
360410
if user_assigned_identities is not None:
361411
user_assigned_identities.set_elements(AAZObjectType, ".")
362412

413+
user_assigned = _builder.get(".identity.userAssigned")
414+
if user_assigned is not None:
415+
user_assigned.set_elements(AAZStrType, ".")
416+
363417
properties = _builder.get(".properties")
364418
if properties is not None:
365419
properties.set_prop("additionalNics", AAZListType, ".additional_nics")
366420
properties.set_prop("bootStrapConfigurationBlobs", AAZListType, ".boot_strap_config_blobs")
367421
properties.set_prop("cloudInitConfiguration", AAZStrType, ".cloud_init_config")
368422
properties.set_prop("cloudInitConfigurationBlobs", AAZListType, ".cloud_init_config_blobs")
369423
properties.set_prop("delegation", AAZObjectType, ".delegation")
370-
properties.set_prop("internetIngressPublicIps", AAZListType, ".internet_ingress_public_ips")
424+
properties.set_prop("internetIngressPublicIps", AAZListType, ".internet_ingress_ips")
371425
properties.set_prop("networkProfile", AAZObjectType, ".network_profile")
426+
properties.set_prop("nvaInterfaceConfigurations", AAZListType, ".nva_interface_configurations")
372427
properties.set_prop("nvaSku", AAZObjectType)
373428
properties.set_prop("virtualApplianceAsn", AAZIntType, ".asn")
374429
properties.set_prop("virtualHub", AAZObjectType)
@@ -432,6 +487,24 @@ def content(self):
432487
if properties is not None:
433488
properties.set_prop("primary", AAZBoolType, ".primary")
434489

490+
nva_interface_configurations = _builder.get(".properties.nvaInterfaceConfigurations")
491+
if nva_interface_configurations is not None:
492+
nva_interface_configurations.set_elements(AAZObjectType, ".")
493+
494+
_elements = _builder.get(".properties.nvaInterfaceConfigurations[]")
495+
if _elements is not None:
496+
_elements.set_prop("name", AAZStrType, ".name")
497+
_elements.set_prop("subnet", AAZObjectType, ".subnet")
498+
_elements.set_prop("type", AAZListType, ".type")
499+
500+
subnet = _builder.get(".properties.nvaInterfaceConfigurations[].subnet")
501+
if subnet is not None:
502+
subnet.set_prop("id", AAZStrType, ".id")
503+
504+
type = _builder.get(".properties.nvaInterfaceConfigurations[].type")
505+
if type is not None:
506+
type.set_elements(AAZStrType, ".")
507+
435508
nva_sku = _builder.get(".properties.nvaSku")
436509
if nva_sku is not None:
437510
nva_sku.set_prop("bundledScaleUnit", AAZStrType, ".scale_unit")
@@ -470,7 +543,7 @@ def _build_schema_on_200_201(cls):
470543
flags={"read_only": True},
471544
)
472545
_schema_on_200_201.id = AAZStrType()
473-
_schema_on_200_201.identity = AAZObjectType()
546+
_schema_on_200_201.identity = AAZIdentityObjectType()
474547
_schema_on_200_201.location = AAZStrType()
475548
_schema_on_200_201.name = AAZStrType(
476549
flags={"read_only": True},
@@ -542,12 +615,19 @@ def _build_schema_on_200_201(cls):
542615
properties.network_profile = AAZObjectType(
543616
serialized_name="networkProfile",
544617
)
618+
properties.nva_interface_configurations = AAZListType(
619+
serialized_name="nvaInterfaceConfigurations",
620+
)
545621
properties.nva_sku = AAZObjectType(
546622
serialized_name="nvaSku",
547623
)
548624
properties.partner_managed_resource = AAZObjectType(
549625
serialized_name="partnerManagedResource",
550626
)
627+
properties.private_ip_address = AAZStrType(
628+
serialized_name="privateIpAddress",
629+
flags={"read_only": True},
630+
)
551631
properties.provisioning_state = AAZStrType(
552632
serialized_name="provisioningState",
553633
flags={"read_only": True},
@@ -636,6 +716,20 @@ def _build_schema_on_200_201(cls):
636716
properties = cls._schema_on_200_201.properties.network_profile.network_interface_configurations.Element.properties.ip_configurations.Element.properties
637717
properties.primary = AAZBoolType()
638718

719+
nva_interface_configurations = cls._schema_on_200_201.properties.nva_interface_configurations
720+
nva_interface_configurations.Element = AAZObjectType()
721+
722+
_element = cls._schema_on_200_201.properties.nva_interface_configurations.Element
723+
_element.name = AAZStrType()
724+
_element.subnet = AAZObjectType()
725+
_element.type = AAZListType()
726+
727+
subnet = cls._schema_on_200_201.properties.nva_interface_configurations.Element.subnet
728+
subnet.id = AAZStrType()
729+
730+
type = cls._schema_on_200_201.properties.nva_interface_configurations.Element.type
731+
type.Element = AAZStrType()
732+
639733
nva_sku = cls._schema_on_200_201.properties.nva_sku
640734
nva_sku.bundled_scale_unit = AAZStrType(
641735
serialized_name="bundledScaleUnit",

src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/virtual_appliance/_delete.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ class Delete(AAZCommand):
2323
"""
2424

2525
_aaz_info = {
26-
"version": "2023-11-01",
26+
"version": "2024-10-01",
2727
"resources": [
28-
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networkvirtualappliances/{}", "2023-11-01"],
28+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networkvirtualappliances/{}", "2024-10-01"],
2929
]
3030
}
3131

@@ -143,7 +143,7 @@ def url_parameters(self):
143143
def query_parameters(self):
144144
parameters = {
145145
**self.serialize_query_param(
146-
"api-version", "2023-11-01",
146+
"api-version", "2024-10-01",
147147
required=True,
148148
),
149149
}

0 commit comments

Comments
 (0)