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

[Network-Manager] BREAKING CHANGE: Make some params required and remove some non-updatable params, fixes for upcoming GA #6843

Merged
merged 7 commits into from
Oct 10, 2023
Merged
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
6 changes: 6 additions & 0 deletions src/network-manager/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

Release History
===============
1.0.0
+++++
* Fix example and help info (Fix #6788)
* BREAKING CHANGE: Make params required and remove non-updatable params (Fix #6786)
* Fix `az network manager security-admin-config rule-collection rule update`: Fix to respect params provided. (Fix #6787)

1.0.0b2
+++++
* `az network manager group static-member create`: Fix cross-tenant --resource-id
Expand Down
16 changes: 8 additions & 8 deletions src/network-manager/azext_network_manager/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
Usage: --applies-to-groups network-group-id=XX use-hub-gateway=XX is-global=XX group-connectivity=XX

network-group-id: Network group Id.
use-hub-gateway: Flag if need to use hub gateway.
is-global: Flag if global is supported.
group-connectivity: Group connectivity type. Allowed values: None, DirectlyConnected
use-hub-gateway: Flag if need to use hub gateway. Only required if topology is Hub and Spoke.
is-global: Flag if global is supported. Only required if topology is Hub and Spoke.
group-connectivity: Group connectivity type. Only required if topology is Hub and Spoke. Allowed values: None, DirectlyConnected

Multiple actions can be specified by using more than one --applies-to-groups argument.
- name: --hub
Expand All @@ -66,7 +66,7 @@
Usage: --hub resource-id=XX resource-type=XX

resource-id: Resource ID
resource-type: Resource Type
resource-type: Resource type, suggested value(s): 'Microsoft.Network/virtualNetworks'

examples:
- name: Create/Update Azure Virtual Network Manager Connectivity Configuration
Expand All @@ -90,9 +90,9 @@
Usage: --applies-to-groups network-group-id=XX use-hub-gateway=XX is-global=XX group-connectivity=XX

network-group-id: Network group Id.
use-hub-gateway: Flag if need to use hub gateway.
is-global: Flag if global is supported.
group-connectivity: Group connectivity type. Allowed values: None, DirectlyConnected
use-hub-gateway: Flag if need to use hub gateway. Only required if topology is Hub and Spoke.
is-global: Flag if global is supported. Only required if topology is Hub and Spoke.
group-connectivity: Group connectivity type. Only required if topology is Hub and Spoke. Allowed values: None, DirectlyConnected

Multiple actions can be specified by using more than one --applies-to-groups argument.
- name: --hub
Expand All @@ -101,7 +101,7 @@
Usage: --hub resource-id=XX resource-type=XX

resource-id: Resource ID
resource-type: Resource Type
resource-type: Resource type, suggested value(s): 'Microsoft.Network/virtualNetworks'
"""

helps['network manager security-admin-config rule-collection create'] = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Create(AAZCommand):
"""Create a new network manager connectivity configuration

:example: Create/Update Azure Virtual Network Manager Connectivity Configuration
az network manager connect-config create --configuration-name "myTestConnectivityConfig" --description "Sample Configuration" --applies-to-groups group-connectivity="None" is- global=false network-group-id="subscriptions/subscriptionA/resourceGroups/myResourceGroup/pr oviders/Microsoft.Network/networkManagers/testNetworkManager/networkManagerGroups/group1" use-hub-gateway=true --connectivity-topology "HubAndSpoke" --delete-existing-peering true --hub resource-id="subscriptions/subscriptionA/resourceGroups/myResourceGroup/providers/Micr osoft.Network/virtualNetworks/myTestConnectivityConfig" resource- type="Microsoft.Network/virtualNetworks" --is-global true --network-manager-name "testNetworkManager" --resource-group "myResourceGroup"
az network manager connect-config create --configuration-name "myTestConnectivityConfig" --description "Sample Configuration" --applies-to-groups group-connectivity="None" is-global=false network-group-id="/subscriptions/subscriptionA/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkManagers/testNetworkManager/networkManagerGroups/group1" use-hub-gateway=true --connectivity-topology "HubAndSpoke" --delete-existing-peering true --hub resource-id="subscriptions/subscriptionA/resourceGroups/myResourceGroup/providers/Micr osoft.Network/virtualNetworks/myTestConnectivityConfig" resource- type="Microsoft.Network/virtualNetworks" --is-global true --network-manager-name "testNetworkManager" --resource-group "myResourceGroup"
"""

_aaz_info = {
Expand Down Expand Up @@ -101,13 +101,13 @@ def _build_arguments_schema(cls, *args, **kwargs):
_element = cls._args_schema.applies_to_groups.Element
_element.group_connectivity = AAZStrArg(
options=["group-connectivity"],
help="Group connectivity type.",
help="Group connectivity type. Only required if topology is Hub and Spoke.",
required=True,
enum={"DirectlyConnected": "DirectlyConnected", "None": "None"},
)
_element.is_global = AAZStrArg(
options=["is-global"],
help="Flag if global is supported.",
help="Flag if global is supported. Only required if topology is Hub and Spoke.",
enum={"False": "False", "True": "True"},
)
_element.network_group_id = AAZStrArg(
Expand All @@ -117,7 +117,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
)
_element.use_hub_gateway = AAZStrArg(
options=["use-hub-gateway"],
help="Flag if need to use hub gateway.",
help="Flag if need to use hub gateway. Only required if topology is Hub and Spoke.",
enum={"False": "False", "True": "True"},
)

Expand All @@ -131,7 +131,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
)
_element.resource_type = AAZStrArg(
options=["resource-type"],
help="Resource Type.",
help="Resource Type, suggested value(s): 'Microsoft.Network/virtualNetworks'",
)
return cls._args_schema

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ def _build_arguments_schema(cls, *args, **kwargs):
_element = cls._args_schema.applies_to_groups.Element
_element.group_connectivity = AAZStrArg(
options=["group-connectivity"],
help="Group connectivity type.",
help="Group connectivity type. Only required if topology is Hub and Spoke.",
enum={"DirectlyConnected": "DirectlyConnected", "None": "None"},
)
_element.is_global = AAZStrArg(
options=["is-global"],
help="Flag if global is supported.",
help="Flag if global is supported. Only required if topology is Hub and Spoke.",
nullable=True,
enum={"False": "False", "True": "True"},
)
Expand All @@ -123,7 +123,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
)
_element.use_hub_gateway = AAZStrArg(
options=["use-hub-gateway"],
help="Flag if need to use hub gateway.",
help="Flag if need to use hub gateway. Only required if topology is Hub and Spoke.",
nullable=True,
enum={"False": "False", "True": "True"},
)
Expand All @@ -141,7 +141,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
)
_element.resource_type = AAZStrArg(
options=["resource-type"],
help="Resource Type.",
help="Resource Type, suggested value(s): 'Microsoft.Network/virtualNetworks'",
nullable=True,
)
return cls._args_schema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Create(AAZCommand):
"""Create a network manager connection on this management group.

:example: Create network manager connection management-group
az network manager connection management-group create --management-group-id "testManagementGroupId" --connection-name "testNetworkManagerConnection" --network-manager "testNetworkManagerId" --description "A sample policy"
az network manager connection management-group create --management-group-id "testManagementGroupId" --connection-name "testNetworkManagerConnection" --network-manager "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Network/networkManagers/testNm" --description "A sample connection."
"""

_aaz_info = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ def _build_arguments_schema(cls, *args, **kwargs):
help="A description of the network manager connection.",
nullable=True,
)
_args_schema.network_manager_id = AAZStrArg(
options=["--network-manager", "--network-manager-id"],
arg_group="Properties",
help="Network Manager Id.",
nullable=True,
)
return cls._args_schema

def _execute_operations(self):
Expand Down Expand Up @@ -290,7 +284,6 @@ def _update_instance(self, instance):
properties = _builder.get(".properties")
if properties is not None:
properties.set_prop("description", AAZStrType, ".description")
properties.set_prop("networkManagerId", AAZStrType, ".network_manager_id")

return _instance_value

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@ def _build_arguments_schema(cls, *args, **kwargs):
help="A description of the network manager connection.",
nullable=True,
)
_args_schema.network_manager_id = AAZStrArg(
options=["--network-manager", "--network-manager-id"],
arg_group="Properties",
help="Network Manager Id.",
nullable=True,
)
return cls._args_schema

def _execute_operations(self):
Expand Down Expand Up @@ -286,7 +280,6 @@ def _update_instance(self, instance):
properties = _builder.get(".properties")
if properties is not None:
properties.set_prop("description", AAZStrType, ".description")
properties.set_prop("networkManagerId", AAZStrType, ".network_manager_id")

return _instance_value

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Create(AAZCommand):
"""Create a static member.

:example: Create network manager group static-member
az network manager group static-member create --network-group-name "testNetworkManagerGroup" --network-manager-name "testNetworkManager" --resource-group "rg1" --static-member-name "testStaticMember" --resource_id "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/ Microsoft.Network/virtualnetworks/virtual_network"
az network manager group static-member create --network-group-name "testNetworkManagerGroup" --network-manager-name "testNetworkManager" --resource-group "rg1" --static-member-name "testStaticMember" --resource-id "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/ Microsoft.Network/virtualnetworks/virtual_network"
"""

_aaz_info = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"network manager group static-member list",
)
class List(AAZCommand):
"""List the specified static member.
"""List the static members within a specific network group.

:example: List static member in a network manager group
az network manager group static-member list --network-manager-name "testNetworkManager" --resource-group "rg1" --network-group-name "testNetworkManagerGroup"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,6 @@ def _build_arguments_schema(cls, *args, **kwargs):
help="A description of the scope connection.",
nullable=True,
)
_args_schema.resource_id = AAZStrArg(
options=["--resource-id"],
arg_group="Properties",
help="Resource ID.",
nullable=True,
)
_args_schema.tenant_id = AAZStrArg(
options=["--tenant-id"],
arg_group="Properties",
help="Tenant ID.",
nullable=True,
)
return cls._args_schema

def _execute_operations(self):
Expand Down Expand Up @@ -317,8 +305,6 @@ def _update_instance(self, instance):
properties = _builder.get(".properties")
if properties is not None:
properties.set_prop("description", AAZStrType, ".description")
properties.set_prop("resourceId", AAZStrType, ".resource_id")
properties.set_prop("tenantId", AAZStrType, ".tenant_id")

return _instance_value

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Delete(AAZCommand):
"""Delete a network manager security admin configuration.

:example: Delete a network manager security admin configuration.
az network manager security-admin-config delete --configuration-name "myTestSecurityConfig" --network-manager-name "testNetworkManager" --resource-group "rg1" --force
az network manager security-admin-config delete --configuration-name "myTestSecurityConfig" --network-manager-name "testNetworkManager" --resource-group "rg1" --force n
"""

_aaz_info = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Create(AAZCommand):
"""Create an admin rule collection.

:example: Create security admin rule collections
az network manager security-admin-config rule-collection create --configuration-name "myTestSecurityConfig" --network-manager-name "testNetworkManager" -g "rg1" --rule-collection-name "myTestCollection" --description "A sample description" --applies-to-groups network-group-id="/subscriptions/sub_id/resourceGroups/rgid/providers/Microsoft.Network/networkManagers/TestNetworkManager/networkGroups/TestNetworkGroup"
az network manager security-admin-config rule-collection create --configuration-name "myTestSecurityConfig" --network-manager-name "testNetworkManager" -g "rg1" --rule-collection-name "myTestCollection" --description "A sample description" --applies-to-groups network-group-id="/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Network/networkManagers/testNetworkManager/networkGroups/testNetworkGroup"
"""

_aaz_info = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Update(AAZCommand):
"""Update an admin rule collection.

:example: Update security admin rule collection
az network manager security-admin-config rule-collection update --configuration-name "myTestSecurityConfig" --network-manager-name "testNetworkManager" --resource-group "rg1" --rule-collection-name "myTestCollection"
az network manager security-admin-config rule-collection update --configuration-name "myTestSecurityConfig" --network-manager-name "testNetworkManager" --resource-group "rg1" --rule-collection-name "myTestCollection" --description "Updated description." --applies-to-groups network-group-id="/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Network/networkManagers/testNetworkManager/networkGroups/testNetworkGroup"
"""

_aaz_info = {
Expand Down
14 changes: 13 additions & 1 deletion src/network-manager/azext_network_manager/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ def load_command_table(self, _):
g.custom_command('create', 'network_manager_admin_rule_collection_create')
g.custom_command('update', 'network_manager_admin_rule_collection_update')

with self.command_group("network manager group static-member") as g:
with self.command_group("network manager group static-member"):
from .custom import GroupStaticMemberCreate
self.command_table["network manager group static-member create"] = GroupStaticMemberCreate(loader=self)

with self.command_group("network manager scope-connection"):
from .custom import ScopeConnectionCreate
self.command_table["network manager scope-connection create"] = ScopeConnectionCreate(loader=self)

with self.command_group("network manager connection subscription"):
from .custom import ConnectionSubscriptionCreate
self.command_table["network manager connection subscription create"] = ConnectionSubscriptionCreate(loader=self)

with self.command_group("network manager connection management-group"):
from .custom import ConnectionManagementGroupCreate
self.command_table["network manager connection management-group create"] = ConnectionManagementGroupCreate(loader=self)
37 changes: 33 additions & 4 deletions src/network-manager/azext_network_manager/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
# pylint: disable=unused-argument
from knack.util import CLIError
from .aaz.latest.network.manager.group.static_member import Create as _GroupStaticMemberCreate
from .aaz.latest.network.manager.scope_connection import Create as _ScopeConnectionCreate
from .aaz.latest.network.manager.connection.management_group import Create as _ConnectionManagementGroupCreate
from .aaz.latest.network.manager.connection.subscription import Create as _ConnectionSubscriptionCreate


def network_manager_create(cmd,
Expand Down Expand Up @@ -180,10 +183,10 @@ def network_manager_admin_rule_create(cmd,
rule['configuration_name'] = configuration_name
rule['rule_collection_name'] = rule_collection_name
rule['rule_name'] = rule_name
if kind == "Default":
if kind == "Default" or flag is not None:
rule['default'] = {}
rule['default']['flag'] = flag
elif kind == "Custom":
else:
rule['custom'] = {}
rule['custom']['description'] = description
rule['custom']['protocol'] = protocol
Expand Down Expand Up @@ -221,11 +224,11 @@ def network_manager_admin_rule_update(cmd,
rule['configuration_name'] = configuration_name
rule['rule_collection_name'] = rule_collection_name
rule['rule_name'] = rule_name
if kind == "Default":
if kind == "Default" or flag is not None:
rule['default'] = {}
if flag is not None:
rule['default']['flag'] = flag
elif kind == "Custom":
else:
rule['custom'] = {}
if description is not None:
rule['custom']['description'] = description
Expand Down Expand Up @@ -256,4 +259,30 @@ def _build_arguments_schema(cls, *args, **kwargs):
args_schema.resource_id._fmt = AAZResourceIdArgFormat(
template="/subscriptions/{subscription}/resourceGroups/{resource_group}/providers/Microsoft.Network/virtualNetworks/{}",
)
args_schema.resource_id._required = True
return args_schema


class ScopeConnectionCreate(_ScopeConnectionCreate):
@classmethod
def _build_arguments_schema(cls, *args, **kwargs):
args_schema = super()._build_arguments_schema(*args, **kwargs)
args_schema.resource_id._required = True
args_schema.tenant_id._required = True
return args_schema


class ConnectionSubscriptionCreate(_ConnectionSubscriptionCreate):
@classmethod
def _build_arguments_schema(cls, *args, **kwargs):
args_schema = super()._build_arguments_schema(*args, **kwargs)
args_schema.network_manager_id._required = True
return args_schema


class ConnectionManagementGroupCreate(_ConnectionManagementGroupCreate):
@classmethod
def _build_arguments_schema(cls, *args, **kwargs):
args_schema = super()._build_arguments_schema(*args, **kwargs)
args_schema.network_manager_id._required = True
return args_schema
Loading