diff --git a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/_actions.py b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/_actions.py index a65a2ff0860..e8f0c2df56a 100644 --- a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/_actions.py +++ b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/_actions.py @@ -66,7 +66,7 @@ def _handle_auth_types(**kwargs): raise CLIError('SSH parameters cannot be used with password authentication type') elif not args.admin_password: raise CLIError('Admin password is required with password authentication type') - elif args.authentication_type == 'sshkey': + elif args.authentication_type == 'ssh': if args.admin_password: raise CLIError('Admin password cannot be used with SSH authentication type') diff --git a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/_help.py b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/_help.py index b6274361bed..b164d820f5c 100644 --- a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/_help.py +++ b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/_help.py @@ -9,7 +9,7 @@ type: string short-summary: OS image (Common, URN or URI). long-summary: | - Common OS types: Win2012R2Datacenter, Win2012Datacenter, Win2008SP1. For other values please run 'az vm image list' + Common OS types: CentOS, CoreOS, Debian, openSUSE, RHEL, SLES, UbuntuLTS, Win2008SP1, Win2012Datacenter, Win2012R2Datacenter. Example URN: MicrosoftWindowsServer:WindowsServer:2012-R2-Datacenter:latest Example URI: http://.blob.core.windows.net/vhds/osdiskimage.vhd populator-commands: @@ -29,7 +29,7 @@ - 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 - --admin-username myadmin --admin-password Admin_001 --authentication-type sshkey + --authentication-type ssh --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 diff --git a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/_params.py b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/_params.py index 5080466cedf..c57e1d741c0 100644 --- a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/_params.py +++ b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/_params.py @@ -76,16 +76,7 @@ 'name': '--admin-username', 'default': getpass.getuser(), 'help': 'Admin login. Defaults to current username.' - } -} - -# EXTRA PARAMETER SETS - -VM_CREATE_EXTRA_PARAMETERS = { - 'image': { - 'name': '--image', - 'action': VMImageFieldAction - }, + }, 'ssh_key_value': { 'name': '--ssh-key-value', 'action': VMSSHFieldAction @@ -100,6 +91,15 @@ } } +# EXTRA PARAMETER SETS + +VM_CREATE_EXTRA_PARAMETERS = { + 'image': { + 'name': '--image', + 'action': VMImageFieldAction + }, +} + VM_PATCH_EXTRA_PARAMETERS = { 'resource_group_name': extend_parameter(PARAMETER_ALIASES['resource_group_name'], required=True), diff --git a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/azuredeploy.json b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/azuredeploy.json index 573cf4fc5d3..899a8d51140 100644 --- a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/azuredeploy.json +++ b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/azuredeploy.json @@ -18,7 +18,6 @@ }, "adminUsername": { "type": "string", - "default": "", "metadata": { "description": "Username for the Virtual Machine." } @@ -28,7 +27,7 @@ "defaultValue": "password", "allowedValues": [ "password", - "sshkey" + "ssh" ], "metadata": { "description": "Password or SSH Public Key authentication." @@ -170,7 +169,7 @@ }, "publicIpAddressType": { "type": "string", - "defaultValue": "none", + "defaultValue": "new", "allowedValues": [ "none", "new", @@ -298,6 +297,10 @@ "Win2008R2SP1": "latest", "Custom": "[parameters('osVersion')]" }, + "authTypePath": { + "ssh": "sshkey", + "password": "password" + }, "vnetDeploymentName": "[concat('VNet', variables('vmName'))]", "nicName": "[concat('VMNic', parameters('name'))]", "vnetAddressPrefix": "[parameters('virtualNetworkIpAddressPrefix')]", @@ -406,7 +409,7 @@ "properties": { "mode": "Incremental", "templateLink": { - "uri": "[concat(parameters('_artifactsLocation'), '/nested_templates/vm_', parameters('availabilitySetType'), '_', parameters('authenticationType'), '.json')]", + "uri": "[concat(parameters('_artifactsLocation'), '/nested_templates/vm_', parameters('availabilitySetType'), '_', variables('authTypePath')[parameters('authenticationType')], '.json')]", "contentVersion": "1.0.0.0" }, "parameters": { @@ -433,5 +436,13 @@ } ], "outputs": { + "vm": { + "value": "[reference(variables('vmDeploymentName')).outputs.vm.value]", + "type": "object" + }, + "vmNic": { + "value": "[reference(variables('nicDeploymentName')).outputs.vmNic.value]", + "type": "object" + } } } diff --git a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/lib/models/deployment_vm.py b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/lib/models/deployment_vm.py index 14918c665b0..758f166cf13 100644 --- a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/lib/models/deployment_vm.py +++ b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/lib/models/deployment_vm.py @@ -32,8 +32,7 @@ class DeploymentVM(Model): :param admin_username: Username for the Virtual Machine. :type admin_username: str :param authentication_type: Password or SSH Public Key authentication. - Possible values include: 'password', 'sshkey'. Default value: "password" - . + Possible values include: 'password', 'ssh'. Default value: "password" . :type authentication_type: str :param availability_set_id: Existing availability set for the VM. :type availability_set_id: str @@ -82,8 +81,8 @@ class DeploymentVM(Model): :param public_ip_address_name: Name of public IP address to use. :type public_ip_address_name: str :param public_ip_address_type: Use a public IP Address for the VM Nic. - Possible values include: 'none', 'new', 'existing'. Default value: - "none" . + Possible values include: 'none', 'new', 'existing'. Default value: "new" + . :type public_ip_address_type: str :param size: The VM Size that should be created. See https://azure.microsoft.com/en-us/pricing/details/virtual-machines/ for @@ -127,7 +126,6 @@ class DeploymentVM(Model): _validation = { 'uri': {'required': True, 'constant': True}, '_artifacts_location': {'required': True, 'constant': True}, - 'admin_username': {'required': True}, 'name': {'required': True}, 'mode': {'required': True, 'constant': True}, } @@ -177,7 +175,7 @@ class DeploymentVM(Model): mode = "Incremental" - def __init__(self, name, content_version=None, storage_container_name="vhds", virtual_network_name=None, subnet_ip_address_prefix="10.0.0.0/24", private_ip_address_allocation="Dynamic", dns_name_for_public_ip=None, storage_account_type="new", os_disk_uri=None, virtual_network_type="new", admin_password=None, os_sku="2012-R2-Datacenter", subnet_name=None, os_type="Win2012R2Datacenter", admin_username=None, os_version="latest", os_disk_name="osdiskimage", ssh_dest_key_path=None, os_offer="WindowsServer", public_ip_address_allocation="Dynamic", authentication_type="password", storage_account_name=None, storage_redundancy_type="Standard_LRS", size="Standard_A2", public_ip_address_type="none", virtual_network_ip_address_prefix="10.0.0.0/16", availability_set_id=None, ssh_key_value=None, location=None, os_publisher="MicrosoftWindowsServer", availability_set_type="none", public_ip_address_name=None, dns_name_type="none"): + def __init__(self, name, content_version=None, admin_password=None, admin_username=None, authentication_type="password", availability_set_id=None, availability_set_type="none", dns_name_for_public_ip=None, dns_name_type="none", location=None, os_disk_name="osdiskimage", os_disk_uri=None, os_offer="WindowsServer", os_publisher="MicrosoftWindowsServer", os_sku="2012-R2-Datacenter", os_type="Win2012R2Datacenter", os_version="latest", private_ip_address_allocation="Dynamic", public_ip_address_allocation="Dynamic", public_ip_address_name=None, public_ip_address_type="new", size="Standard_A2", ssh_dest_key_path=None, ssh_key_value=None, storage_account_name=None, storage_account_type="new", storage_container_name="vhds", storage_redundancy_type="Standard_LRS", subnet_ip_address_prefix="10.0.0.0/24", subnet_name=None, virtual_network_ip_address_prefix="10.0.0.0/16", virtual_network_name=None, virtual_network_type="new"): self.content_version = content_version self.admin_password = admin_password self.admin_username = admin_username diff --git a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/lib/operations/vm_operations.py b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/lib/operations/vm_operations.py index 83894ccf8d7..e079215e944 100644 --- a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/lib/operations/vm_operations.py +++ b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/lib/operations/vm_operations.py @@ -13,6 +13,7 @@ from .. import models + class VMOperations(object): """VMOperations operations. @@ -31,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def create_or_update( - self, resource_group_name, deployment_name, name, content_version=None, storage_container_name="vhds", virtual_network_name=None, subnet_ip_address_prefix="10.0.0.0/24", private_ip_address_allocation="Dynamic", dns_name_for_public_ip=None, storage_account_type="new", os_disk_uri=None, virtual_network_type="new", admin_password=None, os_sku="2012-R2-Datacenter", subnet_name=None, os_type="Win2012R2Datacenter", admin_username=None, os_version="latest", os_disk_name="osdiskimage", ssh_dest_key_path=None, os_offer="WindowsServer", public_ip_address_allocation="Dynamic", authentication_type="password", storage_account_name=None, storage_redundancy_type="Standard_LRS", size="Standard_A2", public_ip_address_type="none", virtual_network_ip_address_prefix="10.0.0.0/16", availability_set_id=None, ssh_key_value=None, location=None, os_publisher="MicrosoftWindowsServer", availability_set_type="none", public_ip_address_name=None, dns_name_type="none", custom_headers={}, raw=False, **operation_config): + self, resource_group_name, deployment_name, name, content_version=None, admin_password=None, admin_username=None, authentication_type="password", availability_set_id=None, availability_set_type="none", dns_name_for_public_ip=None, dns_name_type="none", location=None, os_disk_name="osdiskimage", os_disk_uri=None, os_offer="WindowsServer", os_publisher="MicrosoftWindowsServer", os_sku="2012-R2-Datacenter", os_type="Win2012R2Datacenter", os_version="latest", private_ip_address_allocation="Dynamic", public_ip_address_allocation="Dynamic", public_ip_address_name=None, public_ip_address_type="new", size="Standard_A2", ssh_dest_key_path=None, ssh_key_value=None, storage_account_name=None, storage_account_type="new", storage_container_name="vhds", storage_redundancy_type="Standard_LRS", subnet_ip_address_prefix="10.0.0.0/24", subnet_name=None, virtual_network_ip_address_prefix="10.0.0.0/16", virtual_network_name=None, virtual_network_type="new", custom_headers={}, raw=False, **operation_config): """ Create or update a virtual machine. @@ -40,7 +41,7 @@ def create_or_update( :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param name: The VM resource name. + :param name: The VM name. :type name: str :param content_version: If included it must match the ContentVersion in the template. @@ -48,8 +49,10 @@ def create_or_update( :param admin_password: Password for the Virtual Machine. Required if SSH (Linux only) is not specified. :type admin_password: str + :param admin_username: Username for the Virtual Machine. + :type admin_username: str :param authentication_type: Password or SSH Public Key - authentication. Possible values include: 'password', 'sshkey' + authentication. Possible values include: 'password', 'ssh' :type authentication_type: str :param availability_set_id: Existing availability set for the VM. :type availability_set_id: str @@ -80,8 +83,6 @@ def create_or_update( parameters. Possible values include: 'Win2012R2Datacenter', 'Win2012Datacenter', 'Win2008R2SP1', 'Custom' :type os_type: str - :param admin_username: Username for the Virtual Machine. - :type admin_username: str :param os_version: The OS version to install. :type os_version: str :param private_ip_address_allocation: Private IP address allocation diff --git a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/nested_templates/nic_ip_existing_dns_none.json b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/nested_templates/nic_ip_existing_dns_none.json index 2382d4638b6..c24d642e180 100644 --- a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/nested_templates/nic_ip_existing_dns_none.json +++ b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/nested_templates/nic_ip_existing_dns_none.json @@ -58,5 +58,9 @@ } ], "outputs": { + "VMNic": { + "type": "object", + "value": "[reference(parameters('nicName'))]" + } } } \ No newline at end of file diff --git a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/nested_templates/nic_ip_new_dns_none.json b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/nested_templates/nic_ip_new_dns_none.json index 2b131236155..3a39a60bb80 100644 --- a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/nested_templates/nic_ip_new_dns_none.json +++ b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/nested_templates/nic_ip_new_dns_none.json @@ -73,5 +73,9 @@ } ], "outputs": { + "VMNic": { + "type": "object", + "value": "[reference(parameters('nicName'))]" + } } } \ No newline at end of file diff --git a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/nested_templates/nic_ip_none_dns_none.json b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/nested_templates/nic_ip_none_dns_none.json index c0729dfa8a7..a78f4376ae4 100644 --- a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/nested_templates/nic_ip_none_dns_none.json +++ b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/nested_templates/nic_ip_none_dns_none.json @@ -55,5 +55,9 @@ } ], "outputs": { + "VMNic": { + "type": "object", + "value": "[reference(parameters('nicName'))]" + } } } \ No newline at end of file diff --git a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/nested_templates/vm_existing_password.json b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/nested_templates/vm_existing_password.json index c21e3537b51..7a2a005aefd 100644 --- a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/nested_templates/vm_existing_password.json +++ b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/nested_templates/vm_existing_password.json @@ -124,6 +124,10 @@ } ], "outputs": { + "vm": { + "value": "[reference(variables('vmName'))]", + "type": "object" } } + } } \ No newline at end of file diff --git a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/nested_templates/vm_existing_sshkey.json b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/nested_templates/vm_existing_sshkey.json index 4083af1a5ad..a81051d360d 100644 --- a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/nested_templates/vm_existing_sshkey.json +++ b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/nested_templates/vm_existing_sshkey.json @@ -132,5 +132,9 @@ } ], "outputs": { + "vm": { + "value": "[reference(variables('vmName'))]", + "type": "object" + } } } \ No newline at end of file diff --git a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/nested_templates/vm_none_password.json b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/nested_templates/vm_none_password.json index 21a81b46533..f9f814b5727 100644 --- a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/nested_templates/vm_none_password.json +++ b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/nested_templates/vm_none_password.json @@ -122,5 +122,9 @@ } ], "outputs": { + "vm": { + "value": "[reference(variables('vmName'))]", + "type": "object" + } } } \ No newline at end of file diff --git a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/nested_templates/vm_none_sshkey.json b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/nested_templates/vm_none_sshkey.json index 3d6558d5c57..9ae6d3d999f 100644 --- a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/nested_templates/vm_none_sshkey.json +++ b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/nested_templates/vm_none_sshkey.json @@ -130,5 +130,9 @@ } ], "outputs": { + "vm": { + "value": "[reference(variables('vmName'))]", + "type": "object" + } } } \ No newline at end of file diff --git a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/swagger_create_vm.json b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/swagger_create_vm.json index f3fb705ab9a..ba2b9962493 100644 --- a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/swagger_create_vm.json +++ b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/mgmt_vm_create/swagger_create_vm.json @@ -342,7 +342,7 @@ "https://azuresdkci.blob.core.windows.net/templatehost/CreateVM" ] } - }, + }, "required": [ "value" ] @@ -363,11 +363,7 @@ "description": "Username for the Virtual Machine.", "x-ms-client-name": "adminUsername" } - }, - "required": [ - "value" - ] - + } }, "DeploymentParameter_authenticationType": { "properties": { @@ -377,7 +373,7 @@ "x-ms-client-name": "authenticationType", "enum": [ "password", - "sshkey" + "ssh" ], "default": "password" } @@ -428,7 +424,7 @@ "default": "none" } } - }, + }, "DeploymentParameter_location": { "properties": { "value": { @@ -513,7 +509,6 @@ "Custom" ], "default": "Win2012R2Datacenter" - } } } @@ -576,7 +571,7 @@ "new", "existing" ], - "default": "none" + "default": "new" } } },