Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Compute] (1) vm create: vm create: Add --vmss to specify an existing virtual machine scale set that the virtual machine should be assigned to. (2) vmss create: Add --orchestrator to specify how virtual machines are managed by the scale set. #10646

Merged
merged 16 commits into from
Oct 28, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
1 change: 1 addition & 0 deletions src/azure-cli/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Release History

**Compute**

* vm create: Add --vmss to specify virtual machine scale set that the virtual machine should be assigned to.
* vmss create: Add --computer-name-prefix parameter to support custom computer name prefix of virtual machines in the VMSS.

**Network**
Expand Down
1 change: 1 addition & 0 deletions src/azure-cli/azure/cli/command_modules/vm/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ def load_arguments(self, _):
c.argument('vm_name', name_arg_type, id_part=None, help='Name of the virtual machine.', completer=None)
c.argument('os_disk_size_gb', type=int, help='the size of the os disk in GB', arg_group='Storage')
c.argument('availability_set', help='Name or ID of an existing availability set to add the VM to. None by default.')
c.argument('vmss', help='Virtual machine scale set that the virtual machine should be assigned to.')
qwordy marked this conversation as resolved.
Show resolved Hide resolved
c.argument('nsg', help='The name to use when creating a new Network Security Group (default) or referencing an existing one. Can also reference an existing NSG by ID or specify "" for none.', arg_group='Network')
c.argument('nsg_rule', help='NSG rule to create when creating a new NSG. Defaults to open ports for allowing RDP on Windows and allowing SSH on Linux.', arg_group='Network', arg_type=get_enum_type(['RDP', 'SSH']))
c.argument('application_security_groups', resource_type=ResourceType.MGMT_NETWORK, min_api='2017-09-01', nargs='+', options_list=['--asgs'], help='Space-separated list of existing application security groups to associate with the VM.', arg_group='Network', validator=validate_asg_names_or_ids)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def build_vm_resource( # pylint: disable=too-many-locals
os_publisher=None, os_offer=None, os_sku=None, os_version=None, os_vhd_uri=None,
attach_os_disk=None, os_disk_size_gb=None, custom_data=None, secrets=None, license_type=None, zone=None,
disk_info=None, boot_diagnostics_storage_uri=None, ultra_ssd_enabled=None, proximity_placement_group=None,
computer_name=None, dedicated_host=None, priority=None, max_billing=None, eviction_policy=None):
computer_name=None, dedicated_host=None, priority=None, max_billing=None, eviction_policy=None, vmss=None):

os_caching = disk_info['os'].get('caching')

Expand Down Expand Up @@ -373,6 +373,9 @@ def _build_storage_profile():
if availability_set_id:
vm_properties['availabilitySet'] = {'id': availability_set_id}

if vmss is not None:
vm_properties['virtualMachineScaleSet'] = {'id': vmss}
qwordy marked this conversation as resolved.
Show resolved Hide resolved
qwordy marked this conversation as resolved.
Show resolved Hide resolved

if not attach_os_disk:
vm_properties['osProfile'] = _build_os_profile()

Expand Down
5 changes: 3 additions & 2 deletions src/azure-cli/azure/cli/command_modules/vm/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ def create_vm(cmd, vm_name, resource_group_name, image=None, size='Standard_DS1_
identity_role='Contributor', identity_role_id=None, application_security_groups=None, zone=None,
boot_diagnostics_storage=None, ultra_ssd_enabled=None, ephemeral_os_disk=None,
proximity_placement_group=None, dedicated_host=None, dedicated_host_group=None, aux_subscriptions=None,
priority=None, max_billing=None, eviction_policy=None):
priority=None, max_billing=None, eviction_policy=None, vmss=None):
from azure.cli.core.commands.client_factory import get_subscription_id
from azure.cli.core.util import random_string, hash_string
from azure.cli.core.commands.arm import ArmTemplateBuilder
Expand Down Expand Up @@ -643,7 +643,8 @@ def create_vm(cmd, vm_name, resource_group_name, image=None, size='Standard_DS1_
license_type=license_type, zone=zone, disk_info=disk_info,
boot_diagnostics_storage_uri=boot_diagnostics_storage, ultra_ssd_enabled=ultra_ssd_enabled,
proximity_placement_group=proximity_placement_group, computer_name=computer_name,
dedicated_host=dedicated_host, priority=priority, max_billing=max_billing, eviction_policy=eviction_policy)
dedicated_host=dedicated_host, priority=priority, max_billing=max_billing, eviction_policy=eviction_policy,
vmss=vmss)

vm_resource['dependsOn'] = vm_dependencies

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1385,6 +1385,16 @@ def test_vm_create_existing_options(self, resource_group, storage_account):
self.cmd('vm show -n {vm} -g {rg}',
checks=self.check('storageProfile.osDisk.vhd.uri', 'https://{sa}.blob.core.windows.net/{container}/{disk}.vhd'))

@ResourceGroupPreparer(name_prefix='test_vm_create_vmss_')
def test_vm_create_vmss(self, resource_group):
self.kwargs.update({
'vmss': 'vmss1',
'vm': 'vm1'
})

self.cmd('vmss create -g {rg} -n {vmss} --image UbuntuLTS')
self.cmd('vm create -g {rg} -n {vm} --vmss {vmss}')

@ResourceGroupPreparer(name_prefix='cli_test_vm_create_existing')
def test_vm_create_auth(self, resource_group):
self.kwargs.update({
Expand Down Expand Up @@ -3445,7 +3455,7 @@ def test_vmss_terminate_notification(self, resource_group):
self.cmd('vmss update -g {rg} -n {vm} --enable-terminate-notification')


class VMPriorityEvictionBilling(ScenarioTest):
class VMPriorityEvictionBillingTest(ScenarioTest):

@ResourceGroupPreparer(name_prefix='cli_test_vm_priority_eviction_billing_')
def test_vm_priority_eviction_billing(self, resource_group):
Expand Down