зеркало из https://github.com/microsoft/azure-cli.git
Convert task help and clean up.
This commit is contained in:
Родитель
c87b004854
Коммит
4521a41cf4
|
@ -41,6 +41,9 @@
|
|||
<Compile Include="azure\cli\tests\test_logging.py" />
|
||||
<Compile Include="azure\cli\tests\test_validators.py" />
|
||||
<Compile Include="azure\cli\utils\command_test_script.py" />
|
||||
<Compile Include="command_modules\azure-cli-component\azure\cli\command_modules\component\custom.py" />
|
||||
<Compile Include="command_modules\azure-cli-component\azure\cli\command_modules\component\generated.py" />
|
||||
<Compile Include="command_modules\azure-cli-component\azure\cli\command_modules\component\_params.py" />
|
||||
<Compile Include="command_modules\azure-cli-network\azure\cli\command_modules\network\custom.py">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
@ -71,6 +74,15 @@
|
|||
<Compile Include="command_modules\azure-cli-network\azure\cli\command_modules\network\_params.py">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="command_modules\azure-cli-profile\azure\cli\command_modules\profile\custom.py">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="command_modules\azure-cli-profile\azure\cli\command_modules\profile\generated.py">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="command_modules\azure-cli-profile\azure\cli\command_modules\profile\_params.py">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="command_modules\azure-cli-resource\azure\cli\command_modules\resource\custom.py" />
|
||||
<Compile Include="command_modules\azure-cli-resource\azure\cli\command_modules\resource\generated.py" />
|
||||
<Compile Include="command_modules\azure-cli-resource\azure\cli\command_modules\resource\tests\test_validators.py" />
|
||||
|
@ -87,6 +99,12 @@
|
|||
</Compile>
|
||||
<Compile Include="command_modules\azure-cli-storage\azure\cli\command_modules\storage\_params.py" />
|
||||
<Compile Include="command_modules\azure-cli-storage\azure\cli\command_modules\storage\_validators.py" />
|
||||
<Compile Include="command_modules\azure-cli-taskhelp\azure\cli\command_modules\taskhelp\custom.py">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="command_modules\azure-cli-taskhelp\azure\cli\command_modules\taskhelp\generated.py">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\tests\test_custom_vm_commands.py" />
|
||||
<Compile Include="command_modules\azure-cli-resource\azure\cli\command_modules\resource\tests\test_resource_list_odata_filter.py" />
|
||||
<Compile Include="command_modules\azure-cli-resource\azure\cli\command_modules\resource\tests\test_api_check.py">
|
||||
|
@ -132,10 +150,6 @@
|
|||
<Compile Include="command_modules\azure-cli-network\azure\cli\command_modules\network\tests\test_commands.py" />
|
||||
<Compile Include="command_modules\azure-cli-network\azure\cli\command_modules\network\__init__.py" />
|
||||
<Compile Include="command_modules\azure-cli-network\setup.py" />
|
||||
<Compile Include="command_modules\azure-cli-profile\azure\cli\command_modules\profile\account.py" />
|
||||
<Compile Include="command_modules\azure-cli-profile\azure\cli\command_modules\profile\command_tables.py" />
|
||||
<Compile Include="command_modules\azure-cli-profile\azure\cli\command_modules\profile\login.py" />
|
||||
<Compile Include="command_modules\azure-cli-profile\azure\cli\command_modules\profile\logout.py" />
|
||||
<Compile Include="command_modules\azure-cli-profile\azure\cli\command_modules\profile\__init__.py" />
|
||||
<Compile Include="command_modules\azure-cli-profile\setup.py" />
|
||||
<Compile Include="command_modules\azure-cli-resource\azure\cli\command_modules\resource\tests\command_specs.py">
|
||||
|
|
|
@ -20,8 +20,6 @@ INSTALLED_COMMAND_MODULES = [dist.key.replace('azure-cli-', '')
|
|||
|
||||
logger.info('Installed command modules %s', INSTALLED_COMMAND_MODULES)
|
||||
|
||||
RESOURCE_GROUP_ARG_NAME = 'resource_group_name'
|
||||
|
||||
COMMON_PARAMETERS = {
|
||||
'deployment_name': {
|
||||
'name': '--deployment-name',
|
||||
|
@ -36,7 +34,6 @@ COMMON_PARAMETERS = {
|
|||
},
|
||||
'resource_group_name': {
|
||||
'name': '--resource-group -g',
|
||||
'dest': RESOURCE_GROUP_ARG_NAME,
|
||||
'metavar': 'RESOURCEGROUP',
|
||||
'help': 'The name of the resource group',
|
||||
},
|
||||
|
@ -55,9 +52,14 @@ COMMON_PARAMETERS = {
|
|||
}
|
||||
|
||||
def extend_parameter(parameter_metadata, **kwargs):
|
||||
modified_parameter_metadata = parameter_metadata.copy()
|
||||
modified_parameter_metadata.update(kwargs)
|
||||
return modified_parameter_metadata
|
||||
extended_param = parameter_metadata.copy()
|
||||
extended_param.update(kwargs)
|
||||
return extended_param
|
||||
|
||||
def patch_aliases(aliases, patch):
|
||||
patched_aliases = aliases.copy()
|
||||
patched_aliases.update(patch)
|
||||
return patched_aliases
|
||||
|
||||
class LongRunningOperation(object): #pylint: disable=too-few-public-methods
|
||||
|
||||
|
|
|
@ -59,32 +59,33 @@ def _make_func(client_factory, member_path, return_type_or_func, unbound_func, e
|
|||
def _option_descriptions(operation):
|
||||
"""Pull out parameter help from doccomments of the command
|
||||
"""
|
||||
lines = inspect.getdoc(operation).splitlines()
|
||||
option_descs = {}
|
||||
index = 0
|
||||
while index < len(lines):
|
||||
l = lines[index]
|
||||
regex = r'\s*(:param)\s+(.+)\s*:(.*)'
|
||||
match = re.search(regex, l)
|
||||
if match:
|
||||
# 'arg name' portion might have type info, we don't need it
|
||||
arg_name = str.split(match.group(2))[-1]
|
||||
arg_desc = match.group(3).strip()
|
||||
#look for more descriptions on subsequent lines
|
||||
index += 1
|
||||
while index < len(lines):
|
||||
temp = lines[index].strip()
|
||||
if temp.startswith(':'):
|
||||
break
|
||||
else:
|
||||
if temp:
|
||||
arg_desc += (' ' + temp)
|
||||
index += 1
|
||||
|
||||
option_descs[arg_name] = arg_desc
|
||||
else:
|
||||
index += 1
|
||||
lines = inspect.getdoc(operation)
|
||||
if lines:
|
||||
lines = lines.splitlines()
|
||||
index = 0
|
||||
while index < len(lines):
|
||||
l = lines[index]
|
||||
regex = r'\s*(:param)\s+(.+)\s*:(.*)'
|
||||
match = re.search(regex, l)
|
||||
if match:
|
||||
# 'arg name' portion might have type info, we don't need it
|
||||
arg_name = str.split(match.group(2))[-1]
|
||||
arg_desc = match.group(3).strip()
|
||||
#look for more descriptions on subsequent lines
|
||||
index += 1
|
||||
while index < len(lines):
|
||||
temp = lines[index].strip()
|
||||
if temp.startswith(':'):
|
||||
break
|
||||
else:
|
||||
if temp:
|
||||
arg_desc += (' ' + temp)
|
||||
index += 1
|
||||
|
||||
option_descs[arg_name] = arg_desc
|
||||
else:
|
||||
index += 1
|
||||
return option_descs
|
||||
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ from six.moves import input #pylint: disable=redefined-builtin
|
|||
|
||||
from azure.cli.parser import IncorrectUsageError
|
||||
from azure.cli._locale import L
|
||||
from azure.cli._help_files import helps
|
||||
|
||||
from azure.cli.utils.update_checker import check_for_component_update
|
||||
|
||||
|
@ -49,22 +50,38 @@ class ComponentCommands(object):
|
|||
def __init__(self, **_):
|
||||
pass
|
||||
|
||||
helps['component list'] = """
|
||||
short-summary: List the installed components
|
||||
"""
|
||||
def list(self):
|
||||
''' List the installed components.'''
|
||||
return sorted([{'name': dist.key.replace(COMPONENT_PREFIX, ''), 'version': dist.version}
|
||||
for dist in pip.get_installed_distributions(local_only=True)
|
||||
if dist.key.startswith(COMPONENT_PREFIX)], key=lambda x: x['name'])
|
||||
|
||||
helps['component install'] = """
|
||||
short-summary: Install a component
|
||||
parameters:
|
||||
- name: --name -n
|
||||
short-summary: The component name to install.
|
||||
required: True
|
||||
"""
|
||||
def install(self, component_name, link, private=False, version=None):
|
||||
''' Install a component'''
|
||||
_install_or_update(component_name, version, link, private, upgrade=False)
|
||||
|
||||
helps['component update'] = """
|
||||
short-summary: Update a component
|
||||
parameters:
|
||||
- name: --name -n
|
||||
short-summary: The component name to update.
|
||||
required: True
|
||||
"""
|
||||
def update(self, component_name, link, private=False):
|
||||
''' Update a component'''
|
||||
_install_or_update(component_name, None, link, private, upgrade=True)
|
||||
|
||||
helps['component update-self'] = """
|
||||
short-summary: Update the CLI
|
||||
"""
|
||||
def update_self(self, private=False):
|
||||
''' Update the CLI'''
|
||||
pkg_index_options = []
|
||||
if private:
|
||||
if not PRIVATE_PYPI_URL:
|
||||
|
@ -78,16 +95,24 @@ class ComponentCommands(object):
|
|||
pip.main(['install', '--quiet', '--isolated', '--disable-pip-version-check', '--upgrade']
|
||||
+ [CLI_PACKAGE_NAME] + pkg_index_options)
|
||||
|
||||
helps['component update-all'] = """
|
||||
short-summary: Update all components
|
||||
"""
|
||||
def update_all(self, link, private=False):
|
||||
''' Update all components'''
|
||||
component_names = [dist.key.replace(COMPONENT_PREFIX, '')
|
||||
for dist in pip.get_installed_distributions(local_only=True)
|
||||
if dist.key.startswith(COMPONENT_PREFIX)]
|
||||
for name in component_names:
|
||||
_install_or_update(name, None, link, private, upgrade=True)
|
||||
|
||||
helps['component check'] = """
|
||||
short-summary: Check a component for an update
|
||||
parameters:
|
||||
- name: --name -n
|
||||
short-summary: The component name to check.
|
||||
required: True
|
||||
"""
|
||||
def check_component(self, component_name, private=False):
|
||||
''' Check a component for an update'''
|
||||
found = bool([dist for dist in pip.get_installed_distributions(local_only=True)
|
||||
if dist.key == COMPONENT_PREFIX + component_name])
|
||||
if not found:
|
||||
|
@ -99,8 +124,14 @@ class ComponentCommands(object):
|
|||
result['updateAvailable'] = update_status['update_available']
|
||||
return result
|
||||
|
||||
helps['component remove'] = """
|
||||
short-summary: Remove a component
|
||||
parameters:
|
||||
- name: --name -n
|
||||
short-summary: The component name to remove.
|
||||
required: True
|
||||
"""
|
||||
def remove(self, component_name, force=False):
|
||||
''' Remove a component'''
|
||||
prompt_for_delete = force is None
|
||||
found = bool([dist for dist in pip.get_installed_distributions(local_only=True)
|
||||
if dist.key == COMPONENT_PREFIX + component_name])
|
||||
|
|
|
@ -8,13 +8,6 @@ from .custom import ProfileCommands
|
|||
|
||||
command_table = CommandTable()
|
||||
|
||||
# HELPER METHODS
|
||||
|
||||
def _patch_aliases(alias_items):
|
||||
aliases = PARAMETER_ALIASES.copy()
|
||||
aliases.update(alias_items)
|
||||
return aliases
|
||||
|
||||
# PROFILE COMMANDS
|
||||
|
||||
build_operation(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from azure.mgmt.resource.resources import (ResourceManagementClient,
|
||||
ResourceManagementClientConfiguration)
|
||||
|
||||
from azure.cli.commands import COMMON_PARAMETERS as GLOBAL_COMMON_PARAMETERS
|
||||
from azure.cli.commands import COMMON_PARAMETERS as GLOBAL_COMMON_PARAMETERS, patch_aliases
|
||||
from azure.cli.commands._command_creation import get_mgmt_service_client
|
||||
from azure.cli._locale import L
|
||||
|
||||
|
@ -14,8 +14,7 @@ def _resource_client_factory(_):
|
|||
|
||||
# BASIC PARAMETER CONFIGURATION
|
||||
|
||||
PARAMETER_ALIASES = GLOBAL_COMMON_PARAMETERS.copy()
|
||||
PARAMETER_ALIASES.update({
|
||||
PARAMETER_ALIASES = patch_aliases(GLOBAL_COMMON_PARAMETERS, {
|
||||
'resource_type': {
|
||||
'name': '--resource-type',
|
||||
'help': L('the resource type in <namespace>/<type> format'),
|
||||
|
|
|
@ -5,7 +5,7 @@ from azure.mgmt.resource.resources.operations.deployments_operations import Depl
|
|||
from azure.mgmt.resource.resources.operations.deployment_operations_operations \
|
||||
import DeploymentOperationsOperations
|
||||
from azure.cli.commands._auto_command import build_operation, CommandDefinition
|
||||
from azure.cli.commands import CommandTable, LongRunningOperation
|
||||
from azure.cli.commands import CommandTable, LongRunningOperation, patch_aliases
|
||||
from azure.cli._locale import L
|
||||
|
||||
from ._params import PARAMETER_ALIASES, _resource_client_factory
|
||||
|
@ -13,11 +13,6 @@ from .custom import ConvenienceResourceGroupCommands, ConvenienceResourceCommand
|
|||
|
||||
command_table = CommandTable()
|
||||
|
||||
def _patch_aliases(alias_items):
|
||||
aliases = PARAMETER_ALIASES.copy()
|
||||
aliases.update(alias_items)
|
||||
return aliases
|
||||
|
||||
build_operation(
|
||||
'resource group', 'resource_groups', _resource_client_factory,
|
||||
[
|
||||
|
@ -27,8 +22,7 @@ build_operation(
|
|||
CommandDefinition(ResourceGroupsOperations.get, 'ResourceGroup', 'show'),
|
||||
CommandDefinition(ResourceGroupsOperations.check_existence, 'Bool', 'exists'),
|
||||
],
|
||||
command_table,
|
||||
_patch_aliases({
|
||||
command_table, patch_aliases(PARAMETER_ALIASES, {
|
||||
'resource_group_name': {'name': '--name -n'}
|
||||
}))
|
||||
|
||||
|
@ -38,8 +32,7 @@ build_operation(
|
|||
CommandDefinition(ConvenienceResourceGroupCommands.list, '[ResourceGroup]'),
|
||||
CommandDefinition(ConvenienceResourceGroupCommands.create, 'ResourceGroup'),
|
||||
],
|
||||
command_table,
|
||||
_patch_aliases({
|
||||
command_table, patch_aliases(PARAMETER_ALIASES, {
|
||||
'resource_group_name': {'name': '--name -n'}
|
||||
}))
|
||||
|
||||
|
@ -49,8 +42,7 @@ build_operation(
|
|||
CommandDefinition(ConvenienceResourceCommands.list, '[Resource]'),
|
||||
CommandDefinition(ConvenienceResourceCommands.show, 'Resource'),
|
||||
],
|
||||
command_table,
|
||||
_patch_aliases({
|
||||
command_table, patch_aliases(PARAMETER_ALIASES, {
|
||||
'resource_name': {'name': '--name -n'}
|
||||
}))
|
||||
|
||||
|
@ -63,8 +55,7 @@ build_operation(
|
|||
CommandDefinition(TagsOperations.create_or_update_value, 'Tag', 'add-value'),
|
||||
CommandDefinition(TagsOperations.delete_value, None, 'remove-value'),
|
||||
],
|
||||
command_table,
|
||||
_patch_aliases({
|
||||
command_table, patch_aliases(PARAMETER_ALIASES, {
|
||||
'tag_name': {'name': '--name -n'},
|
||||
'tag_value': {'name': '--value'}
|
||||
}))
|
||||
|
@ -80,8 +71,7 @@ build_operation(
|
|||
#CommandDefinition(DeploymentsOperations.cancel, 'Object'),
|
||||
#CommandDefinition(DeploymentsOperations.create_or_update, 'Object', 'create'),
|
||||
],
|
||||
command_table,
|
||||
_patch_aliases({
|
||||
command_table, patch_aliases(PARAMETER_ALIASES, {
|
||||
'deployment_name': {'name': '--name -n', 'required': True}
|
||||
}))
|
||||
|
||||
|
@ -91,7 +81,6 @@ build_operation(
|
|||
CommandDefinition(DeploymentOperationsOperations.list, '[DeploymentOperations]'),
|
||||
CommandDefinition(DeploymentOperationsOperations.get, 'DeploymentOperations', 'show')
|
||||
],
|
||||
command_table,
|
||||
_patch_aliases({
|
||||
command_table, patch_aliases(PARAMETER_ALIASES, {
|
||||
'deployment_name': {'name': '--name -n', 'required': True}
|
||||
}))
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from os import environ
|
||||
|
||||
from azure.cli.commands import (COMMON_PARAMETERS as GLOBAL_COMMON_PARAMETERS, extend_parameter)
|
||||
from azure.cli.commands import (COMMON_PARAMETERS as GLOBAL_COMMON_PARAMETERS, extend_parameter,
|
||||
patch_aliases)
|
||||
from azure.cli.commands._command_creation import get_mgmt_service_client, get_data_service_client
|
||||
from azure.cli.commands._validators import validate_key_value_pairs
|
||||
from azure.cli._locale import L
|
||||
|
@ -91,8 +92,7 @@ blob_types = {'block': BlockBlobService, 'page': PageBlobService, 'append': Appe
|
|||
|
||||
# BASIC PARAMETER CONFIGURATION
|
||||
|
||||
PARAMETER_ALIASES = GLOBAL_COMMON_PARAMETERS.copy()
|
||||
PARAMETER_ALIASES.update({
|
||||
PARAMETER_ALIASES = patch_aliases(GLOBAL_COMMON_PARAMETERS, {
|
||||
'account_key': {
|
||||
'name': '--account-key -k',
|
||||
'help': L('the storage account key'),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import print_function
|
||||
|
||||
from azure.cli.commands import CommandTable, LongRunningOperation
|
||||
from azure.cli.commands import CommandTable, LongRunningOperation, patch_aliases
|
||||
from azure.cli.commands._auto_command import build_operation, CommandDefinition
|
||||
|
||||
from azure.mgmt.storage.operations import StorageAccountsOperations
|
||||
|
@ -16,13 +16,6 @@ from .custom import (ConvenienceStorageAccountCommands, ConvenienceBlobServiceCo
|
|||
|
||||
command_table = CommandTable()
|
||||
|
||||
# HELPER METHODS
|
||||
|
||||
def _patch_aliases(alias_items):
|
||||
aliases = PARAMETER_ALIASES.copy()
|
||||
aliases.update(alias_items)
|
||||
return aliases
|
||||
|
||||
# STORAGE ACCOUNT COMMANDS
|
||||
|
||||
build_operation(
|
||||
|
@ -51,7 +44,7 @@ build_operation(
|
|||
CommandDefinition(ConvenienceStorageAccountCommands.show_usage, 'Object'),
|
||||
CommandDefinition(ConvenienceStorageAccountCommands.set, 'Object'),
|
||||
CommandDefinition(ConvenienceStorageAccountCommands.connection_string, 'Object')
|
||||
], command_table, _patch_aliases({
|
||||
], command_table, patch_aliases(PARAMETER_ALIASES, {
|
||||
'account_type': {'name': '--type'}
|
||||
}))
|
||||
|
||||
|
@ -130,7 +123,7 @@ build_operation(
|
|||
CommandDefinition(ConvenienceBlobServiceCommands.blob_exists, 'Bool', 'exists'),
|
||||
CommandDefinition(ConvenienceBlobServiceCommands.download, 'Object'),
|
||||
CommandDefinition(ConvenienceBlobServiceCommands.upload, 'Object')
|
||||
], command_table, _patch_aliases({
|
||||
], command_table, patch_aliases(PARAMETER_ALIASES, {
|
||||
'blob_type': {'name': '--type'}
|
||||
}), STORAGE_DATA_CLIENT_ARGS)
|
||||
|
||||
|
@ -236,7 +229,7 @@ build_operation(
|
|||
'SAS', 'generate-sas'),
|
||||
CommandDefinition(FileService.get_file_properties, 'Properties', 'show'),
|
||||
CommandDefinition(FileService.set_file_properties, 'Properties', 'set')
|
||||
], command_table, _patch_aliases({
|
||||
], command_table, patch_aliases(PARAMETER_ALIASES, {
|
||||
'directory_name': {'required': False}
|
||||
}), STORAGE_DATA_CLIENT_ARGS)
|
||||
|
||||
|
@ -253,7 +246,7 @@ build_operation(
|
|||
[
|
||||
CommandDefinition(FileService.get_file_metadata, 'Metadata', 'show'),
|
||||
CommandDefinition(FileService.set_file_metadata, 'Metadata', 'set')
|
||||
], command_table, _patch_aliases({
|
||||
], command_table, patch_aliases(PARAMETER_ALIASES, {
|
||||
'directory_name': {'required': False}
|
||||
}), STORAGE_DATA_CLIENT_ARGS)
|
||||
|
||||
|
|
|
@ -1,22 +1,2 @@
|
|||
from __future__ import print_function
|
||||
from azure.cli.commands import CommandTable
|
||||
from azure.cli._locale import L
|
||||
|
||||
command_table = CommandTable()
|
||||
|
||||
@command_table.command('taskhelp deploy-arm-template')
|
||||
@command_table.description(L('How to deploy and ARM template using Azure CLI.'))
|
||||
def deploy_template_help(args): #pylint: disable=unused-argument
|
||||
print(L("""
|
||||
***********************
|
||||
ARM Template Deployment
|
||||
***********************
|
||||
|
||||
Could this be helpful? Let us know!
|
||||
====================================
|
||||
|
||||
1. First Step
|
||||
2. Second Step
|
||||
|
||||
And you're done!
|
||||
"""))
|
||||
# pylint: disable=unused-import
|
||||
from .generated import command_table
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
# pylint: disable=no-self-use,too-few-public-methods
|
||||
from __future__ import print_function
|
||||
from azure.cli._locale import L
|
||||
|
||||
class TaskHelpCommands(object):
|
||||
|
||||
def __init__(self, **_):
|
||||
pass
|
||||
|
||||
def deploy_arm_template(self):
|
||||
'''How to deploy an ARM template using Azure CLI.'''
|
||||
print(L("""
|
||||
***********************
|
||||
ARM Template Deployment
|
||||
***********************
|
||||
|
||||
Could this be helpful? Let us know!
|
||||
====================================
|
||||
|
||||
1. First Step
|
||||
2. Second Step
|
||||
|
||||
And you're done!
|
||||
"""))
|
|
@ -0,0 +1,14 @@
|
|||
from __future__ import print_function
|
||||
|
||||
from azure.cli.commands import CommandTable
|
||||
from azure.cli.commands._auto_command import build_operation, CommandDefinition
|
||||
|
||||
from .custom import TaskHelpCommands
|
||||
|
||||
command_table = CommandTable()
|
||||
|
||||
build_operation(
|
||||
'taskhelp', None, TaskHelpCommands,
|
||||
[
|
||||
CommandDefinition(TaskHelpCommands.deploy_arm_template, 'Help'),
|
||||
], command_table)
|
|
@ -3,7 +3,8 @@ import argparse
|
|||
from azure.mgmt.compute import ComputeManagementClient, ComputeManagementClientConfiguration
|
||||
from azure.mgmt.compute.models import VirtualHardDisk
|
||||
|
||||
from azure.cli.commands import COMMON_PARAMETERS as GLOBAL_COMMON_PARAMETERS, extend_parameter
|
||||
from azure.cli.commands import (COMMON_PARAMETERS as GLOBAL_COMMON_PARAMETERS, extend_parameter,
|
||||
patch_aliases)
|
||||
from azure.cli.commands._command_creation import get_mgmt_service_client
|
||||
from azure.cli.command_modules.vm._validators import MinMaxValue
|
||||
from azure.cli.command_modules.vm._actions import VMImageFieldAction, VMSSHFieldAction
|
||||
|
@ -17,8 +18,7 @@ def _compute_client_factory(**_):
|
|||
|
||||
# BASIC PARAMETER CONFIGURATION
|
||||
|
||||
PARAMETER_ALIASES = GLOBAL_COMMON_PARAMETERS.copy()
|
||||
PARAMETER_ALIASES.update({
|
||||
PARAMETER_ALIASES = patch_aliases(GLOBAL_COMMON_PARAMETERS, {
|
||||
'diskname': {
|
||||
'name': '--name -n',
|
||||
'help': L('Disk name'),
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
# pylint: disable=no-self-use,too-many-arguments
|
||||
|
||||
import json
|
||||
import re
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ from azure.mgmt.compute.operations import (AvailabilitySetsOperations,
|
|||
|
||||
from azure.cli.commands._auto_command import build_operation, CommandDefinition
|
||||
from azure.cli.commands._command_creation import get_mgmt_service_client
|
||||
from azure.cli.commands import CommandTable, LongRunningOperation
|
||||
from azure.cli.commands import CommandTable, LongRunningOperation, patch_aliases
|
||||
from azure.cli.command_modules.vm.mgmt.lib import (VMCreationClient as VMClient,
|
||||
VMCreationClientConfiguration
|
||||
as VMClientConfig)
|
||||
|
@ -23,11 +23,6 @@ from .custom import ConvenienceVmCommands
|
|||
|
||||
command_table = CommandTable()
|
||||
|
||||
def _patch_aliases(alias_items):
|
||||
aliases = PARAMETER_ALIASES.copy()
|
||||
aliases.update(alias_items)
|
||||
return aliases
|
||||
|
||||
# pylint: disable=line-too-long
|
||||
build_operation(
|
||||
'vm availset', 'availability_sets', _compute_client_factory,
|
||||
|
@ -37,8 +32,7 @@ build_operation(
|
|||
CommandDefinition(AvailabilitySetsOperations.list, '[AvailabilitySet]'),
|
||||
CommandDefinition(AvailabilitySetsOperations.list_available_sizes, '[VirtualMachineSize]', 'list-sizes')
|
||||
],
|
||||
command_table,
|
||||
_patch_aliases({
|
||||
command_table, patch_aliases(PARAMETER_ALIASES, {
|
||||
'availability_set_name': {'name': '--name -n'}
|
||||
}))
|
||||
|
||||
|
@ -66,8 +60,7 @@ build_operation(
|
|||
CommandDefinition(VirtualMachineExtensionsOperations.delete, LongRunningOperation(L('Deleting VM extension'), L('VM extension deleted'))),
|
||||
CommandDefinition(VirtualMachineExtensionsOperations.get, 'VirtualMachineExtension', command_alias='show'),
|
||||
],
|
||||
command_table,
|
||||
_patch_aliases({
|
||||
command_table, patch_aliases(PARAMETER_ALIASES, {
|
||||
'vm_extension_name': {'name': '--name -n'}
|
||||
}))
|
||||
|
||||
|
@ -107,8 +100,7 @@ build_operation(
|
|||
CommandDefinition(VirtualMachinesOperations.restart, LongRunningOperation(L('Restarting VM'), L('VM Restarted'))),
|
||||
CommandDefinition(VirtualMachinesOperations.start, LongRunningOperation(L('Starting VM'), L('VM Started'))),
|
||||
],
|
||||
command_table,
|
||||
_patch_aliases({
|
||||
command_table, patch_aliases(PARAMETER_ALIASES, {
|
||||
'vm_name': {'name': '--name -n'}
|
||||
}))
|
||||
|
||||
|
@ -128,8 +120,7 @@ build_operation(
|
|||
CommandDefinition(VirtualMachineScaleSetsOperations.start, LongRunningOperation(L('Starting VM scale set'), L('VM scale set started'))),
|
||||
CommandDefinition(VirtualMachineScaleSetsOperations.update_instances, LongRunningOperation(L('Updating VM scale set instances'), L('VM scale set instances updated'))),
|
||||
],
|
||||
command_table,
|
||||
_patch_aliases({
|
||||
command_table, patch_aliases(PARAMETER_ALIASES, {
|
||||
'vm_scale_set_name': {'name': '--name -n'}
|
||||
}))
|
||||
|
||||
|
@ -145,8 +136,7 @@ build_operation(
|
|||
CommandDefinition(VirtualMachineScaleSetVMsOperations.restart, LongRunningOperation(L('Restarting VM scale set VMs'), L('VM scale set VMs restarted'))),
|
||||
CommandDefinition(VirtualMachineScaleSetVMsOperations.start, LongRunningOperation(L('Starting VM scale set VMs'), L('VM scale set VMs started'))),
|
||||
],
|
||||
command_table,
|
||||
_patch_aliases({
|
||||
command_table, patch_aliases(PARAMETER_ALIASES, {
|
||||
'vm_scale_set_name': {'name': '--name -n'}
|
||||
}))
|
||||
|
||||
|
@ -173,6 +163,6 @@ build_operation(
|
|||
[
|
||||
CommandDefinition(ConvenienceVmCommands.list_vm_images, 'object', 'list')
|
||||
],
|
||||
command_table, _patch_aliases({
|
||||
command_table, patch_aliases(PARAMETER_ALIASES, {
|
||||
'image_location': {'name': '--location -l'}
|
||||
}))
|
||||
|
|
Загрузка…
Ссылка в новой задаче