Skip to content

Commit ec39c71

Browse files
authored
[serial-console] Add support for managed boot diagnostics storage account (#5203)
* Add support for managed boot diagnostics storage account * Fix typo in help
1 parent 37befeb commit ec39c71

8 files changed

Lines changed: 2001 additions & 1687 deletions

File tree

src/serial-console/HISTORY.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Release History
22
===============
33

4+
0.1.2
5+
++++++
6+
* Change to make custom boot diagnostics optional
7+
48
0.1.1
59
++++++
610
* Change to require custom boot diagnostics

src/serial-console/azext_serialconsole/_help.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
helps['serial-console'] = """
1111
type: group
12-
short-summary: Connent to the Serial Console of a Linux/Windows Virtual Machine or VMSS Instance.
12+
short-summary: Connect to the Serial Console of a Linux/Windows Virtual Machine or VMSS Instance.
1313
"""
1414

1515
helps['serial-console send'] = """

src/serial-console/azext_serialconsole/custom.py

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -597,14 +597,14 @@ def check_resource(cli_ctx, resource_group_name, vm_vmss_name, vmss_instanceid):
597597
raise AzureConnectionError(
598598
error_message, recommendation=recommendation)
599599

600-
if result.boot_diagnostics is None or result.boot_diagnostics.serial_console_log_blob_uri is None:
601-
error_message = ("Azure Serial Console requires boot diagnostics to be enabled. Additionally, "
602-
"Serial Console requires a custom boot diagnostics storage account to be "
603-
"used, and is not yet fully compatible with managed boot diagnostics storage accounts.")
600+
if result.boot_diagnostics is None:
601+
error_message = ("Azure Serial Console requires boot diagnostics to be enabled.")
604602
recommendation = ('Use "az vmss update --name MyScaleSet --resource-group MyResourceGroup --set '
605603
'virtualMachineProfile.diagnosticsProfile="{\\"bootDiagnostics\\": {\\"Enabled\\" : '
606-
'\\"True\\",\\"StorageUri\\":\\"https://mystorageacct.blob.core.windows.net/\\"}}""'
607-
'to enable boot diagnostics.')
604+
'\\"True\\",\\"StorageUri\\" : null}}"" to enable boot diagnostics. '
605+
'You can replace "null" with a custom storage account '
606+
'\\"https://mystor.blob.windows.net/"\\. Then run "az vmss update-instances -n '
607+
'MyScaleSet -g MyResourceGroup --instance-ids *".')
608608
raise AzureConnectionError(
609609
error_message, recommendation=recommendation)
610610
else:
@@ -640,21 +640,13 @@ def check_resource(cli_ctx, resource_group_name, vm_vmss_name, vmss_instanceid):
640640
raise AzureConnectionError(
641641
error_message, recommendation=recommendation)
642642

643-
recommendation = ('Use "az vm boot-diagnostics enable --name MyVM --resource-group MyResourceGroup '
644-
'--storage https://mystor.blob.core.windows.net/" to enable boot diagnostics and '
645-
'make sure to specify a storage account with the --storage parameter.')
646-
647643
if (result.diagnostics_profile is None or
648644
result.diagnostics_profile.boot_diagnostics is None or
649645
not result.diagnostics_profile.boot_diagnostics.enabled):
650-
error_message = ("Azure Serial Console requires boot diagnostics to be enabled. Additionally, "
651-
"Serial Console requires a custom boot diagnostics storage account to be "
652-
"used, and is not yet fully compatible with managed boot diagnostics storage accounts.")
653-
raise AzureConnectionError(
654-
error_message, recommendation=recommendation)
655-
if result.diagnostics_profile.boot_diagnostics.storage_uri is None:
656-
error_message = ("Serial Console requires a custom boot diagnostics storage account to be used, "
657-
"and is not yet fully compatible with managed boot diagnostics storage accounts.")
646+
error_message = ("Azure Serial Console requires boot diagnostics to be enabled.")
647+
recommendation = ('Use "az vm boot-diagnostics enable --name MyVM --resource-group MyResourceGroup" '
648+
'to enable boot diagnostics. You can specify a custom storage account with the '
649+
'parameter "--storage https://mystor.blob.windows.net/".')
658650
raise AzureConnectionError(
659651
error_message, recommendation=recommendation)
660652

src/serial-console/azext_serialconsole/tests/latest/recordings/test_check_resource_VM.yaml

Lines changed: 899 additions & 736 deletions
Large diffs are not rendered by default.

src/serial-console/azext_serialconsole/tests/latest/recordings/test_check_resource_VMSS.yaml

Lines changed: 1073 additions & 913 deletions
Large diffs are not rendered by default.

src/serial-console/azext_serialconsole/tests/latest/recordings/test_enable_disable.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ interactions:
1515
Content-Type:
1616
- application/json
1717
User-Agent:
18-
- AZURECLI/2.27.0 azsdk-python-microsoftserialconsoleclient/unknown Python/3.8.10
19-
(Windows-10-10.0.19042-SP0)
18+
- AZURECLI/2.39.0 azsdk-python-microsoftserialconsoleclient/unknown Python/3.8.13
19+
(Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.35)
2020
method: POST
2121
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.SerialConsole/consoleServices/default/disableConsole?api-version=2018-05-01
2222
response:
@@ -30,7 +30,7 @@ interactions:
3030
content-type:
3131
- application/json; charset=UTF-8
3232
date:
33-
- Mon, 02 Aug 2021 18:41:04 GMT
33+
- Thu, 04 Aug 2022 17:10:07 GMT
3434
expires:
3535
- '-1'
3636
pragma:
@@ -48,7 +48,7 @@ interactions:
4848
x-frame-options:
4949
- deny
5050
x-ms-ratelimit-remaining-subscription-writes:
51-
- '1199'
51+
- '1198'
5252
status:
5353
code: 200
5454
message: OK
@@ -68,8 +68,8 @@ interactions:
6868
Content-Type:
6969
- application/json
7070
User-Agent:
71-
- AZURECLI/2.27.0 azsdk-python-microsoftserialconsoleclient/unknown Python/3.8.10
72-
(Windows-10-10.0.19042-SP0)
71+
- AZURECLI/2.39.0 azsdk-python-microsoftserialconsoleclient/unknown Python/3.8.13
72+
(Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.35)
7373
method: POST
7474
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.SerialConsole/consoleServices/default/enableConsole?api-version=2018-05-01
7575
response:
@@ -83,7 +83,7 @@ interactions:
8383
content-type:
8484
- application/json; charset=UTF-8
8585
date:
86-
- Mon, 02 Aug 2021 18:41:04 GMT
86+
- Thu, 04 Aug 2022 17:10:07 GMT
8787
expires:
8888
- '-1'
8989
pragma:
@@ -101,7 +101,7 @@ interactions:
101101
x-frame-options:
102102
- deny
103103
x-ms-ratelimit-remaining-subscription-writes:
104-
- '1199'
104+
- '1198'
105105
status:
106106
code: 200
107107
message: OK

src/serial-console/azext_serialconsole/tests/latest/test_serialconsole_scenario.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ def test_check_resource_VMSS(self, resource_group, storage_account):
5151
self.cmd('az vmss update --name {name} --resource-group {rg} --set virtualMachineProfile.diagnosticsProfile="{{\\"bootDiagnostics\\": {{\\"Enabled\\" : \\"True\\",\\"StorageUri\\" : null}}}}"')
5252
self.cmd('az vmss update-instances -g {rg} -n {name} --instance-ids {id}')
5353

54-
with self.assertRaises(AzureConnectionError):
55-
check_resource(self.cli_ctx, resource_group, name, iid)
54+
check_resource(self.cli_ctx, resource_group, name, iid)
5655

5756
self.cmd('az vmss deallocate -g {rg} -n {name} --instance-ids {id}')
5857

@@ -62,8 +61,7 @@ def test_check_resource_VMSS(self, resource_group, storage_account):
6261
self.cmd('az vmss start -g {rg} -n {name} --instance-ids {id}')
6362
self.cmd('az vmss stop -g {rg} -n {name} --instance-ids {id}')
6463

65-
with self.assertRaises(AzureConnectionError):
66-
check_resource(self.cli_ctx, resource_group, name, iid)
64+
check_resource(self.cli_ctx, resource_group, name, iid)
6765

6866
self.cmd('az vmss start -g {rg} -n {name} --instance-ids {id}')
6967
self.cmd('az vmss update --name {name} --resource-group {rg} --set virtualMachineProfile.diagnosticsProfile="{{\\"bootDiagnostics\\": {{\\"Enabled\\" : \\"True\\",\\"StorageUri\\":\\"https://{sa}.blob.core.windows.net/\\"}}}}"')
@@ -113,8 +111,7 @@ def test_check_resource_VMSS(self, resource_group, storage_account):
113111

114112
self.cmd('az vmss update-instances -g {rg} -n {name} --instance-ids {id}')
115113

116-
with self.assertRaises(AzureConnectionError):
117-
check_resource(self.cli_ctx, resource_group, name, iid)
114+
check_resource(self.cli_ctx, resource_group, name, iid)
118115

119116
@ResourceGroupPreparer(name_prefix='cli_test_serialconsole', location='westus2')
120117
@StorageAccountPreparer(name_prefix='cli', location="westus2")
@@ -141,8 +138,7 @@ def test_check_resource_VM(self, resource_group, storage_account):
141138

142139
self.cmd('az vm boot-diagnostics enable -g {rg} -n {name}')
143140

144-
with self.assertRaises(AzureConnectionError):
145-
check_resource(self.cli_ctx, resource_group, name, None)
141+
check_resource(self.cli_ctx, resource_group, name, None)
146142

147143
self.cmd('az vm deallocate -g {rg} -n {name}')
148144

@@ -152,8 +148,7 @@ def test_check_resource_VM(self, resource_group, storage_account):
152148
self.cmd('az vm start -g {rg} -n {name}')
153149
self.cmd('az vm stop -g {rg} -n {name}')
154150

155-
with self.assertRaises(AzureConnectionError):
156-
check_resource(self.cli_ctx, resource_group, name, None)
151+
check_resource(self.cli_ctx, resource_group, name, None)
157152

158153
self.cmd('az vm boot-diagnostics disable -g {rg} -n {name}')
159154

src/serial-console/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
# TODO: Confirm this is the right version number you want and it matches your
1818
# HISTORY.rst entry.
19-
VERSION = '0.1.1'
19+
VERSION = '0.1.2'
2020

2121
# The full list of classifiers is available at
2222
# https://pypi.python.org/pypi?%3Aaction=list_classifiers

0 commit comments

Comments
 (0)