Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
84db569
Migrate vm create command
william051200 Jan 27, 2026
0d3dd48
Generated sshkey code from aaz
william051200 Jan 28, 2026
5e1143d
Migrate vm create validator
william051200 Jan 29, 2026
9bb86a5
Update vm create command
william051200 Jan 29, 2026
33acc58
Migrate vm show command
william051200 Jan 29, 2026
aa0eb49
Update vm create command function name
william051200 Jan 29, 2026
3b439b9
Migrate vm update command
william051200 Jan 29, 2026
fced1a4
Merge remote-tracking branch 'origin/dev' into vm-migration
william051200 Jan 29, 2026
6ced81c
Regenerate sshkey code from aaz
william051200 Jan 29, 2026
85d79fc
Edit code
william051200 Jan 29, 2026
4799891
Update vm image show version to match with SDK version
william051200 Jan 29, 2026
e766283
Edit code style
william051200 Jan 29, 2026
52e85c3
Edit code style
william051200 Jan 29, 2026
9bd40ff
Fix code style
william051200 Jan 29, 2026
4cbf8b4
Update aaz vm image list and show version
william051200 Feb 4, 2026
d882bf2
Merge remote-tracking branch 'origin/dev' into vm-migration
william051200 Feb 4, 2026
55d22fb
Updated vm image show version
william051200 Feb 4, 2026
9d59e80
Updated compute image show version
william051200 Feb 4, 2026
cee4839
Updated test case and recordings
william051200 Feb 4, 2026
fc2c831
Updated vm image list version
william051200 Feb 5, 2026
984c7df
Update image collected from az vm image handling
william051200 Feb 5, 2026
439533d
Update test case and recordings
william051200 Feb 5, 2026
5f4780d
update vm image list handling
william051200 Feb 5, 2026
6784adf
Updated test case recording version
william051200 Feb 5, 2026
59395c6
Updated test case recording version
william051200 Feb 5, 2026
326429f
Update test case recordings
william051200 Feb 6, 2026
73b3659
Update vm image list API and add handling to API
william051200 Feb 6, 2026
185d39c
Update test case recording
william051200 Feb 6, 2026
f77ef39
Merge remote-tracking branch 'origin/dev' into vm-migration
william051200 Feb 6, 2026
f120cc2
Fix code style
william051200 Feb 6, 2026
b35d9e7
Update test case and test case recording
william051200 Feb 6, 2026
0296c0e
Fix code style
william051200 Feb 6, 2026
6229fa9
edit test case and recording
william051200 Feb 6, 2026
35b4039
Resolve conflicts
william051200 Feb 9, 2026
a2e8c3b
Fix date time bug
william051200 Feb 9, 2026
516ab9f
Merge remote-tracking branch 'origin/dev' into vm-migration
william051200 Feb 11, 2026
4e2cc1f
Revert unrelated changes
william051200 Feb 12, 2026
4342d20
Add handling to prevent missing aux token
william051200 Feb 12, 2026
3349cc5
Update test case and re-record test case
william051200 Feb 12, 2026
45a92a8
Merge remote-tracking branch 'origin/dev' into vm-migration
william051200 Feb 12, 2026
5b76eb2
Re-ecord test case
william051200 Feb 12, 2026
a8fb68a
Merge remote-tracking branch 'origin/dev' into vm-migration
william051200 Feb 13, 2026
29effae
Re-record test case
william051200 Feb 13, 2026
caea656
Regenerate vm image list code
william051200 Feb 13, 2026
eb05666
Revert code
william051200 Feb 13, 2026
5823064
Update code
william051200 Feb 13, 2026
2b47c68
Update code
william051200 Feb 13, 2026
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
182 changes: 125 additions & 57 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
@@ -0,0 +1,23 @@
# --------------------------------------------------------------------------------------------
# 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 *


@register_command_group(
"sshkey",
)
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 *
Original file line number Diff line number Diff line change
@@ -0,0 +1,264 @@
# --------------------------------------------------------------------------------------------
# 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 *


@register_command(
"sshkey create",
)
class Create(AAZCommand):
"""Create a new SSH public key resource.

:example: Create a new SSH public key resource.
az sshkey create --resource-group myResourceGroup --ssh-public-key-name mySshPublicKeyName --location westus --public-key {ssh-rsa public key}
"""

_aaz_info = {
"version": "2025-04-01",
"resources": [
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/sshpublickeys/{}", "2025-04-01"],
]
}

def _handler(self, command_args):
super()._handler(command_args)
self._execute_operations()
return self._output()

_args_schema = None

@classmethod
def _build_arguments_schema(cls, *args, **kwargs):
if cls._args_schema is not None:
return cls._args_schema
cls._args_schema = super()._build_arguments_schema(*args, **kwargs)

# define Arg Group ""

_args_schema = cls._args_schema
_args_schema.resource_group = AAZResourceGroupNameArg(
required=True,
)
_args_schema.ssh_public_key_name = AAZStrArg(
options=["-n", "--name", "--ssh-public-key-name"],
help="The name of the SSH public key.",
required=True,
)

# define Arg Group "Parameters"

_args_schema = cls._args_schema
_args_schema.location = AAZResourceLocationArg(
arg_group="Parameters",
help="The geo-location where the resource lives",
required=True,
fmt=AAZResourceLocationArgFormat(
resource_group_arg="resource_group",
),
)
_args_schema.tags = AAZDictArg(
options=["--tags"],
arg_group="Parameters",
help="Resource tags.",
)

tags = cls._args_schema.tags
tags.Element = AAZStrArg()

# define Arg Group "Properties"

_args_schema = cls._args_schema
_args_schema.public_key = AAZStrArg(
options=["--public-key"],
arg_group="Properties",
help="SSH public key used to authenticate to a virtual machine through ssh. If this property is not initially provided when the resource is created, the publicKey property will be populated when generateKeyPair is called. If the public key is provided upon resource creation, the provided public key needs to be at least 2048-bit and in ssh-rsa format.",
)
return cls._args_schema

def _execute_operations(self):
self.pre_operations()
self.SshPublicKeysCreate(ctx=self.ctx)()
self.post_operations()

@register_callback
def pre_operations(self):
pass

@register_callback
def post_operations(self):
pass

def _output(self, *args, **kwargs):
result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True)
return result

class SshPublicKeysCreate(AAZHttpOperation):
CLIENT_TYPE = "MgmtClient"

def __call__(self, *args, **kwargs):
request = self.make_request()
session = self.client.send_request(request=request, stream=False, **kwargs)
if session.http_response.status_code in [200, 201]:
return self.on_200_201(session)

return self.on_error(session.http_response)

@property
def url(self):
return self.client.format_url(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}",
**self.url_parameters
)

@property
def method(self):
return "PUT"

@property
def error_format(self):
return "ODataV4Format"

@property
def url_parameters(self):
parameters = {
**self.serialize_url_param(
"resourceGroupName", self.ctx.args.resource_group,
required=True,
),
**self.serialize_url_param(
"sshPublicKeyName", self.ctx.args.ssh_public_key_name,
required=True,
),
**self.serialize_url_param(
"subscriptionId", self.ctx.subscription_id,
required=True,
),
}
return parameters

@property
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2025-04-01",
required=True,
),
}
return parameters

@property
def header_parameters(self):
parameters = {
**self.serialize_header_param(
"Content-Type", "application/json",
),
**self.serialize_header_param(
"Accept", "application/json",
),
}
return parameters

@property
def content(self):
_content_value, _builder = self.new_content_builder(
self.ctx.args,
typ=AAZObjectType,
typ_kwargs={"flags": {"required": True, "client_flatten": True}}
)
_builder.set_prop("location", AAZStrType, ".location", typ_kwargs={"flags": {"required": True}})
_builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}})
_builder.set_prop("tags", AAZDictType, ".tags")

properties = _builder.get(".properties")
if properties is not None:
properties.set_prop("publicKey", AAZStrType, ".public_key")

tags = _builder.get(".tags")
if tags is not None:
tags.set_elements(AAZStrType, ".")

return self.serialize_content(_content_value)

def on_200_201(self, session):
data = self.deserialize_http_content(session)
self.ctx.set_var(
"instance",
data,
schema_builder=self._build_schema_on_200_201
)

_schema_on_200_201 = None

@classmethod
def _build_schema_on_200_201(cls):
if cls._schema_on_200_201 is not None:
return cls._schema_on_200_201

cls._schema_on_200_201 = AAZObjectType()

_schema_on_200_201 = cls._schema_on_200_201
_schema_on_200_201.id = AAZStrType(
flags={"read_only": True},
)
_schema_on_200_201.location = AAZStrType(
flags={"required": True},
)
_schema_on_200_201.name = AAZStrType(
flags={"read_only": True},
)
_schema_on_200_201.properties = AAZObjectType(
flags={"client_flatten": True},
)
_schema_on_200_201.system_data = AAZObjectType(
serialized_name="systemData",
flags={"read_only": True},
)
_schema_on_200_201.tags = AAZDictType()
_schema_on_200_201.type = AAZStrType(
flags={"read_only": True},
)

properties = cls._schema_on_200_201.properties
properties.public_key = AAZStrType(
serialized_name="publicKey",
)

system_data = cls._schema_on_200_201.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_201.tags
tags.Element = AAZStrType()

return cls._schema_on_200_201


class _CreateHelper:
"""Helper class for Create"""


__all__ = ["Create"]
Loading
Loading