-
Notifications
You must be signed in to change notification settings - Fork 1.5k
add az vmware script* #3722
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
Merged
add az vmware script* #3722
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
f129c94
custom action for script execution params
cataggar 74ced2d
script-execution tests recorded
cataggar 0542e07
package and cmdlet tests passing
cataggar b0ebe65
update help
cataggar 99bda24
add named outputs
cataggar 6833ac0
recording are generated
cataggar b139a94
mv .gitattributes to root
cataggar 0ec860f
mv .gitattributes
cataggar 086e2df
it is in azext_vmware
cataggar f26da08
fix style
cataggar f08c74d
fix linter errors
cataggar d8cc242
suppress cred scan false positive
cataggar 7a709dc
remove credential test
cataggar e4d3dfd
Merge remote-tracking branch 'origin/main' into az-vmware-script
cataggar c7bcd09
raise InvalidArgumentValueError, RequiredArgumentMissingError
cataggar 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| src/vmware/azext_vmware/tests/latest/recordings/*.yaml linguist-generated=true | ||
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
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 |
|---|---|---|
|
|
@@ -384,20 +384,12 @@ | |
|
|
||
| helps['vmware cloud-link create'] = """ | ||
| type: command | ||
| short-summary: Create a cloud link in a private cloud. | ||
| short-summary: Create or update a cloud link in a private cloud. | ||
| examples: | ||
| - name: Create a cloud link. | ||
| text: az vmware cloud-link create --resource-group group1 --private-cloud cloud1 --name cloudLink1 --linked-cloud "/subscriptions/12341234-1234-1234-1234-123412341234/resourceGroups/mygroup/providers/Microsoft.AVS/privateClouds/cloud2" | ||
| """ | ||
|
|
||
| helps['vmware cloud-link update'] = """ | ||
| type: command | ||
| short-summary: Create a cloud link in a private cloud. | ||
| examples: | ||
| - name: Update a cloud link. | ||
| text: az vmware cloud-link update --resource-group group1 --private-cloud cloud1 --name cloudLink1 --linked-cloud "/subscriptions/12341234-1234-1234-1234-123412341234/resourceGroups/mygroup/providers/Microsoft.AVS/privateClouds/cloud2" | ||
| """ | ||
|
|
||
| helps['vmware cloud-link list'] = """ | ||
| type: command | ||
| short-summary: List cloud links in a private cloud. | ||
|
|
@@ -421,3 +413,82 @@ | |
| - name: Delete a cloud link. | ||
| text: az vmware cloud-link delete --resource-group group1 --private-cloud cloud1 --name cloudLink1 | ||
| """ | ||
|
|
||
| helps['vmware script-cmdlet'] = """ | ||
| type: group | ||
| short-summary: Commands to list and show script cmdlet resources. | ||
| """ | ||
|
|
||
| helps['vmware script-cmdlet list'] = """ | ||
| type: command | ||
| short-summary: List script cmdlet resources available for a private cloud to create a script execution resource on a private cloud. | ||
| examples: | ||
| - name: List script cmdlet resources. | ||
| text: az vmware script-cmdlet list --resource-group group1 --private-cloud cloud1 --script-package package1 | ||
| """ | ||
|
|
||
| helps['vmware script-cmdlet show'] = """ | ||
| type: command | ||
| short-summary: Get information about a script cmdlet resource in a specific package on a private cloud. | ||
| examples: | ||
| - name: Show a script cmdlet. | ||
| text: az vmware script-cmdlet show --resource-group group1 --private-cloud cloud1 --script-package package1 --name cmdlet1 | ||
| """ | ||
|
|
||
| helps['vmware script-package'] = """ | ||
| type: group | ||
| short-summary: Commands to list and show script packages available to run on the private cloud. | ||
| """ | ||
|
|
||
| helps['vmware script-package list'] = """ | ||
| type: command | ||
| short-summary: List script packages available to run on the private cloud. | ||
| examples: | ||
| - name: List script packages. | ||
| text: az vmware script-package list --resource-group group1 --private-cloud cloud1 | ||
| """ | ||
|
|
||
| helps['vmware script-package show'] = """ | ||
| type: command | ||
| short-summary: Get a script package available to run on a private cloud. | ||
| examples: | ||
| - name: Show a script package. | ||
| text: az vmware script-package show --resource-group group1 --private-cloud cloud1 --name package1 | ||
| """ | ||
|
|
||
| helps['vmware script-execution'] = """ | ||
| type: group | ||
| short-summary: Commands to manage script executions in a private cloud. | ||
| """ | ||
|
|
||
| helps['vmware script-execution create'] = """ | ||
| type: command | ||
| short-summary: Create or update a script execution in a private cloud. | ||
| examples: | ||
| - name: Create a script execution. | ||
| text: az vmware script-execution create --resource-group group1 --private-cloud cloud1 --name addSsoServer --script-cmdlet-id "/subscriptions/{subscription-id}/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/cloud1/scriptPackages/[email protected]/scriptCmdlets/New-SsoExternalIdentitySource" --timeout P0Y0M0DT0H60M60S --retention P0Y0M60DT0H60M60S --parameter name=DomainName type=Value value=placeholderDomain.local --parameter name=BaseUserDN type=Value "value=DC=placeholder, DC=placeholder" --hidden-parameter name=Password type=SecureValue secureValue=PlaceholderPassword | ||
| """ | ||
|
|
||
| helps['vmware script-execution list'] = """ | ||
| type: command | ||
| short-summary: List script executions in a private cloud. | ||
| examples: | ||
| - name: List script executions. | ||
| text: az vmware script-execution list --resource-group group1 --private-cloud cloud1 | ||
| """ | ||
|
|
||
| helps['vmware script-execution show'] = """ | ||
| type: command | ||
| short-summary: Get an script execution by name in a private cloud. | ||
| examples: | ||
| - name: Show a script execution. | ||
| text: az vmware script-execution show --resource-group group1 --private-cloud cloud1 --name addSsoServer | ||
| """ | ||
|
|
||
| helps['vmware script-execution delete'] = """ | ||
| type: command | ||
| short-summary: Delete a script execution in a private cloud. | ||
| examples: | ||
| - name: Delete a script execution. | ||
| text: az vmware script-execution delete --resource-group group1 --private-cloud cloud1 --name addSsoServer | ||
| """ | ||
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
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,70 @@ | ||
|
|
||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
| # pylint: disable=line-too-long, protected-access, too-few-public-methods | ||
|
|
||
| import argparse | ||
| from typing import Dict, List | ||
| from azure.cli.core.azclierror import InvalidArgumentValueError, RequiredArgumentMissingError | ||
| from knack.util import CLIError | ||
| from azext_vmware.vendored_sdks.avs_client.models import ScriptExecutionParameter, ScriptExecutionParameterType, ScriptStringExecutionParameter, ScriptSecureStringExecutionParameter, PSCredentialExecutionParameter | ||
|
|
||
|
|
||
| class ScriptExecutionNamedOutputAction(argparse._AppendAction): | ||
|
|
||
| def __call__(self, parser, namespace, values, option_string=None): | ||
| namespace.named_outputs = script_execution_named_outputs(values) | ||
|
|
||
|
|
||
| def script_execution_named_outputs(values: List[str]) -> Dict[str, str]: | ||
| try: | ||
| return dict(map(lambda x: x.split('=', 1), values)) | ||
| except ValueError as error: | ||
| raise CLIError('parsing named output parameter \'{}\''.format(values)) from error | ||
cataggar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| class ScriptExecutionParameterAction(argparse._AppendAction): | ||
|
|
||
| def __call__(self, parser, namespace, values, option_string=None): | ||
| parameter = script_execution_parameters(values) | ||
| if namespace.parameters: | ||
| namespace.parameters.append(parameter) | ||
| else: | ||
| namespace.parameters = [parameter] | ||
|
|
||
|
|
||
| def script_execution_parameters(values: List[str]) -> ScriptExecutionParameter: | ||
| values = dict(map(lambda x: x.split('=', 1), values)) | ||
| tp = require(values, "type") | ||
| type_lower = tp.lower() | ||
|
|
||
| if type_lower == ScriptExecutionParameterType.VALUE.lower(): | ||
| try: | ||
| return ScriptStringExecutionParameter(name=require(values, "name"), value=values.get("value")) | ||
| except CLIError as error: | ||
| raise InvalidArgumentValueError('parsing {} script execution parameter'.format(ScriptExecutionParameterType.VALUE)) from error | ||
|
|
||
| elif type_lower == ScriptExecutionParameterType.SECURE_VALUE.lower(): | ||
| try: | ||
| return ScriptSecureStringExecutionParameter(name=require(values, "name"), secure_value=values.get("secureValue")) | ||
| except CLIError as error: | ||
| raise InvalidArgumentValueError('parsing {} script execution parameter'.format(ScriptExecutionParameterType.SECURE_VALUE)) from error | ||
|
|
||
| elif type_lower == ScriptExecutionParameterType.CREDENTIAL.lower(): | ||
| try: | ||
| return PSCredentialExecutionParameter(name=require(values, "name"), username=values.get("username"), password=values.get("password")) | ||
| except CLIError as error: | ||
| raise InvalidArgumentValueError('parsing {} script execution parameter'.format(ScriptExecutionParameterType.CREDENTIAL)) from error | ||
|
|
||
| else: | ||
| raise InvalidArgumentValueError('script execution paramater type \'{}\' not matched'.format(tp)) | ||
|
|
||
|
|
||
| def require(values: Dict[str, str], key: str) -> str: | ||
| '''Gets the required script execution parameter or raises a CLIError.''' | ||
| value = values.get(key) | ||
| if value is None: | ||
| raise RequiredArgumentMissingError('script execution parameter \'{}\' required'.format(key)) | ||
| return value | ||
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
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
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.