From 7768d704556eace154651fae0a62d39c3fb7f839 Mon Sep 17 00:00:00 2001 From: william051200 Date: Thu, 5 Mar 2026 07:52:54 +0800 Subject: [PATCH 01/21] Generate aaz code --- .../vm/aaz/latest/vm/host/group/__init__.py | 2 + .../vm/aaz/latest/vm/host/group/_create.py | 375 +++++++++++++ .../vm/aaz/latest/vm/host/group/_delete.py | 7 +- .../vm/aaz/latest/vm/host/group/_list.py | 182 +++++- .../vm/aaz/latest/vm/host/group/_show.py | 99 +++- .../vm/aaz/latest/vm/host/group/_update.py | 519 ++++++++++++++++++ 6 files changed, 1168 insertions(+), 16 deletions(-) create mode 100644 src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_create.py create mode 100644 src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_update.py diff --git a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/__init__.py b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/__init__.py index 054d52707ea..c401f439385 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/__init__.py +++ b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/__init__.py @@ -9,6 +9,8 @@ # flake8: noqa from .__cmd_group import * +from ._create import * from ._delete import * from ._list import * from ._show import * +from ._update import * diff --git a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_create.py b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_create.py new file mode 100644 index 00000000000..2e17d36f12d --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_create.py @@ -0,0 +1,375 @@ +# -------------------------------------------------------------------------------------------- +# 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 Create(AAZCommand): + """Create a dedicated host group. + + :example: Create a dedicated host group. + az vm host group create --name MyDedicatedHostGroup --platform-fault-domain-count 2 --resource-group MyResourceGroup + """ + + _aaz_info = { + "version": "2024-11-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/hostgroups/{}", "2024-11-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.host_group_name = AAZStrArg( + options=["-n", "--name", "--host-group-name"], + help="Name of the Dedicated Host Group.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.location = AAZResourceLocationArg( + arg_group="Parameters", + help="Resource location", + required=True, + fmt=AAZResourceLocationArgFormat( + resource_group_arg="resource_group", + ), + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Resource tags", + ) + _args_schema.zones = AAZListArg( + options=["--zones"], + arg_group="Parameters", + help="Availability Zone to use for this host group. Only single zone is supported. The zone can be assigned only during creation. If not provided, the group supports all zones in the region. If provided, enforces each host in the group to be in the same zone.", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + + zones = cls._args_schema.zones + zones.Element = AAZStrArg() + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.additional_capabilities = AAZObjectArg( + options=["--additional-capabilities"], + arg_group="Properties", + help="Enables or disables a capability on the dedicated host group. Minimum api-version: 2022-03-01.", + ) + _args_schema.platform_fault_domain_count = AAZIntArg( + options=["--platform-fault-domain-count"], + arg_group="Properties", + help="Number of fault domains that the host group can span.", + fmt=AAZIntArgFormat( + minimum=1, + ), + ) + _args_schema.support_automatic_placement = AAZBoolArg( + options=["--support-automatic-placement"], + arg_group="Properties", + help="Specifies whether virtual machines or virtual machine scale sets can be placed automatically on the dedicated host group. Automatic placement means resources are allocated on dedicated hosts, that are chosen by Azure, under the dedicated host group. The value is defaulted to 'false' when not provided. Minimum api-version: 2020-06-01.", + ) + + additional_capabilities = cls._args_schema.additional_capabilities + additional_capabilities.ultra_ssd_enabled = AAZBoolArg( + options=["ultra-ssd-enabled"], + help="The flag that enables or disables a capability to have UltraSSD Enabled Virtual Machines on Dedicated Hosts of the Dedicated Host Group. For the Virtual Machines to be UltraSSD Enabled, UltraSSDEnabled flag for the resource needs to be set true as well. The value is defaulted to 'false' when not provided. Please refer to https://docs.microsoft.com/en-us/azure/virtual-machines/disks-enable-ultra-ssd for more details on Ultra SSD feature. **Note:** The ultraSSDEnabled setting can only be enabled for Host Groups that are created as zonal. Minimum api-version: 2022-03-01.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DedicatedHostGroupsCreateOrUpdate(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 DedicatedHostGroupsCreateOrUpdate(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/hostGroups/{hostGroupName}", + **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( + "hostGroupName", self.ctx.args.host_group_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + 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", "2024-11-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") + _builder.set_prop("zones", AAZListType, ".zones") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("additionalCapabilities", AAZObjectType, ".additional_capabilities") + properties.set_prop("platformFaultDomainCount", AAZIntType, ".platform_fault_domain_count", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("supportAutomaticPlacement", AAZBoolType, ".support_automatic_placement") + + additional_capabilities = _builder.get(".properties.additionalCapabilities") + if additional_capabilities is not None: + additional_capabilities.set_prop("ultraSSDEnabled", AAZBoolType, ".ultra_ssd_enabled") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + zones = _builder.get(".zones") + if zones is not None: + zones.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}, + ) + _schema_on_200_201.zones = AAZListType() + + properties = cls._schema_on_200_201.properties + properties.additional_capabilities = AAZObjectType( + serialized_name="additionalCapabilities", + ) + properties.hosts = AAZListType( + flags={"read_only": True}, + ) + properties.instance_view = AAZObjectType( + serialized_name="instanceView", + flags={"read_only": True}, + ) + properties.platform_fault_domain_count = AAZIntType( + serialized_name="platformFaultDomainCount", + flags={"required": True}, + ) + properties.support_automatic_placement = AAZBoolType( + serialized_name="supportAutomaticPlacement", + ) + + additional_capabilities = cls._schema_on_200_201.properties.additional_capabilities + additional_capabilities.ultra_ssd_enabled = AAZBoolType( + serialized_name="ultraSSDEnabled", + ) + + hosts = cls._schema_on_200_201.properties.hosts + hosts.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.hosts.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + + instance_view = cls._schema_on_200_201.properties.instance_view + instance_view.hosts = AAZListType() + + hosts = cls._schema_on_200_201.properties.instance_view.hosts + hosts.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.instance_view.hosts.Element + _element.asset_id = AAZStrType( + serialized_name="assetId", + flags={"read_only": True}, + ) + _element.available_capacity = AAZObjectType( + serialized_name="availableCapacity", + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.statuses = AAZListType() + + available_capacity = cls._schema_on_200_201.properties.instance_view.hosts.Element.available_capacity + available_capacity.allocatable_v_ms = AAZListType( + serialized_name="allocatableVMs", + ) + + allocatable_v_ms = cls._schema_on_200_201.properties.instance_view.hosts.Element.available_capacity.allocatable_v_ms + allocatable_v_ms.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.instance_view.hosts.Element.available_capacity.allocatable_v_ms.Element + _element.count = AAZFloatType() + _element.vm_size = AAZStrType( + serialized_name="vmSize", + ) + + statuses = cls._schema_on_200_201.properties.instance_view.hosts.Element.statuses + statuses.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.instance_view.hosts.Element.statuses.Element + _element.code = AAZStrType() + _element.display_status = AAZStrType( + serialized_name="displayStatus", + ) + _element.level = AAZStrType() + _element.message = AAZStrType() + _element.time = AAZStrType() + + 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() + + zones = cls._schema_on_200_201.zones + zones.Element = AAZStrType() + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_delete.py b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_delete.py index 72e0d5ab55b..70df2c491e6 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_delete.py +++ b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_delete.py @@ -20,9 +20,9 @@ class Delete(AAZCommand): """ _aaz_info = { - "version": "2019-03-01", + "version": "2024-11-01", "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/hostgroups/{}", "2019-03-01"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/hostgroups/{}", "2024-11-01"], ] } @@ -49,7 +49,6 @@ def _build_arguments_schema(cls, *args, **kwargs): id_part="name", ) _args_schema.resource_group = AAZResourceGroupNameArg( - help="Name of resource group. You can configure the default group using `az configure --defaults group=`.", required=True, ) return cls._args_schema @@ -117,7 +116,7 @@ def url_parameters(self): def query_parameters(self): parameters = { **self.serialize_query_param( - "api-version", "2019-03-01", + "api-version", "2024-11-01", required=True, ), } diff --git a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_list.py b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_list.py index c8f35a2f544..9e50f9e3d88 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_list.py +++ b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_list.py @@ -21,10 +21,10 @@ class List(AAZCommand): """ _aaz_info = { - "version": "2019-03-01", + "version": "2024-11-01", "resources": [ - ["mgmt-plane", "/subscriptions/{}/providers/microsoft.compute/hostgroups", "2019-03-01"], - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/hostgroups", "2019-03-01"], + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.compute/hostgroups", "2024-11-01"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/hostgroups", "2024-11-01"], ] } @@ -45,9 +45,7 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "" _args_schema = cls._args_schema - _args_schema.resource_group = AAZResourceGroupNameArg( - help="Name of resource group. You can configure the default group using `az configure --defaults group=`.", - ) + _args_schema.resource_group = AAZResourceGroupNameArg() return cls._args_schema def _execute_operations(self): @@ -117,7 +115,7 @@ def url_parameters(self): def query_parameters(self): parameters = { **self.serialize_query_param( - "api-version", "2019-03-01", + "api-version", "2024-11-01", required=True, ), } @@ -173,6 +171,10 @@ def _build_schema_on_200(cls): _element.properties = AAZObjectType( flags={"client_flatten": True}, ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) _element.tags = AAZDictType() _element.type = AAZStrType( flags={"read_only": True}, @@ -180,13 +182,28 @@ def _build_schema_on_200(cls): _element.zones = AAZListType() properties = cls._schema_on_200.value.Element.properties + properties.additional_capabilities = AAZObjectType( + serialized_name="additionalCapabilities", + ) properties.hosts = AAZListType( flags={"read_only": True}, ) + properties.instance_view = AAZObjectType( + serialized_name="instanceView", + flags={"read_only": True}, + ) properties.platform_fault_domain_count = AAZIntType( serialized_name="platformFaultDomainCount", flags={"required": True}, ) + properties.support_automatic_placement = AAZBoolType( + serialized_name="supportAutomaticPlacement", + ) + + additional_capabilities = cls._schema_on_200.value.Element.properties.additional_capabilities + additional_capabilities.ultra_ssd_enabled = AAZBoolType( + serialized_name="ultraSSDEnabled", + ) hosts = cls._schema_on_200.value.Element.properties.hosts hosts.Element = AAZObjectType() @@ -196,6 +213,71 @@ def _build_schema_on_200(cls): flags={"read_only": True}, ) + instance_view = cls._schema_on_200.value.Element.properties.instance_view + instance_view.hosts = AAZListType() + + hosts = cls._schema_on_200.value.Element.properties.instance_view.hosts + hosts.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.instance_view.hosts.Element + _element.asset_id = AAZStrType( + serialized_name="assetId", + flags={"read_only": True}, + ) + _element.available_capacity = AAZObjectType( + serialized_name="availableCapacity", + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.statuses = AAZListType() + + available_capacity = cls._schema_on_200.value.Element.properties.instance_view.hosts.Element.available_capacity + available_capacity.allocatable_v_ms = AAZListType( + serialized_name="allocatableVMs", + ) + + allocatable_v_ms = cls._schema_on_200.value.Element.properties.instance_view.hosts.Element.available_capacity.allocatable_v_ms + allocatable_v_ms.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.instance_view.hosts.Element.available_capacity.allocatable_v_ms.Element + _element.count = AAZFloatType() + _element.vm_size = AAZStrType( + serialized_name="vmSize", + ) + + statuses = cls._schema_on_200.value.Element.properties.instance_view.hosts.Element.statuses + statuses.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.instance_view.hosts.Element.statuses.Element + _element.code = AAZStrType() + _element.display_status = AAZStrType( + serialized_name="displayStatus", + ) + _element.level = AAZStrType() + _element.message = AAZStrType() + _element.time = AAZStrType() + + system_data = cls._schema_on_200.value.Element.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.value.Element.tags tags.Element = AAZStrType() @@ -244,7 +326,7 @@ def url_parameters(self): def query_parameters(self): parameters = { **self.serialize_query_param( - "api-version", "2019-03-01", + "api-version", "2024-11-01", required=True, ), } @@ -300,6 +382,10 @@ def _build_schema_on_200(cls): _element.properties = AAZObjectType( flags={"client_flatten": True}, ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) _element.tags = AAZDictType() _element.type = AAZStrType( flags={"read_only": True}, @@ -307,13 +393,28 @@ def _build_schema_on_200(cls): _element.zones = AAZListType() properties = cls._schema_on_200.value.Element.properties + properties.additional_capabilities = AAZObjectType( + serialized_name="additionalCapabilities", + ) properties.hosts = AAZListType( flags={"read_only": True}, ) + properties.instance_view = AAZObjectType( + serialized_name="instanceView", + flags={"read_only": True}, + ) properties.platform_fault_domain_count = AAZIntType( serialized_name="platformFaultDomainCount", flags={"required": True}, ) + properties.support_automatic_placement = AAZBoolType( + serialized_name="supportAutomaticPlacement", + ) + + additional_capabilities = cls._schema_on_200.value.Element.properties.additional_capabilities + additional_capabilities.ultra_ssd_enabled = AAZBoolType( + serialized_name="ultraSSDEnabled", + ) hosts = cls._schema_on_200.value.Element.properties.hosts hosts.Element = AAZObjectType() @@ -323,6 +424,71 @@ def _build_schema_on_200(cls): flags={"read_only": True}, ) + instance_view = cls._schema_on_200.value.Element.properties.instance_view + instance_view.hosts = AAZListType() + + hosts = cls._schema_on_200.value.Element.properties.instance_view.hosts + hosts.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.instance_view.hosts.Element + _element.asset_id = AAZStrType( + serialized_name="assetId", + flags={"read_only": True}, + ) + _element.available_capacity = AAZObjectType( + serialized_name="availableCapacity", + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.statuses = AAZListType() + + available_capacity = cls._schema_on_200.value.Element.properties.instance_view.hosts.Element.available_capacity + available_capacity.allocatable_v_ms = AAZListType( + serialized_name="allocatableVMs", + ) + + allocatable_v_ms = cls._schema_on_200.value.Element.properties.instance_view.hosts.Element.available_capacity.allocatable_v_ms + allocatable_v_ms.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.instance_view.hosts.Element.available_capacity.allocatable_v_ms.Element + _element.count = AAZFloatType() + _element.vm_size = AAZStrType( + serialized_name="vmSize", + ) + + statuses = cls._schema_on_200.value.Element.properties.instance_view.hosts.Element.statuses + statuses.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.instance_view.hosts.Element.statuses.Element + _element.code = AAZStrType() + _element.display_status = AAZStrType( + serialized_name="displayStatus", + ) + _element.level = AAZStrType() + _element.message = AAZStrType() + _element.time = AAZStrType() + + system_data = cls._schema_on_200.value.Element.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.value.Element.tags tags.Element = AAZStrType() diff --git a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_show.py b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_show.py index e4f0226d157..052c5941d99 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_show.py +++ b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_show.py @@ -22,9 +22,9 @@ class Show(AAZCommand): """ _aaz_info = { - "version": "2019-03-01", + "version": "2024-11-01", "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/hostgroups/{}", "2019-03-01"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/hostgroups/{}", "2024-11-01"], ] } @@ -51,9 +51,13 @@ def _build_arguments_schema(cls, *args, **kwargs): id_part="name", ) _args_schema.resource_group = AAZResourceGroupNameArg( - help="Name of resource group. You can configure the default group using `az configure --defaults group=`.", required=True, ) + _args_schema.expand = AAZStrArg( + options=["--expand"], + help="The expand expression to apply on the operation. 'InstanceView' will retrieve the list of instance views of the dedicated hosts under the dedicated host group. 'UserData' is not supported for dedicated host group.", + enum={"instanceView": "instanceView", "resiliencyView": "resiliencyView", "userData": "userData"}, + ) return cls._args_schema def _execute_operations(self): @@ -121,7 +125,10 @@ def url_parameters(self): def query_parameters(self): parameters = { **self.serialize_query_param( - "api-version", "2019-03-01", + "$expand", self.ctx.args.expand, + ), + **self.serialize_query_param( + "api-version", "2024-11-01", required=True, ), } @@ -166,6 +173,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}, @@ -173,13 +184,28 @@ def _build_schema_on_200(cls): _schema_on_200.zones = AAZListType() properties = cls._schema_on_200.properties + properties.additional_capabilities = AAZObjectType( + serialized_name="additionalCapabilities", + ) properties.hosts = AAZListType( flags={"read_only": True}, ) + properties.instance_view = AAZObjectType( + serialized_name="instanceView", + flags={"read_only": True}, + ) properties.platform_fault_domain_count = AAZIntType( serialized_name="platformFaultDomainCount", flags={"required": True}, ) + properties.support_automatic_placement = AAZBoolType( + serialized_name="supportAutomaticPlacement", + ) + + additional_capabilities = cls._schema_on_200.properties.additional_capabilities + additional_capabilities.ultra_ssd_enabled = AAZBoolType( + serialized_name="ultraSSDEnabled", + ) hosts = cls._schema_on_200.properties.hosts hosts.Element = AAZObjectType() @@ -189,6 +215,71 @@ def _build_schema_on_200(cls): flags={"read_only": True}, ) + instance_view = cls._schema_on_200.properties.instance_view + instance_view.hosts = AAZListType() + + hosts = cls._schema_on_200.properties.instance_view.hosts + hosts.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.instance_view.hosts.Element + _element.asset_id = AAZStrType( + serialized_name="assetId", + flags={"read_only": True}, + ) + _element.available_capacity = AAZObjectType( + serialized_name="availableCapacity", + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.statuses = AAZListType() + + available_capacity = cls._schema_on_200.properties.instance_view.hosts.Element.available_capacity + available_capacity.allocatable_v_ms = AAZListType( + serialized_name="allocatableVMs", + ) + + allocatable_v_ms = cls._schema_on_200.properties.instance_view.hosts.Element.available_capacity.allocatable_v_ms + allocatable_v_ms.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.instance_view.hosts.Element.available_capacity.allocatable_v_ms.Element + _element.count = AAZFloatType() + _element.vm_size = AAZStrType( + serialized_name="vmSize", + ) + + statuses = cls._schema_on_200.properties.instance_view.hosts.Element.statuses + statuses.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.instance_view.hosts.Element.statuses.Element + _element.code = AAZStrType() + _element.display_status = AAZStrType( + serialized_name="displayStatus", + ) + _element.level = AAZStrType() + _element.message = AAZStrType() + _element.time = AAZStrType() + + 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() diff --git a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_update.py b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_update.py new file mode 100644 index 00000000000..52391cb6acd --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_update.py @@ -0,0 +1,519 @@ +# -------------------------------------------------------------------------------------------- +# 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 Update(AAZCommand): + """Update a dedicated host group. + """ + + _aaz_info = { + "version": "2024-11-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/hostgroups/{}", "2024-11-01"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + 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.host_group_name = AAZStrArg( + options=["-n", "--name", "--host-group-name"], + help="Name of the Dedicated Host Group.", + required=True, + id_part="name", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Resource tags", + nullable=True, + ) + _args_schema.zones = AAZListArg( + options=["--zones"], + arg_group="Parameters", + help="Availability Zone to use for this host group. Only single zone is supported. The zone can be assigned only during creation. If not provided, the group supports all zones in the region. If provided, enforces each host in the group to be in the same zone.", + nullable=True, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg( + nullable=True, + ) + + zones = cls._args_schema.zones + zones.Element = AAZStrArg( + nullable=True, + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.additional_capabilities = AAZObjectArg( + options=["--additional-capabilities"], + arg_group="Properties", + help="Enables or disables a capability on the dedicated host group. Minimum api-version: 2022-03-01.", + nullable=True, + ) + _args_schema.platform_fault_domain_count = AAZIntArg( + options=["--platform-fault-domain-count"], + arg_group="Properties", + help="Number of fault domains that the host group can span.", + fmt=AAZIntArgFormat( + minimum=1, + ), + ) + _args_schema.support_automatic_placement = AAZBoolArg( + options=["--support-automatic-placement"], + arg_group="Properties", + help="Specifies whether virtual machines or virtual machine scale sets can be placed automatically on the dedicated host group. Automatic placement means resources are allocated on dedicated hosts, that are chosen by Azure, under the dedicated host group. The value is defaulted to 'false' when not provided. Minimum api-version: 2020-06-01.", + nullable=True, + ) + + additional_capabilities = cls._args_schema.additional_capabilities + additional_capabilities.ultra_ssd_enabled = AAZBoolArg( + options=["ultra-ssd-enabled"], + help="The flag that enables or disables a capability to have UltraSSD Enabled Virtual Machines on Dedicated Hosts of the Dedicated Host Group. For the Virtual Machines to be UltraSSD Enabled, UltraSSDEnabled flag for the resource needs to be set true as well. The value is defaulted to 'false' when not provided. Please refer to https://docs.microsoft.com/en-us/azure/virtual-machines/disks-enable-ultra-ssd for more details on Ultra SSD feature. **Note:** The ultraSSDEnabled setting can only be enabled for Host Groups that are created as zonal. Minimum api-version: 2022-03-01.", + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DedicatedHostGroupsGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + self.DedicatedHostGroupsCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class DedicatedHostGroupsGet(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]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "hostGroupName", self.ctx.args.host_group_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + 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", "2024-11-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_dedicated_host_group_read(cls._schema_on_200) + + return cls._schema_on_200 + + class DedicatedHostGroupsCreateOrUpdate(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/hostGroups/{hostGroupName}", + **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( + "hostGroupName", self.ctx.args.host_group_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + 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", "2024-11-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, + value=self.ctx.vars.instance, + ) + + 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() + _UpdateHelper._build_schema_dedicated_host_group_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + _builder.set_prop("tags", AAZDictType, ".tags") + _builder.set_prop("zones", AAZListType, ".zones") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("additionalCapabilities", AAZObjectType, ".additional_capabilities") + properties.set_prop("platformFaultDomainCount", AAZIntType, ".platform_fault_domain_count", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("supportAutomaticPlacement", AAZBoolType, ".support_automatic_placement") + + additional_capabilities = _builder.get(".properties.additionalCapabilities") + if additional_capabilities is not None: + additional_capabilities.set_prop("ultraSSDEnabled", AAZBoolType, ".ultra_ssd_enabled") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + zones = _builder.get(".zones") + if zones is not None: + zones.set_elements(AAZStrType, ".") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_dedicated_host_group_read = None + + @classmethod + def _build_schema_dedicated_host_group_read(cls, _schema): + if cls._schema_dedicated_host_group_read is not None: + _schema.id = cls._schema_dedicated_host_group_read.id + _schema.location = cls._schema_dedicated_host_group_read.location + _schema.name = cls._schema_dedicated_host_group_read.name + _schema.properties = cls._schema_dedicated_host_group_read.properties + _schema.system_data = cls._schema_dedicated_host_group_read.system_data + _schema.tags = cls._schema_dedicated_host_group_read.tags + _schema.type = cls._schema_dedicated_host_group_read.type + _schema.zones = cls._schema_dedicated_host_group_read.zones + return + + cls._schema_dedicated_host_group_read = _schema_dedicated_host_group_read = AAZObjectType() + + dedicated_host_group_read = _schema_dedicated_host_group_read + dedicated_host_group_read.id = AAZStrType( + flags={"read_only": True}, + ) + dedicated_host_group_read.location = AAZStrType( + flags={"required": True}, + ) + dedicated_host_group_read.name = AAZStrType( + flags={"read_only": True}, + ) + dedicated_host_group_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + dedicated_host_group_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + dedicated_host_group_read.tags = AAZDictType() + dedicated_host_group_read.type = AAZStrType( + flags={"read_only": True}, + ) + dedicated_host_group_read.zones = AAZListType() + + properties = _schema_dedicated_host_group_read.properties + properties.additional_capabilities = AAZObjectType( + serialized_name="additionalCapabilities", + ) + properties.hosts = AAZListType( + flags={"read_only": True}, + ) + properties.instance_view = AAZObjectType( + serialized_name="instanceView", + flags={"read_only": True}, + ) + properties.platform_fault_domain_count = AAZIntType( + serialized_name="platformFaultDomainCount", + flags={"required": True}, + ) + properties.support_automatic_placement = AAZBoolType( + serialized_name="supportAutomaticPlacement", + ) + + additional_capabilities = _schema_dedicated_host_group_read.properties.additional_capabilities + additional_capabilities.ultra_ssd_enabled = AAZBoolType( + serialized_name="ultraSSDEnabled", + ) + + hosts = _schema_dedicated_host_group_read.properties.hosts + hosts.Element = AAZObjectType() + + _element = _schema_dedicated_host_group_read.properties.hosts.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + + instance_view = _schema_dedicated_host_group_read.properties.instance_view + instance_view.hosts = AAZListType() + + hosts = _schema_dedicated_host_group_read.properties.instance_view.hosts + hosts.Element = AAZObjectType() + + _element = _schema_dedicated_host_group_read.properties.instance_view.hosts.Element + _element.asset_id = AAZStrType( + serialized_name="assetId", + flags={"read_only": True}, + ) + _element.available_capacity = AAZObjectType( + serialized_name="availableCapacity", + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.statuses = AAZListType() + + available_capacity = _schema_dedicated_host_group_read.properties.instance_view.hosts.Element.available_capacity + available_capacity.allocatable_v_ms = AAZListType( + serialized_name="allocatableVMs", + ) + + allocatable_v_ms = _schema_dedicated_host_group_read.properties.instance_view.hosts.Element.available_capacity.allocatable_v_ms + allocatable_v_ms.Element = AAZObjectType() + + _element = _schema_dedicated_host_group_read.properties.instance_view.hosts.Element.available_capacity.allocatable_v_ms.Element + _element.count = AAZFloatType() + _element.vm_size = AAZStrType( + serialized_name="vmSize", + ) + + statuses = _schema_dedicated_host_group_read.properties.instance_view.hosts.Element.statuses + statuses.Element = AAZObjectType() + + _element = _schema_dedicated_host_group_read.properties.instance_view.hosts.Element.statuses.Element + _element.code = AAZStrType() + _element.display_status = AAZStrType( + serialized_name="displayStatus", + ) + _element.level = AAZStrType() + _element.message = AAZStrType() + _element.time = AAZStrType() + + system_data = _schema_dedicated_host_group_read.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 = _schema_dedicated_host_group_read.tags + tags.Element = AAZStrType() + + zones = _schema_dedicated_host_group_read.zones + zones.Element = AAZStrType() + + _schema.id = cls._schema_dedicated_host_group_read.id + _schema.location = cls._schema_dedicated_host_group_read.location + _schema.name = cls._schema_dedicated_host_group_read.name + _schema.properties = cls._schema_dedicated_host_group_read.properties + _schema.system_data = cls._schema_dedicated_host_group_read.system_data + _schema.tags = cls._schema_dedicated_host_group_read.tags + _schema.type = cls._schema_dedicated_host_group_read.type + _schema.zones = cls._schema_dedicated_host_group_read.zones + + +__all__ = ["Update"] From ae8ffabe7c15bde0f16f4be28573d78497fdfd57 Mon Sep 17 00:00:00 2001 From: william051200 Date: Thu, 5 Mar 2026 07:53:10 +0800 Subject: [PATCH 02/21] Migrate vm host group command group --- .../azure/cli/command_modules/vm/commands.py | 5 +-- .../azure/cli/command_modules/vm/custom.py | 40 ++++++++++++++----- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/vm/commands.py b/src/azure-cli/azure/cli/command_modules/vm/commands.py index 51c50586daf..f868903ae80 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/commands.py +++ b/src/azure-cli/azure/cli/command_modules/vm/commands.py @@ -392,9 +392,8 @@ def load_command_table(self, _): g.custom_command('create', 'create_dedicated_host') g.generic_update_command('update', setter_name='begin_create_or_update') - with self.command_group('vm host group', compute_dedicated_host_groups_sdk, client_factory=cf_dedicated_host_groups, - min_api='2019-03-01') as g: - g.custom_command('get-instance-view', 'get_dedicated_host_group_instance_view', min_api='2020-06-01') + with self.command_group('vm host group') as g: + g.custom_command('get-instance-view', 'get_dedicated_host_group_instance_view') g.custom_command('create', 'create_dedicated_host_group') g.generic_update_command('update') diff --git a/src/azure-cli/azure/cli/command_modules/vm/custom.py b/src/azure-cli/azure/cli/command_modules/vm/custom.py index 5380bfeef8f..d5513170ef8 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/custom.py +++ b/src/azure-cli/azure/cli/command_modules/vm/custom.py @@ -5906,22 +5906,42 @@ def update_image_version(cmd, resource_group_name, gallery_name, gallery_image_n # region dedicated host -def create_dedicated_host_group(cmd, client, host_group_name, resource_group_name, platform_fault_domain_count, +def create_dedicated_host_group(cmd, host_group_name, resource_group_name, platform_fault_domain_count, automatic_placement=None, location=None, zones=None, tags=None, ultra_ssd_enabled=None): - DedicatedHostGroup = cmd.get_models('DedicatedHostGroup') + from .aaz.latest.vm.host.group import Create as VmHostGroupCreate location = location or _get_resource_group_location(cmd.cli_ctx, resource_group_name) + command_args = { + 'host_group_name': host_group_name, + 'resource_group': resource_group_name, + 'location': location, + 'platform_fault_domain_count': platform_fault_domain_count + } - host_group_params = DedicatedHostGroup(location=location, platform_fault_domain_count=platform_fault_domain_count, - support_automatic_placement=automatic_placement, zones=zones, tags=tags) - if ultra_ssd_enabled is not None: - additionalCapabilities = {'ultraSSDEnabled': ultra_ssd_enabled} - host_group_params.additional_capabilities = additionalCapabilities + if tags: + command_args['tags'] = tags + + if zones: + command_args['zones'] = zones - return client.create_or_update(resource_group_name, host_group_name, parameters=host_group_params) + if ultra_ssd_enabled: + command_args['additional_capabilities'] = { + 'ultra_ssd_enabled': ultra_ssd_enabled + } + if automatic_placement is not None: + command_args['support_automatic_placement'] = automatic_placement -def get_dedicated_host_group_instance_view(client, host_group_name, resource_group_name): - return client.get(resource_group_name, host_group_name, expand="instanceView") + return VmHostGroupCreate(cli_ctx=cmd.cli_ctx)(command_args=command_args) + + +def get_dedicated_host_group_instance_view(cmd, host_group_name, resource_group_name): + from .aaz.latest.vm.host.group import Show as VmHostGroupShow + command_args = { + 'host_group_name': host_group_name, + 'resource_group': resource_group_name, + 'expand': 'instanceView' + } + return VmHostGroupShow(cli_ctx=cmd.cli_ctx)(command_args=command_args) def create_dedicated_host(cmd, client, host_group_name, host_name, resource_group_name, sku, platform_fault_domain=None, From 899ee505802d88905d730a9c66f5379b69fc45e0 Mon Sep 17 00:00:00 2001 From: william051200 Date: Thu, 5 Mar 2026 09:42:01 +0800 Subject: [PATCH 03/21] Generate vm host group update --- .../cli/command_modules/vm/aaz/latest/vm/host/group/_update.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_update.py b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_update.py index 52391cb6acd..e111f3cd41e 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_update.py +++ b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_update.py @@ -11,6 +11,9 @@ from azure.cli.core.aaz import * +@register_command( + "vm host group update", +) class Update(AAZCommand): """Update a dedicated host group. """ From b832920b75d82cdf4634cb65290af48820585922 Mon Sep 17 00:00:00 2001 From: william051200 Date: Thu, 5 Mar 2026 09:42:25 +0800 Subject: [PATCH 04/21] Migrate vm host group update --- src/azure-cli/azure/cli/command_modules/vm/commands.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/azure-cli/azure/cli/command_modules/vm/commands.py b/src/azure-cli/azure/cli/command_modules/vm/commands.py index f868903ae80..95f2124f295 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/commands.py +++ b/src/azure-cli/azure/cli/command_modules/vm/commands.py @@ -395,7 +395,6 @@ def load_command_table(self, _): with self.command_group('vm host group') as g: g.custom_command('get-instance-view', 'get_dedicated_host_group_instance_view') g.custom_command('create', 'create_dedicated_host_group') - g.generic_update_command('update') with self.command_group('vmss') as g: g.custom_command('identity assign', 'assign_vmss_identity', validator=process_assign_identity_namespace) From d9980205713b93566db5f89e80cbd1debf6c4a66 Mon Sep 17 00:00:00 2001 From: william051200 Date: Thu, 5 Mar 2026 09:51:39 +0800 Subject: [PATCH 05/21] Update vm host group show command to match command before migration --- .../azure/cli/command_modules/vm/commands.py | 3 +++ .../vm/operations/vm_host_group.py | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/azure-cli/azure/cli/command_modules/vm/operations/vm_host_group.py diff --git a/src/azure-cli/azure/cli/command_modules/vm/commands.py b/src/azure-cli/azure/cli/command_modules/vm/commands.py index 95f2124f295..a01c1bd3393 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/commands.py +++ b/src/azure-cli/azure/cli/command_modules/vm/commands.py @@ -396,6 +396,9 @@ def load_command_table(self, _): g.custom_command('get-instance-view', 'get_dedicated_host_group_instance_view') g.custom_command('create', 'create_dedicated_host_group') + from .operations.vm_host_group import VMHostGroupShow + self.command_table['vm host group show'] = VMHostGroupShow(loader=self) + with self.command_group('vmss') as g: g.custom_command('identity assign', 'assign_vmss_identity', validator=process_assign_identity_namespace) g.custom_command('identity remove', 'remove_vmss_identity', validator=process_remove_identity_namespace, is_preview=True) diff --git a/src/azure-cli/azure/cli/command_modules/vm/operations/vm_host_group.py b/src/azure-cli/azure/cli/command_modules/vm/operations/vm_host_group.py new file mode 100644 index 00000000000..1ffd30ca058 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/vm/operations/vm_host_group.py @@ -0,0 +1,21 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +# pylint: disable=no-self-use, line-too-long, protected-access, too-few-public-methods, unused-argument +from knack.log import get_logger + +from ..aaz.latest.vm.host.group import Show as _VMHostGroupShow + +logger = get_logger(__name__) + + +class VMHostGroupShow(_VMHostGroupShow): + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + args_schema = super()._build_arguments_schema(*args, **kwargs) + + args_schema.expand._registered = False + + return args_schema + From f37fe087fb31bbf6686546a8294078a9b1bd08c8 Mon Sep 17 00:00:00 2001 From: william051200 Date: Thu, 5 Mar 2026 09:51:56 +0800 Subject: [PATCH 06/21] Generate vm host group update command to match command before migration --- .../vm/aaz/latest/vm/host/group/_update.py | 81 +------------------ 1 file changed, 4 insertions(+), 77 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_update.py b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_update.py index e111f3cd41e..67500147292 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_update.py +++ b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_update.py @@ -43,8 +43,8 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "" _args_schema = cls._args_schema - _args_schema.host_group_name = AAZStrArg( - options=["-n", "--name", "--host-group-name"], + _args_schema.name = AAZStrArg( + options=["-n", "--name"], help="Name of the Dedicated Host Group.", required=True, id_part="name", @@ -55,60 +55,7 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "Parameters" - _args_schema = cls._args_schema - _args_schema.tags = AAZDictArg( - options=["--tags"], - arg_group="Parameters", - help="Resource tags", - nullable=True, - ) - _args_schema.zones = AAZListArg( - options=["--zones"], - arg_group="Parameters", - help="Availability Zone to use for this host group. Only single zone is supported. The zone can be assigned only during creation. If not provided, the group supports all zones in the region. If provided, enforces each host in the group to be in the same zone.", - nullable=True, - ) - - tags = cls._args_schema.tags - tags.Element = AAZStrArg( - nullable=True, - ) - - zones = cls._args_schema.zones - zones.Element = AAZStrArg( - nullable=True, - ) - # define Arg Group "Properties" - - _args_schema = cls._args_schema - _args_schema.additional_capabilities = AAZObjectArg( - options=["--additional-capabilities"], - arg_group="Properties", - help="Enables or disables a capability on the dedicated host group. Minimum api-version: 2022-03-01.", - nullable=True, - ) - _args_schema.platform_fault_domain_count = AAZIntArg( - options=["--platform-fault-domain-count"], - arg_group="Properties", - help="Number of fault domains that the host group can span.", - fmt=AAZIntArgFormat( - minimum=1, - ), - ) - _args_schema.support_automatic_placement = AAZBoolArg( - options=["--support-automatic-placement"], - arg_group="Properties", - help="Specifies whether virtual machines or virtual machine scale sets can be placed automatically on the dedicated host group. Automatic placement means resources are allocated on dedicated hosts, that are chosen by Azure, under the dedicated host group. The value is defaulted to 'false' when not provided. Minimum api-version: 2020-06-01.", - nullable=True, - ) - - additional_capabilities = cls._args_schema.additional_capabilities - additional_capabilities.ultra_ssd_enabled = AAZBoolArg( - options=["ultra-ssd-enabled"], - help="The flag that enables or disables a capability to have UltraSSD Enabled Virtual Machines on Dedicated Hosts of the Dedicated Host Group. For the Virtual Machines to be UltraSSD Enabled, UltraSSDEnabled flag for the resource needs to be set true as well. The value is defaulted to 'false' when not provided. Please refer to https://docs.microsoft.com/en-us/azure/virtual-machines/disks-enable-ultra-ssd for more details on Ultra SSD feature. **Note:** The ultraSSDEnabled setting can only be enabled for Host Groups that are created as zonal. Minimum api-version: 2022-03-01.", - nullable=True, - ) return cls._args_schema def _execute_operations(self): @@ -171,7 +118,7 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "hostGroupName", self.ctx.args.host_group_name, + "hostGroupName", self.ctx.args.name, required=True, ), **self.serialize_url_param( @@ -254,7 +201,7 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "hostGroupName", self.ctx.args.host_group_name, + "hostGroupName", self.ctx.args.name, required=True, ), **self.serialize_url_param( @@ -331,26 +278,6 @@ def _update_instance(self, instance): typ=AAZObjectType ) _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) - _builder.set_prop("tags", AAZDictType, ".tags") - _builder.set_prop("zones", AAZListType, ".zones") - - properties = _builder.get(".properties") - if properties is not None: - properties.set_prop("additionalCapabilities", AAZObjectType, ".additional_capabilities") - properties.set_prop("platformFaultDomainCount", AAZIntType, ".platform_fault_domain_count", typ_kwargs={"flags": {"required": True}}) - properties.set_prop("supportAutomaticPlacement", AAZBoolType, ".support_automatic_placement") - - additional_capabilities = _builder.get(".properties.additionalCapabilities") - if additional_capabilities is not None: - additional_capabilities.set_prop("ultraSSDEnabled", AAZBoolType, ".ultra_ssd_enabled") - - tags = _builder.get(".tags") - if tags is not None: - tags.set_elements(AAZStrType, ".") - - zones = _builder.get(".zones") - if zones is not None: - zones.set_elements(AAZStrType, ".") return _instance_value From 521483ea165b29ba6b98ba38686a9324afbcacdd Mon Sep 17 00:00:00 2001 From: william051200 Date: Thu, 5 Mar 2026 10:04:29 +0800 Subject: [PATCH 07/21] Remove unused import --- .../azure/cli/command_modules/vm/_client_factory.py | 4 ---- src/azure-cli/azure/cli/command_modules/vm/commands.py | 7 +------ 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/vm/_client_factory.py b/src/azure-cli/azure/cli/command_modules/vm/_client_factory.py index ee6329e9129..e4a50738666 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/_client_factory.py +++ b/src/azure-cli/azure/cli/command_modules/vm/_client_factory.py @@ -91,10 +91,6 @@ def cf_dedicated_hosts(cli_ctx, _): return _compute_client_factory(cli_ctx).dedicated_hosts -def cf_dedicated_host_groups(cli_ctx, _): - return _compute_client_factory(cli_ctx).dedicated_host_groups - - def _log_analytics_client_factory(cli_ctx, subscription_id, *_): from azure.mgmt.loganalytics import LogAnalyticsManagementClient from azure.cli.core.commands.client_factory import get_mgmt_service_client diff --git a/src/azure-cli/azure/cli/command_modules/vm/commands.py b/src/azure-cli/azure/cli/command_modules/vm/commands.py index a01c1bd3393..e52c2874b90 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/commands.py +++ b/src/azure-cli/azure/cli/command_modules/vm/commands.py @@ -9,7 +9,7 @@ cf_vmss, cf_images, cf_galleries, cf_gallery_images, cf_gallery_image_versions, cf_proximity_placement_groups, - cf_dedicated_hosts, cf_dedicated_host_groups, + cf_dedicated_hosts, cf_log_analytics_data_plane, cf_capacity_reservation_groups, cf_capacity_reservations, cf_community_gallery) @@ -143,11 +143,6 @@ def load_command_table(self, _): client_factory=cf_dedicated_hosts, ) - compute_dedicated_host_groups_sdk = CliCommandType( - operations_tmpl="azure.mgmt.compute.operations#DedicatedHostGroupsOperations.{}", - client_factory=cf_dedicated_host_groups, - ) - image_builder_image_templates_sdk = CliCommandType( operations_tmpl="azure.mgmt.imagebuilder.operations#VirtualMachineImageTemplatesOperations.{}", client_factory=cf_img_bldr_image_templates, From 699e7489aaee0520b539ed492eaef3b4e8d711c9 Mon Sep 17 00:00:00 2001 From: william051200 Date: Thu, 5 Mar 2026 10:10:12 +0800 Subject: [PATCH 08/21] Update code --- src/azure-cli/azure/cli/command_modules/vm/custom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/azure-cli/azure/cli/command_modules/vm/custom.py b/src/azure-cli/azure/cli/command_modules/vm/custom.py index d5513170ef8..249eb1d34d4 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/custom.py +++ b/src/azure-cli/azure/cli/command_modules/vm/custom.py @@ -5923,7 +5923,7 @@ def create_dedicated_host_group(cmd, host_group_name, resource_group_name, platf if zones: command_args['zones'] = zones - if ultra_ssd_enabled: + if ultra_ssd_enabled is not None: command_args['additional_capabilities'] = { 'ultra_ssd_enabled': ultra_ssd_enabled } From 85b088b51a45e406f0506d8608d10437f801d91e Mon Sep 17 00:00:00 2001 From: william051200 Date: Thu, 5 Mar 2026 11:17:39 +0800 Subject: [PATCH 09/21] Add example --- .../cli/command_modules/vm/aaz/latest/vm/host/group/_update.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_update.py b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_update.py index 67500147292..83cbeda3e0e 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_update.py +++ b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_update.py @@ -16,6 +16,9 @@ ) class Update(AAZCommand): """Update a dedicated host group. + + :example: Create or update a dedicated host group with Ultra SSD support. + az vm host group update --resource-group myResourceGroup --name myDedicatedHostGroup --tags "{department:finance}" --zones "[1]" --platform-fault-domain-count 3 --support-automatic-placement True --additional-capabilities "{ultra-ssd-enabled:True}" """ _aaz_info = { From 7230f4f3bb2001da1525fc5baa8c33dd413da435 Mon Sep 17 00:00:00 2001 From: william051200 Date: Thu, 5 Mar 2026 13:55:14 +0800 Subject: [PATCH 10/21] Update code style --- .../azure/cli/command_modules/vm/operations/vm_host_group.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/azure-cli/azure/cli/command_modules/vm/operations/vm_host_group.py b/src/azure-cli/azure/cli/command_modules/vm/operations/vm_host_group.py index 1ffd30ca058..4c80a24e713 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/operations/vm_host_group.py +++ b/src/azure-cli/azure/cli/command_modules/vm/operations/vm_host_group.py @@ -18,4 +18,3 @@ def _build_arguments_schema(cls, *args, **kwargs): args_schema.expand._registered = False return args_schema - From 7d27b7f15835be9bb9aae16374f87733017e5bca Mon Sep 17 00:00:00 2001 From: william051200 Date: Thu, 5 Mar 2026 13:59:58 +0800 Subject: [PATCH 11/21] Update test case recordings --- .../vm/tests/latest/recordings/test_dedicated_host_e2e.yaml | 4 ++-- .../vm/tests/latest/recordings/test_vm_host_management.yaml | 4 ++-- .../vm/tests/latest/recordings/test_vm_host_redeploy.yaml | 2 +- .../cli/command_modules/vm/tests/latest/test_vm_commands.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_dedicated_host_e2e.yaml b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_dedicated_host_e2e.yaml index 0cbdc555684..369b4dc17a0 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_dedicated_host_e2e.yaml +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_dedicated_host_e2e.yaml @@ -3769,7 +3769,7 @@ interactions: - AZURECLI/2.47.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.11 (Linux-5.15.0-1036-azure-x86_64-with-glibc2.31) VSTS_7b238909-6802-4b65-b90d-184bca47f458_build_220_0 method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_dedicated_host_000001/providers/Microsoft.Compute/hostGroups/my-host-group?api-version=2019-03-01 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_dedicated_host_000001/providers/Microsoft.Compute/hostGroups/my-host-group?api-version=2024-11-01 response: body: string: "{\r\n \"name\": \"my-host-group\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/CLI_TEST_DEDICATED_HOST_IJYO5AOQ2IBWTIRNYZVXXGUB3E3A45FXIL4RSKVKBUO6D6I25M2/providers/Microsoft.Compute/hostGroups/my-host-group\",\r\n @@ -4084,7 +4084,7 @@ interactions: - AZURECLI/2.47.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.11 (Linux-5.15.0-1036-azure-x86_64-with-glibc2.31) VSTS_7b238909-6802-4b65-b90d-184bca47f458_build_220_0 method: DELETE - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_dedicated_host_000001/providers/Microsoft.Compute/hostGroups/my-host-group?api-version=2019-03-01 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_dedicated_host_000001/providers/Microsoft.Compute/hostGroups/my-host-group?api-version=2024-11-01 response: body: string: '' diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_host_management.yaml b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_host_management.yaml index ce35f1bea97..a2e13d8e33b 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_host_management.yaml +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_host_management.yaml @@ -114,7 +114,7 @@ interactions: - AZURECLI/2.47.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.11 (Linux-5.15.0-1036-azure-x86_64-with-glibc2.31) VSTS_7b238909-6802-4b65-b90d-184bca47f458_build_220_0 method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_host_management_000001/providers/Microsoft.Compute/hostGroups?api-version=2019-03-01 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_host_management_000001/providers/Microsoft.Compute/hostGroups?api-version=2024-11-01 response: body: string: "{\r\n \"value\": [\r\n {\r\n \"name\": \"my-host-group\",\r\n @@ -893,7 +893,7 @@ interactions: - AZURECLI/2.47.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.11 (Linux-5.15.0-1036-azure-x86_64-with-glibc2.31) VSTS_7b238909-6802-4b65-b90d-184bca47f458_build_220_0 method: DELETE - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_host_management_000001/providers/Microsoft.Compute/hostGroups/my-host-group?api-version=2019-03-01 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_host_management_000001/providers/Microsoft.Compute/hostGroups/my-host-group?api-version=2024-11-01 response: body: string: '' diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_host_redeploy.yaml b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_host_redeploy.yaml index 317a4035f7f..7ba6fe3eaa7 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_host_redeploy.yaml +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_host_redeploy.yaml @@ -122,7 +122,7 @@ interactions: User-Agent: - AZURECLI/2.72.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_vm_host_redeploy_000001/providers/Microsoft.Compute/hostGroups?api-version=2019-03-01 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_host_redeploy_000001/providers/Microsoft.Compute/hostGroups?api-version=2024-11-01 response: body: string: '{"value":[{"name":"my-host-group","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/CLI_TEST_VM_HOST_REDEPLOY_CJ4NDXY3MM2YBFYB25NY3YQ6GDCNAST5DV2Q4AY5UP6COWZWO/providers/Microsoft.Compute/hostGroups/my-host-group","type":"Microsoft.Compute/hostGroups","location":"eastus","properties":{"platformFaultDomainCount":1}}]}' diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py index 45b1af81cf1..68f831fcd5d 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py @@ -9495,7 +9495,7 @@ def test_vm_host_ultra_ssd(self, resource_group): 'host-group': self.create_random_name('host', 10) }) self.cmd('vm host group create -n {host-group} -g {rg} --ultra-ssd-enabled true -c 1 -l eastus2euap --zone 3', checks=[ - self.check('additionalCapabilities.ultraSsdEnabled', True) + self.check('additionalCapabilities.ultraSSDEnabled', True) ]) @AllowLargeResponse() From c9858e34a8928aaf64d9298481981dc6718af975 Mon Sep 17 00:00:00 2001 From: william051200 Date: Fri, 6 Mar 2026 07:54:46 +0800 Subject: [PATCH 12/21] Update code --- src/azure-cli/azure/cli/command_modules/vm/custom.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/vm/custom.py b/src/azure-cli/azure/cli/command_modules/vm/custom.py index 249eb1d34d4..cd92500d95b 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/custom.py +++ b/src/azure-cli/azure/cli/command_modules/vm/custom.py @@ -5917,11 +5917,11 @@ def create_dedicated_host_group(cmd, host_group_name, resource_group_name, platf 'platform_fault_domain_count': platform_fault_domain_count } - if tags: - command_args['tags'] = tags + if tags is not None: + command_args['tags'] = tags or {} - if zones: - command_args['zones'] = zones + if zones is not None: + command_args['zones'] = zones or [] if ultra_ssd_enabled is not None: command_args['additional_capabilities'] = { From 3ac3eaac26bfcbb965f18105d8f620d2d5670e9b Mon Sep 17 00:00:00 2001 From: william051200 Date: Wed, 11 Mar 2026 08:39:02 +0800 Subject: [PATCH 13/21] Update vm host group update aaz --- .../cli/command_modules/vm/aaz/latest/vm/host/group/_update.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_update.py b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_update.py index 83cbeda3e0e..643357c6975 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_update.py +++ b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_update.py @@ -11,9 +11,6 @@ from azure.cli.core.aaz import * -@register_command( - "vm host group update", -) class Update(AAZCommand): """Update a dedicated host group. From cbe4bab7d71d59f4c0a855f5cb09e1e45db0d78c Mon Sep 17 00:00:00 2001 From: william051200 Date: Wed, 11 Mar 2026 08:39:38 +0800 Subject: [PATCH 14/21] Resolve breaking change --- src/azure-cli/azure/cli/command_modules/vm/commands.py | 1 + src/azure-cli/azure/cli/command_modules/vm/custom.py | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/azure-cli/azure/cli/command_modules/vm/commands.py b/src/azure-cli/azure/cli/command_modules/vm/commands.py index e52c2874b90..f7109bdda9e 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/commands.py +++ b/src/azure-cli/azure/cli/command_modules/vm/commands.py @@ -390,6 +390,7 @@ def load_command_table(self, _): with self.command_group('vm host group') as g: g.custom_command('get-instance-view', 'get_dedicated_host_group_instance_view') g.custom_command('create', 'create_dedicated_host_group') + g.generic_update_command('update', getter_name='get_dedicated_host_group_instance_view', setter_name='update_dedicated_host_group', command_type=compute_custom) from .operations.vm_host_group import VMHostGroupShow self.command_table['vm host group show'] = VMHostGroupShow(loader=self) diff --git a/src/azure-cli/azure/cli/command_modules/vm/custom.py b/src/azure-cli/azure/cli/command_modules/vm/custom.py index cd92500d95b..274ea617f3e 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/custom.py +++ b/src/azure-cli/azure/cli/command_modules/vm/custom.py @@ -5944,6 +5944,14 @@ def get_dedicated_host_group_instance_view(cmd, host_group_name, resource_group_ return VmHostGroupShow(cli_ctx=cmd.cli_ctx)(command_args=command_args) +def update_dedicated_host_group(cmd, host_group_name, resource_group_name): + from .aaz.latest.vm.host.group import Update as VmHostGroupUpdate + command_args = { + 'name': host_group_name, + 'resource_group': resource_group_name + } + return VmHostGroupUpdate(cli_ctx=cmd.cli_ctx)(command_args=command_args) + def create_dedicated_host(cmd, client, host_group_name, host_name, resource_group_name, sku, platform_fault_domain=None, auto_replace_on_failure=None, license_type=None, location=None, tags=None): DedicatedHostType = cmd.get_models('DedicatedHost') From 9aa975f610e9c653cae40a27fef02973c299c6fb Mon Sep 17 00:00:00 2001 From: william051200 Date: Wed, 11 Mar 2026 09:26:19 +0800 Subject: [PATCH 15/21] Update vm host group update command --- .../vm/aaz/latest/vm/host/group/_update.py | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_update.py b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_update.py index 643357c6975..9a3e47a6a2d 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_update.py +++ b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_update.py @@ -55,7 +55,60 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "Parameters" + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Resource tags", + nullable=True, + ) + _args_schema.zones = AAZListArg( + options=["--zones"], + arg_group="Parameters", + help="Availability Zone to use for this host group. Only single zone is supported. The zone can be assigned only during creation. If not provided, the group supports all zones in the region. If provided, enforces each host in the group to be in the same zone.", + nullable=True, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg( + nullable=True, + ) + + zones = cls._args_schema.zones + zones.Element = AAZStrArg( + nullable=True, + ) + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.additional_capabilities = AAZObjectArg( + options=["--additional-capabilities"], + arg_group="Properties", + help="Enables or disables a capability on the dedicated host group. Minimum api-version: 2022-03-01.", + nullable=True, + ) + _args_schema.platform_fault_domain_count = AAZIntArg( + options=["--platform-fault-domain-count"], + arg_group="Properties", + help="Number of fault domains that the host group can span.", + fmt=AAZIntArgFormat( + minimum=1, + ), + ) + _args_schema.support_automatic_placement = AAZBoolArg( + options=["--support-automatic-placement"], + arg_group="Properties", + help="Specifies whether virtual machines or virtual machine scale sets can be placed automatically on the dedicated host group. Automatic placement means resources are allocated on dedicated hosts, that are chosen by Azure, under the dedicated host group. The value is defaulted to 'false' when not provided. Minimum api-version: 2020-06-01.", + nullable=True, + ) + + additional_capabilities = cls._args_schema.additional_capabilities + additional_capabilities.ultra_ssd_enabled = AAZBoolArg( + options=["ultra-ssd-enabled"], + help="The flag that enables or disables a capability to have UltraSSD Enabled Virtual Machines on Dedicated Hosts of the Dedicated Host Group. For the Virtual Machines to be UltraSSD Enabled, UltraSSDEnabled flag for the resource needs to be set true as well. The value is defaulted to 'false' when not provided. Please refer to https://docs.microsoft.com/en-us/azure/virtual-machines/disks-enable-ultra-ssd for more details on Ultra SSD feature. **Note:** The ultraSSDEnabled setting can only be enabled for Host Groups that are created as zonal. Minimum api-version: 2022-03-01.", + nullable=True, + ) return cls._args_schema def _execute_operations(self): @@ -278,6 +331,26 @@ def _update_instance(self, instance): typ=AAZObjectType ) _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + _builder.set_prop("tags", AAZDictType, ".tags") + _builder.set_prop("zones", AAZListType, ".zones") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("additionalCapabilities", AAZObjectType, ".additional_capabilities") + properties.set_prop("platformFaultDomainCount", AAZIntType, ".platform_fault_domain_count", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("supportAutomaticPlacement", AAZBoolType, ".support_automatic_placement") + + additional_capabilities = _builder.get(".properties.additionalCapabilities") + if additional_capabilities is not None: + additional_capabilities.set_prop("ultraSSDEnabled", AAZBoolType, ".ultra_ssd_enabled") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + zones = _builder.get(".zones") + if zones is not None: + zones.set_elements(AAZStrType, ".") return _instance_value From 8436b2a2d39b2af3158cff82c34765b416bdf946 Mon Sep 17 00:00:00 2001 From: william051200 Date: Wed, 11 Mar 2026 09:27:35 +0800 Subject: [PATCH 16/21] Update vm host group update command --- .../azure/cli/command_modules/vm/commands.py | 2 +- .../azure/cli/command_modules/vm/custom.py | 10 +++---- .../vm/operations/vm_host_group.py | 26 +++++++++++++++++++ 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/vm/commands.py b/src/azure-cli/azure/cli/command_modules/vm/commands.py index f7109bdda9e..549cba91d37 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/commands.py +++ b/src/azure-cli/azure/cli/command_modules/vm/commands.py @@ -390,7 +390,7 @@ def load_command_table(self, _): with self.command_group('vm host group') as g: g.custom_command('get-instance-view', 'get_dedicated_host_group_instance_view') g.custom_command('create', 'create_dedicated_host_group') - g.generic_update_command('update', getter_name='get_dedicated_host_group_instance_view', setter_name='update_dedicated_host_group', command_type=compute_custom) + g.generic_update_command('update', getter_name='get_dedicated_host_group_instance_view', setter_arg_name='dedicated_host_group', setter_name='update_dedicated_host_group', setter_type=compute_custom, command_type=compute_custom) from .operations.vm_host_group import VMHostGroupShow self.command_table['vm host group show'] = VMHostGroupShow(loader=self) diff --git a/src/azure-cli/azure/cli/command_modules/vm/custom.py b/src/azure-cli/azure/cli/command_modules/vm/custom.py index 274ea617f3e..52f3f52d0cc 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/custom.py +++ b/src/azure-cli/azure/cli/command_modules/vm/custom.py @@ -5944,12 +5944,12 @@ def get_dedicated_host_group_instance_view(cmd, host_group_name, resource_group_ return VmHostGroupShow(cli_ctx=cmd.cli_ctx)(command_args=command_args) -def update_dedicated_host_group(cmd, host_group_name, resource_group_name): +def update_dedicated_host_group(cmd, host_group_name, resource_group_name, **kwargs): from .aaz.latest.vm.host.group import Update as VmHostGroupUpdate - command_args = { - 'name': host_group_name, - 'resource_group': resource_group_name - } + from .operations.vm_host_group import convert_show_result_to_snake_case + command_args = convert_show_result_to_snake_case(kwargs['dedicated_host_group']) + command_args['name'] = host_group_name + command_args['resource_group'] = resource_group_name return VmHostGroupUpdate(cli_ctx=cmd.cli_ctx)(command_args=command_args) def create_dedicated_host(cmd, client, host_group_name, host_name, resource_group_name, sku, platform_fault_domain=None, diff --git a/src/azure-cli/azure/cli/command_modules/vm/operations/vm_host_group.py b/src/azure-cli/azure/cli/command_modules/vm/operations/vm_host_group.py index 4c80a24e713..9fb10f87d05 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/operations/vm_host_group.py +++ b/src/azure-cli/azure/cli/command_modules/vm/operations/vm_host_group.py @@ -18,3 +18,29 @@ def _build_arguments_schema(cls, *args, **kwargs): args_schema.expand._registered = False return args_schema + + +def convert_show_result_to_snake_case(result): + new_result = {} + if 'location' in result: + new_result['location'] = result['location'] + + if 'tags' in result: + new_result['tags'] = result['tags'] + + if 'zones' in result: + new_result['zones'] = result['zones'] + + if 'additionalCapabilities' in result: + new_result['additional_capabilities'] = result['additionalCapabilities'] + + if new_result['additional_capabilities'].get('ultraSSDEnabled'): + new_result['additional_capabilities']['ultra_ssd_enabled'] = new_result['additional_capabilities']['ultraSSDEnabled'] + new_result['additional_capabilities'].pop('ultraSSDEnabled') + + if 'platformFaultDomainCount' in result: + new_result['platform_fault_domain_count'] = result['platformFaultDomainCount'] + + if 'supportAutomaticPlacement' in result: + new_result['support_automatic_placement'] = result['supportAutomaticPlacement'] + return new_result From 777309faa67b25325281775dd16b29b5ad984b48 Mon Sep 17 00:00:00 2001 From: william051200 Date: Wed, 11 Mar 2026 09:49:49 +0800 Subject: [PATCH 17/21] Update vm host group update getter --- .../azure/cli/command_modules/vm/commands.py | 2 +- .../azure/cli/command_modules/vm/custom.py | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/vm/commands.py b/src/azure-cli/azure/cli/command_modules/vm/commands.py index 549cba91d37..4cb43b65e5d 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/commands.py +++ b/src/azure-cli/azure/cli/command_modules/vm/commands.py @@ -390,7 +390,7 @@ def load_command_table(self, _): with self.command_group('vm host group') as g: g.custom_command('get-instance-view', 'get_dedicated_host_group_instance_view') g.custom_command('create', 'create_dedicated_host_group') - g.generic_update_command('update', getter_name='get_dedicated_host_group_instance_view', setter_arg_name='dedicated_host_group', setter_name='update_dedicated_host_group', setter_type=compute_custom, command_type=compute_custom) + g.generic_update_command('update', setter_name='update_dedicated_host_group', setter_type=compute_custom, command_type=compute_custom) from .operations.vm_host_group import VMHostGroupShow self.command_table['vm host group show'] = VMHostGroupShow(loader=self) diff --git a/src/azure-cli/azure/cli/command_modules/vm/custom.py b/src/azure-cli/azure/cli/command_modules/vm/custom.py index 52f3f52d0cc..2d7b2c17176 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/custom.py +++ b/src/azure-cli/azure/cli/command_modules/vm/custom.py @@ -5944,13 +5944,19 @@ def get_dedicated_host_group_instance_view(cmd, host_group_name, resource_group_ return VmHostGroupShow(cli_ctx=cmd.cli_ctx)(command_args=command_args) -def update_dedicated_host_group(cmd, host_group_name, resource_group_name, **kwargs): - from .aaz.latest.vm.host.group import Update as VmHostGroupUpdate +def update_dedicated_host_group(cmd, host_group_name, resource_group_name): + from .aaz.latest.vm.host.group import Update as VmHostGroupUpdate, Show as VmHostGroupShow from .operations.vm_host_group import convert_show_result_to_snake_case - command_args = convert_show_result_to_snake_case(kwargs['dedicated_host_group']) - command_args['name'] = host_group_name - command_args['resource_group'] = resource_group_name - return VmHostGroupUpdate(cli_ctx=cmd.cli_ctx)(command_args=command_args) + command_args = { + 'host_group_name': host_group_name, + 'resource_group': resource_group_name, + 'expand': 'instanceView' + } + vm_host_group = VmHostGroupShow(cli_ctx=cmd.cli_ctx)(command_args=command_args) + vm_host_group = convert_show_result_to_snake_case(vm_host_group) + vm_host_group['name'] = host_group_name + vm_host_group['resource_group'] = resource_group_name + return VmHostGroupUpdate(cli_ctx=cmd.cli_ctx)(command_args=vm_host_group) def create_dedicated_host(cmd, client, host_group_name, host_name, resource_group_name, sku, platform_fault_domain=None, auto_replace_on_failure=None, license_type=None, location=None, tags=None): From 8cd9aafe187a95ac6a9f735762e330b6d76c54d7 Mon Sep 17 00:00:00 2001 From: william051200 Date: Wed, 11 Mar 2026 13:44:35 +0800 Subject: [PATCH 18/21] Update vm host group update command --- .../azure/cli/command_modules/vm/commands.py | 2 +- .../azure/cli/command_modules/vm/custom.py | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/vm/commands.py b/src/azure-cli/azure/cli/command_modules/vm/commands.py index 4cb43b65e5d..80d0065febd 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/commands.py +++ b/src/azure-cli/azure/cli/command_modules/vm/commands.py @@ -390,7 +390,7 @@ def load_command_table(self, _): with self.command_group('vm host group') as g: g.custom_command('get-instance-view', 'get_dedicated_host_group_instance_view') g.custom_command('create', 'create_dedicated_host_group') - g.generic_update_command('update', setter_name='update_dedicated_host_group', setter_type=compute_custom, command_type=compute_custom) + g.generic_update_command('update', getter_name='get_dedicated_host_group', setter_arg_name='dedicated_host_group', setter_name='update_dedicated_host_group', setter_type=compute_custom, command_type=compute_custom) from .operations.vm_host_group import VMHostGroupShow self.command_table['vm host group show'] = VMHostGroupShow(loader=self) diff --git a/src/azure-cli/azure/cli/command_modules/vm/custom.py b/src/azure-cli/azure/cli/command_modules/vm/custom.py index 2d7b2c17176..a134da53f5d 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/custom.py +++ b/src/azure-cli/azure/cli/command_modules/vm/custom.py @@ -5935,24 +5935,24 @@ def create_dedicated_host_group(cmd, host_group_name, resource_group_name, platf def get_dedicated_host_group_instance_view(cmd, host_group_name, resource_group_name): + return get_dedicated_host_group(cmd, host_group_name, resource_group_name, 'instanceView') + + +def get_dedicated_host_group(cmd, host_group_name, resource_group_name, expand=None): from .aaz.latest.vm.host.group import Show as VmHostGroupShow command_args = { 'host_group_name': host_group_name, 'resource_group': resource_group_name, - 'expand': 'instanceView' } + if expand: + command_args['expand'] = expand return VmHostGroupShow(cli_ctx=cmd.cli_ctx)(command_args=command_args) -def update_dedicated_host_group(cmd, host_group_name, resource_group_name): - from .aaz.latest.vm.host.group import Update as VmHostGroupUpdate, Show as VmHostGroupShow +def update_dedicated_host_group(cmd, host_group_name, resource_group_name, **kwargs): + from .aaz.latest.vm.host.group import Update as VmHostGroupUpdate from .operations.vm_host_group import convert_show_result_to_snake_case - command_args = { - 'host_group_name': host_group_name, - 'resource_group': resource_group_name, - 'expand': 'instanceView' - } - vm_host_group = VmHostGroupShow(cli_ctx=cmd.cli_ctx)(command_args=command_args) + vm_host_group = kwargs['dedicated_host_group'] vm_host_group = convert_show_result_to_snake_case(vm_host_group) vm_host_group['name'] = host_group_name vm_host_group['resource_group'] = resource_group_name From 21e12f550a8b42aa60746e6f938b41e2e147b0a5 Mon Sep 17 00:00:00 2001 From: william051200 Date: Wed, 11 Mar 2026 14:17:17 +0800 Subject: [PATCH 19/21] Update code style --- src/azure-cli/azure/cli/command_modules/vm/custom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/azure-cli/azure/cli/command_modules/vm/custom.py b/src/azure-cli/azure/cli/command_modules/vm/custom.py index a134da53f5d..4c568153dc3 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/custom.py +++ b/src/azure-cli/azure/cli/command_modules/vm/custom.py @@ -5958,6 +5958,7 @@ def update_dedicated_host_group(cmd, host_group_name, resource_group_name, **kwa vm_host_group['resource_group'] = resource_group_name return VmHostGroupUpdate(cli_ctx=cmd.cli_ctx)(command_args=vm_host_group) + def create_dedicated_host(cmd, client, host_group_name, host_name, resource_group_name, sku, platform_fault_domain=None, auto_replace_on_failure=None, license_type=None, location=None, tags=None): DedicatedHostType = cmd.get_models('DedicatedHost') @@ -5975,7 +5976,6 @@ def create_dedicated_host(cmd, client, host_group_name, host_name, resource_grou def get_dedicated_host_instance_view(client, host_group_name, host_name, resource_group_name): return client.get(resource_group_name, host_group_name, host_name, expand="instanceView") - # endregion From 12ce760eca2f1f0dee67e883e4e3500788fe37b7 Mon Sep 17 00:00:00 2001 From: william051200 Date: Thu, 12 Mar 2026 07:23:03 +0800 Subject: [PATCH 20/21] Remove az vm host group update aaz --- .../vm/aaz/latest/vm/host/group/__init__.py | 1 - .../vm/aaz/latest/vm/host/group/_update.py | 522 ------------------ 2 files changed, 523 deletions(-) delete mode 100644 src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_update.py diff --git a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/__init__.py b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/__init__.py index c401f439385..efc3964e3fb 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/__init__.py +++ b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/__init__.py @@ -13,4 +13,3 @@ from ._delete import * from ._list import * from ._show import * -from ._update import * diff --git a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_update.py b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_update.py deleted file mode 100644 index 9a3e47a6a2d..00000000000 --- a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/group/_update.py +++ /dev/null @@ -1,522 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# 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 Update(AAZCommand): - """Update a dedicated host group. - - :example: Create or update a dedicated host group with Ultra SSD support. - az vm host group update --resource-group myResourceGroup --name myDedicatedHostGroup --tags "{department:finance}" --zones "[1]" --platform-fault-domain-count 3 --support-automatic-placement True --additional-capabilities "{ultra-ssd-enabled:True}" - """ - - _aaz_info = { - "version": "2024-11-01", - "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/hostgroups/{}", "2024-11-01"], - ] - } - - AZ_SUPPORT_GENERIC_UPDATE = True - - 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.name = AAZStrArg( - options=["-n", "--name"], - help="Name of the Dedicated Host Group.", - required=True, - id_part="name", - ) - _args_schema.resource_group = AAZResourceGroupNameArg( - required=True, - ) - - # define Arg Group "Parameters" - - _args_schema = cls._args_schema - _args_schema.tags = AAZDictArg( - options=["--tags"], - arg_group="Parameters", - help="Resource tags", - nullable=True, - ) - _args_schema.zones = AAZListArg( - options=["--zones"], - arg_group="Parameters", - help="Availability Zone to use for this host group. Only single zone is supported. The zone can be assigned only during creation. If not provided, the group supports all zones in the region. If provided, enforces each host in the group to be in the same zone.", - nullable=True, - ) - - tags = cls._args_schema.tags - tags.Element = AAZStrArg( - nullable=True, - ) - - zones = cls._args_schema.zones - zones.Element = AAZStrArg( - nullable=True, - ) - - # define Arg Group "Properties" - - _args_schema = cls._args_schema - _args_schema.additional_capabilities = AAZObjectArg( - options=["--additional-capabilities"], - arg_group="Properties", - help="Enables or disables a capability on the dedicated host group. Minimum api-version: 2022-03-01.", - nullable=True, - ) - _args_schema.platform_fault_domain_count = AAZIntArg( - options=["--platform-fault-domain-count"], - arg_group="Properties", - help="Number of fault domains that the host group can span.", - fmt=AAZIntArgFormat( - minimum=1, - ), - ) - _args_schema.support_automatic_placement = AAZBoolArg( - options=["--support-automatic-placement"], - arg_group="Properties", - help="Specifies whether virtual machines or virtual machine scale sets can be placed automatically on the dedicated host group. Automatic placement means resources are allocated on dedicated hosts, that are chosen by Azure, under the dedicated host group. The value is defaulted to 'false' when not provided. Minimum api-version: 2020-06-01.", - nullable=True, - ) - - additional_capabilities = cls._args_schema.additional_capabilities - additional_capabilities.ultra_ssd_enabled = AAZBoolArg( - options=["ultra-ssd-enabled"], - help="The flag that enables or disables a capability to have UltraSSD Enabled Virtual Machines on Dedicated Hosts of the Dedicated Host Group. For the Virtual Machines to be UltraSSD Enabled, UltraSSDEnabled flag for the resource needs to be set true as well. The value is defaulted to 'false' when not provided. Please refer to https://docs.microsoft.com/en-us/azure/virtual-machines/disks-enable-ultra-ssd for more details on Ultra SSD feature. **Note:** The ultraSSDEnabled setting can only be enabled for Host Groups that are created as zonal. Minimum api-version: 2022-03-01.", - nullable=True, - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - self.DedicatedHostGroupsGet(ctx=self.ctx)() - self.pre_instance_update(self.ctx.vars.instance) - self.InstanceUpdateByJson(ctx=self.ctx)() - self.InstanceUpdateByGeneric(ctx=self.ctx)() - self.post_instance_update(self.ctx.vars.instance) - self.DedicatedHostGroupsCreateOrUpdate(ctx=self.ctx)() - self.post_operations() - - @register_callback - def pre_operations(self): - pass - - @register_callback - def post_operations(self): - pass - - @register_callback - def pre_instance_update(self, instance): - pass - - @register_callback - def post_instance_update(self, instance): - pass - - def _output(self, *args, **kwargs): - result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) - return result - - class DedicatedHostGroupsGet(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]: - return self.on_200(session) - - return self.on_error(session.http_response) - - @property - def url(self): - return self.client.format_url( - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", - **self.url_parameters - ) - - @property - def method(self): - return "GET" - - @property - def error_format(self): - return "ODataV4Format" - - @property - def url_parameters(self): - parameters = { - **self.serialize_url_param( - "hostGroupName", self.ctx.args.name, - required=True, - ), - **self.serialize_url_param( - "resourceGroupName", self.ctx.args.resource_group, - 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", "2024-11-01", - required=True, - ), - } - return parameters - - @property - def header_parameters(self): - parameters = { - **self.serialize_header_param( - "Accept", "application/json", - ), - } - return parameters - - def on_200(self, session): - data = self.deserialize_http_content(session) - self.ctx.set_var( - "instance", - data, - schema_builder=self._build_schema_on_200 - ) - - _schema_on_200 = None - - @classmethod - def _build_schema_on_200(cls): - if cls._schema_on_200 is not None: - return cls._schema_on_200 - - cls._schema_on_200 = AAZObjectType() - _UpdateHelper._build_schema_dedicated_host_group_read(cls._schema_on_200) - - return cls._schema_on_200 - - class DedicatedHostGroupsCreateOrUpdate(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/hostGroups/{hostGroupName}", - **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( - "hostGroupName", self.ctx.args.name, - required=True, - ), - **self.serialize_url_param( - "resourceGroupName", self.ctx.args.resource_group, - 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", "2024-11-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, - value=self.ctx.vars.instance, - ) - - 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() - _UpdateHelper._build_schema_dedicated_host_group_read(cls._schema_on_200_201) - - return cls._schema_on_200_201 - - class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): - - def __call__(self, *args, **kwargs): - self._update_instance(self.ctx.vars.instance) - - def _update_instance(self, instance): - _instance_value, _builder = self.new_content_builder( - self.ctx.args, - value=instance, - typ=AAZObjectType - ) - _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) - _builder.set_prop("tags", AAZDictType, ".tags") - _builder.set_prop("zones", AAZListType, ".zones") - - properties = _builder.get(".properties") - if properties is not None: - properties.set_prop("additionalCapabilities", AAZObjectType, ".additional_capabilities") - properties.set_prop("platformFaultDomainCount", AAZIntType, ".platform_fault_domain_count", typ_kwargs={"flags": {"required": True}}) - properties.set_prop("supportAutomaticPlacement", AAZBoolType, ".support_automatic_placement") - - additional_capabilities = _builder.get(".properties.additionalCapabilities") - if additional_capabilities is not None: - additional_capabilities.set_prop("ultraSSDEnabled", AAZBoolType, ".ultra_ssd_enabled") - - tags = _builder.get(".tags") - if tags is not None: - tags.set_elements(AAZStrType, ".") - - zones = _builder.get(".zones") - if zones is not None: - zones.set_elements(AAZStrType, ".") - - return _instance_value - - class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): - - def __call__(self, *args, **kwargs): - self._update_instance_by_generic( - self.ctx.vars.instance, - self.ctx.generic_update_args - ) - - -class _UpdateHelper: - """Helper class for Update""" - - _schema_dedicated_host_group_read = None - - @classmethod - def _build_schema_dedicated_host_group_read(cls, _schema): - if cls._schema_dedicated_host_group_read is not None: - _schema.id = cls._schema_dedicated_host_group_read.id - _schema.location = cls._schema_dedicated_host_group_read.location - _schema.name = cls._schema_dedicated_host_group_read.name - _schema.properties = cls._schema_dedicated_host_group_read.properties - _schema.system_data = cls._schema_dedicated_host_group_read.system_data - _schema.tags = cls._schema_dedicated_host_group_read.tags - _schema.type = cls._schema_dedicated_host_group_read.type - _schema.zones = cls._schema_dedicated_host_group_read.zones - return - - cls._schema_dedicated_host_group_read = _schema_dedicated_host_group_read = AAZObjectType() - - dedicated_host_group_read = _schema_dedicated_host_group_read - dedicated_host_group_read.id = AAZStrType( - flags={"read_only": True}, - ) - dedicated_host_group_read.location = AAZStrType( - flags={"required": True}, - ) - dedicated_host_group_read.name = AAZStrType( - flags={"read_only": True}, - ) - dedicated_host_group_read.properties = AAZObjectType( - flags={"client_flatten": True}, - ) - dedicated_host_group_read.system_data = AAZObjectType( - serialized_name="systemData", - flags={"read_only": True}, - ) - dedicated_host_group_read.tags = AAZDictType() - dedicated_host_group_read.type = AAZStrType( - flags={"read_only": True}, - ) - dedicated_host_group_read.zones = AAZListType() - - properties = _schema_dedicated_host_group_read.properties - properties.additional_capabilities = AAZObjectType( - serialized_name="additionalCapabilities", - ) - properties.hosts = AAZListType( - flags={"read_only": True}, - ) - properties.instance_view = AAZObjectType( - serialized_name="instanceView", - flags={"read_only": True}, - ) - properties.platform_fault_domain_count = AAZIntType( - serialized_name="platformFaultDomainCount", - flags={"required": True}, - ) - properties.support_automatic_placement = AAZBoolType( - serialized_name="supportAutomaticPlacement", - ) - - additional_capabilities = _schema_dedicated_host_group_read.properties.additional_capabilities - additional_capabilities.ultra_ssd_enabled = AAZBoolType( - serialized_name="ultraSSDEnabled", - ) - - hosts = _schema_dedicated_host_group_read.properties.hosts - hosts.Element = AAZObjectType() - - _element = _schema_dedicated_host_group_read.properties.hosts.Element - _element.id = AAZStrType( - flags={"read_only": True}, - ) - - instance_view = _schema_dedicated_host_group_read.properties.instance_view - instance_view.hosts = AAZListType() - - hosts = _schema_dedicated_host_group_read.properties.instance_view.hosts - hosts.Element = AAZObjectType() - - _element = _schema_dedicated_host_group_read.properties.instance_view.hosts.Element - _element.asset_id = AAZStrType( - serialized_name="assetId", - flags={"read_only": True}, - ) - _element.available_capacity = AAZObjectType( - serialized_name="availableCapacity", - ) - _element.name = AAZStrType( - flags={"read_only": True}, - ) - _element.statuses = AAZListType() - - available_capacity = _schema_dedicated_host_group_read.properties.instance_view.hosts.Element.available_capacity - available_capacity.allocatable_v_ms = AAZListType( - serialized_name="allocatableVMs", - ) - - allocatable_v_ms = _schema_dedicated_host_group_read.properties.instance_view.hosts.Element.available_capacity.allocatable_v_ms - allocatable_v_ms.Element = AAZObjectType() - - _element = _schema_dedicated_host_group_read.properties.instance_view.hosts.Element.available_capacity.allocatable_v_ms.Element - _element.count = AAZFloatType() - _element.vm_size = AAZStrType( - serialized_name="vmSize", - ) - - statuses = _schema_dedicated_host_group_read.properties.instance_view.hosts.Element.statuses - statuses.Element = AAZObjectType() - - _element = _schema_dedicated_host_group_read.properties.instance_view.hosts.Element.statuses.Element - _element.code = AAZStrType() - _element.display_status = AAZStrType( - serialized_name="displayStatus", - ) - _element.level = AAZStrType() - _element.message = AAZStrType() - _element.time = AAZStrType() - - system_data = _schema_dedicated_host_group_read.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 = _schema_dedicated_host_group_read.tags - tags.Element = AAZStrType() - - zones = _schema_dedicated_host_group_read.zones - zones.Element = AAZStrType() - - _schema.id = cls._schema_dedicated_host_group_read.id - _schema.location = cls._schema_dedicated_host_group_read.location - _schema.name = cls._schema_dedicated_host_group_read.name - _schema.properties = cls._schema_dedicated_host_group_read.properties - _schema.system_data = cls._schema_dedicated_host_group_read.system_data - _schema.tags = cls._schema_dedicated_host_group_read.tags - _schema.type = cls._schema_dedicated_host_group_read.type - _schema.zones = cls._schema_dedicated_host_group_read.zones - - -__all__ = ["Update"] From df8e8af3d19920f4b4f6d2c02b8eb88e52f663cb Mon Sep 17 00:00:00 2001 From: william051200 Date: Thu, 12 Mar 2026 07:23:20 +0800 Subject: [PATCH 21/21] Update code --- src/azure-cli/azure/cli/command_modules/vm/custom.py | 10 +++++----- .../cli/command_modules/vm/operations/vm_host_group.py | 6 ++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/vm/custom.py b/src/azure-cli/azure/cli/command_modules/vm/custom.py index 4c568153dc3..828b839dcbc 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/custom.py +++ b/src/azure-cli/azure/cli/command_modules/vm/custom.py @@ -5939,24 +5939,24 @@ def get_dedicated_host_group_instance_view(cmd, host_group_name, resource_group_ def get_dedicated_host_group(cmd, host_group_name, resource_group_name, expand=None): - from .aaz.latest.vm.host.group import Show as VmHostGroupShow + from .operations.vm_host_group import VMHostGroupShow command_args = { 'host_group_name': host_group_name, 'resource_group': resource_group_name, } if expand: command_args['expand'] = expand - return VmHostGroupShow(cli_ctx=cmd.cli_ctx)(command_args=command_args) + return VMHostGroupShow(cli_ctx=cmd.cli_ctx)(command_args=command_args) def update_dedicated_host_group(cmd, host_group_name, resource_group_name, **kwargs): - from .aaz.latest.vm.host.group import Update as VmHostGroupUpdate + from .aaz.latest.vm.host.group import Create as VmHostGroupCreate from .operations.vm_host_group import convert_show_result_to_snake_case vm_host_group = kwargs['dedicated_host_group'] vm_host_group = convert_show_result_to_snake_case(vm_host_group) - vm_host_group['name'] = host_group_name + vm_host_group['host_group_name'] = host_group_name vm_host_group['resource_group'] = resource_group_name - return VmHostGroupUpdate(cli_ctx=cmd.cli_ctx)(command_args=vm_host_group) + return VmHostGroupCreate(cli_ctx=cmd.cli_ctx)(command_args=vm_host_group) def create_dedicated_host(cmd, client, host_group_name, host_name, resource_group_name, sku, platform_fault_domain=None, diff --git a/src/azure-cli/azure/cli/command_modules/vm/operations/vm_host_group.py b/src/azure-cli/azure/cli/command_modules/vm/operations/vm_host_group.py index 9fb10f87d05..4b7a47b41ae 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/operations/vm_host_group.py +++ b/src/azure-cli/azure/cli/command_modules/vm/operations/vm_host_group.py @@ -19,6 +19,12 @@ def _build_arguments_schema(cls, *args, **kwargs): return args_schema + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + if 'tags' not in result: + result['tags'] = {} + return result + def convert_show_result_to_snake_case(result): new_result = {}