-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Azure CLI Extension - Azure Arc Multicloud Connector #7954
Changes from all commits
e191919
2c8e54f
5a83b07
5145b47
7b859c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.. :changelog: | ||
|
||
Release History | ||
=============== | ||
|
||
1.0.0b1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm guessing 1.0.0.b1 is a beta version. |
||
++++++ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
* Initial release. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Azure CLI MulticloudConnector Extension # | ||
This is an extension to Azure CLI to manage MulticloudConnector resources. | ||
|
||
## How to use ## | ||
|
||
### PublicCloudConnector Usage | ||
- Create a PublicCloudConnector | ||
```bash | ||
arc-multicloud public-cloud-connector create --resource-group rgpublicCloud --name advjwoakdusalamomg --aws-cloud-profile "{account-id:snbnuxckevyqpm,excluded-accounts:[rwgqpukglvbqmogqcliqolucp],is-organizational-account:True}" --host-type AWS --tags "{}" --location jpiglusfxynfcewcjwvvnn | ||
``` | ||
|
||
- GenerateAwsTemplate | ||
```bash | ||
arc-multicloud generate-aws-template --connector-id pnxcfjidglabnwxit --solution-types "[{solution-type:hjyownzpfxwiufmd,solution-settings:{}}]" | ||
``` | ||
|
||
- Test allowed permissions of a PublicCloudConnector | ||
```bash | ||
arc-multicloud public-cloud-connector test-permission --resource-group rgpublicCloud --name sjuahmnojgachluzcbhxhwkxwugbsi | ||
``` | ||
|
||
### SolutionConfiguration Usage | ||
|
||
- Create a SolutionConfiguration | ||
```bash | ||
arc-multicloud solution-configuration create --connector-id ymuj --name keebwujt --solution-type nmtqllkyohwtsthxaimsye --solution-settings "{}" | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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_multicloud_connector._help import helps # pylint: disable=unused-import | ||
|
||
|
||
class MulticloudConnectorCommandsLoader(AzCommandsLoader): | ||
|
||
def __init__(self, cli_ctx=None): | ||
from azure.cli.core.commands import CliCommandType | ||
custom_command_type = CliCommandType( | ||
operations_tmpl='azext_multicloud_connector.custom#{}') | ||
super().__init__(cli_ctx=cli_ctx, | ||
custom_command_type=custom_command_type) | ||
|
||
def load_command_table(self, args): | ||
from azext_multicloud_connector.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_multicloud_connector._params import load_arguments | ||
load_arguments(self, command) | ||
|
||
|
||
COMMAND_LOADER_CLS = MulticloudConnectorCommandsLoader |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
# -------------------------------------------------------------------------------------------- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# | ||
# Code generated by aaz-dev-tools | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
# pylint: skip-file | ||
# flake8: noqa | ||
|
||
from azure.cli.core.aaz import * | ||
|
||
|
||
@register_command_group( | ||
"arc-multicloud", | ||
) | ||
class __CMDGroup(AAZCommandGroup): | ||
"""commands for arc-multicloud | ||
""" | ||
pass | ||
|
||
|
||
__all__ = ["__CMDGroup"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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_aws_template import * |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# 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( | ||
"arc-multicloud generate-aws-template", | ||
) | ||
class GenerateAwsTemplate(AAZCommand): | ||
"""Retrieve AWS Cloud Formation template | ||
|
||
:example: GenerateAwsTemplate_Post | ||
az arc-multicloud generate-aws-template --connector-id pnxcfjidglabnwxit --solution-types "[{solution-type:hjyownzpfxwiufmd,solution-settings:{}}]" | ||
""" | ||
|
||
_aaz_info = { | ||
"version": "2024-12-01", | ||
"resources": [ | ||
["mgmt-plane", "/subscriptions/{}/providers/microsoft.hybridconnectivity/generateawstemplate", "2024-12-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 "" | ||
|
||
# define Arg Group "GenerateAwsTemplateRequest" | ||
|
||
_args_schema = cls._args_schema | ||
_args_schema.connector_id = AAZStrArg( | ||
options=["--connector-id"], | ||
arg_group="GenerateAwsTemplateRequest", | ||
help="The fully qualified Azure Resource manager identifier of the public cloud connector", | ||
required=True, | ||
) | ||
_args_schema.solution_types = AAZListArg( | ||
options=["--solution-types"], | ||
arg_group="GenerateAwsTemplateRequest", | ||
help="The list of solution types and their settings", | ||
) | ||
|
||
solution_types = cls._args_schema.solution_types | ||
solution_types.Element = AAZObjectArg() | ||
|
||
_element = cls._args_schema.solution_types.Element | ||
_element.solution_settings = AAZDictArg( | ||
options=["solution-settings"], | ||
help="Solution settings", | ||
) | ||
_element.solution_type = AAZStrArg( | ||
options=["solution-type"], | ||
help="The type of the solution", | ||
required=True, | ||
) | ||
|
||
solution_settings = cls._args_schema.solution_types.Element.solution_settings | ||
solution_settings.Element = AAZStrArg() | ||
return cls._args_schema | ||
|
||
def _execute_operations(self): | ||
self.pre_operations() | ||
self.GenerateAwsTemplatePost(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 GenerateAwsTemplatePost(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.HybridConnectivity/generateAwsTemplate", | ||
**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( | ||
"subscriptionId", self.ctx.subscription_id, | ||
required=True, | ||
), | ||
} | ||
return parameters | ||
|
||
@property | ||
def query_parameters(self): | ||
parameters = { | ||
**self.serialize_query_param( | ||
"api-version", "2024-12-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("connectorId", AAZStrType, ".connector_id", typ_kwargs={"flags": {"required": True}}) | ||
_builder.set_prop("solutionTypes", AAZListType, ".solution_types") | ||
|
||
solution_types = _builder.get(".solutionTypes") | ||
if solution_types is not None: | ||
solution_types.set_elements(AAZObjectType, ".") | ||
|
||
_elements = _builder.get(".solutionTypes[]") | ||
if _elements is not None: | ||
_elements.set_prop("solutionSettings", AAZDictType, ".solution_settings") | ||
_elements.set_prop("solutionType", AAZStrType, ".solution_type", typ_kwargs={"flags": {"required": True}}) | ||
|
||
solution_settings = _builder.get(".solutionTypes[].solutionSettings") | ||
if solution_settings is not None: | ||
solution_settings.set_elements(AAZStrType, ".") | ||
|
||
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 = AAZFreeFormDictType() | ||
|
||
return cls._schema_on_200 | ||
|
||
|
||
class _GenerateAwsTemplateHelper: | ||
"""Helper class for GenerateAwsTemplate""" | ||
|
||
|
||
__all__ = ["GenerateAwsTemplate"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# | ||
# Code generated by aaz-dev-tools | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
# pylint: skip-file | ||
# flake8: noqa | ||
|
||
from azure.cli.core.aaz import * | ||
|
||
|
||
@register_command_group( | ||
"arc-multicloud public-cloud-connector", | ||
) | ||
class __CMDGroup(AAZCommandGroup): | ||
"""commands for multicloudConnector | ||
""" | ||
pass | ||
|
||
|
||
__all__ = ["__CMDGroup"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Global comments applicable to all the CLI commands
Register the required RPs (Microsoft.AwsConnector, Microsoft.HybridConnectivity, Microsoft.HybridCompute).
Examples in the help message have some random characters. Please it to some meaningful names.
The error is printed twice. This is annoying if the error message is spanned across multiple lines,