Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
3526d1e
Create VM command with included autorest output
BurtBiel Apr 15, 2016
72fbd61
remove artifacts location param from swagger/CLI
BurtBiel Apr 15, 2016
f04a862
address feedback
BurtBiel Apr 18, 2016
3d11330
add module paths
BurtBiel Apr 19, 2016
864b289
correcting package paths
BurtBiel Apr 19, 2016
0b3a986
Merge branch 'master'
BurtBiel Apr 20, 2016
3685252
working refactored vm create, only support no avail set and password …
BurtBiel Apr 21, 2016
44dcf0b
working SSH key deploy
BurtBiel Apr 21, 2016
a7f9b0b
all scenarios for availability set and ssh key working
BurtBiel Apr 21, 2016
534fb99
working vm create with new autorest
BurtBiel Apr 22, 2016
7dcbd4d
remove aliases
BurtBiel Apr 22, 2016
fa976e1
remove ip-address field
BurtBiel Apr 22, 2016
2f5c166
make location an optional parameter
BurtBiel Apr 22, 2016
5968155
add IP Addresses to output
BurtBiel Apr 22, 2016
7039e0a
cleanup + troubleshooting optional storage account (broken)
BurtBiel Apr 26, 2016
ec80258
fix templates
BurtBiel Apr 26, 2016
d964613
cleanup, variables, etc.
BurtBiel Apr 26, 2016
cfb2e64
working vm create with existing storage account
BurtBiel Apr 27, 2016
01c3126
working with new ip and new dns. Not working with options
BurtBiel Apr 28, 2016
550dd4c
ip none, dns none working
BurtBiel Apr 28, 2016
3c5fa07
all working nic scenarios
BurtBiel Apr 28, 2016
559f2c1
include new proj files
BurtBiel Apr 28, 2016
188a41f
fully working vm create
BurtBiel Apr 28, 2016
6ee3187
use image aliases from https://raw.githubusercontent.com/Azure/azure-…
BurtBiel Apr 29, 2016
71736a1
move to more reliable template storage
BurtBiel Apr 29, 2016
061b769
fix typo
BurtBiel Apr 29, 2016
3d88a45
update vnet to point to reliable storage
BurtBiel Apr 29, 2016
5a65e98
ditto
BurtBiel Apr 29, 2016
318ac20
Merge branch 'master'
BurtBiel Apr 29, 2016
7809d48
merge changes with master
BurtBiel Apr 29, 2016
3739e4f
merge master
BurtBiel Apr 29, 2016
8d52eab
lint
BurtBiel Apr 29, 2016
4b598cd
make private ip allocation a param
BurtBiel Apr 29, 2016
b728a9f
add support for custom VHDs
BurtBiel Apr 29, 2016
b1261e0
move template URLs from template to swagger (allows client-side versi…
BurtBiel May 2, 2016
e383dc3
hide _artifactslocation
BurtBiel May 2, 2016
25493af
update comments and a param alias
BurtBiel May 2, 2016
17da685
add preamble to autocommand and implement the multi-purpose vm create…
BurtBiel May 2, 2016
aae9b90
Add help content
BurtBiel May 2, 2016
1369fb1
switch from preamble to argparse action
BurtBiel May 3, 2016
7084086
remove comments
BurtBiel May 3, 2016
120165c
move help to vm module
BurtBiel May 3, 2016
a53071d
lint and tests
BurtBiel May 3, 2016
87d2472
added a file that was somehow missing
BurtBiel May 3, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions azure-cli.pyproj
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,26 @@
<Compile Include="command_modules\azure-cli-storage\setup.py" />
<Compile Include="command_modules\azure-cli-taskhelp\azure\cli\command_modules\taskhelp\__init__.py" />
<Compile Include="command_modules\azure-cli-taskhelp\setup.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\credentials.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\exceptions.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\basic_dependency.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\dependency.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\deployment_extended.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\deployment_parameter_virtual_network_ip_address_prefix.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\deployment_properties_extended.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\deployment_vm.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\parameters_link.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\provider.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\provider_resource_type.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\template_link.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\vm_creation_client_enums.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\__init__.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\operations\vm_operations.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\operations\__init__.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\version.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\vm_creation_client.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\__init__.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\__init__.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\tests\command_specs.py">
<SubType>Code</SubType>
</Compile>
Expand All @@ -141,6 +161,9 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\__init__.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\__init__.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\__init__.py" />
<Compile Include="command_modules\azure-cli-vm\azure\__init__.py" />
<Compile Include="command_modules\azure-cli-vm\setup.py" />
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -197,6 +220,11 @@
<Folder Include="command_modules\azure-cli-vm\azure\cli\" />
<Folder Include="command_modules\azure-cli-vm\azure\cli\command_modules\" />
<Folder Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\" />
<Folder Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\" />
<Folder Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\" />
<Folder Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\" />
<Folder Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\operations\" />
<Folder Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\nested_templates\" />
<Folder Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\tests\" />
<Folder Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\tests\recordings\" />
</ItemGroup>
Expand All @@ -223,6 +251,20 @@
<Content Include="command_modules\azure-cli-storage\requirements.txt" />
<Content Include="command_modules\azure-cli-taskhelp\requirements.txt" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\tests\aliases.json" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\azuredeploy.json" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\nested_templates\ExistingStorageAccount.json" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\nested_templates\ExistingVNet.json" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\nested_templates\NewStorageAccount.json" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\nested_templates\NewVNet.json" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\nested_templates\nic_ip_existing_dns_none.json" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\nested_templates\nic_ip_new_dns_new.json" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\nested_templates\nic_ip_new_dns_none.json" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\nested_templates\nic_ip_none_dns_none.json" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\nested_templates\vm_existing_password.json" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\nested_templates\vm_existing_sshkey.json" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\nested_templates\vm_none_password.json" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\nested_templates\vm_none_sshkey.json" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\swagger_create_vm.json" />
<Content Include="command_modules\azure-cli-vm\requirements.txt" />
</ItemGroup>
<ItemGroup>
Expand Down
20 changes: 15 additions & 5 deletions src/azure/cli/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,16 @@ def print_arguments(help_file):
indent,
max_name_length + indent*4 + 2)

indent = 2
indent = 4
if p.long_summary:
_print_indent('{0}'.format(p.long_summary.rstrip()), indent)

if p.value_sources:
_print_indent('')
_print_indent(L("Values from: {0}").format(', '.join(p.value_sources)), indent)

if p.long_summary or p.value_sources:
print('')
return indent

def _print_header(help_file):
Expand Down Expand Up @@ -249,10 +252,17 @@ def update_from_data(self, data):
data.get('required'),
data.get('name')))

self.type = data.get('type')
self.short_summary = data.get('short-summary')
self.long_summary = data.get('long-summary')
self.value_sources = data.get('populator-commands')
if data.get('type'):
self.type = data.get('type')

if data.get('short-summary'):
self.short_summary = data.get('short-summary')

if data.get('long-summary'):
self.long_summary = data.get('long-summary')

if data.get('populator-commands'):
self.value_sources = data.get('populator-commands')


class HelpExample(object): #pylint: disable=too-few-public-methods
Expand Down
2 changes: 1 addition & 1 deletion src/azure/cli/_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def get_login_credentials(self):
username_or_sp_id)

return BasicTokenAuthentication(
{'access_token': access_token}), active_account[_SUBSCRIPTION_ID]
{'access_token': access_token}), str(active_account[_SUBSCRIPTION_ID])


class SubscriptionFinder(object):
Expand Down
16 changes: 10 additions & 6 deletions src/azure/cli/tests/test_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,13 @@ def test_handler(args):

Arguments
--foobar2 -fb2 [Required]: one line partial sentence
paragraph(s)
paragraph(s)

--foobar -fb : one line partial sentence
text, markdown, etc.
text, markdown, etc.

Values from: az vm list, default

Values from: az vm list, default
--foobar3 -fb3 : the foobar3
--help -h : show this help message and exit
'''
Expand Down Expand Up @@ -295,11 +297,13 @@ def test_handler(args):

Arguments
--foobar2 -fb2 [Required]: one line partial sentence
paragraph(s)
paragraph(s)

--foobar -fb : one line partial sentence
text, markdown, etc.
text, markdown, etc.

Values from: az vm list, default

Values from: az vm list, default
--help -h : show this help message and exit
Examples
foo example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ 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"
"https://azuresdkci.blob.core.windows.net/templatehost/CreateVNet/azuredeploy.json"
.
:param str content_version: If included it must match the ContentVersion
in the template.
Expand Down Expand Up @@ -52,7 +52,7 @@ class DeploymentVNet(Model):
}

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.uri = "https://azuresdkci.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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ 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"
"https://azuresdkci.blob.core.windows.net/templatehost/CreateVNet/azuredeploy.json"
.
:param str content_version: If included it must match the ContentVersion
in the template.
Expand All @@ -30,5 +30,5 @@ class TemplateLink(Model):
}

def __init__(self, content_version=None, **kwargs):
self.uri = "https://azuretemplatehost.blob.core.windows.net/templatehost/CreateVNet/azuredeploy.json"
self.uri = "https://azuresdkci.blob.core.windows.net/templatehost/CreateVNet/azuredeploy.json"
self.content_version = content_version
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
"type": "string",
"description": "URI referencing the template.",
"enum": [
"https://azuretemplatehost.blob.core.windows.net/templatehost/CreateVNet/azuredeploy.json"
"https://azuresdkci.blob.core.windows.net/templatehost/CreateVNet/azuredeploy.json"
]
},
"contentVersion": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def _update_progress(current, total):
message += '{: >5.1f}'.format(percent_done)
print('\b' * len(message) + message, end='', file=stderr)
stderr.flush()
if current == total:
print('', file=stderr)

#### ACCOUNT COMMANDS #############################################################################

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import argparse
import re
from azure.mgmt.compute import ComputeManagementClient, ComputeManagementClientConfiguration
from azure.mgmt.compute.operations import (AvailabilitySetsOperations,
VirtualMachineExtensionImagesOperations,
Expand All @@ -13,6 +15,11 @@
from azure.cli.commands._auto_command import build_operation, AutoCommandDefinition
from azure.cli.commands import CommandTable, LongRunningOperation
from azure.cli._locale import L
from azure.cli.command_modules.vm.mgmt.lib import (VMCreationClient as VMClient,
VMCreationClientConfiguration
as VMClientConfig)
from azure.cli.command_modules.vm.mgmt.lib.operations import VMOperations
from azure.cli._help_files import helps

from ._params import PARAMETER_ALIASES
from .custom import ConvenienceVmCommands
Expand Down Expand Up @@ -157,3 +164,101 @@ def _patch_aliases(alias_items):
AutoCommandDefinition(ConvenienceVmCommands.list_ip_addresses, 'object'),
],
command_table, PARAMETER_ALIASES)

vm_param_aliases = {
'name': {
'name': '--name -n'
},
'os_disk_uri': {
'name': '--os-disk-uri',
'help': argparse.SUPPRESS
},
'os_offer': {
'name': '--os_offer',
'help': argparse.SUPPRESS
},
'os_publisher': {
'name': '--os-publisher',
'help': argparse.SUPPRESS
},
'os_sku': {
'name': '--os-sku',
'help': argparse.SUPPRESS
},
'os_type': {
'name': '--os-type',
'help': argparse.SUPPRESS
},
'os_version': {
'name': '--os-version',
'help': argparse.SUPPRESS
},
}

class VMImageFieldAction(argparse.Action): #pylint: disable=too-few-public-methods
def __call__(self, parser, namespace, values, option_string=None):
image = values
match = re.match('([^:]*):([^:]*):([^:]*):([^:]*)', image)

if image.lower().endswith('.vhd'):
namespace.os_disk_uri = image
elif match:
namespace.os_type = 'Custom'
namespace.os_publisher = match.group(1)
namespace.os_offer = match.group(2)
namespace.os_sku = match.group(3)
namespace.os_version = match.group(4)
else:
namespace.os_type = image

extra_parameters = [
{
'name': '--image',
'help': 'The OS image. Supported values: Common OS (e.g. Win2012R2Datacenter), URN (e.g. "publisher:offer:sku:version"), or existing VHD URI.',
'action': VMImageFieldAction
}
]

helps['vm create'] = """
type: command
short-summary: Create an Azure Virtual Machine
long-summary: See https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-linux-quick-create-cli/ for an end-to-end tutorial
parameters:
- name: --image
type: string
required: false
short-summary: OS image
long-summary: |
Common OS types: CentOS, CoreOS, Debian, openSUSE, RHEL, SLES, UbuntuLTS,
Win2012R2Datacenter, Win2012Datacenter, Win2008R2SP1
Example URN: canonical:Ubuntu_Snappy_Core:15.04:2016.0318.1949
Example URI: http://<storageAccount>.blob.core.windows.net/vhds/osdiskimage.vhd
populator-commands:
- az vm image list
- az vm image show
examples:
- name: Create a simple Windows Server VM with private IP address
text: >
az vm create --image Win2012R2Datacenter --admin-username myadmin --admin-password Admin_001
-l "West US" -g myvms --name myvm001
- name: Create a Linux VM with SSH key authentication, add a public DNS entry and add to an existing Virtual Network and Availability Set.
text: >
az vm create --image canonical:Ubuntu_Snappy_Core:15.04:2016.0318.1949
--admin-username myadmin --admin-password Admin_001 --authentication-type sshkey
--virtual-network-type existing --virtual-network-name myvnet --subnet-name default
--availability-set-type existing --availability-set-id myavailset
--public-ip-address-type new --dns-name-for-public-ip myGloballyUniqueVmDnsName
-l "West US" -g myvms --name myvm18o --ssh-key-value "<ssh-rsa-key>"
"""

build_operation('vm',
'vm',
lambda _: get_mgmt_service_client(VMClient, VMClientConfig),
[
AutoCommandDefinition(VMOperations.create_or_update,
LongRunningOperation(L('Creating virtual machine'), L('Virtual machine created')),
'create')
],
command_table,
vm_param_aliases,
extra_parameters)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pylint: skip-file
import pkg_resources
pkg_resources.declare_namespace(__name__)
Loading