diff --git a/src/compute-diagnostic-rp/HISTORY.rst b/src/compute-diagnostic-rp/HISTORY.rst new file mode 100644 index 00000000000..abbff5a61a7 --- /dev/null +++ b/src/compute-diagnostic-rp/HISTORY.rst @@ -0,0 +1,8 @@ +.. :changelog: + +Release History +=============== + +1.0.0b1 +++++++ +* Initial release. \ No newline at end of file diff --git a/src/compute-diagnostic-rp/README.md b/src/compute-diagnostic-rp/README.md new file mode 100644 index 00000000000..c8ff0b6ec04 --- /dev/null +++ b/src/compute-diagnostic-rp/README.md @@ -0,0 +1,6 @@ +# Azure CLI ComputeDiagnosticRp Extension # +This is an extension to Azure CLI to manage ComputeDiagnosticRp resources. + +## How to use ## +### Generate the spot vm placement scores +`az compute diagnostic spot-placement-recommender generate -l eastus --subscription ffffffff-ffff-ffff-ffff-ffffffffffff --availability-zones true --desired-locations '["eastus", "eastus2"]' --desired-count 1 --desired-sizes '[{"sku": "Standard_D2_v2"}]'` diff --git a/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/__init__.py b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/__init__.py new file mode 100644 index 00000000000..b28a1412238 --- /dev/null +++ b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/__init__.py @@ -0,0 +1,42 @@ +# -------------------------------------------------------------------------------------------- +# 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 +# -------------------------------------------------------------------------------------------- + +from azure.cli.core import AzCommandsLoader +from azext_compute_diagnostic_rp._help import helps # pylint: disable=unused-import + + +class ComputeDiagnosticRpCommandsLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + custom_command_type = CliCommandType( + operations_tmpl='azext_compute_diagnostic_rp.custom#{}') + super().__init__(cli_ctx=cli_ctx, + custom_command_type=custom_command_type) + + def load_command_table(self, args): + from azext_compute_diagnostic_rp.commands import load_command_table + from azure.cli.core.aaz import load_aaz_command_table + try: + from . import aaz + except ImportError: + aaz = None + if aaz: + load_aaz_command_table( + loader=self, + aaz_pkg_name=aaz.__name__, + args=args + ) + load_command_table(self, args) + return self.command_table + + def load_arguments(self, command): + from azext_compute_diagnostic_rp._params import load_arguments + load_arguments(self, command) + + +COMMAND_LOADER_CLS = ComputeDiagnosticRpCommandsLoader diff --git a/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/_help.py b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/_help.py new file mode 100644 index 00000000000..126d5d00714 --- /dev/null +++ b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/_help.py @@ -0,0 +1,11 @@ +# -------------------------------------------------------------------------------------------- +# 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: disable=line-too-long +# pylint: disable=too-many-lines + +from knack.help_files import helps # pylint: disable=unused-import diff --git a/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/_params.py b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/_params.py new file mode 100644 index 00000000000..cfcec717c9c --- /dev/null +++ b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/_params.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# 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: disable=too-many-lines +# pylint: disable=too-many-statements + + +def load_arguments(self, _): # pylint: disable=unused-argument + pass diff --git a/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/aaz/__init__.py b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/aaz/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/aaz/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# 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 +# -------------------------------------------------------------------------------------------- diff --git a/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/aaz/latest/__init__.py b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/aaz/latest/__init__.py new file mode 100644 index 00000000000..f6acc11aa4e --- /dev/null +++ b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/aaz/latest/__init__.py @@ -0,0 +1,10 @@ +# -------------------------------------------------------------------------------------------- +# 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 + diff --git a/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/aaz/latest/compute_diagnostic/__cmd_group.py b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/aaz/latest/compute_diagnostic/__cmd_group.py new file mode 100644 index 00000000000..8141a1967bd --- /dev/null +++ b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/aaz/latest/compute_diagnostic/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "compute-diagnostic", +) +class __CMDGroup(AAZCommandGroup): + """Mange vm sku recommender info + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/aaz/latest/compute_diagnostic/__init__.py b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/aaz/latest/compute_diagnostic/__init__.py new file mode 100644 index 00000000000..5a9d61963d6 --- /dev/null +++ b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/aaz/latest/compute_diagnostic/__init__.py @@ -0,0 +1,11 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * diff --git a/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/aaz/latest/compute_diagnostic/spot_placement_recommender/__cmd_group.py b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/aaz/latest/compute_diagnostic/spot_placement_recommender/__cmd_group.py new file mode 100644 index 00000000000..8ced6b1b9e8 --- /dev/null +++ b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/aaz/latest/compute_diagnostic/spot_placement_recommender/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "compute-diagnostic spot-placement-recommender", +) +class __CMDGroup(AAZCommandGroup): + """Manage spot vm placement score info + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/aaz/latest/compute_diagnostic/spot_placement_recommender/__init__.py b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/aaz/latest/compute_diagnostic/spot_placement_recommender/__init__.py new file mode 100644 index 00000000000..422378d85da --- /dev/null +++ b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/aaz/latest/compute_diagnostic/spot_placement_recommender/__init__.py @@ -0,0 +1,12 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._generate import * diff --git a/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/aaz/latest/compute_diagnostic/spot_placement_recommender/_generate.py b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/aaz/latest/compute_diagnostic/spot_placement_recommender/_generate.py new file mode 100644 index 00000000000..9f6b450edb0 --- /dev/null +++ b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/aaz/latest/compute_diagnostic/spot_placement_recommender/_generate.py @@ -0,0 +1,258 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "compute-diagnostic spot-placement-recommender generate", +) +class Generate(AAZCommand): + """Generates placement scores for Spot VM skus. + + :example: generate spot vm placement score example + az compute diagnostic spot-placement-recommender generate -l eastus --subscription ffffffff-ffff-ffff-ffff-ffffffffffff --availability-zones true --desired-locations '["eastus", "eastus2"]' --desired-count 1 --desired-sizes '[{"sku": "Standard_D2_v2"}]' + """ + + _aaz_info = { + "version": "2021-06-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.compute/locations/{}/diagnostics/spotplacementrecommender/generate", "2021-06-01-preview"], + ] + } + + 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.location = AAZResourceLocationArg( + required=True, + id_part="name", + ) + + # define Arg Group "SpotPlacementRecommenderInput" + + _args_schema = cls._args_schema + _args_schema.availability_zones = AAZBoolArg( + options=["--availability-zones"], + arg_group="SpotPlacementRecommenderInput", + help="Defines if the scope is zonal or regional.", + ) + _args_schema.desired_count = AAZIntArg( + options=["--desired-count"], + arg_group="SpotPlacementRecommenderInput", + help="Desired instance count per region/zone based on the scope.", + ) + _args_schema.desired_locations = AAZListArg( + options=["--desired-locations"], + arg_group="SpotPlacementRecommenderInput", + help="The desired regions", + ) + _args_schema.desired_sizes = AAZListArg( + options=["--desired-sizes"], + arg_group="SpotPlacementRecommenderInput", + help="The desired resource SKUs.", + ) + + desired_locations = cls._args_schema.desired_locations + desired_locations.Element = AAZStrArg() + + desired_sizes = cls._args_schema.desired_sizes + desired_sizes.Element = AAZObjectArg() + + _element = cls._args_schema.desired_sizes.Element + _element.sku = AAZStrArg( + options=["sku"], + help="The resource's CRP virtual machine SKU size.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.SpotPlacementRecommenderPost(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 SpotPlacementRecommenderPost(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}/providers/Microsoft.Compute/locations/{location}/diagnostics/spotPlacementRecommender/generate", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "location", self.ctx.args.location, + 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", "2021-06-01-preview", + 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("availabilityZones", AAZBoolType, ".availability_zones") + _builder.set_prop("desiredCount", AAZIntType, ".desired_count") + _builder.set_prop("desiredLocations", AAZListType, ".desired_locations") + _builder.set_prop("desiredSizes", AAZListType, ".desired_sizes") + + desired_locations = _builder.get(".desiredLocations") + if desired_locations is not None: + desired_locations.set_elements(AAZStrType, ".") + + desired_sizes = _builder.get(".desiredSizes") + if desired_sizes is not None: + desired_sizes.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".desiredSizes[]") + if _elements is not None: + _elements.set_prop("sku", AAZStrType, ".sku") + + return self.serialize_content(_content_value) + + 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() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.availability_zones = AAZBoolType( + serialized_name="availabilityZones", + ) + _schema_on_200.desired_count = AAZIntType( + serialized_name="desiredCount", + ) + _schema_on_200.desired_locations = AAZListType( + serialized_name="desiredLocations", + ) + _schema_on_200.desired_sizes = AAZListType( + serialized_name="desiredSizes", + ) + _schema_on_200.placement_scores = AAZListType( + serialized_name="placementScores", + ) + + desired_locations = cls._schema_on_200.desired_locations + desired_locations.Element = AAZStrType() + + desired_sizes = cls._schema_on_200.desired_sizes + desired_sizes.Element = AAZObjectType() + + _element = cls._schema_on_200.desired_sizes.Element + _element.sku = AAZStrType() + + placement_scores = cls._schema_on_200.placement_scores + placement_scores.Element = AAZObjectType() + + _element = cls._schema_on_200.placement_scores.Element + _element.availability_zone = AAZStrType( + serialized_name="availabilityZone", + ) + _element.is_quota_available = AAZBoolType( + serialized_name="isQuotaAvailable", + ) + _element.region = AAZStrType() + _element.score = AAZStrType() + _element.sku = AAZStrType() + + return cls._schema_on_200 + + +class _GenerateHelper: + """Helper class for Generate""" + + +__all__ = ["Generate"] diff --git a/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/azext_metadata.json b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/azext_metadata.json new file mode 100644 index 00000000000..0761e47ffb8 --- /dev/null +++ b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/azext_metadata.json @@ -0,0 +1,4 @@ +{ + "azext.isPreview": true, + "azext.minCliCoreVersion": "2.56.0" +} \ No newline at end of file diff --git a/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/commands.py b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/commands.py new file mode 100644 index 00000000000..b0d842e4993 --- /dev/null +++ b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/commands.py @@ -0,0 +1,15 @@ +# -------------------------------------------------------------------------------------------- +# 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: disable=too-many-lines +# pylint: disable=too-many-statements + +# from azure.cli.core.commands import CliCommandType + + +def load_command_table(self, _): # pylint: disable=unused-argument + pass diff --git a/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/custom.py b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/custom.py new file mode 100644 index 00000000000..86df1e48ef5 --- /dev/null +++ b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/custom.py @@ -0,0 +1,14 @@ +# -------------------------------------------------------------------------------------------- +# 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: disable=too-many-lines +# pylint: disable=too-many-statements + +from knack.log import get_logger + + +logger = get_logger(__name__) diff --git a/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/tests/__init__.py b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/tests/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/tests/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# 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 +# -------------------------------------------------------------------------------------------- diff --git a/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/tests/latest/__init__.py b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/tests/latest/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/tests/latest/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# 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 +# -------------------------------------------------------------------------------------------- diff --git a/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/tests/latest/recordings/test_spot_placement_recommender_generate.yaml b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/tests/latest/recordings/test_spot_placement_recommender_generate.yaml new file mode 100644 index 00000000000..cc809214326 --- /dev/null +++ b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/tests/latest/recordings/test_spot_placement_recommender_generate.yaml @@ -0,0 +1,56 @@ +interactions: +- request: + body: '{"availabilityZones": true, "desiredCount": 1, "desiredLocations": ["eastus", + "eastus2"], "desiredSizes": [{"sku": "Standard_D2_v2"}]}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - compute-diagnostic spot-placement-recommender generate + Connection: + - keep-alive + Content-Length: + - '134' + Content-Type: + - application/json + ParameterSetName: + - -l --subscription --availability-zones --desired-locations --desired-count + --desired-sizes + User-Agent: + - AZURECLI/2.58.0 azsdk-python-core/1.28.0 Python/3.8.18 (macOS-13.6.4-x86_64-i386-64bit) + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus/diagnostics/spotPlacementRecommender/generate?api-version=2021-06-01-preview + response: + body: + string: '{"desiredLocations":["eastus","eastus2"],"desiredSizes":[{"sku":"Standard_D2_v2"}],"desiredCount":1,"availabilityZones":true,"placementScores":[{"sku":"Standard_D2_v2","region":"eastus","availabilityZone":"1","score":"High","isQuotaAvailable":true},{"sku":"Standard_D2_v2","region":"eastus","availabilityZone":"2","score":"High","isQuotaAvailable":true},{"sku":"Standard_D2_v2","region":"eastus","availabilityZone":"3","score":"High","isQuotaAvailable":true},{"sku":"Standard_D2_v2","region":"eastus2","availabilityZone":"1","score":"DataNotFoundOrStale","isQuotaAvailable":true},{"sku":"Standard_D2_v2","region":"eastus2","availabilityZone":"2","score":"High","isQuotaAvailable":true},{"sku":"Standard_D2_v2","region":"eastus2","availabilityZone":"3","score":"High","isQuotaAvailable":true}]}' + headers: + api-supported-versions: + - 2021-06-01-preview, 2022-12-01 + cache-control: + - no-cache + content-length: + - '793' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 20 Mar 2024 21:53:47 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + x-msedge-ref: + - 'Ref A: AFBC06E971AA4F1C9C942A44028EF1BE Ref B: CO6AA3150219053 Ref C: 2024-03-20T21:53:45Z' + status: + code: 200 + message: OK +version: 1 diff --git a/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/tests/latest/test_compute_diagnostic_rp.py b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/tests/latest/test_compute_diagnostic_rp.py new file mode 100644 index 00000000000..b53696b9f6f --- /dev/null +++ b/src/compute-diagnostic-rp/azext_compute_diagnostic_rp/tests/latest/test_compute_diagnostic_rp.py @@ -0,0 +1,24 @@ +# -------------------------------------------------------------------------------------------- +# 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 +# -------------------------------------------------------------------------------------------- + +from azure.cli.testsdk import ScenarioTest + + +class ComputeDiagnosticRpScenario(ScenarioTest): + def test_spot_placement_recommender_generate(self): + self.kwargs.update({ + 'location': 'eastus', + 'subscription_id': self.get_subscription_id(), + 'availability_zones': 'true', + 'desired_locations': '["eastus", "eastus2"]', + 'desired_count': 1, + 'desired_sizes': '[{"sku": "Standard_D2_v2"}]' + }) + + spot_scores_output = self.cmd('az compute-diagnostic spot-placement-recommender generate -l {location} --subscription {subscription_id} --availability-zones {availability_zones} --desired-locations \'{desired_locations}\' --desired-count {desired_count} --desired-sizes \'{desired_sizes}\'').get_output_in_json() + + self.assertTrue(len(spot_scores_output["placementScores"]) > 0, "Spot scores should have at least one item") diff --git a/src/compute-diagnostic-rp/setup.cfg b/src/compute-diagnostic-rp/setup.cfg new file mode 100644 index 00000000000..2fdd96e5d39 --- /dev/null +++ b/src/compute-diagnostic-rp/setup.cfg @@ -0,0 +1 @@ +#setup.cfg \ No newline at end of file diff --git a/src/compute-diagnostic-rp/setup.py b/src/compute-diagnostic-rp/setup.py new file mode 100644 index 00000000000..5594bc1a01a --- /dev/null +++ b/src/compute-diagnostic-rp/setup.py @@ -0,0 +1,49 @@ +# -------------------------------------------------------------------------------------------- +# 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 +# -------------------------------------------------------------------------------------------- + +from codecs import open +from setuptools import setup, find_packages + + +# HISTORY.rst entry. +VERSION = '1.0.0b1' + +# The full list of classifiers is available at +# https://pypi.python.org/pypi?%3Aaction=list_classifiers +CLASSIFIERS = [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'License :: OSI Approved :: MIT License', +] + +DEPENDENCIES = [] + +with open('README.md', 'r', encoding='utf-8') as f: + README = f.read() +with open('HISTORY.rst', 'r', encoding='utf-8') as f: + HISTORY = f.read() + +setup( + name='compute-diagnostic-rp', + version=VERSION, + description='Microsoft Azure Command-Line Tools ComputeDiagnosticRp Extension.', + long_description=README + '\n\n' + HISTORY, + license='MIT', + author='Microsoft Corporation', + author_email='azpycli@microsoft.com', + url='https://github.com/Azure/azure-cli-extensions/tree/main/src/compute-diagnostic-rp', + classifiers=CLASSIFIERS, + packages=find_packages(exclude=["tests"]), + package_data={'azext_compute_diagnostic_rp': ['azext_metadata.json']}, + install_requires=DEPENDENCIES +) diff --git a/src/service_name.json b/src/service_name.json index b7658a4aa9a..46cc1ac05d9 100644 --- a/src/service_name.json +++ b/src/service_name.json @@ -99,6 +99,11 @@ "AzureServiceName": "Communication Services", "URL": "https://learn.microsoft.com/azure/communication-services" }, + { + "Command": "az compute-diagnostic", + "AzureServiceName": "Compute Diagnostic", + "URL": "" + }, { "Command": "az confcom", "AzureServiceName": "Confidential Computing",