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

SCVMM Extension for Public Preview #4631

Merged
merged 9 commits into from
Apr 18, 2022
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
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,5 @@
/src/quota/ @kairu-ms @ZengTaoxu

/src/containerapp/ @calvinsID @haroonf @panchagnula

/src/scvmm/ @nascarsayan
1 change: 1 addition & 0 deletions src/scvmm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vscode
6 changes: 6 additions & 0 deletions src/scvmm/.vscode.example/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"ms-python.python",
"ms-python.vscode-pylance"
]
}
44 changes: 44 additions & 0 deletions src/scvmm/.vscode.example/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Set AZCLI_SRC_PATH as the path to the azure-cli source code on your local machine.
// You may also replace the content of `${env:AZCLI_SRC_PATH}` with the absolute path, if desired :).
{
"version": "0.2.0",
"configurations": [
{
"name": "Azure CLI Debug (Integrated Console)",
"type": "python",
"request": "launch",
"python": "${command:python.interpreterPath}",
"program": "${env:AZCLI_SRC_PATH}/src/azure-cli/azure/cli/__main__.py",
"args": [
"--help"
],
"console": "integratedTerminal",
"justMyCode": false
},
{
"name": "Azure CLI Debug (External Console)",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"python": "${command:python.interpreterPath}",
"program": "${env:AZCLI_SRC_PATH}/src/azure-cli/azure/cli/__main__.py",
"cwd": "${workspaceRoot}",
"args": [
"--help"
],
"console": "externalTerminal"
},
{
"name": "Azdev Scripts",
"type": "python",
"request": "launch",
"python": "${command:python.interpreterPath}",
"program": "${env:AZCLI_SRC_PATH}/src/azure-cli/azure/cli/__main__.py",
"cwd": "${workspaceRoot}",
"args": [
"--help"
],
"console": "integratedTerminal"
}
]
}
21 changes: 21 additions & 0 deletions src/scvmm/.vscode.example/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"python.languageServer": "Pylance",
"python.formatting.provider": "black",
"python.formatting.blackArgs": [
"--skip-string-normalization",
"--exclude **/vendored_sdks/"
],
"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
"python.linting.flake8Args": [
"--ignore=E203",
"--ignore=E266",
"--ignore=E501",
"--ignore=W503",
"--max-line-length=88",
"--select = B,C,E,F,W,T4,B9",
"--max-complexity = 18"
],
"editor.formatOnSave": true,
"python.pythonPath": "$azcli/.venv/bin/python" // Set the path to python inside your virtual environment.
}
28 changes: 28 additions & 0 deletions src/scvmm/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.. :changelog:

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

0.1.0
++++++
* Initial release.

0.1.1
++++++
* CRUD of VMMServer, Cloud, VMTemplate, VM. Tags Supported. azdev lint passing.

0.1.2
++++++
* Interactive password.

0.1.3
++++++
* View Inventory, onboard inventory item to azure.
* CRUD for availablity sets.

0.1.4
++++++
* Bug fixes
* Force and retain flags in VM delete
* Generated SDK now requires updated version of azure-cli
* Long running PATCH operations
119 changes: 119 additions & 0 deletions src/scvmm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Microsoft Azure CLI SCVMM Extension

The Azure CLI extension for [Azure Arc for SCVMM PrivateCloud](https://aka.ms/azure-arc/scvmm/docs) is an extension for Azure CLI 2.0.

## Install

```
az extension add --name scvmm
```

## Usage

See the [extension reference documenation](https://aka.ms/azure-arc/scvmm/docs).
_Examples:_

##### Create VMMServer Resource

```
az scvmm vmmserver connect \
--subscription subscriptionId \
--resource-group resourceGroupName \
--location locationName \
--custom-location customLocationName \
--fqdn vmmserverFqdn \
--username userName \
--password password \
--name resourceName
```

##### Create Cloud Resource

```
az scvmm cloud create \
--subscription subscriptionId \
--resource-group resourceGroupName \
--location locationName \
--custom-location customLocationName \
--vmmserver vmmserverResourceName \
--inventory-item inventoryItemUUID \
--name resourceName
```

##### Create VM Template Resource

```
az scvmm vm-template create \
--subscription subscriptionId \
--resource-group resourceGroupName \
--location locationName \
--custom-location customLocationName \
--vmmserver vmmserverResourceName \
--inventory-item inventoryItemUUID \
--name resourceName
```

##### Create Virtual Network Resource

```
az scvmm virtual-network create \
--subscription subscriptionId \
--resource-group resourceGroupName \
--location locationName \
--custom-location customLocationName \
--vmmserver vmmserverResourceName \
--inventory-item inventoryItemUUID \
--name resourceName
```

##### Create Availabilty Set Resource

```
az scvmm avset create \
--subscription subscriptionId \
--resource-group resourceGroupName \
--location locationName \
--custom-location customLocationName \
--vmmserver vmmserverResourceName \
--avset-name availabiltySetName \
--name resourceName
```

##### Create Virtual Machine Resource

###### Onboard exisitng Virtual Machine to azure

```
az scvmm vm create \
--subscription subscriptionId \
--resource-group resourceGroupName \
--location locationName \
--custom-location customLocationName \
--vmmserver vmmserverResourceName \
--inventory-item inventoryItemUUID \
--name resourceName
```

###### Create new Virtual Machine

```
az scvmm vm create \
--subscription subscriptionId \
--resource-group resourceGroupName \
--location locationName \
--custom-location customLocationName \
--cloud cloudResourceName \
--vm-template vmTemplateResourceName \
--name resourceName
```


## Uninstall

You can see if the extension is installed by running `az --version` or `az extension list`. You can remove the extension by running:

```
az extension remove --name scvmm
```

If you have issues, please give feedback by opening an issue at https://github.com/Azure/azure-cli-extensions/issues.
5 changes: 5 additions & 0 deletions src/scvmm/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Microsoft Azure CLI 'scvmm' Extension
==========================================

This package is for the 'scvmm' extension.
i.e. 'az scvmm'
33 changes: 33 additions & 0 deletions src/scvmm/azext_scvmm/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# --------------------------------------------------------------------------------------------
# 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 ._help import helps # pylint: disable=unused-import


class ScVmmCommandsLoader(AzCommandsLoader):
def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
from ._client_factory import cf_scvmm

scvmm_custom = CliCommandType(
operations_tmpl='azext_scvmm.custom#{}', client_factory=cf_scvmm
)
super().__init__(cli_ctx=cli_ctx, custom_command_type=scvmm_custom)

def load_command_table(self, args):
from .commands import load_command_table

load_command_table(self, args)
return self.command_table

def load_arguments(self, command):
from ._params import load_arguments

load_arguments(self, command)


COMMAND_LOADER_CLS = ScVmmCommandsLoader
38 changes: 38 additions & 0 deletions src/scvmm/azext_scvmm/_actions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# pylint: disable=protected-access,too-few-public-methods

"""
This file contains actions for parsing complex arguments.
"""

import argparse
from .scvmm_utils import create_dictionary_from_arg_string


class VmNicAddAction(argparse._AppendAction):
"""
Action for parsing the nic arguments.
"""

def __call__(self, parser, namespace, values, option_string=None):
nic_params_dict = create_dictionary_from_arg_string(values, option_string)
if namespace.nics:
namespace.nics.append(nic_params_dict)
else:
namespace.nics = [nic_params_dict]


class VmDiskAddAction(argparse._AppendAction):
"""
Action for parsing the disk arguments.
"""

def __call__(self, parser, namespace, values, option_string=None):
disk_params_dict = create_dictionary_from_arg_string(values, option_string)
if namespace.disks:
namespace.disks.append(disk_params_dict)
else:
namespace.disks = [disk_params_dict]
63 changes: 63 additions & 0 deletions src/scvmm/azext_scvmm/_client_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# --------------------------------------------------------------------------------------------
# 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.commands.client_factory import get_mgmt_service_client
from .vendored_sdks import SCVMM


def cf_scvmm(cli_ctx, *_) -> SCVMM:
"""
Client factory for scvmm clients.
"""
return get_mgmt_service_client(cli_ctx, SCVMM)


def cf_vmmserver(cli_ctx, *_):
"""
Client factory for vmmservers.
"""
return cf_scvmm(cli_ctx).vmm_servers


def cf_cloud(cli_ctx, *_):
"""
Client factory for clouds.
"""
return cf_scvmm(cli_ctx).clouds


def cf_virtual_network(cli_ctx, *_):
"""
Client factory for virtual networks.
"""
return cf_scvmm(cli_ctx).virtual_networks


def cf_virtual_machine_template(cli_ctx, *_):
"""
Client factory for vm templates.
"""
return cf_scvmm(cli_ctx).virtual_machine_templates


def cf_virtual_machine(cli_ctx, *_):
"""
Client factory for virtual machines.
"""
return cf_scvmm(cli_ctx).virtual_machines


def cf_availability_sets(cli_ctx, *_):
"""
Client factory for availability sets.
"""
return cf_scvmm(cli_ctx).availability_sets


def cf_inventory_items(cli_ctx, *_):
"""
Client factory for inventory items.
"""
return cf_scvmm(cli_ctx).inventory_items
Loading