зеркало из https://github.com/microsoft/azure-cli.git
Merge branch 'master'
This commit is contained in:
Коммит
274e708247
5
pylintrc
5
pylintrc
|
@ -5,8 +5,11 @@
|
|||
# I0011 Warning locally suppressed using disable-msg
|
||||
# W0511 fixme
|
||||
disable=C0111,C0103,I0011,W0511
|
||||
[VARIABLES]
|
||||
# Tells whether we should check for unused import in __init__ files.
|
||||
init-import=yes
|
||||
[DESIGN]
|
||||
# Maximum number of locals for function / method body
|
||||
max-locals=25
|
||||
# Maximum number of branch for function / method body
|
||||
max-branches=20
|
||||
max-branches=20
|
||||
|
|
|
@ -18,7 +18,7 @@ COMMON_PARAMETERS = {
|
|||
'name': '--resource-group -g',
|
||||
'dest': RESOURCE_GROUP_ARG_NAME,
|
||||
'metavar': 'RESOURCEGROUP',
|
||||
'help': 'Name of resource group',
|
||||
'help': 'The name of the resource group.',
|
||||
'required': True
|
||||
},
|
||||
'location': {
|
||||
|
@ -30,7 +30,7 @@ COMMON_PARAMETERS = {
|
|||
'deployment_name': {
|
||||
'name': '--deployment-name',
|
||||
'metavar': 'DEPLOYMENTNAME',
|
||||
'help': 'Name of the resource deployment',
|
||||
'help': 'The name of the resource deployment.',
|
||||
'default': 'azurecli' + str(time.time()) + str(random.randint(0, 10000000)),
|
||||
'required': False
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from __future__ import print_function
|
||||
import re
|
||||
import inspect
|
||||
from msrest.paging import Paged
|
||||
from msrest.exceptions import ClientException
|
||||
|
@ -54,13 +55,37 @@ def _make_func(client_factory, member_path, return_type_or_func, unbound_func):
|
|||
|
||||
return call_client
|
||||
|
||||
def _option_description(operation, arg):
|
||||
def _option_descriptions(operation):
|
||||
"""Pull out parameter help from doccomments of the command
|
||||
"""
|
||||
# TODO: We are currently doing this for every option/argument.
|
||||
# We should do it (at most) once for a given command...
|
||||
return ' '.join(l.split(':')[-1] for l in inspect.getdoc(operation).splitlines()
|
||||
if l.startswith(':param') and arg + ':' in l)
|
||||
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
|
||||
|
||||
return option_descs
|
||||
|
||||
|
||||
#pylint: disable=too-many-arguments
|
||||
def build_operation(command_name,
|
||||
|
@ -85,13 +110,18 @@ def build_operation(command_name,
|
|||
args = sig.args
|
||||
|
||||
options = []
|
||||
for arg in [a for a in args if not a in EXCLUDED_PARAMS]:
|
||||
|
||||
option_helps = _option_descriptions(op.operation)
|
||||
filtered_args = [a for a in args if not a in EXCLUDED_PARAMS]
|
||||
for arg in filtered_args:
|
||||
try:
|
||||
# this works in python3
|
||||
default = args[arg].default
|
||||
required = default == inspect.Parameter.empty #pylint: disable=no-member
|
||||
except TypeError:
|
||||
arg_defaults = dict(zip(sig.args[-len(sig.defaults):], sig.defaults))
|
||||
arg_defaults = (dict(zip(sig.args[-len(sig.defaults):], sig.defaults))
|
||||
if sig.defaults
|
||||
else {})
|
||||
default = arg_defaults.get(arg)
|
||||
required = arg not in arg_defaults
|
||||
|
||||
|
@ -109,7 +139,7 @@ def build_operation(command_name,
|
|||
'required': required,
|
||||
'default': default,
|
||||
'dest': arg,
|
||||
'help': _option_description(op.operation, arg),
|
||||
'help': option_helps.get(arg),
|
||||
'action': action
|
||||
}
|
||||
parameter.update(COMMON_PARAMETERS.get(arg, {}))
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import logging
|
||||
import unittest
|
||||
|
||||
from azure.cli.commands._auto_command import build_operation
|
||||
from azure.cli.commands._auto_command import build_operation, _option_descriptions
|
||||
from azure.cli.commands import CommandTable
|
||||
from azure.cli.commands._auto_command import AutoCommandDefinition
|
||||
from azure.cli.main import main as cli
|
||||
|
@ -27,7 +27,8 @@ class Test_autocommand(unittest.TestCase):
|
|||
:type resource_group_name: str
|
||||
:param vm_name: The name of the virtual machine.
|
||||
:type vm_name: str
|
||||
:param opt_param: Used to verify auto-command correctly identifies optional params
|
||||
:param opt_param: Used to verify auto-command correctly
|
||||
identifies optional params.
|
||||
:type opt_param: object
|
||||
:param expand: The expand expression to apply on the operation.
|
||||
:type expand: str
|
||||
|
@ -53,9 +54,10 @@ class Test_autocommand(unittest.TestCase):
|
|||
self.assertEqual(command_metadata['name'], 'test autocommand sample-vm-get', 'Unexpected command name...')
|
||||
self.assertEqual(len(command_metadata['arguments']), 4, 'We expected exactly 4 arguments')
|
||||
some_expected_arguments = [
|
||||
{'name': '--resource-group -g', 'dest': 'resource_group_name', 'required': True},
|
||||
{'name': '--vm-name', 'dest': 'vm_name', 'required': True},
|
||||
{'name': '--opt-param', 'required': False},
|
||||
{'name': '--resource-group -g', 'dest': 'resource_group_name', 'required': True, 'help':'The name of the resource group.'},
|
||||
{'name': '--vm-name', 'dest': 'vm_name', 'required': True, 'help': 'The name of the virtual machine.'},
|
||||
{'name': '--opt-param', 'required': False, 'help': 'Used to verify auto-command correctly identifies optional params.'},
|
||||
{'name': '--expand', 'required': False, 'help': 'The expand expression to apply on the operation.'},
|
||||
]
|
||||
|
||||
for probe in some_expected_arguments:
|
||||
|
@ -144,5 +146,40 @@ class Test_autocommand(unittest.TestCase):
|
|||
command_metadata = list(command_table.values())[0]
|
||||
self.assertEqual(command_metadata['name'], 'test autocommand woot', 'Unexpected command name...')
|
||||
|
||||
def test_autocommand_build_argument_help_text(self):
|
||||
def sample_sdk_method_with_weired_docstring(self, param_a, param_b, param_c):
|
||||
"""
|
||||
An operation with nothing good.
|
||||
|
||||
:param dict param_a:
|
||||
:param param_b: The name
|
||||
of
|
||||
nothing.
|
||||
:param param_c: The name
|
||||
of
|
||||
|
||||
nothing2.
|
||||
"""
|
||||
command_table = CommandTable()
|
||||
build_operation("test autocommand",
|
||||
"",
|
||||
None,
|
||||
[
|
||||
AutoCommandDefinition(sample_sdk_method_with_weired_docstring, None)
|
||||
],
|
||||
command_table)
|
||||
|
||||
command_metadata = list(command_table.values())[0]
|
||||
self.assertEqual(len(command_metadata['arguments']), 3, 'We expected exactly 3 arguments')
|
||||
some_expected_arguments = [
|
||||
{'name': '--param-a', 'dest': 'param_a', 'required': True, 'help': ''},
|
||||
{'name': '--param-b', 'dest': 'param_b', 'required': True, 'help': 'The name of nothing.'},
|
||||
{'name': '--param-c', 'dest': 'param_c', 'required': True, 'help': 'The name of nothing2.'},
|
||||
]
|
||||
|
||||
for probe in some_expected_arguments:
|
||||
existing = next(arg for arg in command_metadata['arguments'] if arg['name'] == probe['name'])
|
||||
self.assertDictContainsSubset(probe, existing)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -4,10 +4,10 @@ import pip
|
|||
from six.moves import input #pylint: disable=redefined-builtin
|
||||
|
||||
from azure.cli.parser import IncorrectUsageError
|
||||
from azure.cli.commands import CommandTable, COMMON_PARAMETERS
|
||||
from azure.cli.commands import CommandTable
|
||||
from azure.cli._locale import L
|
||||
|
||||
from azure.cli.utils.update_checker import check_for_component_update, UpdateCheckError
|
||||
from azure.cli.utils.update_checker import check_for_component_update
|
||||
|
||||
CLI_PACKAGE_NAME = 'azure-cli'
|
||||
COMPONENT_PREFIX = 'azure-cli-'
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import time
|
||||
from azure.mgmt.network import NetworkManagementClient, NetworkManagementClientConfiguration
|
||||
from azure.mgmt.network.operations import (ApplicationGatewaysOperations,
|
||||
ExpressRouteCircuitAuthorizationsOperations,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import azure.cli.command_modules.profile.account
|
||||
import azure.cli.command_modules.profile.login
|
||||
import azure.cli.command_modules.profile.logout
|
||||
from azure.cli.command_modules.profile.command_tables import COMMAND_TABLES, generate_command_table
|
||||
import azure.cli.command_modules.profile.account #pylint: disable=unused-import
|
||||
import azure.cli.command_modules.profile.login #pylint: disable=unused-import
|
||||
import azure.cli.command_modules.profile.logout #pylint: disable=unused-import
|
||||
from azure.cli.command_modules.profile.command_tables import generate_command_table
|
||||
|
||||
command_table = generate_command_table()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from azure.cli.parser import IncorrectUsageError
|
||||
from azure.cli.commands import CommandTable, COMMON_PARAMETERS
|
||||
from azure.cli.commands import CommandTable, COMMON_PARAMETERS, RESOURCE_GROUP_ARG_NAME
|
||||
from azure.cli.commands._command_creation import get_mgmt_service_client
|
||||
from azure.cli._locale import L
|
||||
|
||||
|
@ -57,7 +57,7 @@ def show_resource(args):
|
|||
L('API version is required and could not be resolved for resource {}'
|
||||
.format(full_type)))
|
||||
results = rmc.resources.get(
|
||||
resource_group_name=args.get('resourcegroup'),
|
||||
resource_group_name=args.get(RESOURCE_GROUP_ARG_NAME),
|
||||
resource_name=args.get('name'),
|
||||
resource_provider_namespace=provider_namespace,
|
||||
resource_type=resource_type,
|
||||
|
@ -127,7 +127,7 @@ def _resolve_api_version(args, rmc):
|
|||
|
||||
# if api-version not supplied, attempt to resolve using provider namespace
|
||||
parent = args.get('parent')
|
||||
full_type = args.get('resource-type').split('/')
|
||||
full_type = args.get('resource_type').split('/')
|
||||
try:
|
||||
provider_namespace = full_type[0]
|
||||
resource_type = full_type[1]
|
||||
|
|
|
@ -6,6 +6,10 @@ TEST_DEF = [
|
|||
{
|
||||
'test_name': 'resource_group_list',
|
||||
'command': 'resource group list --output json'
|
||||
},
|
||||
{
|
||||
'test_name': 'resource_show_under_group',
|
||||
'command': 'resource show -n xplatvmExt1314 --resource-group XPLATTESTGEXTENSION9085 --resource-type Microsoft.Compute/virtualMachines --output json'
|
||||
}
|
||||
]
|
||||
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -0,0 +1,130 @@
|
|||
interactions:
|
||||
- request:
|
||||
body: null
|
||||
headers:
|
||||
Accept: [application/json]
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Connection: [keep-alive]
|
||||
Content-Type: [application/json; charset=utf-8]
|
||||
User-Agent: [python/3.5.0 requests/2.9.1 msrest/0.2.0 msrest_azure/0.2.1 resourcemanagementclient/2015-11-01
|
||||
Azure-SDK-For-Python AZURECLI_0.0.32]
|
||||
accept-language: [en-US]
|
||||
method: GET
|
||||
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute?api-version=2015-11-01
|
||||
response:
|
||||
body:
|
||||
string: !!binary |
|
||||
H4sIAAAAAAAEAO29B2AcSZYlJi9tynt/SvVK1+B0oQiAYBMk2JBAEOzBiM3mkuwdaUcjKasqgcpl
|
||||
VmVdZhZAzO2dvPfee++999577733ujudTif33/8/XGZkAWz2zkrayZ4hgKrIHz9+fB8/In7xR8Xs
|
||||
o0cf3W3Wk2ZaF6u2qJbN3Z3J7vmn+w92t3cn5zvb+7NZtp3l03vb08nDvQd75zsP7z/cubuqq8ti
|
||||
ltfN3S+KaV011Xk7PqkWq3WbfzT6aJkt8maVTXOCHvs+W7fzqi5+kKHHjx794o+y1aospvznGVD6
|
||||
dCf/dDr79MH2w+nBdHv/4f3d7YeTe9PtvXvTvfvZ3u6nD7NzglNXZf40Py+WhX0z33/wYCebTrYJ
|
||||
15ywnx5sHzw4v7e9u3e+v599uru3t7f/0S+hV/OmWtfT/M31Km8+evS9Xxx8QoCyy6wos0lRFu31
|
||||
67xtqLuyEhTR/qPTrGnTr17Tx/pbuke/fzfn3+m3k3zZ1lkpf7yo6naeBh+9rogI4UfS6nRdV4SB
|
||||
wrJ/cS/HTZHR7/xu7n3wnWyVLVM0sX/gbfrjeN2ggyIz37oPLBT69Emd/aAo5SP6k3+mZ8sZQzdI
|
||||
mr8BWv/4Pk3mqvhJYgRDl72d3U+3d+5t39uhlvTH/e2dT7d379s/6H+726s6vyzyK7w+JWyZygXm
|
||||
4aMTYpbmlU7F53W1Xpk/vqgu81HK37/2GNb/mia2N4+XRd2us/KLbDovltTFj6bR/A3Q+gfNw/+3
|
||||
pvFu/q7Nl4Ltj2bU/A3Q+gdNyf+nZvT1NCvzH+lZvGL/Bmj9g+bjm53OF9XyfWblR/IG6AZJ8zdA
|
||||
6x9E4W92gliejAz9LMrb3fDzH03vz8r0vsd8LPP2qqrfni3bvD4nH/pHM/JzPSPh5z+aIfqpk+CG
|
||||
Yv4GaP3jZ2GGHJVDiv9sdnWXaFzLr/S2/RidgGwyPfrbj+aZ6UIk/qaIf7l4XfzgRxJGSJq/AVr/
|
||||
+Fml/LrJLn5EeELS/A3Q+sfPKuFX60lZNHMCTm/bj9EJxiI0099+RHymC5H4w4hPw/2RijdImr8B
|
||||
Wv/4WSB516mibi6WVdMWU/K52mJ58fNpKqL03d/eof/t3op6i7yti6nLhf+IeJZ49HWdXxQAA2q8
|
||||
bjNag3j00Sv+LK/z2Ue/5P8BmyM4hgkZAAA=
|
||||
headers:
|
||||
Cache-Control: [no-cache]
|
||||
Content-Encoding: [gzip]
|
||||
Content-Length: ['881']
|
||||
Content-Type: [application/json; charset=utf-8]
|
||||
Date: ['Fri, 29 Apr 2016 19:56:00 GMT']
|
||||
Expires: ['-1']
|
||||
Pragma: [no-cache]
|
||||
Strict-Transport-Security: [max-age=31536000; includeSubDomains]
|
||||
Vary: [Accept-Encoding]
|
||||
status: {code: 200, message: OK}
|
||||
- request:
|
||||
body: null
|
||||
headers:
|
||||
Accept: [application/json]
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Connection: [keep-alive]
|
||||
Content-Type: [application/json; charset=utf-8]
|
||||
User-Agent: [python/3.5.0 requests/2.9.1 msrest/0.2.0 msrest_azure/0.2.1 resourcemanagementclient/2015-11-01
|
||||
Azure-SDK-For-Python AZURECLI_0.0.32]
|
||||
accept-language: [en-US]
|
||||
method: GET
|
||||
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/XPLATTESTGEXTENSION9085/providers/Microsoft.Compute/virtualMachines/xplatvmExt1314?api-version=2016-03-30
|
||||
response:
|
||||
body:
|
||||
string: !!binary |
|
||||
H4sIAAAAAAAEAO29B2AcSZYlJi9tynt/SvVK1+B0oQiAYBMk2JBAEOzBiM3mkuwdaUcjKasqgcpl
|
||||
VmVdZhZAzO2dvPfee++999577733ujudTif33/8/XGZkAWz2zkrayZ4hgKrIHz9+fB8/In7xb5yk
|
||||
6UerulrldVvkzUePUv6IPrxcnM3oz492sv1PH3x6MNvO7u/vb+/P9qfb2flsuv1w79P7u7s79/J8
|
||||
99OPRvrSPKtnV1mdv6yr86LM6X0FR99dLl4XP8BHH71us+WMWv7+x7sfyde/xABo2qrOLqLvFwv6
|
||||
4lV+ntf5chp8RV+u1pOyaOZ5TZ9/9EUxraumOm+/Wyxn1VXzOq8v8/q0afJlW2RlY9DF81F1ThDx
|
||||
1m0aN2/Xt21K3zRFtUTz3fHOeG9n997uzu6BDtgNmZpWzdOieUst/RFVzZvrFYZpegugL7MFfzct
|
||||
i908y2cPDib3Pp3l5/fu39uumu3d/fv39ncf3r/38OH+/eDFaZ1nbf7lqlXcntXV4gyUDVpdzjH3
|
||||
Hjr02bou6LOP5m27ah7dvftuVWatTte7dv/Te/fGk7KajKdVnY+vBOXxMm+DhtNlS413Hxw8vHsb
|
||||
zMfAwyHhSEboTLPpvFheAKVXeTb7bl20uW3rWn40y9oM5AVvf+/78rH5mogc47RptVit27x+oUTm
|
||||
EVwuTgnze7v7jlAfZbNFsfyqyWszHdkP1nW+pg+8RkqLk2p5Xlys60wpb7ujJiSAlwW45Se/OL4g
|
||||
ZqKv23qdWxjUJF9mkzI/XrfVgiBMv1rRuFhe0dC0M+Oi9k1OM92iQW/QNClXVf3WG7n56Iympz7P
|
||||
pgD8vV8MtKxe+MW/ZPRRQUzx0d1mPWmmdcEc1Nzdmeyef7r/YHd7d3K+s70/m2XbWT69tz2dPNx7
|
||||
sHe+8/D+w527dd5U63qaf15X61UjHPEmb9rPiaT5EgN/uHNw/y71d1nMSG7uWgkevxDM7vYwFCjL
|
||||
Ykow9g/27330S75vRzgrsotl1RCdovM7qar2qWvif0ffCqVpqExaBYnHKKevvqYgOO6UXyy6PG5Q
|
||||
gfiZdCPxMYF/vZ5O83xGiKCVtP0IM5B+E1Pwe798fvzmzenrN5+f/t5vTl+8PvvyxeAUnIg43L0s
|
||||
6nadlV+w4JkJ6IiFVUzRL1vVaDfC1vZlNSVmZ3H5iNBv53nWtFlTZPp9m13w7BFBf8n/A4L7AA3L
|
||||
BgAA
|
||||
headers:
|
||||
Cache-Control: [no-cache]
|
||||
Content-Encoding: [gzip]
|
||||
Content-Type: [application/json; charset=utf-8]
|
||||
Date: ['Fri, 29 Apr 2016 19:56:01 GMT']
|
||||
Expires: ['-1']
|
||||
Pragma: [no-cache]
|
||||
Server: [Microsoft-HTTPAPI/2.0, Microsoft-HTTPAPI/2.0]
|
||||
Strict-Transport-Security: [max-age=31536000; includeSubDomains]
|
||||
Vary: [Accept-Encoding]
|
||||
status: {code: 200, message: OK}
|
||||
- request:
|
||||
body: null
|
||||
headers:
|
||||
Accept: [application/json]
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Connection: [keep-alive]
|
||||
Content-Type: [application/json; charset=utf-8]
|
||||
User-Agent: [python/3.5.0 requests/2.9.1 msrest/0.2.0 msrest_azure/0.2.1 resourcemanagementclient/2015-11-01
|
||||
Azure-SDK-For-Python AZURECLI_0.0.32]
|
||||
accept-language: [en-US]
|
||||
method: GET
|
||||
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/XPLATTESTGEXTENSION9085/providers/Microsoft.Compute//virtualMachines/xplatvmExt1314?api-version=2016-03-30
|
||||
response:
|
||||
body:
|
||||
string: !!binary |
|
||||
H4sIAAAAAAAEAO29B2AcSZYlJi9tynt/SvVK1+B0oQiAYBMk2JBAEOzBiM3mkuwdaUcjKasqgcpl
|
||||
VmVdZhZAzO2dvPfee++999577733ujudTif33/8/XGZkAWz2zkrayZ4hgKrIHz9+fB8/In7xb5yk
|
||||
6UerulrldVvkzUePUv6IPrxcnM3oz492sv1PH3x6MNvO7u/vb+/P9qfb2flsuv1w79P7u7s79/J8
|
||||
99OPRvrSPKtnV1mdv6yr86LM6X0FR99dLl4XP8BHH71us+WMWv7+x7sfyde/xABo2qrOLqLvFwv6
|
||||
4lV+ntf5chp8RV+u1pOyaOZ5TZ9/9EUxraumOm+/Wyxn1VXzOq8v8/q0afJlW2RlY9DF81F1ThDx
|
||||
1m0aN2/Xt21K3zRFtUTz3fHOeG9n997uzu6BDtgNmZpWzdOieUst/RFVzZvrFYZpegugL7MFfzct
|
||||
i908y2cPDib3Pp3l5/fu39uumu3d/fv39ncf3r/38OH+/eDFaZ1nbf7lqlXcntXV4gyUDVpdzjH3
|
||||
Hjr02bou6LOP5m27ah7dvftuVWatTte7dv/Te/fGk7KajKdVnY+vBOXxMm+DhtNlS413Hxw8vHsb
|
||||
zMfAwyHhSEboTLPpvFheAKVXeTb7bl20uW3rWn40y9oM5AVvf+/78rH5mogc47RptVit27x+oUTm
|
||||
EVwuTgnze7v7jlAfZbNFsfyqyWszHdkP1nW+pg+8RkqLk2p5Xlys60wpb7ujJiSAlwW45Se/OL4g
|
||||
ZqKv23qdWxjUJF9mkzI/XrfVgiBMv1rRuFhe0dC0M+Oi9k1OM92iQW/QNClXVf3WG7n56Iympz7P
|
||||
pgD8vV8MtKxe+MW/ZPRRQUzx0d1mPWmmdcEc1Nzdmeyef7r/YHd7d3K+s70/m2XbWT69tz2dPNx7
|
||||
sHe+8/D+w527dd5U63qaf15X61UjHPEmb9rPiaT5EgN/uHNw/y71d1nMSG7uWgkevxDM7vYwFCjL
|
||||
Ykow9g/27330S75vRzgrsotl1RCdovM7qar2qWvif0ffCqVpqExaBYnHKKevvqYgOO6UXyy6PG5Q
|
||||
gfiZdCPxMYF/vZ5O83xGiKCVtP0IM5B+E1Pwe798fvzmzenrN5+f/t5vTl+8PvvyxeAUnIg43L0s
|
||||
6nadlV+w4JkJ6IiFVUzRL1vVaDfC1vZlNSVmZ3H5iNBv53nWtFlTZPp9m13w7BFBf8n/A4L7AA3L
|
||||
BgAA
|
||||
headers:
|
||||
Cache-Control: [no-cache]
|
||||
Content-Encoding: [gzip]
|
||||
Content-Type: [application/json; charset=utf-8]
|
||||
Date: ['Fri, 29 Apr 2016 19:56:01 GMT']
|
||||
Expires: ['-1']
|
||||
Pragma: [no-cache]
|
||||
Server: [Microsoft-HTTPAPI/2.0, Microsoft-HTTPAPI/2.0]
|
||||
Strict-Transport-Security: [max-age=31536000; includeSubDomains]
|
||||
Vary: [Accept-Encoding]
|
||||
status: {code: 200, message: OK}
|
||||
version: 1
|
|
@ -24,22 +24,22 @@ class TestApiCheck(unittest.TestCase):
|
|||
|
||||
def test_resolve_api_max_priority_option(self):
|
||||
""" Verifies the --api-version parameter has maximum priority. """
|
||||
args = {'api-version': '2015-01-01', 'resource-type': 'Mock/test'}
|
||||
args = {'api-version': '2015-01-01', 'resource_type': 'Mock/test'}
|
||||
self.assertEqual(resolve_api_version(args, self._get_mock_client()), "2015-01-01")
|
||||
|
||||
def test_resolve_api_provider_backup(self):
|
||||
""" Verifies provider is used as backup if api-version not specified. """
|
||||
args = {'resource-type': 'Mock/test'}
|
||||
args = {'resource_type': 'Mock/test'}
|
||||
self.assertEqual(resolve_api_version(args, self._get_mock_client()), "2016-01-01")
|
||||
|
||||
def test_resolve_api_provider_with_parent_backup(self):
|
||||
""" Verifies provider (with parent) is used as backup if api-version not specified. """
|
||||
args = {'resource-type': 'Mock/bar', 'parent': 'foo/testfoo123'}
|
||||
args = {'resource_type': 'Mock/bar', 'parent': 'foo/testfoo123'}
|
||||
self.assertEqual(resolve_api_version(args, self._get_mock_client()), "1999-01-01")
|
||||
|
||||
def test_resolve_api_all_previews(self):
|
||||
""" Verifies most recent preview version returned only if there are no non-preview versions. """
|
||||
args = {'resource-type': 'Mock/preview'}
|
||||
args = {'resource_type': 'Mock/preview'}
|
||||
self.assertEqual(resolve_api_version(args, self._get_mock_client()), "2005-01-01-preview")
|
||||
|
||||
def _get_mock_client(self):
|
||||
|
|
|
@ -23,30 +23,30 @@ class TestListResources(unittest.TestCase):
|
|||
'tag': 'foo'
|
||||
}
|
||||
filter = _list_resources_odata_filter_builder(args)
|
||||
self.assertEquals(filter, "tagname eq 'foo'")
|
||||
self.assertEqual(filter, "tagname eq 'foo'")
|
||||
|
||||
def test_tag_name_starts_with(self):
|
||||
args = {
|
||||
'tag': 'f*'
|
||||
}
|
||||
filter = _list_resources_odata_filter_builder(args)
|
||||
self.assertEquals(filter, "startswith(tagname, 'f')")
|
||||
self.assertEqual(filter, "startswith(tagname, 'f')")
|
||||
|
||||
def test_tag_name_value_equals(self):
|
||||
args = {
|
||||
'tag': 'foo=bar'
|
||||
}
|
||||
filter = _list_resources_odata_filter_builder(args)
|
||||
self.assertEquals(filter, "tagname eq 'foo' and tagvalue eq 'bar'")
|
||||
self.assertEqual(filter, "tagname eq 'foo' and tagvalue eq 'bar'")
|
||||
|
||||
def test_name_location_equals(self):
|
||||
def test_name_location_with_resource_type_equals(self):
|
||||
args = {
|
||||
'name': 'wonky',
|
||||
'location': 'dory',
|
||||
'resourcetype': 'resource/type'
|
||||
'resource_type': 'resource/type'
|
||||
}
|
||||
filter = _list_resources_odata_filter_builder(args)
|
||||
self.assertEquals(filter, "name eq 'wonky' and location eq 'dory' and resourceType eq 'resource/type'")
|
||||
self.assertEqual(filter, "name eq 'wonky' and location eq 'dory' and resourceType eq 'resource/type'")
|
||||
|
||||
def test_name_location_equals(self):
|
||||
args = {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
from __future__ import print_function
|
||||
import os
|
||||
from sys import stderr
|
||||
|
||||
from azure.storage.blob import PublicAccess, BlockBlobService, AppendBlobService, PageBlobService
|
||||
|
|
|
@ -7,7 +7,7 @@ except ImportError:
|
|||
from azure.mgmt.compute.models import DataDisk
|
||||
from azure.mgmt.compute.models.compute_management_client_enums import DiskCreateOptionTypes
|
||||
from azure.cli._locale import L
|
||||
from azure.cli.commands import CommandTable, LongRunningOperation
|
||||
from azure.cli.commands import CommandTable, LongRunningOperation, RESOURCE_GROUP_ARG_NAME
|
||||
from azure.cli.commands._command_creation import get_mgmt_service_client
|
||||
from azure.mgmt.compute import ComputeManagementClient, ComputeManagementClientConfiguration
|
||||
|
||||
|
@ -22,7 +22,7 @@ def vm_getter(args):
|
|||
''' Retreive a VM based on the `args` passed in.
|
||||
'''
|
||||
client = _compute_client_factory(args)
|
||||
result = client.virtual_machines.get(args.get('resourcegroup'), args.get('vm_name'))
|
||||
result = client.virtual_machines.get(args.get(RESOURCE_GROUP_ARG_NAME), args.get('vm_name'))
|
||||
return result
|
||||
|
||||
def vm_setter(args, instance, start_msg, end_msg):
|
||||
|
@ -31,7 +31,7 @@ def vm_setter(args, instance, start_msg, end_msg):
|
|||
instance.resources = None # Issue: https://github.com/Azure/autorest/issues/934
|
||||
client = _compute_client_factory(args)
|
||||
poller = client.virtual_machines.create_or_update(
|
||||
resource_group_name=args.get('resourcegroup'),
|
||||
resource_group_name=args.get(RESOURCE_GROUP_ARG_NAME),
|
||||
vm_name=args.get('vm_name'),
|
||||
parameters=instance)
|
||||
return LongRunningOperation(start_msg, end_msg)(poller)
|
||||
|
@ -65,7 +65,7 @@ def patches_vm(start_msg, finish_msg):
|
|||
@command_table.option(**PARAMETER_ALIASES['optional_resource_group_name'])
|
||||
def list_vm(args):
|
||||
ccf = _compute_client_factory(args)
|
||||
group = args.get('resourcegroup')
|
||||
group = args.get(RESOURCE_GROUP_ARG_NAME)
|
||||
vm_list = ccf.virtual_machines.list(resource_group_name=group) if group else \
|
||||
ccf.virtual_machines.list_all()
|
||||
return list(vm_list)
|
||||
|
|
|
@ -6,5 +6,9 @@ TEST_DEF = [
|
|||
{
|
||||
'test_name': 'vm_usage_list_westus',
|
||||
'command': 'vm usage list --location westus --output json',
|
||||
},
|
||||
{
|
||||
'test_name': 'vm_list_from_group',
|
||||
'command': 'vm list --resource-group XPLATTESTGEXTENSION9085',
|
||||
}
|
||||
]
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
{
|
||||
"test_vm_list_from_group": "Availability Set : None\nId : /subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourceGroups/XPLATTESTGEXTENSION9085/providers/Microsoft.Compute/virtualMachines/xplatvmExt1314\nInstance View : None\nLicense Type : None\nLocation : southeastasia\nName : xplatvmExt1314\nPlan : None\nProvisioning State : Succeeded\nResource Group : XPLATTESTGEXTENSION9085\nResources : None\nType : Microsoft.Compute/virtualMachines\nDiagnostics Profile :\n Boot Diagnostics :\n Enabled : True\n Storage Uri : https://xplatstoragext4633.blob.core.windows.net/\nHardware Profile :\n Vm Size : Standard_A1\nNetwork Profile :\n Network Interfaces :\n Id : /subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourceGroups/xplatTestGExtension9085/providers/Microsoft.Network/networkInterfaces/xplatnicExt4843\n Primary : None\n Resource Group : xplatTestGExtension9085\nOs Profile :\n Admin Password : None\n Admin Username : azureuser\n Computer Name : xplatvmExt1314\n Custom Data : None\n Linux Configuration : None\n Secrets :\n None\n Windows Configuration :\n Additional Unattend Content : None\n Enable Automatic Updates : True\n Provision Vm Agent : True\n Time Zone : None\n Win Rm : None\nStorage Profile :\n Data Disks :\n None\n Image Reference :\n Offer : WindowsServerEssentials\n Publisher : MicrosoftWindowsServerEssentials\n Sku : WindowsServerEssentials\n Version : 1.0.20131018\n Os Disk :\n Caching : ReadWrite\n Create Option : fromImage\n Disk Size Gb : None\n Encryption Settings : None\n Image : None\n Name : cli1eaed78b36def353-os-1453419539945\n Os Type : Windows\n Vhd :\n Uri : https://xplatstoragext4633.blob.core.windows.net/xplatstoragecntext1789/cli1eaed78b36def353-os-1453419539945.vhd\nTags :\n None\n\n\n",
|
||||
"test_vm_usage_list_westus": "[\n {\n \"currentValue\": 0,\n \"limit\": 2000,\n \"name\": {\n \"localizedValue\": \"Availability Sets\",\n \"value\": \"availabilitySets\"\n },\n \"unit\": \"Count\"\n },\n {\n \"currentValue\": 7,\n \"limit\": 100,\n \"name\": {\n \"localizedValue\": \"Total Regional Cores\",\n \"value\": \"cores\"\n },\n \"unit\": \"Count\"\n },\n {\n \"currentValue\": 5,\n \"limit\": 10000,\n \"name\": {\n \"localizedValue\": \"Virtual Machines\",\n \"value\": \"virtualMachines\"\n },\n \"unit\": \"Count\"\n },\n {\n \"currentValue\": 0,\n \"limit\": 50,\n \"name\": {\n \"localizedValue\": \"Virtual Machine Scale Sets\",\n \"value\": \"virtualMachineScaleSets\"\n },\n \"unit\": \"Count\"\n },\n {\n \"currentValue\": 1,\n \"limit\": 100,\n \"name\": {\n \"localizedValue\": \"Standard D Family Cores\",\n \"value\": \"standardDFamily\"\n },\n \"unit\": \"Count\"\n },\n {\n \"currentValue\": 6,\n \"limit\": 100,\n \"name\": {\n \"localizedValue\": \"Standard A0-A7 Family Cores\",\n \"value\": \"standardA0_A7Family\"\n },\n \"unit\": \"Count\"\n }\n]\n"
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
interactions:
|
||||
- request:
|
||||
body: null
|
||||
headers:
|
||||
Accept: [application/json]
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Connection: [keep-alive]
|
||||
Content-Type: [application/json; charset=utf-8]
|
||||
User-Agent: [python/3.5.0 requests/2.9.1 msrest/0.2.0 msrest_azure/0.2.1 computemanagementclient/2015-06-15
|
||||
Azure-SDK-For-Python AZURECLI_0.0.32]
|
||||
accept-language: [en-US]
|
||||
method: GET
|
||||
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/XPLATTESTGEXTENSION9085/providers/Microsoft.Compute/virtualMachines?api-version=2015-06-15
|
||||
response:
|
||||
body:
|
||||
string: !!binary |
|
||||
H4sIAAAAAAAEAO29B2AcSZYlJi9tynt/SvVK1+B0oQiAYBMk2JBAEOzBiM3mkuwdaUcjKasqgcpl
|
||||
VmVdZhZAzO2dvPfee++999577733ujudTif33/8/XGZkAWz2zkrayZ4hgKrIHz9+fB8/In7xb5yk
|
||||
6UeXWbnOP3qUfg9/pSl/iOejVV2t8rot8oa+tR/TF5eLsxl99NFOtv/pg08PZtvZ/f397f3Z/nQ7
|
||||
O59Ntx/ufXp/d3fnXp7vfvrRyHtxntWzq6zOX9bVeVGiUw8sfX+5eF38AB9/9LrNljNq/fsf737k
|
||||
mvwSH1jTVnV2MQirWNCXr/LzvM6X097X1GC1npRFM89r+u6jL4ppXTXVefvdYjmrrprXeX2Z16dN
|
||||
ky/bIisbfxh4PqrOCTLevO0Lzdv1+zSnb5uiWuKV3fHOeG9n997uzu6BR4yQHPRK1Twtmrf0Rnek
|
||||
VfPmegUSmN57vS2zBX8/LYvdPMtnDw4m9z6d5ef37t/brprt3f379/Z3H96/9/Dh/v3ey9M6z9r8
|
||||
y1Wr+D6rq8UZqN9reTkH33TQo8/XdUGffzRv21Xz6O7dd6sya3V637X7n967N56U1WQ8rep8fCVD
|
||||
GC/zNmg4XbbUePfBwcO7txnFGLiEiITkJLSm2XReLC+A2qs8m323Lto8eCd846NZ1maYAsjL977v
|
||||
vvKb0WQMcey0WqzWbV6/0Mng0V0uTmlU93b3Q2J+lM0WxfKrJq/N1GU/WNf5mj7oNFR6nVTL8+Ji
|
||||
XWc6S0HX1IyE/bIAx/3kF8cXxJTUpK3XeQCLmuXLbFLmx+u2WhCk6VcrGjPrBzT22/pjpveanLik
|
||||
RcNBwtCEXlX1W4865qMzmtr6PJuio+/9YqBq9dIv/iWjjwpiqo/uNutJM60L5sLm7s5k9/zT/Qe7
|
||||
27uT853t/dks287y6b3t6eTh3oO9852H9x/u3K3zplrX0/zzulqvGuGmN3nTfk4kz5cgxsOdg/t3
|
||||
qb/LYkbyeNdqifELwexuD0OBsiymBGP/YP/eR7/k+8EoZ0V2sawaot0gH0yqqn3qmnW/pxYyCzRs
|
||||
JrsHHo9RjF99TaEKOdz9EQyDaQIKkXyQria5oK5er6fTPJ8RYqale+cjzFL6TUzT7/3y+fGbN6ev
|
||||
33x++nu/OX3x+uzLF4PTdCIidfeyqNt1Vn7BAm0mKSJaVhEONmhVk97Yh/dOWU1JWFjsPqKhtPM8
|
||||
a9qsKTKvTZtd8EwrwfkHScov+X8AMvMTLaQHAAA=
|
||||
headers:
|
||||
Cache-Control: [no-cache]
|
||||
Content-Encoding: [gzip]
|
||||
Content-Type: [application/json; charset=utf-8]
|
||||
Date: ['Fri, 29 Apr 2016 19:53:17 GMT']
|
||||
Expires: ['-1']
|
||||
Pragma: [no-cache]
|
||||
Server: [Microsoft-HTTPAPI/2.0, Microsoft-HTTPAPI/2.0]
|
||||
Strict-Transport-Security: [max-age=31536000; includeSubDomains]
|
||||
Vary: [Accept-Encoding]
|
||||
status: {code: 200, message: OK}
|
||||
version: 1
|
Загрузка…
Ссылка в новой задаче