def test_resize(self, resize_action_mock): with patch(self._get_vm_client_string() + '.begin_update') as resize_action_mock: p = self.load_policy({ 'name': 'test-azure-vm', 'resource': 'azure.vm', 'filters': [{ 'type': 'value', 'key': 'name', 'op': 'eq', 'value_type': 'normalize', 'value': 'cctestvm' }], 'actions': [{ 'type': 'resize', 'vmSize': 'Standard_A2_v2' }] }) p.run() expected_hardware_profile = HardwareProfile(vm_size='Standard_A2_v2') resize_action_mock.assert_called_with( self.fake_running_vms[0]['resourceGroup'], self.fake_running_vms[0]['name'], VirtualMachineUpdate(hardware_profile=expected_hardware_profile))
def set_tags(client, rg_name, vm_name, tags): client.virtual_machines.begin_update(rg_name, vm_name, VirtualMachineUpdate(tags=tags))
def _process_resource(self, resource): hardware_profile = HardwareProfile(vm_size=self.vm_size) self.client.virtual_machines.begin_update( resource['resourceGroup'], resource['name'], VirtualMachineUpdate(hardware_profile=hardware_profile))