Skip to content
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

Merged
merged 5 commits into from
Sep 18, 2024
Merged
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
8 changes: 8 additions & 0 deletions src/multicloud-connector/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. :changelog:

Copy link

@bagajjal bagajjal Sep 19, 2024

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

  1. Register the required RPs (Microsoft.AwsConnector, Microsoft.HybridConnectivity, Microsoft.HybridCompute).

  2. Examples in the help message have some random characters. Please it to some meaningful names.
    image

  3. The error is printed twice. This is annoying if the error message is spanned across multiple lines,
    image

image

  1. The "--ids" argument have a generic text, it's unclear what it represents.

image

image

  1. The help should be very clear and should also point to our public documentation page that capture various options.

Release History
===============

1.0.0b1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing 1.0.0.b1 is a beta version.
For GA, we should get rid of the beta version.

++++++
Copy link

@bagajjal bagajjal Sep 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

az arc-multicloud generate-aws-template command,

  1. output is of no use for customer consumption. It's not a valid aws cloudformation template.
    From the response body, remove the "body:" json element to make it valid aws cloudformation template.
    image

  2. Register the required RPs (Microsoft.AwsConnector, Microsoft.HybridConnectivity, Microsoft.HybridCompute). This is a global comment for all the CLI commands.

  3. Write the aws cloudformation template to a file named aws-cft-<customer-inputted-connector-name> and output the file on to the console. Ex - If the connector name is 264617844946 then the filename should be aws-cft-264617844946.json

  4. Add a new parameter --output-directory, used for writing the aws cloudformation template.

  5. remove the --solution-types parameter to avoid unnecessary confusion to customers. Help message doesn't show what should be provided in the --solution-types parameter. This was added mainly for the portal onboard flow. For CLI, we can assume that it's not supported scenario.
    Also, the help is not useful.
    image

  6. The examples should be more meaningful rather than some random strings,
    image

* Initial release.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test-permission command,

  1. The output {} doesn't make sense.

image

  1. It's NOT working.

CLI output
image

Portal output
image

  1. It's unclear what does --ids represent. Is it the connector Id or something else. Please treat this as a global comment as it's there in all the commands.

image

  1. It's unclear what --no-wait does. I don't see any difference of behavior with "0 or 1". Looks like the CLI command is not executing as I don't see the response {}

image

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

az arc-multicloud public-cloud-connector list command

  1. Command says list connector resources by subscriptionId but there is no argument to provide the subscriptionId. Interestingly there is an argument for resourcegroup. This seems odd.
    image

  2. -o table prints weird resource group names like clitest.rgy7xqoupodpyivrat6cuddih5wgnzd5rey6tir2xophpvkqckipflrawo2wred7tvs, looks like a formatting issue. can we suppress the global options?

image

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

az arc-multicloud public-cloud-connector update command,

  1. Exception rather than an error message. It would be hard for customers to understand stdout exception message, (ObjectMissingRequiredProperty) Missing required property: awsCloudProfile. Paths in payload: '$.properties.awsCloudProfile'

image

  1. connector is created as per the example, but the response is wrong as the awsCloudProfile is empty. This is also a bug on our controller. Please file a bug to fix the controller.
    Help message
    image

Connector Response
image

  1. As an end user, it's very hard to understand what should go into the aws-cloud-profile. The help should be very clear and should also point to our public documentation page that capture various options.
    image

27 changes: 27 additions & 0 deletions src/multicloud-connector/README.md
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 "{}"
```
42 changes: 42 additions & 0 deletions src/multicloud-connector/azext_multicloud_connector/__init__.py
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
11 changes: 11 additions & 0 deletions src/multicloud-connector/azext_multicloud_connector/_help.py
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
13 changes: 13 additions & 0 deletions src/multicloud-connector/azext_multicloud_connector/_params.py
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"]
Loading
Loading