Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -5318,7 +5318,7 @@ interactions:
User-Agent:
- AZURECLI/2.78.0 azsdk-python-core/1.35.0 Python/3.11.9 (Windows-10-10.0.26200-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/AzureBackupRG_clitest_000001/providers/Microsoft.Compute/virtualMachines/clitest-vm000003?api-version=2024-11-01
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/AzureBackupRG_clitest_000001/providers/Microsoft.Compute/virtualMachines/clitest-vm000003?api-version=2025-04-01
response:
body:
string: "{\r\n \"name\": \"clitest-vm000003\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/AzureBackupRG_clitest_000001/providers/Microsoft.Compute/virtualMachines/clitest-vm000003\",\r\n
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1854,7 +1854,7 @@ interactions:
User-Agent:
- AZURECLI/2.78.0 azsdk-python-core/1.35.0 Python/3.11.9 (Windows-10-10.0.26200-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/AzureBackupRG_clitest_000001/providers/Microsoft.Compute/virtualMachines/clitest-vm000003?api-version=2024-11-01
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/AzureBackupRG_clitest_000001/providers/Microsoft.Compute/virtualMachines/clitest-vm000003?api-version=2025-04-01
response:
body:
string: "{\r\n \"name\": \"clitest-vm000003\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/AzureBackupRG_clitest_000001/providers/Microsoft.Compute/virtualMachines/clitest-vm000003\",\r\n
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4145,7 +4145,7 @@ interactions:
User-Agent:
- AZURECLI/2.74.0 azsdk-python-core/1.31.0 Python/3.12.10 (Windows-11-10.0.26100-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_nic_convenience_test000001/providers/Microsoft.Compute/virtualMachines/conveniencevm1?api-version=2024-11-01
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_nic_convenience_test000001/providers/Microsoft.Compute/virtualMachines/conveniencevm1?api-version=2025-04-01
response:
body:
string: "{\r\n \"name\": \"conveniencevm1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_nic_convenience_test000001/providers/Microsoft.Compute/virtualMachines/conveniencevm1\",\r\n
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ interactions:
User-Agent:
- AZURECLI/2.71.0 azsdk-python-core/1.31.0 Python/3.10.11 (Windows-10-10.0.26100-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resource_patch_000001/providers/Microsoft.Compute/virtualMachines/vm?api-version=2024-11-01
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resource_patch_000001/providers/Microsoft.Compute/virtualMachines/vm?api-version=2025-04-01
response:
body:
string: "{\r\n \"name\": \"vm\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resource_patch_000001/providers/Microsoft.Compute/virtualMachines/vm\",\r\n
Expand Down
187 changes: 117 additions & 70 deletions src/azure-cli/azure/cli/command_modules/vm/_validators.py

Large diffs are not rendered by default.

36 changes: 1 addition & 35 deletions src/azure-cli/azure/cli/command_modules/vm/_vm_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,40 +337,6 @@ def normalize_disk_info(image_data_disks=None,


def update_disk_caching(model, caching_settings):
def _update(model, lun, value):
if isinstance(model, dict):
luns = model.keys() if lun is None else [lun]
for lun_item in luns:
if lun_item not in model:
raise CLIError("Data disk with lun of '{}' doesn't exist. Existing luns: {}."
.format(lun_item, list(model.keys())))
model[lun_item]['caching'] = value
else:
if lun is None:
disks = [model.os_disk] + (model.data_disks or [])
elif lun == 'os':
disks = [model.os_disk]
else:
disk = next((d for d in model.data_disks if d.lun == lun), None)
if not disk:
raise CLIError("data disk with lun of '{}' doesn't exist".format(lun))
disks = [disk]
for disk in disks:
disk.caching = value

if len(caching_settings) == 1 and '=' not in caching_settings[0]:
_update(model, None, caching_settings[0])
else:
for x in caching_settings:
if '=' not in x:
raise CLIError("usage error: please use 'LUN=VALUE' to configure caching on individual disk")
lun, value = x.split('=', 1)
lun = lun.lower()
lun = int(lun) if lun != 'os' else lun
_update(model, lun, value)


def update_disk_caching_by_aaz(model, caching_settings):
def _update(model, lun, value):
luns = model.keys() if lun is None else [lun]
for lun_item in luns:
Expand Down Expand Up @@ -656,7 +622,7 @@ def validate_vm_disk_trusted_launch(namespace, disk_security_profile):
logger.warning(UPGRADE_SECURITY_HINT)
return

security_type = disk_security_profile.security_type if hasattr(disk_security_profile, 'security_type') else None
security_type = disk_security_profile.get('securityType')
if security_type and security_type.lower() == 'trustedlaunch':
if namespace.enable_secure_boot is None:
namespace.enable_secure_boot = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class __CMDGroup(AAZCommandGroup):
"""Manage Azure Managed Disks.
Azure Virtual Machines use disks as a place to store an operating system, applications, and data. All Azure virtual machines have at least two disks: An operating system disk, and a temporary disk. The operating system disk is created from an image, and both the operating system disk and the image are actually virtual hard disks (VHDs) stored in an Azure storage account. Virtual machines also can have one or more data disks, that are also stored as VHDs.
Azure Virtual Machines use disks as a place to store an operating system, applications, and data. All Azure virtual machines have at least two disks: An operating system disk, and a temporary disk. The operating system disk is created from an image, and both the operating system disk and the image are actually virtual hard disks (VHDs) stored in an Azure storage account. Virtual machines also can have one or more data disks, that are also stored as VHDs.\\
Azure Unmanaged Data Disks have a maximum size of 4095 GB. To use disks larger than 4095 GB use [Azure Managed Disks](https://learn.microsoft.com/azure/virtual-machines/managed-disks-overview)
"""
pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
)
class Show(AAZCommand):
"""Get an image.

:example: Get information about a virtual machine image.
az image show --resource-group myResourceGroup --image-name myImage
"""

_aaz_info = {
"version": "2024-07-01",
"version": "2024-11-01",
"resources": [
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/images/{}", "2024-07-01"],
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/images/{}", "2024-11-01"],
]
}

Expand Down Expand Up @@ -124,7 +127,7 @@ def query_parameters(self):
"$expand", self.ctx.args.expand,
),
**self.serialize_query_param(
"api-version", "2024-07-01",
"api-version", "2024-11-01",
required=True,
),
}
Expand Down Expand Up @@ -172,6 +175,10 @@ def _build_schema_on_200(cls):
_schema_on_200.properties = AAZObjectType(
flags={"client_flatten": True},
)
_schema_on_200.system_data = AAZObjectType(
serialized_name="systemData",
flags={"read_only": True},
)
_schema_on_200.tags = AAZDictType()
_schema_on_200.type = AAZStrType(
flags={"read_only": True},
Expand Down Expand Up @@ -266,6 +273,26 @@ def _build_schema_on_200(cls):
serialized_name="storageAccountType",
)

system_data = cls._schema_on_200.system_data
system_data.created_at = AAZStrType(
serialized_name="createdAt",
)
system_data.created_by = AAZStrType(
serialized_name="createdBy",
)
system_data.created_by_type = AAZStrType(
serialized_name="createdByType",
)
system_data.last_modified_at = AAZStrType(
serialized_name="lastModifiedAt",
)
system_data.last_modified_by = AAZStrType(
serialized_name="lastModifiedBy",
)
system_data.last_modified_by_type = AAZStrType(
serialized_name="lastModifiedByType",
)

tags = cls._schema_on_200.tags
tags.Element = AAZStrType()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Wait(AAZWaitCommand):

_aaz_info = {
"resources": [
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/images/{}", "2024-07-01"],
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/images/{}", "2024-11-01"],
]
}

Expand Down Expand Up @@ -123,7 +123,7 @@ def query_parameters(self):
"$expand", self.ctx.args.expand,
),
**self.serialize_query_param(
"api-version", "2024-07-01",
"api-version", "2024-11-01",
required=True,
),
}
Expand Down Expand Up @@ -171,6 +171,10 @@ def _build_schema_on_200(cls):
_schema_on_200.properties = AAZObjectType(
flags={"client_flatten": True},
)
_schema_on_200.system_data = AAZObjectType(
serialized_name="systemData",
flags={"read_only": True},
)
_schema_on_200.tags = AAZDictType()
_schema_on_200.type = AAZStrType(
flags={"read_only": True},
Expand Down Expand Up @@ -265,6 +269,26 @@ def _build_schema_on_200(cls):
serialized_name="storageAccountType",
)

system_data = cls._schema_on_200.system_data
system_data.created_at = AAZStrType(
serialized_name="createdAt",
)
system_data.created_by = AAZStrType(
serialized_name="createdBy",
)
system_data.created_by_type = AAZStrType(
serialized_name="createdByType",
)
system_data.last_modified_at = AAZStrType(
serialized_name="lastModifiedAt",
)
system_data.last_modified_by = AAZStrType(
serialized_name="lastModifiedBy",
)
system_data.last_modified_by_type = AAZStrType(
serialized_name="lastModifiedByType",
)

tags = cls._schema_on_200.tags
tags.Element = AAZStrType()

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from azure.cli.core.aaz import *


class __CMDGroup(AAZCommandGroup):
"""Manage Ssh Public Key
"""
pass


__all__ = ["__CMDGroup"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from .__cmd_group import *
from ._create import *
from ._delete import *
from ._list import *
from ._show import *
from ._update import *
Loading
Loading