Skip to content

Commit 22cba3e

Browse files
committed
get boot
1 parent 610453d commit 22cba3e

File tree

3 files changed

+226
-0
lines changed

3 files changed

+226
-0
lines changed

src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/virtual_appliance/__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 ._create import *
1313
from ._delete import *
14+
from ._get_boot_diagnostic_log import *
1415
from ._list import *
1516
from ._reimage import *
1617
from ._restart import *
Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
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+
"network virtual-appliance get-boot-diagnostic-log",
16+
)
17+
class GetBootDiagnosticLog(AAZCommand):
18+
"""Retrieve the boot diagnostic logs for a VM instance belonging to the specified Network Virtual Appliance.
19+
20+
:example: Get boot diagnostic logs
21+
az network virtual-appliance get-boot-diagnostic-log --resource-group rg --network-virtual-appliance-name name
22+
"""
23+
24+
_aaz_info = {
25+
"version": "2024-07-01",
26+
"resources": [
27+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networkvirtualappliances/{}/getbootdiagnosticlogs", "2024-07-01"],
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_virtual_appliance_name = AAZStrArg(
49+
options=["-n", "--name", "--network-virtual-appliance-name"],
50+
help="The name of Network Virtual Appliance.",
51+
required=True,
52+
id_part="name",
53+
fmt=AAZStrArgFormat(
54+
pattern="^[A-Za-z0-9_]+",
55+
),
56+
)
57+
_args_schema.resource_group = AAZResourceGroupNameArg(
58+
required=True,
59+
)
60+
61+
# define Arg Group "Request"
62+
63+
_args_schema = cls._args_schema
64+
_args_schema.console_screenshot_storage_sas_url = AAZStrArg(
65+
options=["--css-sas-url", "--console-screenshot-storage-sas-url"],
66+
arg_group="Request",
67+
help="Specify the sas-url to the storage blob into which console screen shot for the requested instance will be written",
68+
)
69+
_args_schema.instance_id = AAZIntArg(
70+
options=["--instance-id"],
71+
arg_group="Request",
72+
help="The network virtual appliance instance id for which boot diagnostic logs is being requested",
73+
)
74+
_args_schema.serial_console_storage_sas_url = AAZStrArg(
75+
options=["--scs-sas-url", "--serial-console-storage-sas-url"],
76+
arg_group="Request",
77+
help="Specify the sas-url to the storage blob into which serial console logs for the requested instance will be written",
78+
)
79+
return cls._args_schema
80+
81+
def _execute_operations(self):
82+
self.pre_operations()
83+
yield self.NetworkVirtualAppliancesGetBootDiagnosticLogs(ctx=self.ctx)()
84+
self.post_operations()
85+
86+
@register_callback
87+
def pre_operations(self):
88+
pass
89+
90+
@register_callback
91+
def post_operations(self):
92+
pass
93+
94+
def _output(self, *args, **kwargs):
95+
result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True)
96+
return result
97+
98+
class NetworkVirtualAppliancesGetBootDiagnosticLogs(AAZHttpOperation):
99+
CLIENT_TYPE = "MgmtClient"
100+
101+
def __call__(self, *args, **kwargs):
102+
request = self.make_request()
103+
session = self.client.send_request(request=request, stream=False, **kwargs)
104+
if session.http_response.status_code in [202]:
105+
return self.client.build_lro_polling(
106+
self.ctx.args.no_wait,
107+
session,
108+
self.on_200,
109+
self.on_error,
110+
lro_options={"final-state-via": "location"},
111+
path_format_arguments=self.url_parameters,
112+
)
113+
if session.http_response.status_code in [200]:
114+
return self.client.build_lro_polling(
115+
self.ctx.args.no_wait,
116+
session,
117+
self.on_200,
118+
self.on_error,
119+
lro_options={"final-state-via": "location"},
120+
path_format_arguments=self.url_parameters,
121+
)
122+
123+
return self.on_error(session.http_response)
124+
125+
@property
126+
def url(self):
127+
return self.client.format_url(
128+
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkVirtualAppliances/{networkVirtualApplianceName}/getBootDiagnosticLogs",
129+
**self.url_parameters
130+
)
131+
132+
@property
133+
def method(self):
134+
return "POST"
135+
136+
@property
137+
def error_format(self):
138+
return "ODataV4Format"
139+
140+
@property
141+
def url_parameters(self):
142+
parameters = {
143+
**self.serialize_url_param(
144+
"networkVirtualApplianceName", self.ctx.args.network_virtual_appliance_name,
145+
required=True,
146+
),
147+
**self.serialize_url_param(
148+
"resourceGroupName", self.ctx.args.resource_group,
149+
required=True,
150+
),
151+
**self.serialize_url_param(
152+
"subscriptionId", self.ctx.subscription_id,
153+
required=True,
154+
),
155+
}
156+
return parameters
157+
158+
@property
159+
def query_parameters(self):
160+
parameters = {
161+
**self.serialize_query_param(
162+
"api-version", "2024-07-01",
163+
required=True,
164+
),
165+
}
166+
return parameters
167+
168+
@property
169+
def header_parameters(self):
170+
parameters = {
171+
**self.serialize_header_param(
172+
"Content-Type", "application/json",
173+
),
174+
**self.serialize_header_param(
175+
"Accept", "application/json",
176+
),
177+
}
178+
return parameters
179+
180+
@property
181+
def content(self):
182+
_content_value, _builder = self.new_content_builder(
183+
self.ctx.args,
184+
typ=AAZObjectType,
185+
typ_kwargs={"flags": {"required": True, "client_flatten": True}}
186+
)
187+
_builder.set_prop("consoleScreenshotStorageSasUrl", AAZStrType, ".console_screenshot_storage_sas_url")
188+
_builder.set_prop("instanceId", AAZIntType, ".instance_id")
189+
_builder.set_prop("serialConsoleStorageSasUrl", AAZStrType, ".serial_console_storage_sas_url")
190+
191+
return self.serialize_content(_content_value)
192+
193+
def on_200(self, session):
194+
data = self.deserialize_http_content(session)
195+
self.ctx.set_var(
196+
"instance",
197+
data,
198+
schema_builder=self._build_schema_on_200
199+
)
200+
201+
_schema_on_200 = None
202+
203+
@classmethod
204+
def _build_schema_on_200(cls):
205+
if cls._schema_on_200 is not None:
206+
return cls._schema_on_200
207+
208+
cls._schema_on_200 = AAZObjectType()
209+
210+
_schema_on_200 = cls._schema_on_200
211+
_schema_on_200.instance_id = AAZIntType(
212+
serialized_name="instanceId",
213+
)
214+
215+
return cls._schema_on_200
216+
217+
218+
class _GetBootDiagnosticLogHelper:
219+
"""Helper class for GetBootDiagnosticLog"""
220+
221+
222+
__all__ = ["GetBootDiagnosticLog"]

src/azure-cli/azure/cli/command_modules/network/tests/latest/test_network_commands.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6812,6 +6812,9 @@ def test_network_virtual_appliance(self, resource_group):
68126812
self.check('virtualApplianceAsn', 20000),
68136813
self.check('cloudInitConfiguration', "echo $abcd")
68146814
])
6815+
self.cmd('network virtual-appliance get-boot-diagnostic-log -n {name} -g {rg} ', checks=[
6816+
self.check('instanceId', 0)
6817+
])
68156818
self.cmd('network virtual-appliance list -g {rg}', checks=[
68166819
self.check('length(@)', 1)
68176820
])

0 commit comments

Comments
 (0)