Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
6 changes: 5 additions & 1 deletion src/connectedmachine/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
Release History
===============

0.2.0
+++++
* machineextensions support

0.1.1
+++++
* Remove the limitation of max compatible cli core version

0.1.0
++++++
* Initial release.
* Initial release.
104 changes: 104 additions & 0 deletions src/connectedmachine/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# 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

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
```

##### List connected machines in resource group

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

##### Delete a connected machine

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

#### Connected Machine Extension Management

*Examples:*

##### Create or Update a Machine Extension

```sh
az connectedmachine machine-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"
```

##### Get all Machine Extensions

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

##### Get a Machine Extension

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

##### Update a Machine Extension

```sh
az connectedmachine machine-extension update \
--machine-name "myMachine" \
--name "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"
```

##### Delete a Machine Extension

```sh
az connectedmachine machine-extension delete \
--machine-name "myMachine" \
--name "MMA" \
--resource-group "myResourceGroup"
```
5 changes: 0 additions & 5 deletions src/connectedmachine/README.rst

This file was deleted.

44 changes: 31 additions & 13 deletions src/connectedmachine/azext_connectedmachine/__init__.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,50 @@
# --------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# 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.
# --------------------------------------------------------------------------

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

from azext_connectedmachine._help import helps # pylint: disable=unused-import


class ConnectedmachineCommandsLoader(AzCommandsLoader):
class ConnectedMachineCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
from azext_connectedmachine._client_factory import cf_connectedmachine
from azext_connectedmachine.generated._client_factory import cf_connectedmachine_cl
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)
client_factory=cf_connectedmachine_cl)
parent = super(ConnectedMachineCommandsLoader, self)
parent.__init__(cli_ctx=cli_ctx, custom_command_type=connectedmachine_custom)

def load_command_table(self, args):
from azext_connectedmachine.commands import load_command_table
from azext_connectedmachine.generated.commands import load_command_table
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
return self.command_table

def load_arguments(self, command):
from azext_connectedmachine._params import load_arguments
from azext_connectedmachine.generated._params import load_arguments
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


COMMAND_LOADER_CLS = ConnectedmachineCommandsLoader
COMMAND_LOADER_CLS = ConnectedMachineCommandsLoader
11 changes: 0 additions & 11 deletions src/connectedmachine/azext_connectedmachine/_client_factory.py

This file was deleted.

28 changes: 0 additions & 28 deletions src/connectedmachine/azext_connectedmachine/_help.py

This file was deleted.

23 changes: 0 additions & 23 deletions src/connectedmachine/azext_connectedmachine/_params.py

This file was deleted.

21 changes: 0 additions & 21 deletions src/connectedmachine/azext_connectedmachine/_validators.py

This file was deleted.

17 changes: 17 additions & 0 deletions src/connectedmachine/azext_connectedmachine/action.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# --------------------------------------------------------------------------
# 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

from .generated.action import * # noqa: F403
try:
from .manual.action import * # noqa: F403
except ImportError:
pass
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"azext.isPreview": true,
"azext.minCliCoreVersion": "2.0.67"
"azext.isExperimental": true,
"azext.minCliCoreVersion": "2.11.0"
}
23 changes: 0 additions & 23 deletions src/connectedmachine/azext_connectedmachine/commands.py

This file was deleted.

31 changes: 15 additions & 16 deletions src/connectedmachine/azext_connectedmachine/custom.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# --------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# 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


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)
from .generated.custom import * # noqa: F403
try:
from .manual.custom import * # noqa: F403
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,4 @@
# regenerated.
# --------------------------------------------------------------------------

from ._machines_operations import MachinesOperations
from ._machine_extensions_operations import MachineExtensionsOperations
from ._operations import Operations

__all__ = [
'MachinesOperations',
'MachineExtensionsOperations',
'Operations',
]
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
Loading