Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions src/connectedvmware/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vscode/
42 changes: 42 additions & 0 deletions src/connectedvmware/.vscode.example/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// 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": [ ], // list of command arguments to execute when running in debug mode.
"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"
}
]
}
22 changes: 22 additions & 0 deletions src/connectedvmware/.vscode.example/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{​​​​​
"python.languageServer": "Pylance",
"python.formatting.provider": "black",
"python.formatting.blackArgs": [
"--skip-string-normalization"
],
"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.
}​​​​​


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.
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'
32 changes: 32 additions & 0 deletions src/connectedvmware/azext_connectedvmware/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# --------------------------------------------------------------------------------------------
# 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 azure.cli.core.commands import CliCommandType
from azext_connectedvmware._client_factory import cf_connectedvmware
from azext_connectedvmware._params import load_arguments
from azext_connectedvmware.commands import load_command_table


class ConnectedvmwareCommandsLoader(AzCommandsLoader):
def __init__(self, cli_ctx=None):
connectedvmware_custom = CliCommandType(
operations_tmpl='azext_connectedvmware.custom#{}',
client_factory=cf_connectedvmware,
)
# pylint: disable=R1725
super(ConnectedvmwareCommandsLoader, self).__init__(
cli_ctx=cli_ctx, custom_command_type=connectedvmware_custom
)

def load_command_table(self, args):
load_command_table(self, args)
return self.command_table

def load_arguments(self, command):
load_arguments(self, command)


COMMAND_LOADER_CLS = ConnectedvmwareCommandsLoader
36 changes: 36 additions & 0 deletions src/connectedvmware/azext_connectedvmware/_actions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
"""
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): # pylint: disable=W0212, R0903
"""
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): # pylint: disable=W0212, R0903
"""
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