Skip to content

Commit e22162f

Browse files
Update networkfabric device refresh-configuration and reboot command parameters (#8926)
* Update networkfabric device refresh-configuration and reboot command parameters 'network-device-name' to 'resource-name' for consistency. * re-adding network-device-name parameter
1 parent 692f7b8 commit e22162f

15 files changed

+1010
-90
lines changed

src/managednetworkfabric/HISTORY.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
Release History
44
===============
55

6+
8.0.0b6
7+
* Enables the 'device refresh-configuration' command that was previously disabled/removed.
8+
* Renames the 'network-device-name' parameter on 'device refresh-configuration' and 'device reboot' operations to 'resource-name' for better overall consistency.
9+
610
8.0.0b5
711
* Fixes 'taprule create' command as the API cannot support float values for 'polling-interval-in-seconds' option, i.e. - '30.0'.
812
* Fixes the response object model for validate-configuration operations that cause response of the operation to not show any output.

src/managednetworkfabric/azext_managednetworkfabric/aaz/latest/networkfabric/device/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from .__cmd_group import *
1212
from ._list import *
1313
from ._reboot import *
14+
from ._refresh_configuration import *
1415
from ._run_ro import *
1516
from ._run_rw import *
1617
from ._show import *

src/managednetworkfabric/azext_managednetworkfabric/aaz/latest/networkfabric/device/_reboot.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
)
1717
class Reboot(AAZCommand):
1818
"""Reboot the Network Device.
19+
20+
:example: NetworkDevices_Reboot_MaximumSet_Gen
21+
az networkfabric device reboot --resource-group example-rg --resource-name example-device --reboot-type GracefulRebootWithZTP
1922
"""
2023

2124
_aaz_info = {
@@ -43,7 +46,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
4346

4447
_args_schema = cls._args_schema
4548
_args_schema.network_device_name = AAZStrArg(
46-
options=["--network-device-name"],
49+
options=["--resource-name", "--network-device-name"],
4750
help="Name of the Network Device.",
4851
required=True,
4952
id_part="name",
Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
7+
8+
# pylint: skip-file
9+
# flake8: noqa
10+
11+
from azure.cli.core.aaz import *
12+
13+
14+
@register_command(
15+
"networkfabric device refresh-configuration",
16+
)
17+
class RefreshConfiguration(AAZCommand):
18+
"""Refreshes the configuration the Network Device.
19+
20+
:example: NetworkDevices_RefreshConfiguration_MaximumSet_Gen
21+
az networkfabric device refresh-configuration --resource-group example-rg --resource-name example-device
22+
"""
23+
24+
_aaz_info = {
25+
"version": "2024-06-15-preview",
26+
"resources": [
27+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.managednetworkfabric/networkdevices/{}/refreshconfiguration", "2024-06-15-preview"],
28+
]
29+
}
30+
31+
AZ_SUPPORT_NO_WAIT = True
32+
33+
def _handler(self, command_args):
34+
super()._handler(command_args)
35+
return self.build_lro_poller(self._execute_operations, self._output)
36+
37+
_args_schema = None
38+
39+
@classmethod
40+
def _build_arguments_schema(cls, *args, **kwargs):
41+
if cls._args_schema is not None:
42+
return cls._args_schema
43+
cls._args_schema = super()._build_arguments_schema(*args, **kwargs)
44+
45+
# define Arg Group ""
46+
47+
_args_schema = cls._args_schema
48+
_args_schema.network_device_name = AAZStrArg(
49+
options=["--resource-name", "--network-device-name"],
50+
help="Name of the Network Device.",
51+
required=True,
52+
id_part="name",
53+
fmt=AAZStrArgFormat(
54+
pattern="^[a-zA-Z]{1}[a-zA-Z0-9-_]{2,127}$",
55+
),
56+
)
57+
_args_schema.resource_group = AAZResourceGroupNameArg(
58+
required=True,
59+
)
60+
return cls._args_schema
61+
62+
def _execute_operations(self):
63+
self.pre_operations()
64+
yield self.NetworkDevicesRefreshConfiguration(ctx=self.ctx)()
65+
self.post_operations()
66+
67+
@register_callback
68+
def pre_operations(self):
69+
pass
70+
71+
@register_callback
72+
def post_operations(self):
73+
pass
74+
75+
def _output(self, *args, **kwargs):
76+
result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True)
77+
return result
78+
79+
class NetworkDevicesRefreshConfiguration(AAZHttpOperation):
80+
CLIENT_TYPE = "MgmtClient"
81+
82+
def __call__(self, *args, **kwargs):
83+
request = self.make_request()
84+
session = self.client.send_request(request=request, stream=False, **kwargs)
85+
if session.http_response.status_code in [202]:
86+
return self.client.build_lro_polling(
87+
self.ctx.args.no_wait,
88+
session,
89+
self.on_200,
90+
self.on_error,
91+
lro_options={"final-state-via": "location"},
92+
path_format_arguments=self.url_parameters,
93+
)
94+
if session.http_response.status_code in [200]:
95+
return self.client.build_lro_polling(
96+
self.ctx.args.no_wait,
97+
session,
98+
self.on_200,
99+
self.on_error,
100+
lro_options={"final-state-via": "location"},
101+
path_format_arguments=self.url_parameters,
102+
)
103+
104+
return self.on_error(session.http_response)
105+
106+
@property
107+
def url(self):
108+
return self.client.format_url(
109+
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetworkFabric/networkDevices/{networkDeviceName}/refreshConfiguration",
110+
**self.url_parameters
111+
)
112+
113+
@property
114+
def method(self):
115+
return "POST"
116+
117+
@property
118+
def error_format(self):
119+
return "MgmtErrorFormat"
120+
121+
@property
122+
def url_parameters(self):
123+
parameters = {
124+
**self.serialize_url_param(
125+
"networkDeviceName", self.ctx.args.network_device_name,
126+
required=True,
127+
),
128+
**self.serialize_url_param(
129+
"resourceGroupName", self.ctx.args.resource_group,
130+
required=True,
131+
),
132+
**self.serialize_url_param(
133+
"subscriptionId", self.ctx.subscription_id,
134+
required=True,
135+
),
136+
}
137+
return parameters
138+
139+
@property
140+
def query_parameters(self):
141+
parameters = {
142+
**self.serialize_query_param(
143+
"api-version", "2024-06-15-preview",
144+
required=True,
145+
),
146+
}
147+
return parameters
148+
149+
@property
150+
def header_parameters(self):
151+
parameters = {
152+
**self.serialize_header_param(
153+
"Accept", "application/json",
154+
),
155+
}
156+
return parameters
157+
158+
def on_200(self, session):
159+
data = self.deserialize_http_content(session)
160+
self.ctx.set_var(
161+
"instance",
162+
data,
163+
schema_builder=self._build_schema_on_200
164+
)
165+
166+
_schema_on_200 = None
167+
168+
@classmethod
169+
def _build_schema_on_200(cls):
170+
if cls._schema_on_200 is not None:
171+
return cls._schema_on_200
172+
173+
cls._schema_on_200 = AAZObjectType()
174+
175+
_schema_on_200 = cls._schema_on_200
176+
_schema_on_200.configuration_state = AAZStrType(
177+
serialized_name="configurationState",
178+
flags={"read_only": True},
179+
)
180+
_schema_on_200.error = AAZObjectType()
181+
_RefreshConfigurationHelper._build_schema_error_detail_read(_schema_on_200.error)
182+
183+
return cls._schema_on_200
184+
185+
186+
class _RefreshConfigurationHelper:
187+
"""Helper class for RefreshConfiguration"""
188+
189+
_schema_error_detail_read = None
190+
191+
@classmethod
192+
def _build_schema_error_detail_read(cls, _schema):
193+
if cls._schema_error_detail_read is not None:
194+
_schema.additional_info = cls._schema_error_detail_read.additional_info
195+
_schema.code = cls._schema_error_detail_read.code
196+
_schema.details = cls._schema_error_detail_read.details
197+
_schema.message = cls._schema_error_detail_read.message
198+
_schema.target = cls._schema_error_detail_read.target
199+
return
200+
201+
cls._schema_error_detail_read = _schema_error_detail_read = AAZObjectType()
202+
203+
error_detail_read = _schema_error_detail_read
204+
error_detail_read.additional_info = AAZListType(
205+
serialized_name="additionalInfo",
206+
flags={"read_only": True},
207+
)
208+
error_detail_read.code = AAZStrType(
209+
flags={"read_only": True},
210+
)
211+
error_detail_read.details = AAZListType(
212+
flags={"read_only": True},
213+
)
214+
error_detail_read.message = AAZStrType(
215+
flags={"read_only": True},
216+
)
217+
error_detail_read.target = AAZStrType(
218+
flags={"read_only": True},
219+
)
220+
221+
additional_info = _schema_error_detail_read.additional_info
222+
additional_info.Element = AAZObjectType()
223+
224+
_element = _schema_error_detail_read.additional_info.Element
225+
_element.info = AAZFreeFormDictType(
226+
flags={"read_only": True},
227+
)
228+
_element.type = AAZStrType(
229+
flags={"read_only": True},
230+
)
231+
232+
details = _schema_error_detail_read.details
233+
details.Element = AAZObjectType()
234+
cls._build_schema_error_detail_read(details.Element)
235+
236+
_schema.additional_info = cls._schema_error_detail_read.additional_info
237+
_schema.code = cls._schema_error_detail_read.code
238+
_schema.details = cls._schema_error_detail_read.details
239+
_schema.message = cls._schema_error_detail_read.message
240+
_schema.target = cls._schema_error_detail_read.target
241+
242+
243+
__all__ = ["RefreshConfiguration"]

0 commit comments

Comments
 (0)