Skip to content

Commit

Permalink
[Connectedmachine] Updated the module connectedmachine using API stab…
Browse files Browse the repository at this point in the history
…le 2021-05-20 (#3709)

* update

1. Added table format for connectedmachine list.
2. Renamed subgroups

* updated the README.md

* fixed code styling

* fixed --n ambiguity

* addressed code reviews

* addressed code reviews

* generated and tested the extension module

* updated the README.md

* upgraded the version number

* added the removed function

* solved linter issue

* address code review

* removed extra s' in _help.py

* removed more s'

* Apply suggestions from code review

* used InvalidArgumentValueError instead

* re-ran tests

Co-authored-by: Xing Zhou <Zhou.Xing@microsoft.com>
  • Loading branch information
dorothyhu and zhoxing-ms authored Aug 6, 2021
1 parent 0d080ea commit 090128c
Show file tree
Hide file tree
Showing 49 changed files with 7,733 additions and 7,789 deletions.
6 changes: 5 additions & 1 deletion src/connectedmachine/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

0.4.0
+++++
* Add private link scope and private endpoint connection commands

0.3.0
+++++
* Renamed machine-extension subgroup to extension
Expand All @@ -18,4 +22,4 @@ Release History

0.1.0
++++++
* Initial release.
* Initial release.
204 changes: 114 additions & 90 deletions src/connectedmachine/README.md
Original file line number Diff line number Diff line change
@@ -1,104 +1,128 @@
# Microsoft Azure CLI 'connectedmachine' Extension

This package is for the 'connectedmachine' extension, i.e. 'az connectedmachine'.

## Prerequisite

In order to use this extension,
first follow the quick start for
[Hybrid Compute](https://docs.microsoft.com/en-us/azure/azure-arc/servers/learn/quick-enable-hybrid-vm)
and onboard your machine(s).

## How to use
# Azure CLI connectedmachine Extension #
This is the extension for connectedmachine

### How to use ###
Install this extension using the below CLI command

```sh
```
az extension add --name connectedmachine
```

### Included Features

#### Connected Machine Management

*Examples:*

##### Show connected machine

```sh
az connectedmachine show \
--subscription subscription_id \
--resource-group my-rg \
--name my-cluster
### Included Features ###
#### connectedmachine ####
##### List #####
```

##### List connected machines in resource group

```sh
az connectedmachine list --resource-group my-rg
az connectedmachine list --resource-group "myResourceGroup"
```

##### Delete a connected machine

```sh
az connectedmachine delete \
--subscription subscription_id \
--resource-group my-rg \
--name my-machine
##### Show #####
```

#### Connected Machine Extension Management

*Examples:*

##### Create or Update a Machine Extension

```sh
az connectedmachine extension create \
--machine-name "myMachine" \
--name "customScriptExtension" \
--location "eastus2euap" \
--type "CustomScriptExtension" \
--publisher "Microsoft.Compute" \
--settings "{\"commandToExecute\":\"powershell.exe -c \\\"Get-Process | Where-Object { $_.CPU -gt 10000 }\\\"\"}" \
--type-handler-version "1.10" \
--resource-group "myResourceGroup"
az connectedmachine show --name "myMachine" --resource-group "myResourceGroup"
```

##### Get all Machine Extensions

```sh
az connectedmachine extension list \
--machine-name "myMachine" \
--resource-group "myResourceGroup"
##### Delete #####
```

##### Get a Machine Extension

```sh
az connectedmachine extension show \
--machine-name "myMachine" \
--name "CustomScriptExtension" \
--resource-group "myResourceGroup"
az connectedmachine delete --name "myMachine" --resource-group "myResourceGroup"
```

##### Update a Machine Extension

```sh
az connectedmachine extension update \
--machine-name "myMachine" \
--name "CustomScriptExtension" \
--type "CustomScriptExtension" \
#### connectedmachine extension ####
##### Create #####
```
az connectedmachine extension create --n "CustomScriptExtension" --location "eastus2euap" \
--type "CustomScriptExtension" --publisher "Microsoft.Compute" \
--settings "{\\"commandToExecute\\":\\"powershell.exe -c \\\\\\"Get-Process | Where-Object { $_.CPU -gt 10000 }\\\\\\"\\"}" \
--type-handler-version "1.10" --machine-name "myMachine" --resource-group "myResourceGroup"
```
##### Show #####
```
az connectedmachine extension show --n "CustomScriptExtension" --machine-name "myMachine" \
--resource-group "myResourceGroup"
```
##### List #####
```
az connectedmachine extension list --machine-name "myMachine" --resource-group "myResourceGroup"
```
##### Update #####
```
az connectedmachine extension update --n "CustomScriptExtension" --type "CustomScriptExtension" \
--publisher "Microsoft.Compute" \
--settings "{\"commandToExecute\":\"powershell.exe -c \\\"Get-Process | Where-Object { $_.CPU -lt 100 }\\\"\"}" \ --type-handler-version "1.10" \
--resource-group "myResourceGroup"
--settings "{\\"commandToExecute\\":\\"powershell.exe -c \\\\\\"Get-Process | Where-Object { $_.CPU -lt 100 }\\\\\\"\\"}" \
--type-handler-version "1.10" --machine-name "myMachine" --resource-group "myResourceGroup"
```

##### Delete a Machine Extension

```sh
az connectedmachine extension delete \
--machine-name "myMachine" \
--name "MMA" \
--resource-group "myResourceGroup"
##### Delete #####
```
az connectedmachine extension delete --n "MMA" --machine-name "myMachine" --resource-group "myResourceGroup"
```
#### connectedmachine ####
##### Upgrade-extension #####
```
az connectedmachine upgrade-extension \
--extension-targets "{\\"Microsoft.Azure.Monitoring\\":{\\"targetVersion\\":\\"2.0\\"},\\"Microsoft.Compute.CustomScriptExtension\\":{\\"targetVersion\\":\\"1.10\\"}}" \
--machine-name "myMachine" --resource-group "myResourceGroup"
```
#### connectedmachine private-link-scope ####
##### Create #####
```
az connectedmachine private-link-scope create --location "westus" --resource-group "my-resource-group" \
--scope-name "my-privatelinkscope"
```
##### Update #####
```
az connectedmachine private-link-scope update --location "westus" --tags Tag1="Value1" \
--resource-group "my-resource-group" --scope-name "my-privatelinkscope"
```
##### List #####
```
az connectedmachine private-link-scope list --resource-group "my-resource-group"
```
##### Show #####
```
az connectedmachine private-link-scope show --resource-group "my-resource-group" --scope-name "my-privatelinkscope"
```
##### Show-validation-detail #####
```
az connectedmachine private-link-scope show-validation-detail --location "wus2" \
--private-link-scope-id "f5dc51d3-92ed-4d7e-947a-775ea79b4919"
```
##### Show-validation-detail-for-machine #####
```
az connectedmachine private-link-scope show-validation-detail-for-machine --machine-name "machineName" \
--resource-group "my-resource-group"
```
##### Update-tag #####
```
az connectedmachine private-link-scope update-tag --tags Tag1="Value1" Tag2="Value2" \
--resource-group "my-resource-group" --scope-name "my-privatelinkscope"
```
##### Delete #####
```
az connectedmachine private-link-scope delete --resource-group "my-resource-group" --scope-name "my-privatelinkscope"
```
#### connectedmachine private-link-resource ####
##### List #####
```
az connectedmachine private-link-resource list --resource-group "myResourceGroup" --scope-name "myPrivateLinkScope"
```
##### Show #####
```
az connectedmachine private-link-resource show --group-name "hybridcompute" --resource-group "myResourceGroup" \
--scope-name "myPrivateLinkScope"
```
#### connectedmachine private-endpoint-connection ####
##### Update #####
```
az connectedmachine private-endpoint-connection update \
--private-link-service-connection-state description="Approved by johndoe@contoso.com" status="Approved" \
--name "private-endpoint-connection-name" --resource-group "myResourceGroup" --scope-name "myPrivateLinkScope"
```
##### Show #####
```
az connectedmachine private-endpoint-connection show --name "private-endpoint-connection-name" \
--resource-group "myResourceGroup" --scope-name "myPrivateLinkScope"
```
##### List #####
```
az connectedmachine private-endpoint-connection list --resource-group "myResourceGroup" \
--scope-name "myPrivateLinkScope"
```
##### Delete #####
```
az connectedmachine private-endpoint-connection delete --name "private-endpoint-connection-name" \
--resource-group "myResourceGroup" --scope-name "myPrivateLinkScope"
```
21 changes: 12 additions & 9 deletions src/connectedmachine/azext_connectedmachine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
# pylint: disable=unused-import

import azext_connectedmachine._help
from azure.cli.core import AzCommandsLoader
from azext_connectedmachine.generated._help import helps # pylint: disable=unused-import
try:
from azext_connectedmachine.manual._help import helps # pylint: disable=reimported
except ImportError:
pass


class ConnectedMachineCommandsLoader(AzCommandsLoader):
Expand All @@ -33,8 +30,11 @@ def load_command_table(self, args):
try:
from azext_connectedmachine.manual.commands import load_command_table as load_command_table_manual
load_command_table_manual(self, args)
except ImportError:
pass
except ImportError as e:
if e.name.endswith('manual.commands'):
pass
else:
raise e
return self.command_table

def load_arguments(self, command):
Expand All @@ -43,8 +43,11 @@ def load_arguments(self, command):
try:
from azext_connectedmachine.manual._params import load_arguments as load_arguments_manual
load_arguments_manual(self, command)
except ImportError:
pass
except ImportError as e:
if e.name.endswith('manual._params'):
pass
else:
raise e


COMMAND_LOADER_CLS = ConnectedMachineCommandsLoader
20 changes: 20 additions & 0 deletions src/connectedmachine/azext_connectedmachine/_help.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# --------------------------------------------------------------------------
# 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 Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
# pylint: disable=wildcard-import
# pylint: disable=unused-wildcard-import
# pylint: disable=unused-import
from .generated._help import helps # pylint: disable=reimported
try:
from .manual._help import helps # pylint: disable=reimported
except ImportError as e:
if e.name.endswith('manual._help'):
pass
else:
raise e
7 changes: 5 additions & 2 deletions src/connectedmachine/azext_connectedmachine/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
from .generated.action import * # noqa: F403
try:
from .manual.action import * # noqa: F403
except ImportError:
pass
except ImportError as e:
if e.name.endswith('manual.action'):
pass
else:
raise e
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"azext.isExperimental": true,
"azext.minCliCoreVersion": "2.11.0"
"azext.minCliCoreVersion": "2.15.0"
}
7 changes: 5 additions & 2 deletions src/connectedmachine/azext_connectedmachine/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
from .generated.custom import * # noqa: F403
try:
from .manual.custom import * # noqa: F403
except ImportError:
pass
except ImportError as e:
if e.name.endswith('manual.custom'):
pass
else:
raise e
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,26 @@

def cf_connectedmachine_cl(cli_ctx, *_):
from azure.cli.core.commands.client_factory import get_mgmt_service_client
from ..vendored_sdks.connectedmachine import ConnectedMachine
from azext_connectedmachine.vendored_sdks.connectedmachine import ConnectedMachine
return get_mgmt_service_client(cli_ctx,
ConnectedMachine)


def cf_machine(cli_ctx, *_):
return cf_connectedmachine_cl(cli_ctx).machine
return cf_connectedmachine_cl(cli_ctx).machines


def cf_machine_extension(cli_ctx, *_):
return cf_connectedmachine_cl(cli_ctx).machine_extension
return cf_connectedmachine_cl(cli_ctx).machine_extensions


def cf_private_link_scope(cli_ctx, *_):
return cf_connectedmachine_cl(cli_ctx).private_link_scopes


def cf_private_link_resource(cli_ctx, *_):
return cf_connectedmachine_cl(cli_ctx).private_link_resources


def cf_private_endpoint_connection(cli_ctx, *_):
return cf_connectedmachine_cl(cli_ctx).private_endpoint_connections
Loading

0 comments on commit 090128c

Please sign in to comment.