Skip to content
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 @@ -191,3 +191,5 @@
/src/cloudservice/ @qwordy

/src/webpubsub/ @zackliu

/src/connectedvmware/ @sanmishra18
2 changes: 2 additions & 0 deletions src/connectedvmware/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vscode/
.vscode.example
8 changes: 8 additions & 0 deletions src/connectedvmware/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. :changelog:

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

0.1.0
++++++
* Initial release.
87 changes: 87 additions & 0 deletions src/connectedvmware/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Microsoft Azure CLI ConnectedVMware Extension #

The Azure CLI extension for [Azure Arc for VMware PrivateCloud](https://github.com/Azure/azure-arc-enabled-vmware-vsphere-preview/blob/main/docs/overview.md) is an extension for Azure CLI 2.0.

## Install
```
az extension add --name connectedvmware
```

## Usage
See the [extension reference documenation](https://github.com/Azure/azure-arc-enabled-vmware-vsphere-preview/blob/main/docs/overview.md).
*Examples:*

##### Create Vcenter Resource

```
az connectedvmware vcenter connect \
--subscription subscriptionId \
--resource-group resourceGroupName \
--location locationName \
--custom-location customLocationName \
--fqdn vcenterFqdn \
--username userName \
--password password \
--name resourceName
```

##### Create Resource Pool Resource

```
az connectedvmware resource-pool create \
--subscription subscriptionId \
--resource-group resourceGroupName \
--location locationName \
--custom-location customLocationName \
--vcenter vcenterResourceName \
--mo-ref-id morefId \
--name resourceName
```

##### Create VM Template Resource

```
az connectedvmware vm-template create \
--subscription subscriptionId \
--resource-group resourceGroupName \
--location locationName \
--custom-location customLocationName \
--vcenter vcenterResourceName \
--mo-ref-id morefId \
--name resourceName
```

##### Create Virtual Network Resource

```
az connectedvmware virtual-network create \
--subscription subscriptionId \
--resource-group resourceGroupName \
--location locationName \
--custom-location customLocationName \
--vcenter vcenterResourceName \
--mo-ref-id morefId \
--name resourceName
```

##### Create Virtual Machine Resource

```
az connectedvmware vm create \
--subscription subscriptionId \
--resource-group resourceGroupName \
--location locationName \
--custom-location customLocationName \
--vcenter vcenterResourceName \
--resource-pool resourcePoolResourceName \
--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 connectedvmware
```

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/connectedvmware/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Microsoft Azure CLI 'connectedvmware' Extension
==========================================

This package is for the 'connectedvmware' extension.
i.e. 'az connectedvmware'
33 changes: 33 additions & 0 deletions src/connectedvmware/azext_connectedvmware/__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.
# --------------------------------------------------------------------------------------------
# pylint: disable= unused-import, import-outside-toplevel, super-with-arguments

from azure.cli.core import AzCommandsLoader
from azext_connectedvmware._help import helps


class ConnectedvmwareCommandsLoader(AzCommandsLoader):
def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
from azext_connectedvmware._client_factory import cf_connectedvmware
connectedvmware_custom = CliCommandType(
operations_tmpl='azext_connectedvmware.custom#{}',
client_factory=cf_connectedvmware,
)
super(ConnectedvmwareCommandsLoader, self).__init__(
cli_ctx=cli_ctx, custom_command_type=connectedvmware_custom
)

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

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


COMMAND_LOADER_CLS = ConnectedvmwareCommandsLoader
38 changes: 38 additions & 0 deletions src/connectedvmware/azext_connectedvmware/_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 azext_connectedvmware.vmware_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]
54 changes: 54 additions & 0 deletions src/connectedvmware/azext_connectedvmware/_client_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# --------------------------------------------------------------------------------------------
# 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
# Client factory for vmware clients.
from .vendored_sdks import AzureArcVMwareManagementServiceAPI


def cf_connectedvmware(cli_ctx, *_):
return get_mgmt_service_client(cli_ctx, AzureArcVMwareManagementServiceAPI)


def cf_vcenter(cli_ctx, *_):
"""
Client factory for vcenters.
"""
return cf_connectedvmware(cli_ctx).vcenters


def cf_resource_pool(cli_ctx, *_):
"""
Client factory for resourcepools.
"""
return cf_connectedvmware(cli_ctx).resource_pools


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


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


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


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