Skip to content

Commit 090128c

Browse files
[Connectedmachine] Updated the module connectedmachine using API stable 2021-05-20 (Azure#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 <[email protected]>
1 parent 0d080ea commit 090128c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+7733
-7789
lines changed

src/connectedmachine/HISTORY.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
Release History
44
===============
55

6+
0.4.0
7+
+++++
8+
* Add private link scope and private endpoint connection commands
9+
610
0.3.0
711
+++++
812
* Renamed machine-extension subgroup to extension
@@ -18,4 +22,4 @@ Release History
1822

1923
0.1.0
2024
++++++
21-
* Initial release.
25+
* Initial release.

src/connectedmachine/README.md

Lines changed: 114 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,128 @@
1-
# Microsoft Azure CLI 'connectedmachine' Extension
2-
3-
This package is for the 'connectedmachine' extension, i.e. 'az connectedmachine'.
4-
5-
## Prerequisite
6-
7-
In order to use this extension,
8-
first follow the quick start for
9-
[Hybrid Compute](https://docs.microsoft.com/en-us/azure/azure-arc/servers/learn/quick-enable-hybrid-vm)
10-
and onboard your machine(s).
11-
12-
## How to use
1+
# Azure CLI connectedmachine Extension #
2+
This is the extension for connectedmachine
133

4+
### How to use ###
145
Install this extension using the below CLI command
15-
16-
```sh
6+
```
177
az extension add --name connectedmachine
188
```
199

20-
### Included Features
21-
22-
#### Connected Machine Management
23-
24-
*Examples:*
25-
26-
##### Show connected machine
27-
28-
```sh
29-
az connectedmachine show \
30-
--subscription subscription_id \
31-
--resource-group my-rg \
32-
--name my-cluster
10+
### Included Features ###
11+
#### connectedmachine ####
12+
##### List #####
3313
```
34-
35-
##### List connected machines in resource group
36-
37-
```sh
38-
az connectedmachine list --resource-group my-rg
14+
az connectedmachine list --resource-group "myResourceGroup"
3915
```
40-
41-
##### Delete a connected machine
42-
43-
```sh
44-
az connectedmachine delete \
45-
--subscription subscription_id \
46-
--resource-group my-rg \
47-
--name my-machine
16+
##### Show #####
4817
```
49-
50-
#### Connected Machine Extension Management
51-
52-
*Examples:*
53-
54-
##### Create or Update a Machine Extension
55-
56-
```sh
57-
az connectedmachine extension create \
58-
--machine-name "myMachine" \
59-
--name "customScriptExtension" \
60-
--location "eastus2euap" \
61-
--type "CustomScriptExtension" \
62-
--publisher "Microsoft.Compute" \
63-
--settings "{\"commandToExecute\":\"powershell.exe -c \\\"Get-Process | Where-Object { $_.CPU -gt 10000 }\\\"\"}" \
64-
--type-handler-version "1.10" \
65-
--resource-group "myResourceGroup"
18+
az connectedmachine show --name "myMachine" --resource-group "myResourceGroup"
6619
```
67-
68-
##### Get all Machine Extensions
69-
70-
```sh
71-
az connectedmachine extension list \
72-
--machine-name "myMachine" \
73-
--resource-group "myResourceGroup"
20+
##### Delete #####
7421
```
75-
76-
##### Get a Machine Extension
77-
78-
```sh
79-
az connectedmachine extension show \
80-
--machine-name "myMachine" \
81-
--name "CustomScriptExtension" \
82-
--resource-group "myResourceGroup"
22+
az connectedmachine delete --name "myMachine" --resource-group "myResourceGroup"
8323
```
84-
85-
##### Update a Machine Extension
86-
87-
```sh
88-
az connectedmachine extension update \
89-
--machine-name "myMachine" \
90-
--name "CustomScriptExtension" \
91-
--type "CustomScriptExtension" \
24+
#### connectedmachine extension ####
25+
##### Create #####
26+
```
27+
az connectedmachine extension create --n "CustomScriptExtension" --location "eastus2euap" \
28+
--type "CustomScriptExtension" --publisher "Microsoft.Compute" \
29+
--settings "{\\"commandToExecute\\":\\"powershell.exe -c \\\\\\"Get-Process | Where-Object { $_.CPU -gt 10000 }\\\\\\"\\"}" \
30+
--type-handler-version "1.10" --machine-name "myMachine" --resource-group "myResourceGroup"
31+
```
32+
##### Show #####
33+
```
34+
az connectedmachine extension show --n "CustomScriptExtension" --machine-name "myMachine" \
35+
--resource-group "myResourceGroup"
36+
```
37+
##### List #####
38+
```
39+
az connectedmachine extension list --machine-name "myMachine" --resource-group "myResourceGroup"
40+
```
41+
##### Update #####
42+
```
43+
az connectedmachine extension update --n "CustomScriptExtension" --type "CustomScriptExtension" \
9244
--publisher "Microsoft.Compute" \
93-
--settings "{\"commandToExecute\":\"powershell.exe -c \\\"Get-Process | Where-Object { $_.CPU -lt 100 }\\\"\"}" \ --type-handler-version "1.10" \
94-
--resource-group "myResourceGroup"
45+
--settings "{\\"commandToExecute\\":\\"powershell.exe -c \\\\\\"Get-Process | Where-Object { $_.CPU -lt 100 }\\\\\\"\\"}" \
46+
--type-handler-version "1.10" --machine-name "myMachine" --resource-group "myResourceGroup"
9547
```
96-
97-
##### Delete a Machine Extension
98-
99-
```sh
100-
az connectedmachine extension delete \
101-
--machine-name "myMachine" \
102-
--name "MMA" \
103-
--resource-group "myResourceGroup"
48+
##### Delete #####
49+
```
50+
az connectedmachine extension delete --n "MMA" --machine-name "myMachine" --resource-group "myResourceGroup"
51+
```
52+
#### connectedmachine ####
53+
##### Upgrade-extension #####
54+
```
55+
az connectedmachine upgrade-extension \
56+
--extension-targets "{\\"Microsoft.Azure.Monitoring\\":{\\"targetVersion\\":\\"2.0\\"},\\"Microsoft.Compute.CustomScriptExtension\\":{\\"targetVersion\\":\\"1.10\\"}}" \
57+
--machine-name "myMachine" --resource-group "myResourceGroup"
58+
```
59+
#### connectedmachine private-link-scope ####
60+
##### Create #####
61+
```
62+
az connectedmachine private-link-scope create --location "westus" --resource-group "my-resource-group" \
63+
--scope-name "my-privatelinkscope"
64+
```
65+
##### Update #####
66+
```
67+
az connectedmachine private-link-scope update --location "westus" --tags Tag1="Value1" \
68+
--resource-group "my-resource-group" --scope-name "my-privatelinkscope"
69+
```
70+
##### List #####
71+
```
72+
az connectedmachine private-link-scope list --resource-group "my-resource-group"
73+
```
74+
##### Show #####
75+
```
76+
az connectedmachine private-link-scope show --resource-group "my-resource-group" --scope-name "my-privatelinkscope"
77+
```
78+
##### Show-validation-detail #####
79+
```
80+
az connectedmachine private-link-scope show-validation-detail --location "wus2" \
81+
--private-link-scope-id "f5dc51d3-92ed-4d7e-947a-775ea79b4919"
82+
```
83+
##### Show-validation-detail-for-machine #####
84+
```
85+
az connectedmachine private-link-scope show-validation-detail-for-machine --machine-name "machineName" \
86+
--resource-group "my-resource-group"
87+
```
88+
##### Update-tag #####
89+
```
90+
az connectedmachine private-link-scope update-tag --tags Tag1="Value1" Tag2="Value2" \
91+
--resource-group "my-resource-group" --scope-name "my-privatelinkscope"
92+
```
93+
##### Delete #####
94+
```
95+
az connectedmachine private-link-scope delete --resource-group "my-resource-group" --scope-name "my-privatelinkscope"
96+
```
97+
#### connectedmachine private-link-resource ####
98+
##### List #####
99+
```
100+
az connectedmachine private-link-resource list --resource-group "myResourceGroup" --scope-name "myPrivateLinkScope"
101+
```
102+
##### Show #####
103+
```
104+
az connectedmachine private-link-resource show --group-name "hybridcompute" --resource-group "myResourceGroup" \
105+
--scope-name "myPrivateLinkScope"
106+
```
107+
#### connectedmachine private-endpoint-connection ####
108+
##### Update #####
109+
```
110+
az connectedmachine private-endpoint-connection update \
111+
--private-link-service-connection-state description="Approved by [email protected]" status="Approved" \
112+
--name "private-endpoint-connection-name" --resource-group "myResourceGroup" --scope-name "myPrivateLinkScope"
113+
```
114+
##### Show #####
115+
```
116+
az connectedmachine private-endpoint-connection show --name "private-endpoint-connection-name" \
117+
--resource-group "myResourceGroup" --scope-name "myPrivateLinkScope"
118+
```
119+
##### List #####
120+
```
121+
az connectedmachine private-endpoint-connection list --resource-group "myResourceGroup" \
122+
--scope-name "myPrivateLinkScope"
123+
```
124+
##### Delete #####
104125
```
126+
az connectedmachine private-endpoint-connection delete --name "private-endpoint-connection-name" \
127+
--resource-group "myResourceGroup" --scope-name "myPrivateLinkScope"
128+
```

src/connectedmachine/azext_connectedmachine/__init__.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,10 @@
77
# Changes may cause incorrect behavior and will be lost if the code is
88
# regenerated.
99
# --------------------------------------------------------------------------
10+
# pylint: disable=unused-import
1011

12+
import azext_connectedmachine._help
1113
from azure.cli.core import AzCommandsLoader
12-
from azext_connectedmachine.generated._help import helps # pylint: disable=unused-import
13-
try:
14-
from azext_connectedmachine.manual._help import helps # pylint: disable=reimported
15-
except ImportError:
16-
pass
1714

1815

1916
class ConnectedMachineCommandsLoader(AzCommandsLoader):
@@ -33,8 +30,11 @@ def load_command_table(self, args):
3330
try:
3431
from azext_connectedmachine.manual.commands import load_command_table as load_command_table_manual
3532
load_command_table_manual(self, args)
36-
except ImportError:
37-
pass
33+
except ImportError as e:
34+
if e.name.endswith('manual.commands'):
35+
pass
36+
else:
37+
raise e
3838
return self.command_table
3939

4040
def load_arguments(self, command):
@@ -43,8 +43,11 @@ def load_arguments(self, command):
4343
try:
4444
from azext_connectedmachine.manual._params import load_arguments as load_arguments_manual
4545
load_arguments_manual(self, command)
46-
except ImportError:
47-
pass
46+
except ImportError as e:
47+
if e.name.endswith('manual._params'):
48+
pass
49+
else:
50+
raise e
4851

4952

5053
COMMAND_LOADER_CLS = ConnectedMachineCommandsLoader
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# --------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for
4+
# license information.
5+
#
6+
# Code generated by Microsoft (R) AutoRest Code Generator.
7+
# Changes may cause incorrect behavior and will be lost if the code is
8+
# regenerated.
9+
# --------------------------------------------------------------------------
10+
# pylint: disable=wildcard-import
11+
# pylint: disable=unused-wildcard-import
12+
# pylint: disable=unused-import
13+
from .generated._help import helps # pylint: disable=reimported
14+
try:
15+
from .manual._help import helps # pylint: disable=reimported
16+
except ImportError as e:
17+
if e.name.endswith('manual._help'):
18+
pass
19+
else:
20+
raise e

src/connectedmachine/azext_connectedmachine/action.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@
1313
from .generated.action import * # noqa: F403
1414
try:
1515
from .manual.action import * # noqa: F403
16-
except ImportError:
17-
pass
16+
except ImportError as e:
17+
if e.name.endswith('manual.action'):
18+
pass
19+
else:
20+
raise e
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"azext.isExperimental": true,
3-
"azext.minCliCoreVersion": "2.11.0"
2+
"azext.minCliCoreVersion": "2.15.0"
43
}

src/connectedmachine/azext_connectedmachine/custom.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@
1313
from .generated.custom import * # noqa: F403
1414
try:
1515
from .manual.custom import * # noqa: F403
16-
except ImportError:
17-
pass
16+
except ImportError as e:
17+
if e.name.endswith('manual.custom'):
18+
pass
19+
else:
20+
raise e

src/connectedmachine/azext_connectedmachine/generated/_client_factory.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,26 @@
1111

1212
def cf_connectedmachine_cl(cli_ctx, *_):
1313
from azure.cli.core.commands.client_factory import get_mgmt_service_client
14-
from ..vendored_sdks.connectedmachine import ConnectedMachine
14+
from azext_connectedmachine.vendored_sdks.connectedmachine import ConnectedMachine
1515
return get_mgmt_service_client(cli_ctx,
1616
ConnectedMachine)
1717

1818

1919
def cf_machine(cli_ctx, *_):
20-
return cf_connectedmachine_cl(cli_ctx).machine
20+
return cf_connectedmachine_cl(cli_ctx).machines
2121

2222

2323
def cf_machine_extension(cli_ctx, *_):
24-
return cf_connectedmachine_cl(cli_ctx).machine_extension
24+
return cf_connectedmachine_cl(cli_ctx).machine_extensions
25+
26+
27+
def cf_private_link_scope(cli_ctx, *_):
28+
return cf_connectedmachine_cl(cli_ctx).private_link_scopes
29+
30+
31+
def cf_private_link_resource(cli_ctx, *_):
32+
return cf_connectedmachine_cl(cli_ctx).private_link_resources
33+
34+
35+
def cf_private_endpoint_connection(cli_ctx, *_):
36+
return cf_connectedmachine_cl(cli_ctx).private_endpoint_connections

0 commit comments

Comments
 (0)