This commit is contained in:
Burt Bielicki 2016-04-20 16:15:50 -07:00
Родитель 864b289966 5cdc28cf89
Коммит 0b3a986c67
39 изменённых файлов: 1717 добавлений и 184 удалений

Просмотреть файл

@ -27,6 +27,6 @@ RUN pip3 install -r $AZURECLITEMP/requirements.txt
RUN chmod +x $AZURECLITEMP/az
RUN ln /usr/bin/python3 /usr/bin/python
RUN echo "source $AZURECLITEMP/az.completion.sh" >> ~/.bashrc
RUN az --help
RUN az
ENV EDITOR vim

Просмотреть файл

@ -30,6 +30,6 @@ RUN pip install -r $AZURECLITEMP/requirements.txt
RUN chmod +x $AZURECLITEMP/az
RUN echo "source $AZURECLITEMP/az.completion.sh" >> ~/.bashrc
RUN az --help
RUN az
ENV EDITOR vim

Просмотреть файл

@ -9,6 +9,53 @@ This package has [not] been tested [much] with Python 2.7, 3.4 and 3.5.
Installation
============
cURL Installation
-----------------
To install via cURL on Linux, Unix and OS X, type:
.. code:: shell
curl http://azure-cli-nightly.cloudapp.net/install | bash
Note: This will install the latest nightly builds.
If you get errors on install with cffi or cryptography such as the examples below,
install libssl-dev, libffi-dev and python3-dev by typing:
.. code:: shell
sudo apt-get update
sudo apt-get install -y build-essential libssl-dev libffi-dev python3-dev
**Example Errors**
.. code:: shell
Downloading cffi-1.5.2.tar.gz (388kB)
100% |################################| 389kB 3.9MB/s
Complete output from command python setup.py egg_info:
No working compiler found, or bogus compiler options
passed to the compiler from Python's distutils module.
See the error messages above.
(If they are about -mno-fused-madd and you are on OS/X 10.8,
see http://stackoverflow.com/questions/22313407/ .)
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-77i2fido/cffi/
.. code:: shell
#include <openssl/e_os2.h>
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Failed building wheel for cryptography
Download Package
----------------

Просмотреть файл

@ -37,6 +37,27 @@
<Compile Include="azure\cli\extensions\__init__.py" />
<Compile Include="azure\cli\main.py" />
<Compile Include="azure\cli\tests\test_add_resourcegroup_transform.py" />
<Compile Include="command_modules\azure-cli-network\azure\cli\command_modules\network\mgmt\lib\credentials.py" />
<Compile Include="command_modules\azure-cli-network\azure\cli\command_modules\network\mgmt\lib\exceptions.py" />
<Compile Include="command_modules\azure-cli-network\azure\cli\command_modules\network\mgmt\lib\models\basic_dependency.py" />
<Compile Include="command_modules\azure-cli-network\azure\cli\command_modules\network\mgmt\lib\models\dependency.py" />
<Compile Include="command_modules\azure-cli-network\azure\cli\command_modules\network\mgmt\lib\models\deployment_extended.py" />
<Compile Include="command_modules\azure-cli-network\azure\cli\command_modules\network\mgmt\lib\models\deployment_properties_extended.py" />
<Compile Include="command_modules\azure-cli-network\azure\cli\command_modules\network\mgmt\lib\models\deployment_vnet.py" />
<Compile Include="command_modules\azure-cli-network\azure\cli\command_modules\network\mgmt\lib\models\parameters_link.py" />
<Compile Include="command_modules\azure-cli-network\azure\cli\command_modules\network\mgmt\lib\models\provider.py" />
<Compile Include="command_modules\azure-cli-network\azure\cli\command_modules\network\mgmt\lib\models\provider_resource_type.py" />
<Compile Include="command_modules\azure-cli-network\azure\cli\command_modules\network\mgmt\lib\models\resource_management_client_enums.py" />
<Compile Include="command_modules\azure-cli-network\azure\cli\command_modules\network\mgmt\lib\models\template_link.py" />
<Compile Include="command_modules\azure-cli-network\azure\cli\command_modules\network\mgmt\lib\models\__init__.py" />
<Compile Include="command_modules\azure-cli-network\azure\cli\command_modules\network\mgmt\lib\operations\vnet_operations.py" />
<Compile Include="command_modules\azure-cli-network\azure\cli\command_modules\network\mgmt\lib\operations\__init__.py" />
<Compile Include="command_modules\azure-cli-network\azure\cli\command_modules\network\mgmt\lib\resource_management_client.py" />
<Compile Include="command_modules\azure-cli-network\azure\cli\command_modules\network\mgmt\lib\version.py" />
<Compile Include="command_modules\azure-cli-network\azure\cli\command_modules\network\mgmt\lib\__init__.py" />
<Compile Include="command_modules\azure-cli-network\azure\cli\command_modules\network\mgmt\__init__.py">
<SubType>Code</SubType>
</Compile>
<Compile Include="command_modules\azure-cli-resource\azure\cli\command_modules\resource\tests\test_api_check.py">
<SubType>Code</SubType>
</Compile>
@ -183,6 +204,10 @@
<Folder Include="command_modules\azure-cli-network\azure\cli\" />
<Folder Include="command_modules\azure-cli-network\azure\cli\command_modules\" />
<Folder Include="command_modules\azure-cli-network\azure\cli\command_modules\network\" />
<Folder Include="command_modules\azure-cli-network\azure\cli\command_modules\network\mgmt\" />
<Folder Include="command_modules\azure-cli-network\azure\cli\command_modules\network\mgmt\lib\" />
<Folder Include="command_modules\azure-cli-network\azure\cli\command_modules\network\mgmt\lib\models\" />
<Folder Include="command_modules\azure-cli-network\azure\cli\command_modules\network\mgmt\lib\operations\" />
<Folder Include="command_modules\azure-cli-network\azure\cli\command_modules\network\tests\" />
<Folder Include="command_modules\azure-cli-network\azure\cli\command_modules\network\tests\recordings\" />
<Folder Include="command_modules\azure-cli-profile\" />
@ -239,6 +264,8 @@
</ItemGroup>
<ItemGroup>
<Content Include="command_modules\azure-cli-component\requirements.txt" />
<Content Include="command_modules\azure-cli-network\azure\cli\command_modules\network\mgmt\azuredeploy.json" />
<Content Include="command_modules\azure-cli-network\azure\cli\command_modules\network\mgmt\swagger_create_vnet.json" />
<Content Include="command_modules\azure-cli-network\requirements.txt" />
<Content Include="command_modules\azure-cli-profile\requirements.txt" />
<Content Include="command_modules\azure-cli-resource\requirements.txt" />

Просмотреть файл

@ -80,7 +80,7 @@ print_heading('Installed command package(s).')
# STEP 3:: Validate the installation
success = exec_command('az --help')
success = exec_command('az')
if not success:
print_heading('Error running the CLI!', file=sys.stderr)
sys.exit(1)

Просмотреть файл

@ -0,0 +1,23 @@
import json
import sys
from azure.cli.application import Configuration
class Exporter(json.JSONEncoder):
def default(self, o):#pylint: disable=method-hidden
try:
return super(Exporter, self).default(o)
except TypeError:
return str(o)
cmd_set_names = None
if len(sys.argv) > 1:
cmd_set_names = sys.argv[1].split(',')
config = Configuration([])
cmd_table = config.get_command_table()
cmd_names = [x['name'] for x in cmd_table.values()
if cmd_set_names is None or (x['name'].split()[0]) in cmd_set_names]
print('\n'.join(cmd_names))

19
scripts/install Normal file
Просмотреть файл

@ -0,0 +1,19 @@
#!/usr/bin/env bash
#
# Bash script to install the Azure CLI
#
INSTALL_SCRIPT_URL=http://azure-cli-nightly.cloudapp.net/install.py
_TTY=/dev/tty
install_script=$(mktemp -t azure_cli_install_tmp_XXXX) || exit
echo "Downloading Azure CLI install script from $INSTALL_SCRIPT_URL to $install_script."
curl -# $INSTALL_SCRIPT_URL > $install_script || exit
chmod 775 $install_script
echo "Running install script."
if [[ -z "$AZURE_CLI_DISABLE_PROMPTS" && -t 1 ]]; then
$install_script < $_TTY
else
export AZURE_CLI_DISABLE_PROMPTS=1
$install_script
fi

164
scripts/install.py Normal file
Просмотреть файл

@ -0,0 +1,164 @@
#!/usr/bin/env python
#
# This script will install the CLI into a directory and create an executable
# at a specified file path that is the entry point into the CLI.
#
# By default, the latest versions of all CLI command packages will be installed.
#
# - Optional Environment Variables Available
# AZURE_CLI_DISABLE_PROMPTS - Disable prompts during installation and use the defaults
# AZURE_CLI_ENVIRONMENT_NAME - The name of the profile/environment you want to create
# AZURE_CLI_PACKAGE_VERSION - The version of the CLI and its command packages to install
# AZURE_CLI_PRIVATE_PYPI_URL - The URL to a PyPI server to include as an index for pip
# AZURE_CLI_PRIVATE_PYPI_HOST - The IP address/hostname of the PyPI server
#
from __future__ import print_function
import os
import sys
import platform
import stat
import tarfile
import tempfile
from subprocess import check_call
try:
# Attempt to load python 3 module
from urllib.request import urlretrieve
except ImportError:
# Import python 2 version
from urllib import urlretrieve
try:
# Rename raw_input to input to support Python 2
input = raw_input
except NameError:
# Python 3 doesn't have raw_input
pass
AZ_DISPATCH_TEMPLATE = """#!/usr/bin/env python
import os
import sys
from subprocess import check_call, CalledProcessError
ENVIRONMENT_NAME = os.environ.get('AZURE_CLI_ENVIRONMENT_NAME') or '{environment_name}'
PATH_TO_PYTHON = os.path.join('{install_location}', '{envs_dir_name}', ENVIRONMENT_NAME, '{bin_dir_name}', 'python')
try:
check_call([PATH_TO_PYTHON, '-m', 'azure.cli'] + sys.argv[1:])
except CalledProcessError as err:
sys.exit(err.returncode)
"""
DEFAULT_INSTALL_LOCATION = os.path.join(os.path.sep, 'usr', 'local', 'az')
DEFAULT_EXEC_FILENAME = os.path.join(os.path.sep, 'usr', 'local', 'bin', 'az')
VIRTUALENV_VERSION = '15.0.0'
BIN_DIR_NAME = 'Scripts' if platform.system() == 'Windows' else 'bin'
ENVS_DIR_NAME = 'envs'
DEFAULT_ENVIRONMENT_NAME = 'default'
DISABLE_PROMPTS = os.environ.get('AZURE_CLI_DISABLE_PROMPTS')
PACKAGE_VERSION = os.environ.get('AZURE_CLI_PACKAGE_VERSION')
PRIVATE_PYPI_URL = os.environ.get('AZURE_CLI_PRIVATE_PYPI_URL')
PRIVATE_PYPI_HOST = os.environ.get('AZURE_CLI_PRIVATE_PYPI_HOST')
def exec_command(command, cwd=None, env=None):
print('Executing: '+command)
command_list = command if isinstance(command, list) else command.split()
check_call(command_list, cwd=cwd, env=env)
def create_tmp_dir():
return tempfile.mkdtemp()
def create_dir(directory):
if not os.path.isdir(directory):
os.makedirs(directory)
def create_virtualenv(tmp_dir, version, install_dir):
file_name = 'virtualenv-'+version+'.tar.gz'
download_location = os.path.join(tmp_dir, file_name)
downloaded_file, _ = urlretrieve('https://pypi.python.org/packages/source/v/virtualenv/'+file_name,
download_location)
package_tar = tarfile.open(downloaded_file)
package_tar.extractall(path=tmp_dir)
package_tar.close()
virtualenv_dir_name = 'virtualenv-'+version
working_dir = os.path.join(tmp_dir, virtualenv_dir_name)
exec_command('{0} virtualenv.py --python {0} {1}'.format(sys.executable, install_dir), cwd=working_dir)
def get_pip_install_command(module_name, path_to_pip):
version = '==' + PACKAGE_VERSION if PACKAGE_VERSION else ''
param_extra_index_url = '--extra-index-url '+PRIVATE_PYPI_URL if PRIVATE_PYPI_URL else ''
param_trusted_host = '--trusted-host '+PRIVATE_PYPI_HOST if PRIVATE_PYPI_HOST else ''
return '{pip} install {module_name}{version} {param_extra_index_url} {param_trusted_host}'.format(
pip=path_to_pip,
module_name=module_name,
version=version,
param_extra_index_url=param_extra_index_url,
param_trusted_host=param_trusted_host,
)
def install_cli(install_dir):
path_to_pip = os.path.join(install_dir, BIN_DIR_NAME, 'pip')
exec_command(get_pip_install_command('azure-cli', path_to_pip),
env=dict(os.environ, AZURE_CLI_DISABLE_POST_INSTALL='1'))
modules_to_install = ['azure-cli-component', 'azure-cli-profile', 'azure-cli-storage',
'azure-cli-vm', 'azure-cli-network', 'azure-cli-resource',
'azure-cli-taskhelp']
for module_name in modules_to_install:
exec_command(get_pip_install_command(module_name, path_to_pip))
def create_executable(exec_filename, install_location, environment_name):
exec_dir = os.path.dirname(exec_filename)
create_dir(exec_dir)
with open(exec_filename, 'w') as exec_file:
exec_file.write(AZ_DISPATCH_TEMPLATE.format(
install_location=install_location,
environment_name=environment_name,
envs_dir_name=ENVS_DIR_NAME,
bin_dir_name=BIN_DIR_NAME))
cur_stat = os.stat(exec_filename)
os.chmod(exec_filename, cur_stat.st_mode | stat.S_IEXEC)
def prompt_input(message):
return None if DISABLE_PROMPTS else input(message)
def verify_executable_overwrite(exec_filename):
if os.path.isfile(exec_filename):
ans = prompt_input("'{}' exists! Overwrite? [y/n]: ".format(exec_filename))
if ans and ans.lower() != 'y':
return False
return True
def get_install_location():
prompt_message = 'Where would you like to install? (default {}): '.format(DEFAULT_INSTALL_LOCATION)
install_location = prompt_input(prompt_message) or DEFAULT_INSTALL_LOCATION
install_location = os.path.expanduser(install_location)
print("We will install at '{}'.".format(install_location))
return install_location
def get_exec_filename():
prompt_message = 'Where would you like to place the executable? (default {}): '.format(DEFAULT_EXEC_FILENAME)
exec_filename = prompt_input(prompt_message) or DEFAULT_EXEC_FILENAME
exec_filename = os.path.expanduser(exec_filename)
exec_filename = os.path.realpath(exec_filename)
print("The executable will be '{}'.".format(exec_filename))
return exec_filename
def get_environment_name():
return os.environ.get('AZURE_CLI_ENVIRONMENT_NAME') or DEFAULT_ENVIRONMENT_NAME
def main():
tmp_dir = create_tmp_dir()
install_location = get_install_location()
exec_filename = get_exec_filename()
if not verify_executable_overwrite(exec_filename):
print("Installation cancelled.")
sys.exit(1)
environment_name = get_environment_name()
env_dir = os.path.join(install_location, ENVS_DIR_NAME, environment_name)
create_dir(env_dir)
create_virtualenv(tmp_dir, VIRTUALENV_VERSION, env_dir)
install_cli(env_dir)
create_executable(exec_filename, install_location, environment_name)
print("Installation successful.")
print("Run the CLI with {} --help".format(exec_filename))
if __name__ == '__main__':
main()

Просмотреть файл

@ -1,4 +1,5 @@
from __future__ import print_function
import argparse
import sys
import textwrap
import yaml
@ -10,9 +11,27 @@ __all__ = ['print_detailed_help', 'print_welcome_message', 'GroupHelpFile', 'Com
_out = sys.stdout
def print_welcome_message(out=sys.stdout):
global _out #pylint: disable=global-statement
_out = out
def show_help(nouns, parser, is_group):
delimiters = ' '.join(nouns)
help_file = CommandHelpFile(delimiters, parser) \
if not is_group \
else GroupHelpFile(delimiters, parser)
help_file.load(parser)
if len(nouns) == 0:
print('\nSpecial intro help for az')
help_file.command = 'az'
print_detailed_help(help_file)
def show_welcome(parser):
print_welcome_message()
help_file = GroupHelpFile('', parser)
print_description_list(help_file.children)
def print_welcome_message():
_print_indent(L(r"""
/\
/ \ _____ _ _ __ ___
@ -43,7 +62,7 @@ def print_description_list(help_files, out=sys.stdout):
indent = 1
max_name_length = max(len(f.name) for f in help_files) if help_files else 0
for help_file in help_files:
for help_file in sorted(help_files, key=lambda h: h.name):
_print_indent('{0}{1}{2}'.format(help_file.name,
_get_column_indent(help_file.name, max_name_length),
': ' + help_file.short_summary \
@ -61,14 +80,15 @@ def print_arguments(help_file):
if len(help_file.parameters) == 0:
_print_indent('none', indent)
required_tag = L(' [Required]')
max_name_length = max(len(p.name) + 11 if p.required else 0 for p in help_file.parameters)
for p in help_file.parameters:
max_name_length = max(len(p.name) + (len(required_tag) if p.required else 0)
for p in help_file.parameters)
for p in sorted(help_file.parameters, key=lambda p: str(not p.required) + p.name):
indent = 1
required_text = required_tag if p.required else ''
_print_indent('{0}{1}{2}{3}'.format(p.name,
required_text,
_get_column_indent(p.name + required_text,
max_name_length),
required_text,
': ' + p.short_summary if p.short_summary else ''),
indent,
max_name_length + indent*4 + 2)
@ -80,29 +100,34 @@ def print_arguments(help_file):
if p.value_sources:
_print_indent('')
_print_indent(L("Values from: {0}").format(', '.join(p.value_sources)), indent)
_print_indent('')
return indent
def _print_header(help_file):
indent = 0
_print_indent('')
_print_indent(L('Command') if help_file.type == 'command' else L('Group'), indent)
indent += 1
_print_indent('{0}{1}'.format(help_file.command,
': ' + help_file.short_summary
if help_file.short_summary
else ''),
indent)
indent = 1
indent += 1
if help_file.long_summary:
_print_indent('{0}'.format(help_file.long_summary.rstrip()), indent)
_print_indent('')
def _print_groups(help_file):
indent = 1
for c in help_file.children:
_print_indent('{0}{1}'.format(c.name,
': ' + c.short_summary if c.short_summary else ''),
max_name_length = max(len(c.name) for c in help_file.children) \
if len(help_file.children) > 0 \
else 0
for c in sorted(help_file.children, key=lambda h: h.name):
_print_indent('{0}{1}{2}'.format(c.name,
_get_column_indent(c.name, max_name_length),
': ' + c.short_summary if c.short_summary else ''),
indent)
_print_indent('')
@ -121,16 +146,19 @@ def _print_examples(help_file):
class HelpFile(object): #pylint: disable=too-few-public-methods
def __init__(self, delimiters):
self.delimiters = delimiters
self.name = delimiters.split('.')[-1]
self.command = delimiters.replace('.', ' ')
self.name = delimiters.split()[-1] if len(delimiters) > 0 else delimiters
self.command = delimiters
self.type = ''
self.short_summary = ''
self.long_summary = ''
self.examples = ''
def load(self, noun_map):
self.short_summary = noun_map.get('$description', '')
file_data = _load_help_file_from_string(noun_map.get('$doctext', None))
def load(self, options):
self.short_summary = getattr(options, 'description', None)
file_data = (_load_help_file_from_string(options.help_file)
if hasattr(options, '_defaults')
else None)
if file_data:
self._load_from_data(file_data)
else:
@ -162,27 +190,28 @@ class HelpFile(object): #pylint: disable=too-few-public-methods
class GroupHelpFile(HelpFile): #pylint: disable=too-few-public-methods
def __init__(self, delimiters, child_names):
def __init__(self, delimiters, parser):
super(GroupHelpFile, self).__init__(delimiters)
self.type = 'group'
self.children = [HelpFile('{0}.{1}'.format(self.delimiters, n)) for n in child_names]
def _load_from_data(self, data):
super(GroupHelpFile, self)._load_from_data(data)
child_helps = [GroupHelpFile(child.delimiters, []) for child in self.children]
loaded_children = []
for child in self.children:
child_help = next((h for h in child_helps if h.name == child.name), None)
loaded_children.append(child_help if child_help else child)
self.children = loaded_children
self.children = []
for options in parser.choices.values():
delimiters = ' '.join(options.prog.split()[1:])
child = HelpFile(delimiters)
child.load(options)
self.children.append(child)
class CommandHelpFile(HelpFile): #pylint: disable=too-few-public-methods
def __init__(self, delimiters, argdoc):
def __init__(self, delimiters, parser):
super(CommandHelpFile, self).__init__(delimiters)
self.type = 'command'
self.parameters = [HelpParameter(a, d, r) for a, d, r in argdoc]
self.parameters = []
for action in [a for a in parser._actions if a.help != argparse.SUPPRESS]: # pylint: disable=protected-access
self.parameters.append(HelpParameter('/'.join(sorted(action.option_strings)),
action.help,
required=action.required))
def _load_from_data(self, data):
super(CommandHelpFile, self)._load_from_data(data)
@ -238,7 +267,6 @@ class HelpExample(object): #pylint: disable=too-few-public-methods
self.name = _data['name']
self.text = _data['text']
def _print_indent(s, indent=0, subsequent_spaces=-1):
tw = textwrap.TextWrapper(initial_indent=' '*indent,
subsequent_indent=(' '*indent
@ -259,5 +287,9 @@ def _load_help_file_from_string(text):
except Exception: #pylint: disable=broad-except
return text
def _get_single_metadata(cmd_table):
assert len(cmd_table) == 1
return next(metadata for _, metadata in cmd_table.items())
class HelpAuthoringException(Exception):
pass

Просмотреть файл

@ -1,80 +1,17 @@
import yaml
helps = {'test_group1 test_group2': """
type: group
short-summary: this module does xyz one-line or so
long-summary: |
this module.... kjsdflkj... klsfkj paragraph1
this module.... kjsdflkj... klsfkj paragraph2
examples:
- name: foo example
text: example details
"""
}
def _load_help_file(delimiters):
helps = {'test_group1.test_group2': """
type: group
short-summary: this module does xyz one-line or so
long-summary: |
this module.... kjsdflkj... klsfkj paragraph1
this module.... kjsdflkj... klsfkj paragraph2
examples:
- name: foo example
text: example details
""",
'login': """
type: command
short-summary: this module does xyz one-line or so
long-summary: |
this module.... kjsdflkj... klsfkj paragraph1
this module.... kjsdflkj... klsfkj paragraph2
parameters:
- name: --username/-u
type: string
required: False
short-summary: one line partial sentence
long-summary: text, markdown, etc.
populator-commands:
- az vm list
- default
- name: --service-principal
type: string
short-summary: one line partial sentence, except that this one is a little bit longer than one line, how do we handle line wrapping?
long-summary: |
paragraph(s)
paragraph(s)
This is a long paragraph with text that wraps down to the next line. The text is broken up by the wrap method after 100 chars.
- name: --tenant/-t
type: string
short-summary: one line partial sentence
long-summary: paragraph(s)
examples:
- name: foo example
text: example details
""",
'account': """
type: group
short-summary: this module does xyz one-line or so
long-summary: |
this module.... kjsdflkj... klsfkj paragraph1
this module.... kjsdflkj... klsfkj paragraph2
parameters:
- name: --username/-u
type: string
required: false
short-summary: one line partial sentence
long-summary: text, markdown, etc.
populator-commands:
- az vm list
- default
- name: --password/-p
type: string
short-summary: one line partial sentence
long-summary: paragraph(s)
- name: --service-principal
type: string
short-summary: one line partial sentence
long-summary: paragraph(s)
- name: --tenant/-t
type: string
short-summary: one line partial sentence
long-summary: paragraph(s)
examples:
- name: foo example
text: example details
""",
'azure-cli': 'detailed intro help'
}
if delimiters in helps:
return yaml.load(helps[delimiters])
else:

Просмотреть файл

@ -7,6 +7,7 @@ import logging
from enum import Enum
from .parser import AzCliCommandParser
import azure.cli.extensions
import azure.cli._help as _help
class Configuration(object): # pylint: disable=too-few-public-methods
"""The configuration object tracks session specific data such
@ -56,11 +57,16 @@ class Application(object):
self.parser = AzCliCommandParser(prog='az', parents=[self.global_parser])
self.raise_event(self.COMMAND_PARSER_CREATED, self.parser)
def load_commands(self):
self.parser.load_command_table(self.configuration.get_command_table())
def execute(self, argv):
command_table = self.configuration.get_command_table()
self.parser.load_command_table(command_table)
self.raise_event(self.COMMAND_PARSER_LOADED, self.parser)
def execute(self, argv):
if len(argv) == 0:
az_subparser = self.parser.subparsers[tuple()]
_help.show_welcome(az_subparser)
return None
args = self.parser.parse_args(argv)
self.raise_event(self.COMMAND_PARSER_PARSED, args)
@ -130,7 +136,8 @@ class Application(object):
def _register_builtin_arguments(parser):
parser.add_argument('--subscription', dest='_subscription_id', help=argparse.SUPPRESS)
parser.add_argument('--output', '-o', dest='_output_format',
choices=['list', 'json', 'tsv'])
choices=['list', 'json', 'tsv'],
help='Output format of type "list", "json" or "tsv"')
def _handle_builtin_arguments(self, args):
self.configuration.output_format = args._output_format #pylint: disable=protected-access

Просмотреть файл

@ -1,6 +1,7 @@
from __future__ import print_function
import sys
import time
import random
from importlib import import_module
from collections import defaultdict, OrderedDict
from pip import get_installed_distributions
@ -13,7 +14,7 @@ INSTALLED_COMMAND_MODULES = [dist.key.replace('azure-cli-', '')
COMMON_PARAMETERS = {
'resource_group_name': {
'name': '--resourcegroup -g',
'metavar': 'RESOURCE GROUP',
'metavar': 'RESOURCEGROUP',
'help': 'Name of resource group',
'required': True
},
@ -22,6 +23,13 @@ COMMON_PARAMETERS = {
'metavar': 'LOCATION',
'help': 'Location',
'required': True
},
'deployment_name': {
'name': '--deployment-name',
'metavar': 'DEPLOYMENTNAME',
'help': 'Name of the resource deployment',
'default': 'azurecli' + str(time.time()) + str(random.randint(0, 10000000)),
'required': False
}
}
@ -79,6 +87,12 @@ class CommandTable(defaultdict):
return func
return wrapper
def help(self, help_file):
def wrapper(func):
self[func]['help_file'] = help_file
return func
return wrapper
def option(self, name, **kwargs):
def wrapper(func):
opt = dict(kwargs)

Просмотреть файл

@ -1,12 +1,12 @@
from __future__ import print_function
import inspect
import sys
from msrest.paging import Paged
from msrest.exceptions import ClientException
from azure.cli.parser import IncorrectUsageError
from ..commands import COMMON_PARAMETERS
EXCLUDED_PARAMS = frozenset(['self', 'raw', 'custom_headers', 'operation_config'])
EXCLUDED_PARAMS = frozenset(['self', 'raw', 'custom_headers', 'operation_config',
'content_version'])
class AutoCommandDefinition(object): #pylint: disable=too-few-public-methods
@ -47,13 +47,10 @@ def _make_func(client_factory, member_path, return_type_or_func, unbound_func):
if isinstance(return_type_or_func, str):
return list(result) if isinstance(result, Paged) else result
except TypeError as exception:
# TODO: Evaluate required/missing parameters and provide specific
# usage for missing params...
raise IncorrectUsageError(exception)
except ClientException as client_exception:
# TODO: Better error handling for cloud exceptions...
message = getattr(client_exception, 'message', client_exception)
print(message, file=sys.stderr)
raise RuntimeError(message)
return call_client
@ -71,13 +68,9 @@ def build_operation(command_name,
client_type,
operations,
command_table,
common_parameters=None,
custom_parameters=None,
extra_parameters=None):
merged_common_parameters = COMMON_PARAMETERS.copy()
merged_common_parameters.update(common_parameters or {})
extra_parameters = extra_parameters or {}
for op in operations:
func = _make_func(client_type, member_path, op.return_type, op.operation)
@ -96,29 +89,40 @@ def build_operation(command_name,
try:
# this works in python3
default = args[arg].default
required = default == inspect.Parameter.empty # pylint: disable=no-member
required = default == inspect.Parameter.empty #pylint: disable=no-member
except TypeError:
arg_defaults = dict(zip(sig.args[-len(sig.defaults):], sig.defaults))
default = arg_defaults.get(arg)
required = arg not in arg_defaults
action = 'store_' + str(not default).lower() if isinstance(default, bool) else None
common_param = merged_common_parameters.get(arg, {
try:
default = (default
if default != inspect._empty #pylint: disable=protected-access, no-member
else None)
except AttributeError:
pass
parameter = {
'name': '--' + arg.replace('_', '-'),
'required': required,
'default': default,
'dest': arg,
'help': _option_description(op.operation, arg),
'action': action
}).copy() # We need to make a copy to allow consumers to mutate the value
# retrieved from the common parameters without polluting future
# use...
common_param['dest'] = common_param.get('dest', arg)
options.append(common_param)
}
parameter.update(COMMON_PARAMETERS.get(arg, {}))
if custom_parameters:
parameter.update(custom_parameters.get(arg, {}))
options.append(parameter)
# append any 'extra' args needed (for example to obtain a client) that aren't required
# by the SDK.
for arg in extra_parameters.values():
options.append(arg.copy())
if extra_parameters:
for arg in extra_parameters.values():
options.append(arg.copy())
command_table[func] = {
'name': ' '.join([command_name, op.opname]),

Просмотреть файл

@ -34,7 +34,6 @@ def main(args, file=sys.stdout): #pylint: disable=redefined-builtin
config = Configuration(args)
app = Application(config)
app.load_commands()
try:
cmd_result = app.execute(args)
# Commands can return a dictionary/list of results

Просмотреть файл

@ -1,4 +1,5 @@
import argparse
import azure.cli._help as _help
class IncorrectUsageError(Exception):
'''Raised when a command is incorrectly used and the usage should be
@ -11,9 +12,10 @@ class AzCliCommandParser(argparse.ArgumentParser):
Azure CLI utility.
"""
def __init__(self, **kwargs):
super(AzCliCommandParser, self).__init__(**kwargs)
self.subparsers = {}
self.parents = kwargs.get('parents', [])
self.help_file = kwargs.pop('help_file', None)
super(AzCliCommandParser, self).__init__(**kwargs)
def load_command_table(self, command_table):
"""Load a command table into our parser.
@ -33,7 +35,8 @@ class AzCliCommandParser(argparse.ArgumentParser):
subparser.choices[command_name] = command_name
command_parser = subparser.add_parser(command_name,
description=metadata.get('description'),
parents=self.parents, conflict_handler='resolve')
parents=self.parents, conflict_handler='resolve',
help_file=metadata.get('help_file'))
for arg in metadata['arguments']:
names = arg.get('name').split()
command_parser.add_argument(*names, **{k:v for k, v in arg.items() if k != 'name'})
@ -63,3 +66,12 @@ class AzCliCommandParser(argparse.ArgumentParser):
parent_subparser.required = True
self.subparsers[tuple(path[0:length])] = parent_subparser
return parent_subparser
def format_help(self):
is_group = not self._defaults.get('func')
_help.show_help(self.prog.split()[1:],
(self._actions[-1]
if is_group
else self),
is_group)
self.exit()

Просмотреть файл

@ -1,3 +1,4 @@
import time
from azure.mgmt.network import NetworkManagementClient, NetworkManagementClientConfiguration
from azure.mgmt.network.operations import (ApplicationGatewaysOperations,
ExpressRouteCircuitAuthorizationsOperations,
@ -18,9 +19,14 @@ from azure.mgmt.network.operations import (ApplicationGatewaysOperations,
VirtualNetworkGatewaysOperations,
VirtualNetworksOperations)
from azure.cli.command_modules.network.mgmt.lib import (ResourceManagementClient as VNetClient,
ResourceManagementClientConfiguration
as VNetClientConfig)
from azure.cli.command_modules.network.mgmt.lib.operations import VNetOperations
from azure.cli.commands._command_creation import get_mgmt_service_client
from azure.cli.commands._auto_command import build_operation, AutoCommandDefinition
from azure.cli.commands import CommandTable, LongRunningOperation
from azure.cli.commands import CommandTable, LongRunningOperation, COMMON_PARAMETERS
from azure.cli._locale import L
command_table = CommandTable()
@ -28,7 +34,6 @@ command_table = CommandTable()
def _network_client_factory(_):
return get_mgmt_service_client(NetworkManagementClient, NetworkManagementClientConfiguration)
# pylint: disable=line-too-long
# Application gateways
build_operation("network appgateway",
@ -245,34 +250,43 @@ build_operation("network vnet",
],
command_table)
@command_table.command('network vnet create')
@command_table.description(L('Create or update a virtual network (VNet)'))
@command_table.option('--resource-group -g', help=L('the resource group name'), required=True)
@command_table.option('--name -n', help=L('the VNet name'), required=True)
@command_table.option('--location -l', help=L('the VNet location'), required=True)
@command_table.option('--address-space -a', metavar='ADDRESS SPACE', help=L('the VNet address-space in CIDR notation or multiple address-spaces, quoted and space-separated'), required=True)
@command_table.option('--dns-servers -d', metavar='DNS SERVERS', help=L('the VNet DNS servers, quoted and space-separated'))
def create_update_vnet(args):
from azure.mgmt.network.models import AddressSpace, DhcpOptions, VirtualNetwork
# BUG: we are waiting on autorest to support this rename (https://github.com/Azure/autorest/issues/941)
VNET_SPECIFIC_PARAMS = {
'deployment_parameter_virtual_network_name_value': {
'name': '--vnet-name',
'metavar': 'VNETNAME',
},
'deployment_parameter_virtual_network_prefix_value': {
'name': '--vnet-prefix',
'metavar': 'VNETPREFIX',
},
'deployment_parameter_subnet_name_value': {
'name': '--subnet-name',
'metavar': 'SUBNETNAME',
},
'deployment_parameter_subnet_prefix_value': {
'name': '--subnet-prefix',
'metavar': 'SUBNETPREFIX',
},
'deployment_parameter_location_value': {
'name': '--location',
'metavar': 'LOCATION',
}
}
resource_group = args.get('resource_group')
name = args.get('name')
location = args.get('location')
address_space = AddressSpace(address_prefixes=args.get('address_space').split())
dhcp_options = DhcpOptions(dns_servers=args.get('dns_servers').split())
vnet_settings = VirtualNetwork(location=location,
address_space=address_space,
dhcp_options=dhcp_options)
op = LongRunningOperation('Creating virtual network', 'Virtual network created')
smc = _network_client_factory({})
poller = smc.virtual_networks.create_or_update(resource_group, name, vnet_settings)
return op(poller)
build_operation('network vnet',
'vnet',
lambda _: get_mgmt_service_client(VNetClient, VNetClientConfig),
[
AutoCommandDefinition(VNetOperations.create,
LongRunningOperation(L('Creating virtual network'), L('Virtual network created')))
],
command_table,
VNET_SPECIFIC_PARAMS)
@command_table.command('network subnet create')
@command_table.description(L('Create or update a virtual network (VNet) subnet'))
@command_table.option('--resource-group -g', help=L('the the resource group name'), required=True)
@command_table.option(**COMMON_PARAMETERS['resource_group_name'])
@command_table.option('--name -n', help=L('the the subnet name'), required=True)
@command_table.option('--vnet -v', help=L('the name of the subnet vnet'), required=True)
@command_table.option('--address-prefix -a', help=L('the the address prefix in CIDR format'), required=True)

Просмотреть файл

@ -0,0 +1,3 @@
#pylint: skip-file
import pkg_resources
pkg_resources.declare_namespace(__name__)

Просмотреть файл

@ -0,0 +1,79 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"virtualNetworkName": {
"type": "string",
"metadata": {
"description": "Name of the virtual network."
}
},
"virtualNetworkPrefix": {
"type": "string",
"defaultValue": "10.0.0.0/16",
"metadata": {
"description": "IP address prefix for the virtual network."
}
},
"subnetName": {
"type": "string",
"defaultValue": "Subnet1",
"metadata": {
"description": "Name of the subnet."
}
},
"subnetPrefix": {
"type": "string",
"defaultValue": "10.0.0.0/24",
"metadata": {
"description": "IP address for the subnet."
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Virtual network location."
}
}
},
"variables": {
"NewVNetName": "[parameters('virtualNetworkName')]",
"NewVNetPrefix": "[parameters('virtualNetworkPrefix')]",
"NewVNetSubnet1Name": "[parameters('subnetName')]",
"NewVNetSubnet1Prefix": "[parameters('subnetPrefix')]"
},
"resources": [
{
"name": "[variables('NewVNetName')]",
"type": "Microsoft.Network/virtualNetworks",
"location": "[parameters('location')]",
"apiVersion": "2015-06-15",
"dependsOn": [ ],
"tags": {
"displayName": "NewVNet"
},
"properties": {
"addressSpace": {
"addressPrefixes": [
"[variables('NewVNetPrefix')]"
]
},
"subnets": [
{
"name": "[variables('NewVNetSubnet1Name')]",
"properties": {
"addressPrefix": "[variables('NewVNetSubnet1Prefix')]"
}
}
]
}
}
],
"outputs": {
"NewVNet": {
"type": "object",
"value": "[reference(variables('NewVNetName'))]"
}
}
}

Просмотреть файл

@ -0,0 +1,18 @@
#pylint: skip-file
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator 0.15.0.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from .resource_management_client import ResourceManagementClient, ResourceManagementClientConfiguration
from .version import VERSION
__all__ = [
'ResourceManagementClient',
'ResourceManagementClientConfiguration'
]
__version__ = VERSION

Просмотреть файл

@ -0,0 +1,17 @@
#pylint: skip-file
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator 0.15.0.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from msrest.authentication import (
BasicAuthentication,
BasicTokenAuthentication,
OAuthTokenAuthentication)
from msrestazure.azure_active_directory import (
InteractiveCredentials,
ServicePrincipalCredentials,
UserPassCredentials)

Просмотреть файл

@ -0,0 +1,20 @@
#pylint: skip-file
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator 0.15.0.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from msrest.exceptions import (
ClientException,
SerializationError,
DeserializationError,
TokenExpiredError,
ClientRequestError,
AuthenticationError,
HttpOperationError,
ValidationError,
)
from msrestazure.azure_exceptions import CloudError

Просмотреть файл

@ -0,0 +1,33 @@
#pylint: skip-file
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator 0.15.0.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from .deployment_vnet import DeploymentVNet
from .template_link import TemplateLink
from .parameters_link import ParametersLink
from .provider_resource_type import ProviderResourceType
from .provider import Provider
from .basic_dependency import BasicDependency
from .dependency import Dependency
from .deployment_properties_extended import DeploymentPropertiesExtended
from .deployment_extended import DeploymentExtended
from .resource_management_client_enums import (
DeploymentMode,
)
__all__ = [
'DeploymentVNet',
'TemplateLink',
'ParametersLink',
'ProviderResourceType',
'Provider',
'BasicDependency',
'Dependency',
'DeploymentPropertiesExtended',
'DeploymentExtended',
'DeploymentMode',
]

Просмотреть файл

@ -0,0 +1,30 @@
#pylint: skip-file
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator 0.15.0.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from msrest.serialization import Model
class BasicDependency(Model):
"""
Deployment dependency information.
:param str id: Gets or sets the ID of the dependency.
:param str resource_type: Gets or sets the dependency resource type.
:param str resource_name: Gets or sets the dependency resource name.
"""
_attribute_map = {
'id': {'key': 'id', 'type': 'str'},
'resource_type': {'key': 'resourceType', 'type': 'str'},
'resource_name': {'key': 'resourceName', 'type': 'str'},
}
def __init__(self, id=None, resource_type=None, resource_name=None, **kwargs):
self.id = id
self.resource_type = resource_type
self.resource_name = resource_name

Просмотреть файл

@ -0,0 +1,33 @@
#pylint: skip-file
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator 0.15.0.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from msrest.serialization import Model
class Dependency(Model):
"""
Deployment dependency information.
:param list depends_on: Gets the list of dependencies.
:param str id: Gets or sets the ID of the dependency.
:param str resource_type: Gets or sets the dependency resource type.
:param str resource_name: Gets or sets the dependency resource name.
"""
_attribute_map = {
'depends_on': {'key': 'dependsOn', 'type': '[BasicDependency]'},
'id': {'key': 'id', 'type': 'str'},
'resource_type': {'key': 'resourceType', 'type': 'str'},
'resource_name': {'key': 'resourceName', 'type': 'str'},
}
def __init__(self, depends_on=None, id=None, resource_type=None, resource_name=None, **kwargs):
self.depends_on = depends_on
self.id = id
self.resource_type = resource_type
self.resource_name = resource_name

Просмотреть файл

@ -0,0 +1,35 @@
#pylint: skip-file
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator 0.15.0.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from msrest.serialization import Model
class DeploymentExtended(Model):
"""
Deployment information.
:param str id: Gets or sets the ID of the deployment.
:param str name: Gets or sets the name of the deployment.
:param DeploymentPropertiesExtended properties: Gets or sets deployment
properties.
"""
_validation = {
'name': {'required': True},
}
_attribute_map = {
'id': {'key': 'id', 'type': 'str'},
'name': {'key': 'name', 'type': 'str'},
'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'},
}
def __init__(self, name, id=None, properties=None, **kwargs):
self.id = id
self.name = name
self.properties = properties

Просмотреть файл

@ -0,0 +1,63 @@
#pylint: skip-file
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator 0.15.0.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from msrest.serialization import Model
class DeploymentPropertiesExtended(Model):
"""
Deployment properties with additional details.
:param str provisioning_state: Gets or sets the state of the provisioning.
:param str correlation_id: Gets or sets the correlation ID of the
deployment.
:param datetime timestamp: Gets or sets the timestamp of the template
deployment.
:param object outputs: Gets or sets key/value pairs that represent
deploymentoutput.
:param list providers: Gets the list of resource providers needed for the
deployment.
:param list dependencies: Gets the list of deployment dependencies.
:param object template: Gets or sets the template content. Use only one
of Template or TemplateLink.
:param TemplateLink template_link: Gets or sets the URI referencing the
template. Use only one of Template or TemplateLink.
:param object parameters: Deployment parameters. Use only one of
Parameters or ParametersLink.
:param ParametersLink parameters_link: Gets or sets the URI referencing
the parameters. Use only one of Parameters or ParametersLink.
:param str mode: Gets or sets the deployment mode. Possible values
include: 'Incremental', 'Complete'
"""
_attribute_map = {
'provisioning_state': {'key': 'provisioningState', 'type': 'str'},
'correlation_id': {'key': 'correlationId', 'type': 'str'},
'timestamp': {'key': 'timestamp', 'type': 'iso-8601'},
'outputs': {'key': 'outputs', 'type': 'object'},
'providers': {'key': 'providers', 'type': '[Provider]'},
'dependencies': {'key': 'dependencies', 'type': '[Dependency]'},
'template': {'key': 'template', 'type': 'object'},
'template_link': {'key': 'TemplateLink', 'type': 'TemplateLink'},
'parameters': {'key': 'parameters', 'type': 'object'},
'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'},
'mode': {'key': 'mode', 'type': 'DeploymentMode'},
}
def __init__(self, provisioning_state=None, correlation_id=None, timestamp=None, outputs=None, providers=None, dependencies=None, template=None, template_link=None, parameters=None, parameters_link=None, mode=None, **kwargs):
self.provisioning_state = provisioning_state
self.correlation_id = correlation_id
self.timestamp = timestamp
self.outputs = outputs
self.providers = providers
self.dependencies = dependencies
self.template = template
self.template_link = template_link
self.parameters = parameters
self.parameters_link = parameters_link
self.mode = mode

Просмотреть файл

@ -0,0 +1,62 @@
#pylint: skip-file
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator 0.15.0.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from msrest.serialization import Model
class DeploymentVNet(Model):
"""
Deployment operation parameters.
:param str uri: URI referencing the template. Default value:
"https://azuretemplatehost.blob.core.windows.net/templatehost/CreateVNet/azuredeploy.json"
.
:param str content_version: If included it must match the ContentVersion
in the template.
:param str deployment_parameter_virtual_network_prefix_value: IP address
prefix for the virtual network.
:param str deployment_parameter_subnet_prefix_value: IP address prefix
for the subnet.
:param str deployment_parameter_virtual_network_name_value: Name of the
virtual network.
:param str deployment_parameter_subnet_name_value: Name of the subnet.
:param str deployment_parameter_location_value: Location of the virtual
network.
:param str mode: Gets or sets the deployment mode. Default value:
"Incremental" .
"""
_validation = {
'uri': {'required': True},
'deployment_parameter_virtual_network_prefix_value': {'pattern': '^[\d\./]+$'},
'deployment_parameter_subnet_prefix_value': {'pattern': '^[\d\./]+$'},
'deployment_parameter_virtual_network_name_value': {'max_length': 80, 'min_length': 2, 'pattern': '^[-\w\._]+$'},
'deployment_parameter_subnet_name_value': {'max_length': 80, 'min_length': 2, 'pattern': '^[-\w\._]+$'},
'mode': {'required': True},
}
_attribute_map = {
'uri': {'key': 'properties.templateLink.uri', 'type': 'str'},
'content_version': {'key': 'properties.templateLink.contentVersion', 'type': 'str'},
'deployment_parameter_virtual_network_prefix_value': {'key': 'properties.parameters.virtualNetworkPrefix.value', 'type': 'str'},
'deployment_parameter_subnet_prefix_value': {'key': 'properties.parameters.subnetPrefix.value', 'type': 'str'},
'deployment_parameter_virtual_network_name_value': {'key': 'properties.parameters.virtualNetworkName.value', 'type': 'str'},
'deployment_parameter_subnet_name_value': {'key': 'properties.parameters.subnetName.value', 'type': 'str'},
'deployment_parameter_location_value': {'key': 'properties.parameters.location.value', 'type': 'str'},
'mode': {'key': 'properties.mode', 'type': 'str'},
}
def __init__(self, content_version=None, deployment_parameter_virtual_network_prefix_value=None, deployment_parameter_subnet_prefix_value=None, deployment_parameter_virtual_network_name_value=None, deployment_parameter_subnet_name_value=None, deployment_parameter_location_value=None, **kwargs):
self.uri = "https://azuretemplatehost.blob.core.windows.net/templatehost/CreateVNet/azuredeploy.json"
self.content_version = content_version
self.deployment_parameter_virtual_network_prefix_value = deployment_parameter_virtual_network_prefix_value
self.deployment_parameter_subnet_prefix_value = deployment_parameter_subnet_prefix_value
self.deployment_parameter_virtual_network_name_value = deployment_parameter_virtual_network_name_value
self.deployment_parameter_subnet_name_value = deployment_parameter_subnet_name_value
self.deployment_parameter_location_value = deployment_parameter_location_value
self.mode = "Incremental"

Просмотреть файл

@ -0,0 +1,32 @@
#pylint: skip-file
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator 0.15.0.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from msrest.serialization import Model
class ParametersLink(Model):
"""
Entity representing the reference to the deployment paramaters.
:param str uri: URI referencing the template.
:param str content_version: If included it must match the ContentVersion
in the template.
"""
_validation = {
'uri': {'required': True},
}
_attribute_map = {
'uri': {'key': 'uri', 'type': 'str'},
'content_version': {'key': 'contentVersion', 'type': 'str'},
}
def __init__(self, uri, content_version=None, **kwargs):
self.uri = uri
self.content_version = content_version

Просмотреть файл

@ -0,0 +1,35 @@
#pylint: skip-file
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator 0.15.0.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from msrest.serialization import Model
class Provider(Model):
"""
Resource provider information.
:param str id: Gets or sets the provider id.
:param str namespace: Gets or sets the namespace of the provider.
:param str registration_state: Gets or sets the registration state of the
provider.
:param list resource_types: Gets or sets the collection of provider
resource types.
"""
_attribute_map = {
'id': {'key': 'id', 'type': 'str'},
'namespace': {'key': 'namespace', 'type': 'str'},
'registration_state': {'key': 'registrationState', 'type': 'str'},
'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'},
}
def __init__(self, id=None, namespace=None, registration_state=None, resource_types=None, **kwargs):
self.id = id
self.namespace = namespace
self.registration_state = registration_state
self.resource_types = resource_types

Просмотреть файл

@ -0,0 +1,34 @@
#pylint: skip-file
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator 0.15.0.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from msrest.serialization import Model
class ProviderResourceType(Model):
"""
Resource type managed by the resource provider.
:param str resource_type: Gets or sets the resource type.
:param list locations: Gets or sets the collection of locations where
this resource type can be created in.
:param list api_versions: Gets or sets the api version.
:param dict properties: Gets or sets the properties.
"""
_attribute_map = {
'resource_type': {'key': 'resourceType', 'type': 'str'},
'locations': {'key': 'locations', 'type': '[str]'},
'api_versions': {'key': 'apiVersions', 'type': '[str]'},
'properties': {'key': 'properties', 'type': '{str}'},
}
def __init__(self, resource_type=None, locations=None, api_versions=None, properties=None, **kwargs):
self.resource_type = resource_type
self.locations = locations
self.api_versions = api_versions
self.properties = properties

Просмотреть файл

@ -0,0 +1,15 @@
#pylint: skip-file
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator 0.15.0.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from enum import Enum
class DeploymentMode(Enum):
incremental = "Incremental"
complete = "Complete"

Просмотреть файл

@ -0,0 +1,34 @@
#pylint: skip-file
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator 0.15.0.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from msrest.serialization import Model
class TemplateLink(Model):
"""
Entity representing the reference to the template.
:param str uri: URI referencing the template. Default value:
"https://azuretemplatehost.blob.core.windows.net/templatehost/CreateVNet/azuredeploy.json"
.
:param str content_version: If included it must match the ContentVersion
in the template.
"""
_validation = {
'uri': {'required': True},
}
_attribute_map = {
'uri': {'key': 'uri', 'type': 'str'},
'content_version': {'key': 'contentVersion', 'type': 'str'},
}
def __init__(self, content_version=None, **kwargs):
self.uri = "https://azuretemplatehost.blob.core.windows.net/templatehost/CreateVNet/azuredeploy.json"
self.content_version = content_version

Просмотреть файл

@ -0,0 +1,13 @@
#pylint: skip-file
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator 0.15.0.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from .vnet_operations import VNetOperations
__all__ = [
'VNetOperations',
]

Просмотреть файл

@ -0,0 +1,134 @@
#pylint: skip-file
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator 0.15.0.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from msrest.pipeline import ClientRawResponse
from msrestazure.azure_exceptions import CloudError
from msrestazure.azure_operation import AzureOperationPoller
import uuid
from .. import models
class VNetOperations(object):
"""VNetOperations operations.
:param client: Client for service requests.
:param config: Configuration of service client.
:param serializer: An object model serializer.
:param deserializer: An objec model deserializer.
"""
def __init__(self, client, config, serializer, deserializer):
self._client = client
self._serialize = serializer
self._deserialize = deserializer
self.config = config
def create(
self, resource_group_name, deployment_name, content_version=None, deployment_parameter_virtual_network_prefix_value=None, deployment_parameter_subnet_prefix_value=None, deployment_parameter_virtual_network_name_value=None, deployment_parameter_subnet_name_value=None, deployment_parameter_location_value=None, custom_headers={}, raw=False, **operation_config):
"""
Create a named template deployment using a template.
:param resource_group_name: The name of the resource group. The name
is case insensitive.
:type resource_group_name: str
:param deployment_name: The name of the deployment.
:type deployment_name: str
:param content_version: If included it must match the ContentVersion
in the template.
:type content_version: str
:param deployment_parameter_virtual_network_prefix_value: IP address
prefix for the virtual network.
:type deployment_parameter_virtual_network_prefix_value: str
:param deployment_parameter_subnet_prefix_value: IP address prefix
for the subnet.
:type deployment_parameter_subnet_prefix_value: str
:param deployment_parameter_virtual_network_name_value: Name of the
virtual network.
:type deployment_parameter_virtual_network_name_value: str
:param deployment_parameter_subnet_name_value: Name of the subnet.
:type deployment_parameter_subnet_name_value: str
:param deployment_parameter_location_value: Location of the virtual
network.
:type deployment_parameter_location_value: str
:param dict custom_headers: headers that will be added to the request
:param boolean raw: returns the direct response alongside the
deserialized response
:rtype: DeploymentExtended
:rtype: msrest.pipeline.ClientRawResponse if raw=True
"""
parameters = models.DeploymentVNet(content_version=content_version, deployment_parameter_virtual_network_prefix_value=deployment_parameter_virtual_network_prefix_value, deployment_parameter_subnet_prefix_value=deployment_parameter_subnet_prefix_value, deployment_parameter_virtual_network_name_value=deployment_parameter_virtual_network_name_value, deployment_parameter_subnet_name_value=deployment_parameter_subnet_name_value, deployment_parameter_location_value=deployment_parameter_location_value)
# Construct URL
url = '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'
path_format_arguments = {
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=64, min_length=1, pattern='^[-\w\._]+$'),
'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern='^[-\w\._]+$'),
'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {}
query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str')
# Construct headers
header_parameters = {}
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
if self.config.generate_client_request_id:
header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
if custom_headers:
header_parameters.update(custom_headers)
if self.config.accept_language is not None:
header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
# Construct body
body_content = self._serialize.body(parameters, 'DeploymentVNet')
# Construct and send request
def long_running_send():
request = self._client.put(url, query_parameters)
return self._client.send(
request, header_parameters, body_content, **operation_config)
def get_long_running_status(status_link, headers={}):
request = self._client.get(status_link)
request.headers.update(headers)
return self._client.send(
request, header_parameters, **operation_config)
def get_long_running_output(response):
if response.status_code not in [200, 201]:
exp = CloudError(response)
exp.request_id = response.headers.get('x-ms-request-id')
raise exp
deserialized = None
if response.status_code == 200:
deserialized = self._deserialize('DeploymentExtended', response)
if response.status_code == 201:
deserialized = self._deserialize('DeploymentExtended', response)
if raw:
client_raw_response = ClientRawResponse(deserialized, response)
return client_raw_response
return deserialized
long_running_operation_timeout = operation_config.get(
'long_running_operation_timeout',
self.config.long_running_operation_timeout)
return AzureOperationPoller(
long_running_send, get_long_running_output,
get_long_running_status, long_running_operation_timeout)

Просмотреть файл

@ -0,0 +1,87 @@
#pylint: skip-file
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator 0.15.0.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from msrest.service_client import ServiceClient
from msrest import Serializer, Deserializer
from msrestazure import AzureConfiguration
from .version import VERSION
from .operations.vnet_operations import VNetOperations
from . import models
class ResourceManagementClientConfiguration(AzureConfiguration):
"""Configuration for ResourceManagementClient
Note that all parameters used to create this instance are saved as instance
attributes.
:param credentials: Gets Azure subscription credentials.
:type credentials: credentials
:param subscription_id: Gets subscription credentials which uniquely
identify Microsoft Azure subscription. The subscription ID forms part of
the URI for every service call.
:type subscription_id: str
:param api_version: Client Api Version.
:type api_version: str
:param accept_language: Gets or sets the preferred language for the
response.
:type accept_language: str
:param long_running_operation_retry_timeout: Gets or sets the retry
timeout in seconds for Long Running Operations. Default value is 30.
:type long_running_operation_retry_timeout: int
:param generate_client_request_id: When set to true a unique
x-ms-client-request-id value is generated and included in each request.
Default is true.
:type generate_client_request_id: bool
:param str base_url: Service URL
:param str filepath: Existing config
"""
def __init__(
self, credentials, subscription_id, api_version='2015-11-01', accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None):
if credentials is None:
raise ValueError('credentials must not be None.')
if subscription_id is None:
raise ValueError('subscription_id must not be None.')
if not base_url:
base_url = 'https://management.azure.com'
super(ResourceManagementClientConfiguration, self).__init__(base_url, filepath)
self.add_user_agent('resourcemanagementclient/{}'.format(VERSION))
self.add_user_agent('Azure-SDK-For-Python')
self.credentials = credentials
self.subscription_id = subscription_id
self.api_version = api_version
self.accept_language = accept_language
self.long_running_operation_retry_timeout = long_running_operation_retry_timeout
self.generate_client_request_id = generate_client_request_id
class ResourceManagementClient(object):
"""ResourceManagementClient
:param config: Configuration for client.
:type config: ResourceManagementClientConfiguration
:ivar vnet: VNet operations
:vartype vnet: .operations.VNetOperations
"""
def __init__(self, config):
self._client = ServiceClient(config.credentials, config)
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer()
self._deserialize = Deserializer(client_models)
self.config = config
self.vnet = VNetOperations(
self._client, self.config, self._serialize, self._deserialize)

Просмотреть файл

@ -0,0 +1,10 @@
#pylint: skip-file
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator 0.15.0.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
VERSION = "2015-11-01"

Просмотреть файл

@ -0,0 +1,464 @@
{
"swagger": "2.0",
"info": {
"title": "ResourceManagementClient",
"version": "2015-11-01"
},
"host": "management.azure.com",
"schemes": [
"https"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"security": [
{
"azure_auth": [
"user_impersonation"
]
}
],
"securityDefinitions": {
"azure_auth": {
"type": "oauth2",
"authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize",
"flow": "implicit",
"description": "Azure Active Directory OAuth2 Flow",
"scopes": {
"user_impersonation": "impersonate your user account"
}
}
},
"paths": {
"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}": {
"put": {
"tags": [
"VNet"
],
"operationId": "VNet_Create",
"description": "Create a named template deployment using a template.",
"parameters": [
{
"name": "resourceGroupName",
"in": "path",
"required": true,
"type": "string",
"description": "The name of the resource group. The name is case insensitive.",
"pattern": "^[-\\w\\._]+$",
"minLength": 1,
"maxLength": 64
},
{
"name": "deploymentName",
"in": "path",
"required": true,
"type": "string",
"description": "The name of the deployment.",
"pattern": "^[-\\w\\._]+$",
"minLength": 1,
"maxLength": 64
},
{
"name": "parameters",
"x-ms-client-flatten": true,
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/Deployment_VNet"
},
"description": "Additional parameters supplied to the operation."
},
{
"$ref": "#/parameters/ApiVersionParameter"
},
{
"$ref": "#/parameters/SubscriptionIdParameter"
}
],
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/DeploymentExtended"
}
},
"201": {
"description": "",
"schema": {
"$ref": "#/definitions/DeploymentExtended"
}
}
},
"x-ms-long-running-operation": true
}
}
},
"definitions": {
"Deployment_VNet": {
"properties": {
"properties": {
"$ref": "#/definitions/DeploymentProperties_VNet",
"description": "Gets or sets the deployment properties.",
"x-ms-client-flatten": true
}
},
"required": [
"properties"
],
"description": "Deployment operation parameters."
},
"DeploymentProperties_VNet": {
"properties": {
"templateLink": {
"$ref": "#/definitions/TemplateLink",
"description": "Gets or sets the URI referencing the template. Use only one of Template or TemplateLink.",
"x-ms-client-flatten": true
},
"parameters": {
"$ref": "#/definitions/VNetParameters",
"type": "object",
"description": "Deployment parameters. Use only one of Parameters or ParametersLink.",
"x-ms-client-flatten": true
},
"mode": {
"type": "string",
"description": "Gets or sets the deployment mode.",
"enum": [
"Incremental"
],
"x-ms-enum": {
"name": "DeploymentMode",
"modelAsString": false
}
}
},
"required": [
"templateLink",
"parameters",
"mode"
],
"description": "Deployment properties."
},
"TemplateLink": {
"properties": {
"uri": {
"type": "string",
"description": "URI referencing the template.",
"enum": [
"https://azuretemplatehost.blob.core.windows.net/templatehost/CreateVNet/azuredeploy.json"
]
},
"contentVersion": {
"type": "string",
"description": "If included it must match the ContentVersion in the template."
}
},
"required": [
"uri"
],
"description": "Entity representing the reference to the template."
},
"VNetParameters": {
"properties": {
"virtualNetworkPrefix": {
"type": "object",
"$ref": "#/definitions/DeploymentParameter_virtualNetworkPrefix",
"x-ms-client-flatten": true,
},
"subnetPrefix": {
"type": "object",
"$ref": "#/definitions/DeploymentParameter_subnetPrefix",
"x-ms-client-flatten": true
},
"virtualNetworkName": {
"type": "object",
"$ref": "#/definitions/DeploymentParameter_virtualNetworkName",
"x-ms-client-flatten": true
},
"subnetName": {
"type": "object",
"$ref": "#/definitions/DeploymentParameter_subnetName",
"x-ms-client-flatten": true
},
"location": {
"type": "object",
"$ref": "#/definitions/DeploymentParameter_location",
"x-ms-client-flatten": true
}
},
"required": [
"virtualNetworkName"
]
},
"DeploymentParameter_virtualNetworkPrefix": {
"properties": {
"value": {
"type": "string",
"description": "IP address prefix for the virtual network.",
"pattern": "^[\\d\\./]+$",
"x-ms-client-name": "virtualNetworkPrefix"
}
}
},
"DeploymentParameter_subnetPrefix": {
"properties": {
"value": {
"type": "string",
"description": "IP address prefix for the subnet.",
"pattern": "^[\\d\\./]+$",
"x-ms-client-name": "subnetPrefix"
}
}
},
"DeploymentParameter_virtualNetworkName": {
"properties": {
"value": {
"type": "string",
"description": "Name of the virtual network.",
"pattern": "^[-\\w\\._]+$",
"minLength": 2,
"maxLength": 80,
"x-ms-client-name": "virtualNetworkName"
}
},
"required": [
"value"
]
},
"DeploymentParameter_subnetName": {
"properties": {
"value": {
"type": "string",
"description": "Name of the subnet.",
"pattern": "^[-\\w\\._]+$",
"minLength": 2,
"maxLength": 80,
"x-ms-client-name": "subnetName"
}
}
},
"DeploymentParameter_location": {
"properties": {
"value": {
"type": "string",
"description": "Location of the virtual network.",
"x-ms-client-name": "location"
}
}
},
"ParametersLink": {
"properties": {
"uri": {
"type": "string",
"description": "URI referencing the template."
},
"contentVersion": {
"type": "string",
"description": "If included it must match the ContentVersion in the template."
}
},
"required": [
"uri"
],
"description": "Entity representing the reference to the deployment paramaters."
},
"ProviderResourceType": {
"properties": {
"resourceType": {
"type": "string",
"description": "Gets or sets the resource type."
},
"locations": {
"type": "array",
"items": {
"type": "string"
},
"description": "Gets or sets the collection of locations where this resource type can be created in."
},
"apiVersions": {
"type": "array",
"items": {
"type": "string"
},
"description": "Gets or sets the api version."
},
"properties": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"description": "Gets or sets the properties."
}
},
"description": "Resource type managed by the resource provider."
},
"Provider": {
"properties": {
"id": {
"type": "string",
"description": "Gets or sets the provider id."
},
"namespace": {
"type": "string",
"description": "Gets or sets the namespace of the provider."
},
"registrationState": {
"type": "string",
"description": "Gets or sets the registration state of the provider."
},
"resourceTypes": {
"type": "array",
"items": {
"$ref": "#/definitions/ProviderResourceType"
},
"description": "Gets or sets the collection of provider resource types."
}
},
"description": "Resource provider information."
},
"BasicDependency": {
"properties": {
"id": {
"type": "string",
"description": "Gets or sets the ID of the dependency."
},
"resourceType": {
"type": "string",
"description": "Gets or sets the dependency resource type."
},
"resourceName": {
"type": "string",
"description": "Gets or sets the dependency resource name."
}
},
"description": "Deployment dependency information."
},
"Dependency": {
"properties": {
"dependsOn": {
"type": "array",
"items": {
"$ref": "#/definitions/BasicDependency"
},
"description": "Gets the list of dependencies."
},
"id": {
"type": "string",
"description": "Gets or sets the ID of the dependency."
},
"resourceType": {
"type": "string",
"description": "Gets or sets the dependency resource type."
},
"resourceName": {
"type": "string",
"description": "Gets or sets the dependency resource name."
}
},
"description": "Deployment dependency information."
},
"DeploymentPropertiesExtended": {
"properties": {
"provisioningState": {
"type": "string",
"description": "Gets or sets the state of the provisioning."
},
"correlationId": {
"type": "string",
"description": "Gets or sets the correlation ID of the deployment."
},
"timestamp": {
"type": "string",
"format": "date-time",
"description": "Gets or sets the timestamp of the template deployment."
},
"outputs": {
"type": "object",
"description": "Gets or sets key/value pairs that represent deploymentoutput."
},
"providers": {
"type": "array",
"items": {
"$ref": "#/definitions/Provider"
},
"description": "Gets the list of resource providers needed for the deployment."
},
"dependencies": {
"type": "array",
"items": {
"$ref": "#/definitions/Dependency"
},
"description": "Gets the list of deployment dependencies."
},
"template": {
"type": "object",
"description": "Gets or sets the template content. Use only one of Template or TemplateLink."
},
"TemplateLink": {
"$ref": "#/definitions/TemplateLink",
"description": "Gets or sets the URI referencing the template. Use only one of Template or TemplateLink."
},
"parameters": {
"type": "object",
"description": "Deployment parameters. Use only one of Parameters or ParametersLink."
},
"parametersLink": {
"$ref": "#/definitions/ParametersLink",
"description": "Gets or sets the URI referencing the parameters. Use only one of Parameters or ParametersLink."
},
"mode": {
"type": "string",
"description": "Gets or sets the deployment mode.",
"enum": [
"Incremental",
"Complete"
],
"x-ms-enum": {
"name": "DeploymentMode",
"modelAsString": false
}
}
},
"description": "Deployment properties with additional details."
},
"DeploymentExtended": {
"properties": {
"id": {
"type": "string",
"description": "Gets or sets the ID of the deployment."
},
"name": {
"type": "string",
"description": "Gets or sets the name of the deployment."
},
"properties": {
"$ref": "#/definitions/DeploymentPropertiesExtended",
"description": "Gets or sets deployment properties."
}
},
"required": [
"name"
],
"description": "Deployment information."
}
},
"parameters": {
"SubscriptionIdParameter": {
"name": "subscriptionId",
"in": "path",
"required": true,
"type": "string",
"description": "Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call."
},
"ApiVersionParameter": {
"name": "api-version",
"in": "query",
"required": true,
"type": "string",
"description": "Client Api Version."
}
}
}

Просмотреть файл

@ -60,6 +60,10 @@ setup(
],
packages=[
'azure.cli.command_modules.network',
'azure.cli.command_modules.network.mgmt',
'azure.cli.command_modules.network.mgmt.lib',
'azure.cli.command_modules.network.mgmt.lib.models',
'azure.cli.command_modules.network.mgmt.lib.operations',
],
install_requires=DEPENDENCIES,
)

Просмотреть файл

@ -10,16 +10,6 @@ COMMAND_TABLES.append(command_table)
@command_table.command('account list', description=L('List the imported subscriptions.'))
def list_subscriptions(_):
"""
type: command
long-summary: |
this module.... kjsdflkj... klsfkj paragraph1
this module.... kjsdflkj... klsfkj paragraph2
parameters:
examples:
- name: foo example
text: example details
"""
profile = Profile()
subscriptions = profile.load_cached_subscriptions()
if not subscriptions:
@ -34,17 +24,6 @@ def list_subscriptions(_):
help=L('Subscription Id, unique name also works.'),
required=True)
def set_active_subscription(args):
"""
type: command
short-summary: this module does xyz one-line or so
long-summary: |
this module.... kjsdflkj... klsfkj paragraph1
this module.... kjsdflkj... klsfkj paragraph2
parameters:
examples:
- name: foo example
text: example details
"""
subscription_name_or_id = args.get('subscription-name-or-id')
if not id:
raise ValueError(L('Please provide subscription id or unique name.'))