-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[connected vmware] Onboarding connected vmware az cli extension #3340
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
Merged
xfz11
merged 13 commits into
Azure:master
from
sanmishra18:OnboardingConnectedVMwareExtension
May 21, 2021
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7d4c8f3
Oboarding connected vmware az cli extension
sanmishra18 c3fe961
Fix validator issue
sanmishra18 49463b2
Addressed Zhou reviews comments
sanmishra18 4dcd3b7
Fixes issue and added a simple test
sanmishra18 8816603
fix some general issue
sanmishra18 97c67e1
Updated CODEOWNERS
sanmishra18 c7448d6
Added more test cases
sanmishra18 85dad44
Added more test.
sanmishra18 5c45cdd
Add vm put, get, show and list test cases
sanmishra18 6d5e640
Fix VM stop issue and add vm stop and start test.
sanmishra18 8be147d
Update README.md file and revert show command name.
sanmishra18 e4b3bb6
Added vm nic and vm disk test.
sanmishra18 9a5b410
Ignore Unused argument 'tags' warning.
sanmishra18 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -191,3 +191,5 @@ | |
| /src/cloudservice/ @qwordy | ||
|
|
||
| /src/webpubsub/ @zackliu | ||
|
|
||
| /src/connectedvmware/ @sanmishra18 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| .vscode/ | ||
| .vscode.example |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| .. :changelog: | ||
|
|
||
| Release History | ||
| =============== | ||
|
|
||
| 0.1.0 | ||
| ++++++ | ||
| * Initial release. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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' | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
54
src/connectedvmware/azext_connectedvmware/_client_factory.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.