Skip to content

Commit

Permalink
vmss: support * to list instance view across vms (#2467)
Browse files Browse the repository at this point in the history
  • Loading branch information
yugangw-msft committed Mar 13, 2017
1 parent 0a6a6a7 commit 89b42b8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Expand Up @@ -1291,7 +1291,9 @@ def get_vmss_instance_view(resource_group_name, vm_scale_set_name, instance_id=N
if instance_id:
if instance_id == '*':
return client.virtual_machine_scale_set_vms.list(resource_group_name,
vm_scale_set_name)
vm_scale_set_name,
select='instanceView',
expand='instanceView')
else:
return client.virtual_machine_scale_set_vms.get_instance_view(resource_group_name,
vm_scale_set_name,
Expand Down
Expand Up @@ -14,7 +14,7 @@
_LINUX_ACCESS_EXT,
_WINDOWS_ACCESS_EXT)
from azure.cli.command_modules.vm.custom import \
(attach_unmanaged_data_disk, detach_data_disk)
(attach_unmanaged_data_disk, detach_data_disk, get_vmss_instance_view)
from azure.cli.command_modules.vm.disk_encryption import enable, disable
from azure.mgmt.compute.models import (NetworkProfile, StorageProfile, DataDisk, OSDisk,
OperatingSystemTypes, InstanceViewStatus,
Expand Down Expand Up @@ -196,6 +196,17 @@ def test_deattach_disk_on_vm(self, mock_vm_set, mock_vm_get):
mock_vm_set.assert_called_once_with(vm)
self.assertEqual(len(vm.storage_profile.data_disks), 0)

@mock.patch('azure.cli.command_modules.vm.custom._compute_client_factory')
def test_show_vmss_instance_view(self, factory_mock):
vm_client = mock.MagicMock()
factory_mock.return_value = vm_client

# execute
get_vmss_instance_view('rg1', 'vmss1', '*')
# assert
vm_client.virtual_machine_scale_set_vms.list.assert_called_once_with('rg1', 'vmss1', expand='instanceView',
select='instanceView')

# pylint: disable=line-too-long
@mock.patch('azure.cli.command_modules.vm.disk_encryption._compute_client_factory', autospec=True)
@mock.patch('azure.cli.command_modules.vm.disk_encryption._get_keyvault_key_url', autospec=True)
Expand Down

0 comments on commit 89b42b8

Please sign in to comment.