Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# flake8: noqa

from .__cmd_group import *
from ._create import *
from ._delete import *
from ._list import *
from ._show import *
Original file line number Diff line number Diff line change
@@ -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"]
Loading
Loading