forked from Azure/azure-cli-extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
az connectedmachine extension (Azure#1031)
* Az cli extension for connected machines * add code owners * add code owners * update name
- Loading branch information
Showing
30 changed files
with
4,775 additions
and
0 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,4 +72,6 @@ | |
|
||
/src/peering/ @zikalino | ||
|
||
/src/connectedmachine/ @farehar | ||
|
||
/src/ip-group/ @haroldrandom |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.. :changelog: | ||
Release History | ||
=============== | ||
|
||
0.1.0 | ||
++++++ | ||
* Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Microsoft Azure CLI 'connectedmachine' Extension | ||
========================================== | ||
|
||
This package is for the 'connectedmachine' extension. | ||
i.e. 'az connectedmachine' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
from azure.cli.core import AzCommandsLoader | ||
|
||
from azext_connectedmachine._help import helps # pylint: disable=unused-import | ||
|
||
|
||
class ConnectedmachineCommandsLoader(AzCommandsLoader): | ||
|
||
def __init__(self, cli_ctx=None): | ||
from azure.cli.core.commands import CliCommandType | ||
from azext_connectedmachine._client_factory import cf_connectedmachine | ||
connectedmachine_custom = CliCommandType( | ||
operations_tmpl='azext_connectedmachine.custom#{}', | ||
client_factory=cf_connectedmachine) | ||
super(ConnectedmachineCommandsLoader, self).__init__(cli_ctx=cli_ctx, | ||
custom_command_type=connectedmachine_custom) | ||
|
||
def load_command_table(self, args): | ||
from azext_connectedmachine.commands import load_command_table | ||
load_command_table(self, args) | ||
return self.command_table | ||
|
||
def load_arguments(self, command): | ||
from azext_connectedmachine._params import load_arguments | ||
load_arguments(self, command) | ||
|
||
|
||
COMMAND_LOADER_CLS = ConnectedmachineCommandsLoader |
11 changes: 11 additions & 0 deletions
11
src/connectedmachine/azext_connectedmachine/_client_factory.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
|
||
def cf_connectedmachine(cli_ctx, *_): | ||
|
||
from azure.cli.core.commands.client_factory import get_mgmt_service_client | ||
from azext_connectedmachine.vendored_sdks import HybridComputeManagementClient | ||
return get_mgmt_service_client(cli_ctx, HybridComputeManagementClient) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
from knack.help_files import helps # pylint: disable=unused-import | ||
|
||
|
||
helps['connectedmachine'] = """ | ||
type: group | ||
short-summary: Commands to manage Connected machines. | ||
""" | ||
|
||
helps['connectedmachine list'] = """ | ||
type: command | ||
short-summary: List Connected machines. | ||
""" | ||
|
||
helps['connectedmachine delete'] = """ | ||
type: command | ||
short-summary: Delete a Connected machine. | ||
""" | ||
|
||
helps['connectedmachine show'] = """ | ||
type: command | ||
short-summary: Show details of a Connected machine. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
# -------------------------------------------------------------------------------------------- | ||
# pylint: disable=line-too-long | ||
|
||
from knack.arguments import CLIArgumentType | ||
|
||
|
||
def load_arguments(self, _): | ||
|
||
from azure.cli.core.commands.parameters import tags_type | ||
from azure.cli.core.commands.validators import get_default_location_from_resource_group | ||
|
||
name_type = CLIArgumentType(options_list='--name', help='Name of the Connected machine.', id_part='name') | ||
|
||
with self.argument_context('connectedmachine') as c: | ||
c.argument('tags', tags_type) | ||
c.argument('location', validator=get_default_location_from_resource_group) | ||
c.argument('name', name_type, options_list=['--name', '-n']) | ||
|
||
with self.argument_context('connectedmachine list') as c: | ||
c.argument('name', name_type, id_part=None) |
21 changes: 21 additions & 0 deletions
21
src/connectedmachine/azext_connectedmachine/_validators.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
|
||
def example_name_or_id_validator(cmd, namespace): | ||
# Example of a storage account name or ID validator. | ||
# See: | ||
# https://github.com/Azure/azure-cli/blob/dev/doc/authoring_command_modules/authoring_commands.md#supporting-name-or-id-parameters | ||
from azure.cli.core.commands.client_factory import get_subscription_id | ||
from msrestazure.tools import is_valid_resource_id, resource_id | ||
if namespace.storage_account: | ||
if not is_valid_resource_id(namespace.RESOURCE): | ||
namespace.storage_account = resource_id( | ||
subscription=get_subscription_id(cmd.cli_ctx), | ||
resource_group=namespace.resource_group_name, | ||
namespace='Microsoft.Storage', | ||
type='storageAccounts', | ||
name=namespace.storage_account | ||
) |
5 changes: 5 additions & 0 deletions
5
src/connectedmachine/azext_connectedmachine/azext_metadata.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"azext.isPreview": true, | ||
"azext.minCliCoreVersion": "2.0.67", | ||
"azext.maxCliCoreVersion": "2.1.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
# pylint: disable=line-too-long | ||
from azure.cli.core.commands import CliCommandType | ||
from azext_connectedmachine._client_factory import cf_connectedmachine | ||
|
||
|
||
def load_command_table(self, _): | ||
|
||
connectedmachine_sdk = CliCommandType( | ||
operations_tmpl='azext_connectedmachine.vendored_sdks.operations#MachinesOperations.{}', | ||
client_factory=cf_connectedmachine) | ||
|
||
with self.command_group('connectedmachine', connectedmachine_sdk, client_factory=cf_connectedmachine) as g: | ||
g.custom_command('delete', 'delete_connectedmachine') | ||
g.custom_command('list', 'list_connectedmachine') | ||
g.custom_command('show', 'show_connectedmachine') | ||
|
||
with self.command_group('connectedmachine', is_preview=True): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
|
||
def list_connectedmachine(client, resource_group_name=None): | ||
if resource_group_name: | ||
return client.machines.list_by_resource_group(resource_group_name) | ||
return client.machines.list_by_subscription() | ||
|
||
|
||
def show_connectedmachine(client, resource_group_name, name): | ||
return client.machines.get(resource_group_name, name) | ||
|
||
|
||
def delete_connectedmachine(client, resource_group_name, name): | ||
return client.machines.delete(resource_group_name, name) |
5 changes: 5 additions & 0 deletions
5
src/connectedmachine/azext_connectedmachine/tests/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# ----------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for | ||
# license information. | ||
# ----------------------------------------------------------------------------- |
5 changes: 5 additions & 0 deletions
5
src/connectedmachine/azext_connectedmachine/tests/latest/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# ----------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for | ||
# license information. | ||
# ----------------------------------------------------------------------------- |
Oops, something went wrong.