Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new child resources IPAM + VNV to existing CLI ext 'virtual-network-manager' #7989

Merged
merged 28 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d19fbda
Tests passing for both IPAM and VNV
danlope Sep 17, 2024
6ae6a2f
revert routing changes
danlope Sep 17, 2024
077077f
Merge branch 'main' into feature-ipam-vnv-2024-01-01-preview
danlope Sep 17, 2024
b726c44
update HISTORY.rst
danlope Sep 18, 2024
42707d3
update version in HISTORY.rst
danlope Sep 18, 2024
e0b8d82
corrected to prev version in HISTORY.rst
danlope Sep 19, 2024
108e972
reverted breaking changes for sec admin
danlope Sep 25, 2024
a64acda
added tests for sec admin rule
danlope Sep 25, 2024
6ef5e16
added --help for --desc arg to resolve CI failure "missing_parameter_…
danlope Sep 25, 2024
017c5de
Merge remote-tracking branch 'upstream/main' into feature-ipam-vnv-20…
danlope Sep 26, 2024
1d2875f
resolve ci failures: missing_parameter_help & option_length_too_long
danlope Sep 26, 2024
5eab807
not using brazilus.management.azure
danlope Sep 26, 2024
1222186
reverted test_network_manager_security_admin_config_crud
danlope Sep 26, 2024
733a069
added space to revert test_network_manager_security_admin_config_crud…
danlope Sep 26, 2024
7771f53
updated cassettes after syncing latest in azure-cli.. resolve CannotO…
danlope Sep 27, 2024
5edb0e8
Merge branch 'main' of https://github.com/Azure/azure-cli-extensions …
danlope Sep 27, 2024
9e83fe3
retry
danlope Sep 27, 2024
ad30bd6
Merge branch 'main' of https://github.com/Azure/azure-cli-extensions …
danlope Sep 27, 2024
a63736d
retry syncing latest from upstream
danlope Sep 27, 2024
29c66bf
resolving other cassettes
danlope Sep 28, 2024
93c5851
Merge remote-tracking branch 'upstream/main' into feature-ipam-vnv-20…
danlope Sep 30, 2024
23ff89b
update version to 1.3.0b1 in setup.py [cx will use this version when …
danlope Sep 30, 2024
070dda7
update version to b2 because of release-version-block error tag on CI…
danlope Oct 1, 2024
28e83fb
Merge branch 'main' of https://github.com/Azure/azure-cli-extensions …
danlope Oct 1, 2024
4966de9
reverted to 1.3.0b1
danlope Oct 1, 2024
8b6b1b0
trying 1.3.0
danlope Oct 1, 2024
b13974b
require location for vnv create
danlope Oct 1, 2024
17604d3
staticCidr and analysisRun tests + resolve CI failure missing_paramet…
danlope Oct 1, 2024
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
@@ -0,0 +1,24 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from azure.cli.core.aaz import *


@register_command_group(
"network manager ipam-pool",
is_preview=True,
)
class __CMDGroup(AAZCommandGroup):
"""Manage IPAM pool with network.
"""
pass


__all__ = ["__CMDGroup"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from .__cmd_group import *
from ._create import *
from ._delete import *
from ._get_pool_usage import *
from ._list import *
from ._list_associated_resource import *
from ._show import *
from ._update import *
from ._wait import *
Original file line number Diff line number Diff line change
@@ -0,0 +1,328 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from azure.cli.core.aaz import *


@register_command(
"network manager ipam-pool create",
is_preview=True,
)
class Create(AAZCommand):
"""Create the Pool resource.

:example: IpamPools_Create
az network manager ipam-pool create --name "myIpamPool" --network-manager-name "myAVNM" --resource-group "myAVNMResourceGroup" --address-prefixes "['10.0.0.0/16', '10.1.0.0/16']" --parent-pool-name "myParentIpamPool" --display-name "myIpamPoolDisplayName" --description "New Description"
"""

_aaz_info = {
"version": "2024-01-01-preview",
"resources": [
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networkmanagers/{}/ipampools/{}", "2024-01-01-preview"],
]
}

def _handler(self, command_args):
super()._handler(command_args)
self._execute_operations()
return self._output()

_args_schema = None

@classmethod
def _build_arguments_schema(cls, *args, **kwargs):
if cls._args_schema is not None:
return cls._args_schema
cls._args_schema = super()._build_arguments_schema(*args, **kwargs)

# define Arg Group ""

_args_schema = cls._args_schema
_args_schema.network_manager_name = AAZStrArg(
options=["--manager-name", "--network-manager-name"],
help="The name of the network manager.",
required=True,
fmt=AAZStrArgFormat(
pattern="^[a-zA-Z0-9-]*$",
),
)
_args_schema.pool_name = AAZStrArg(
options=["-n", "--name", "--pool-name"],
help="IP Address Manager Pool resource name.",
required=True,
fmt=AAZStrArgFormat(
pattern="^[a-zA-Z0-9-]*$",
),
)
_args_schema.resource_group = AAZResourceGroupNameArg(
required=True,
)

# define Arg Group "Body"

_args_schema = cls._args_schema
_args_schema.location = AAZResourceLocationArg(
arg_group="Body",
help="The geo-location where the resource lives",
required=True,
# todo: confirm
# fmt=AAZResourceLocationArgFormat(
# resource_group_arg="resource_group",
# ),
)
_args_schema.tags = AAZDictArg(
options=["--tags"],
arg_group="Body",
help="Resource tags.",
)

tags = cls._args_schema.tags
tags.Element = AAZStrArg()

# define Arg Group "Properties"

_args_schema = cls._args_schema
_args_schema.address_prefixes = AAZListArg(
options=["--address-prefixes"],
arg_group="Properties",
help="List of IP address prefixes of the resource.",
required=True,
)
_args_schema.description = AAZStrArg(
options=["--description"],
arg_group="Properties",
)
_args_schema.display_name = AAZStrArg(
options=["--display-name"],
arg_group="Properties",
help="String representing a friendly name for the resource.",
)
_args_schema.parent_pool_name = AAZStrArg(
options=["--parent-pool-name"],
arg_group="Properties",
help="String representing parent IpamPool resource name. If empty the IpamPool will be a root pool.",
)

address_prefixes = cls._args_schema.address_prefixes
address_prefixes.Element = AAZStrArg()
return cls._args_schema

def _execute_operations(self):
self.pre_operations()
self.IpamPoolsCreate(ctx=self.ctx)()
self.post_operations()

@register_callback
def pre_operations(self):
pass

@register_callback
def post_operations(self):
pass

def _output(self, *args, **kwargs):
result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True)
return result

class IpamPoolsCreate(AAZHttpOperation):
CLIENT_TYPE = "MgmtClient"

def __call__(self, *args, **kwargs):
request = self.make_request()
session = self.client.send_request(request=request, stream=False, **kwargs)
if session.http_response.status_code in [200, 201]:
return self.on_200_201(session)

return self.on_error(session.http_response)

@property
def url(self):
return self.client.format_url(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkManagers/{networkManagerName}/ipamPools/{poolName}",
**self.url_parameters
)

@property
def method(self):
return "PUT"

@property
def error_format(self):
return "MgmtErrorFormat"

@property
def url_parameters(self):
parameters = {
**self.serialize_url_param(
"networkManagerName", self.ctx.args.network_manager_name,
required=True,
),
**self.serialize_url_param(
"poolName", self.ctx.args.pool_name,
required=True,
),
**self.serialize_url_param(
"resourceGroupName", self.ctx.args.resource_group,
required=True,
),
**self.serialize_url_param(
"subscriptionId", self.ctx.subscription_id,
required=True,
),
}
return parameters

@property
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2024-01-01-preview",
required=True,
),
}
return parameters

@property
def header_parameters(self):
parameters = {
**self.serialize_header_param(
"Content-Type", "application/json",
),
**self.serialize_header_param(
"Accept", "application/json",
),
}
return parameters

@property
def content(self):
_content_value, _builder = self.new_content_builder(
self.ctx.args,
typ=AAZObjectType,
typ_kwargs={"flags": {"required": True, "client_flatten": True}}
)
_builder.set_prop("location", AAZStrType, ".location", typ_kwargs={"flags": {"required": True}})
_builder.set_prop("properties", AAZObjectType, ".", typ_kwargs={"flags": {"required": True}})
_builder.set_prop("tags", AAZDictType, ".tags")

properties = _builder.get(".properties")
if properties is not None:
properties.set_prop("addressPrefixes", AAZListType, ".address_prefixes", typ_kwargs={"flags": {"required": True}})
properties.set_prop("description", AAZStrType, ".description")
properties.set_prop("displayName", AAZStrType, ".display_name")
properties.set_prop("parentPoolName", AAZStrType, ".parent_pool_name")

address_prefixes = _builder.get(".properties.addressPrefixes")
if address_prefixes is not None:
address_prefixes.set_elements(AAZStrType, ".")

tags = _builder.get(".tags")
if tags is not None:
tags.set_elements(AAZStrType, ".")

return self.serialize_content(_content_value)

def on_200_201(self, session):
data = self.deserialize_http_content(session)
self.ctx.set_var(
"instance",
data,
schema_builder=self._build_schema_on_200_201
)

_schema_on_200_201 = None

@classmethod
def _build_schema_on_200_201(cls):
if cls._schema_on_200_201 is not None:
return cls._schema_on_200_201

cls._schema_on_200_201 = AAZObjectType()

_schema_on_200_201 = cls._schema_on_200_201
_schema_on_200_201.id = AAZStrType(
flags={"read_only": True},
)
_schema_on_200_201.location = AAZStrType(
flags={"required": True},
)
_schema_on_200_201.name = AAZStrType(
flags={"read_only": True},
)
_schema_on_200_201.properties = AAZObjectType(
flags={"required": True},
)
_schema_on_200_201.system_data = AAZObjectType(
serialized_name="systemData",
flags={"read_only": True},
)
_schema_on_200_201.tags = AAZDictType()
_schema_on_200_201.type = AAZStrType(
flags={"read_only": True},
)

properties = cls._schema_on_200_201.properties
properties.address_prefixes = AAZListType(
serialized_name="addressPrefixes",
flags={"required": True},
)
properties.description = AAZStrType()
properties.display_name = AAZStrType(
serialized_name="displayName",
)
properties.ip_address_type = AAZListType(
serialized_name="ipAddressType",
flags={"read_only": True},
)
properties.parent_pool_name = AAZStrType(
serialized_name="parentPoolName",
)
properties.provisioning_state = AAZStrType(
serialized_name="provisioningState",
flags={"read_only": True},
)

address_prefixes = cls._schema_on_200_201.properties.address_prefixes
address_prefixes.Element = AAZStrType()

ip_address_type = cls._schema_on_200_201.properties.ip_address_type
ip_address_type.Element = AAZStrType()

system_data = cls._schema_on_200_201.system_data
system_data.created_at = AAZStrType(
serialized_name="createdAt",
)
system_data.created_by = AAZStrType(
serialized_name="createdBy",
)
system_data.created_by_type = AAZStrType(
serialized_name="createdByType",
)
system_data.last_modified_at = AAZStrType(
serialized_name="lastModifiedAt",
)
system_data.last_modified_by = AAZStrType(
serialized_name="lastModifiedBy",
)
system_data.last_modified_by_type = AAZStrType(
serialized_name="lastModifiedByType",
)

tags = cls._schema_on_200_201.tags
tags.Element = AAZStrType()

return cls._schema_on_200_201


class _CreateHelper:
"""Helper class for Create"""


__all__ = ["Create"]
Loading
Loading