Skip to content

Commit e6e7df2

Browse files
committed
get boot log uris
1 parent 4387901 commit e6e7df2

File tree

6 files changed

+2617
-1990
lines changed

6 files changed

+2617
-1990
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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_group(
15+
"vm boot-diagnostics",
16+
)
17+
class __CMDGroup(AAZCommandGroup):
18+
"""Troubleshoot the startup of an Azure Virtual Machine. Use this feature to troubleshoot boot failures for custom or platform images.
19+
"""
20+
pass
21+
22+
23+
__all__ = ["__CMDGroup"]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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 .__cmd_group import *
12+
from ._get_boot_log_uris import *
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
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+
"vm boot-diagnostics get-boot-log-uris",
16+
)
17+
class GetBootLogUris(AAZCommand):
18+
"""Get SAS URIs for a virtual machine's boot diagnostic
19+
20+
:example: Get SAS URIs for a virtual machine's boot diagnostic logs.
21+
az vm boot-diagnostics get-boot-log-uris -g MyResourceGroup -n MyVirtualMachine
22+
"""
23+
24+
_aaz_info = {
25+
"version": "2024-07-01",
26+
"resources": [
27+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/virtualmachines/{}/retrievebootdiagnosticsdata", "2024-07-01"],
28+
]
29+
}
30+
31+
def _handler(self, command_args):
32+
super()._handler(command_args)
33+
self._execute_operations()
34+
return self._output()
35+
36+
_args_schema = None
37+
38+
@classmethod
39+
def _build_arguments_schema(cls, *args, **kwargs):
40+
if cls._args_schema is not None:
41+
return cls._args_schema
42+
cls._args_schema = super()._build_arguments_schema(*args, **kwargs)
43+
44+
# define Arg Group ""
45+
46+
_args_schema = cls._args_schema
47+
_args_schema.resource_group = AAZResourceGroupNameArg(
48+
required=True,
49+
)
50+
_args_schema.name = AAZStrArg(
51+
options=["-n", "--name"],
52+
help="The name of the Virtual Machine. You can configure the default using `az configure --defaults vm=<name>`.",
53+
required=True,
54+
id_part="name",
55+
)
56+
_args_schema.expire = AAZIntArg(
57+
options=["--expire"],
58+
help="Expiration duration in minutes for the SAS URIs with a value between 1 to 1440 minutes. If not specified, SAS URIs will be generated with a default expiration duration of 120 minutes.",
59+
)
60+
return cls._args_schema
61+
62+
def _execute_operations(self):
63+
self.pre_operations()
64+
self.VirtualMachinesRetrieveBootDiagnosticsData(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 VirtualMachinesRetrieveBootDiagnosticsData(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 [200]:
86+
return self.on_200(session)
87+
88+
return self.on_error(session.http_response)
89+
90+
@property
91+
def url(self):
92+
return self.client.format_url(
93+
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/retrieveBootDiagnosticsData",
94+
**self.url_parameters
95+
)
96+
97+
@property
98+
def method(self):
99+
return "POST"
100+
101+
@property
102+
def error_format(self):
103+
return "ODataV4Format"
104+
105+
@property
106+
def url_parameters(self):
107+
parameters = {
108+
**self.serialize_url_param(
109+
"resourceGroupName", self.ctx.args.resource_group,
110+
required=True,
111+
),
112+
**self.serialize_url_param(
113+
"subscriptionId", self.ctx.subscription_id,
114+
required=True,
115+
),
116+
**self.serialize_url_param(
117+
"vmName", self.ctx.args.name,
118+
required=True,
119+
),
120+
}
121+
return parameters
122+
123+
@property
124+
def query_parameters(self):
125+
parameters = {
126+
**self.serialize_query_param(
127+
"sasUriExpirationTimeInMinutes", self.ctx.args.expire,
128+
),
129+
**self.serialize_query_param(
130+
"api-version", "2024-07-01",
131+
required=True,
132+
),
133+
}
134+
return parameters
135+
136+
@property
137+
def header_parameters(self):
138+
parameters = {
139+
**self.serialize_header_param(
140+
"Accept", "application/json",
141+
),
142+
}
143+
return parameters
144+
145+
def on_200(self, session):
146+
data = self.deserialize_http_content(session)
147+
self.ctx.set_var(
148+
"instance",
149+
data,
150+
schema_builder=self._build_schema_on_200
151+
)
152+
153+
_schema_on_200 = None
154+
155+
@classmethod
156+
def _build_schema_on_200(cls):
157+
if cls._schema_on_200 is not None:
158+
return cls._schema_on_200
159+
160+
cls._schema_on_200 = AAZObjectType()
161+
162+
_schema_on_200 = cls._schema_on_200
163+
_schema_on_200.console_screenshot_blob_uri = AAZStrType(
164+
serialized_name="consoleScreenshotBlobUri",
165+
flags={"read_only": True},
166+
)
167+
_schema_on_200.serial_console_log_blob_uri = AAZStrType(
168+
serialized_name="serialConsoleLogBlobUri",
169+
flags={"read_only": True},
170+
)
171+
172+
return cls._schema_on_200
173+
174+
175+
class _GetBootLogUrisHelper:
176+
"""Helper class for GetBootLogUris"""
177+
178+
179+
__all__ = ["GetBootLogUris"]

src/azure-cli/azure/cli/command_modules/vm/commands.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ def load_command_table(self, _):
347347
g.custom_command('disable', 'disable_boot_diagnostics')
348348
g.custom_command('enable', 'enable_boot_diagnostics')
349349
g.custom_command('get-boot-log', 'get_boot_log')
350-
g.custom_command('get-boot-log-uris', 'get_boot_log_uris', min_api='2020-06-01')
351350

352351
with self.command_group('vm diagnostics', compute_vm_sdk) as g:
353352
g.custom_command('set', 'set_diagnostics_extension')

src/azure-cli/azure/cli/command_modules/vm/custom.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,12 +2015,6 @@ def get_boot_log(cmd, resource_group_name, vm_name):
20152015

20162016
# our streamwriter not seekable, so no parallel.
20172017
storage_client.get_blob_to_stream(container, blob, BootLogStreamWriter(sys.stdout), max_connections=1)
2018-
2019-
2020-
def get_boot_log_uris(cmd, resource_group_name, vm_name, expire=None):
2021-
client = _compute_client_factory(cmd.cli_ctx)
2022-
return client.virtual_machines.retrieve_boot_diagnostics_data(
2023-
resource_group_name, vm_name, sas_uri_expiration_time_in_minutes=expire)
20242018
# endregion
20252019

20262020

0 commit comments

Comments
 (0)