def test_process_updates_for_updated_VM(self): self.mock.StubOutWithMock(api, 'vm_save') api.vm_save(mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None) self.mock.StubOutWithMock(api, 'vm_delete_by_ids') api.vm_delete_by_ids(mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None) self.mock.StubOutWithMock(nova_db, 'service_get_all_by_topic') nova_db.service_get_all_by_topic(mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None) self.mock.StubOutWithMock( InventoryCacheManager, 'get_compute_conn_driver') InventoryCacheManager.get_compute_conn_driver( self.libvirtVM.compute_id, Constants.VmHost).AndReturn(fake.get_connection()) self.mock.ReplayAll() domainObj = libvirt.virDomain() self.assertEquals( self.libvirtVM.process_updates_for_updated_VM(domainObj), None) vm = InventoryCacheManager.get_object_from_cache( "25f04dd3-e924-02b2-9eac-876e3c943262", Constants.Vm) # self.assertEquals("TestVirtMgrVM7", vm.get_name()) self.assertEquals("1048576", str(vm.get_memorySize())) self.assertEquals("hd", str(vm.get_bootOrder()).strip()) self.mock.stubs.UnsetAll()
def test_vm_host_get_all_for_vm(self): host_id = 'VH1' vmhost = VmHost() vmhost.id = host_id healthnmon_db_api.vm_host_save(get_admin_context(), vmhost) vm = Vm() vm.id = 'VM11' vm.set_vmHostId(host_id) healthnmon_db_api.vm_save(get_admin_context(), vm) vmhosts = \ healthnmon_db_api.vm_host_get_all(get_admin_context()) self.assertFalse(vmhosts is None, 'Host get by id returned a none list') self.assertTrue( len(vmhosts) > 0, 'Host get by id returned invalid number of list') self.assertTrue(vmhosts[0].id == host_id) vmids = vmhosts[0].get_virtualMachineIds() self.assert_(vmids is not None) self.assert_(len(vmids) == 1) self.assert_(vm.id in vmids) healthnmon_db_api.vm_delete_by_ids(get_admin_context(), [vm.id]) vmhosts = \ healthnmon_db_api.vm_host_get_all(get_admin_context()) self.assertTrue(vmhosts[0].id == host_id) vmids = vmhosts[0].get_virtualMachineIds() self.assert_((vmids is None) or (len(vmids) == 0))
def test_vm_get_all_by_filters_changessince(self): # Create Vm vm_ids = ('VM1', 'VM2', 'VM3') vm_names = ('name1', 'name2', 'name3') for i in range(len(vm_ids)): self.__create_vm(id=vm_ids[i], name=vm_names[i]) created_time = long(time.time() * 1000L) # Wait for 1 sec and update second vm and delete third vm time.sleep(1) second_vm = healthnmon_db_api.vm_get_by_ids( self.admin_context, [vm_ids[1]])[0] second_vm.name = 'New name' healthnmon_db_api.vm_save(self.admin_context, second_vm) healthnmon_db_api.vm_delete_by_ids(self.admin_context, [vm_ids[2]]) # Query with filter expected_updated_ids = [vm_ids[1], vm_ids[2]] filters = {'changes-since': created_time} vms = healthnmon_db_api.vm_get_all_by_filters( self.admin_context, filters, None, None) self.assert_(vms is not None) self.assert_(len(vms) == 2) for vm in vms: self.assert_(vm is not None) self.assert_(vm.id in expected_updated_ids)
def test_process_incomplete_vms(self): self.mock.StubOutWithMock(api, 'vm_save') api.vm_save(mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None) self.mock.StubOutWithMock(api, 'vm_delete_by_ids') api.vm_delete_by_ids(mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None) self.mock.StubOutWithMock(nova_db, 'service_get_all_by_topic') nova_db.service_get_all_by_topic( mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None) self.mock.StubOutWithMock( InventoryCacheManager, 'get_compute_conn_driver') InventoryCacheManager.get_compute_conn_driver( self.libvirtVM.compute_id, Constants.VmHost).AndReturn(fake.get_connection()) self.mock.ReplayAll() libvirt_inventorymonitor.incomplete_vms = \ {self.libvirtVM.compute_id: {'25f04dd3-e924-02b2-9eac-876e3c943262': 1}} self.libvirtVM.process_incomplete_vms() vm = InventoryCacheManager.get_object_from_cache( "25f04dd3-e924-02b2-9eac-876e3c943262", Constants.Vm) self.assert_(vm.get_vmDisks(), "VM disks inventory not collected") self.assert_( '25f04dd3-e924-02b2-9eac-876e3c943262' not in libvirt_inventorymonitor.incomplete_vms[ self.libvirtVM.compute_id], "VM id not removed from incomplete list") self.mock.stubs.UnsetAll()
def test_processVmDeletes(self): self.mock.StubOutWithMock(api, 'vm_delete_by_ids') api.vm_delete_by_ids(mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None) self.mock.StubOutWithMock(nova_db, 'service_get_all_by_topic') nova_db.service_get_all_by_topic( mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None) self.mock.StubOutWithMock(InventoryCacheManager, 'get_object_from_cache') deleted_vm_id = '25f04dd3-e924-02b2-9eac-876e3c943123' deleted_vm = Vm() deleted_vm.id = deleted_vm_id InventoryCacheManager.get_object_from_cache( deleted_vm_id, Constants.Vm).AndReturn(deleted_vm) self.mock.ReplayAll() cachedList = ['25f04dd3-e924-02b2-9eac-876e3c943262', deleted_vm_id] updatedList = ['25f04dd3-e924-02b2-9eac-876e3c943262'] self.assertEquals(self.libvirtVM.processVmDeletes(cachedList, updatedList), None) self.assertTrue(deleted_vm_id not in InventoryCacheManager.get_inventory_cache().keys()) self.mock.stubs.UnsetAll()
def test_ProcessUpdatesException(self): self.mock.StubOutWithMock(api, 'vm_save') api.vm_save(mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None) self.mock.StubOutWithMock(api, 'vm_delete_by_ids') api.vm_delete_by_ids(mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None) self.mock.StubOutWithMock(nova_db, 'service_get_all_by_topic') nova_db.service_get_all_by_topic(mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None) self.mock.StubOutWithMock( InventoryCacheManager, 'get_compute_conn_driver') InventoryCacheManager.get_compute_conn_driver( self.libvirtVM.compute_id, Constants.VmHost).AndReturn(fake.get_connection()) mock_libvirtVm = LibvirtVM(self.connection, '1') self.mock.StubOutWithMock(mock_libvirtVm, 'processVmDeletes') mock_libvirtVm.processVmDeletes([], []).AndRaise(Exception) self.mock.ReplayAll() self.assertEquals(self.libvirtVM.processUpdates(), None) self.assertRaises(Exception, LibvirtVM) self.mock.stubs.UnsetAll()
def test_vm_deleted_event(self): self.mox.StubOutWithMock(api, 'vm_delete_by_ids') api.vm_delete_by_ids(mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None) deleted_vm_id = '25f04dd3-e924-02b2-9eac-876e3c943123' deleted_vm = Vm() deleted_vm.id = deleted_vm_id self.mox.StubOutWithMock(InventoryCacheManager, 'get_object_from_cache') InventoryCacheManager.get_object_from_cache( deleted_vm_id, Constants.Vm).AndReturn(deleted_vm) self.mox.ReplayAll() cachedList = ['25f04dd3-e924-02b2-9eac-876e3c943262', deleted_vm_id] updatedList = ['25f04dd3-e924-02b2-9eac-876e3c943262'] self.libvirtVM.processVmDeletes(cachedList, updatedList) self.assertTrue(len(test_notifier.NOTIFICATIONS) == 1) msg = test_notifier.NOTIFICATIONS[0] self.assertTrue(msg is not None) self.assertEquals(msg['priority'], notifier_api.INFO) event_type = \ event_metadata.get_EventMetaData( event_metadata.EVENT_TYPE_VM_DELETED) self.assertEquals(msg['event_type'], event_type.get_event_fully_qal_name()) payload = msg['payload'] self.assertEquals(payload['entity_type'], 'Vm') self.assertEquals(payload['entity_id'], deleted_vm_id)
def test_vm_deleted_event(self): self.mox.StubOutWithMock(api, 'vm_delete_by_ids') api.vm_delete_by_ids(mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None) deleted_vm_id = '25f04dd3-e924-02b2-9eac-876e3c943123' deleted_vm = Vm() deleted_vm.id = deleted_vm_id self.mox.StubOutWithMock( InventoryCacheManager, 'get_object_from_cache') InventoryCacheManager.get_object_from_cache( deleted_vm_id, Constants.Vm).AndReturn(deleted_vm) self.mox.ReplayAll() cachedList = ['25f04dd3-e924-02b2-9eac-876e3c943262', deleted_vm_id] updatedList = ['25f04dd3-e924-02b2-9eac-876e3c943262'] self.libvirtVM.processVmDeletes(cachedList, updatedList) self.assertTrue(len(test_notifier.NOTIFICATIONS) == 1) msg = test_notifier.NOTIFICATIONS[0] self.assertTrue(msg is not None) self.assertEquals(msg['priority'], notifier_api.INFO) event_type = \ event_metadata.get_EventMetaData( event_metadata.EVENT_TYPE_VM_DELETED) self.assertEquals(msg['event_type'], event_type.get_event_fully_qal_name()) payload = msg['payload'] self.assertEquals(payload['entity_type'], 'Vm') self.assertEquals(payload['entity_id'], deleted_vm_id)
def test_vm_host_get_all_for_vm(self): host_id = 'VH1' vmhost = VmHost() vmhost.id = host_id healthnmon_db_api.vm_host_save(get_admin_context(), vmhost) vm = Vm() vm.id = 'VM11' vm.set_vmHostId(host_id) healthnmon_db_api.vm_save(get_admin_context(), vm) vmhosts = \ healthnmon_db_api.vm_host_get_all(get_admin_context()) self.assertFalse(vmhosts is None, 'Host get by id returned a none list') self.assertTrue(len(vmhosts) > 0, 'Host get by id returned invalid number of list' ) self.assertTrue(vmhosts[0].id == host_id) vmids = vmhosts[0].get_virtualMachineIds() self.assert_(vmids is not None) self.assert_(len(vmids) == 1) self.assert_(vm.id in vmids) healthnmon_db_api.vm_delete_by_ids(get_admin_context(), [vm.id]) vmhosts = \ healthnmon_db_api.vm_host_get_all(get_admin_context()) self.assertTrue(vmhosts[0].id == host_id) vmids = vmhosts[0].get_virtualMachineIds() self.assert_((vmids is None) or (len(vmids) == 0))
def test_processVmDeletes(self): self.mock.StubOutWithMock(api, 'vm_delete_by_ids') api.vm_delete_by_ids(mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None) self.mock.StubOutWithMock(nova_db, 'service_get_all_by_topic') nova_db.service_get_all_by_topic(mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None) self.mock.StubOutWithMock(InventoryCacheManager, 'get_object_from_cache' ) deleted_vm_id = '25f04dd3-e924-02b2-9eac-876e3c943123' deleted_vm = Vm() deleted_vm.id = deleted_vm_id InventoryCacheManager.get_object_from_cache(deleted_vm_id, Constants.Vm).AndReturn(deleted_vm) self.mock.ReplayAll() cachedList = ['25f04dd3-e924-02b2-9eac-876e3c943262', deleted_vm_id] updatedList = ['25f04dd3-e924-02b2-9eac-876e3c943262'] self.assertEquals(self.libvirtVM.processVmDeletes(cachedList, updatedList), None) self.assertTrue(deleted_vm_id not in InventoryCacheManager.get_inventory_cache().keys()) self.mock.stubs.UnsetAll()
def test_vm_netadpater_save(self): vm = Vm() vm.id = 'VM1' vmNetAdapter = VmNetAdapter() vmNetAdapter.set_id('netAdapter-01') vmNetAdapter.set_name('netAdapter-01') vmNetAdapter.set_addressType('assigned') vmNetAdapter.set_adapterType('E1000') vmNetAdapter.set_switchType('vSwitch') vmNetAdapter.set_macAddress('00:50:56:81:1c:d0') vmNetAdapter.add_ipAddresses('1.1.1.1') vmNetAdapter.set_networkName('br100') vmNetAdapter.set_vlanId(0) vm.add_vmNetAdapters(vmNetAdapter) healthnmon_db_api.vm_save(get_admin_context(), vm) virual_machines = \ healthnmon_db_api.vm_get_by_ids(get_admin_context(), ['VM1' ]) vm_from_db = virual_machines[0] netAdapters = vm_from_db.get_vmNetAdapters() netAdapter = netAdapters[0] self.assertTrue(vmNetAdapter.get_id() == netAdapter.get_id()) healthnmon_db_api.vm_delete_by_ids(get_admin_context(), [vm.id]) vms = healthnmon_db_api.vm_get_by_ids(get_admin_context(), [vm.id]) self.assertTrue(vms is None or len(vms) == 0, 'VM not deleted')
def test_ProcessUpdatesException(self): self.mock.StubOutWithMock(api, 'vm_save') api.vm_save(mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None) self.mock.StubOutWithMock(api, 'vm_delete_by_ids') api.vm_delete_by_ids(mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None) self.mock.StubOutWithMock(nova_db, 'service_get_all_by_topic') nova_db.service_get_all_by_topic( mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None) self.mock.StubOutWithMock( InventoryCacheManager, 'get_compute_conn_driver') InventoryCacheManager.get_compute_conn_driver( self.libvirtVM.compute_id, Constants.VmHost).AndReturn(fake.get_connection()) mock_libvirtVm = LibvirtVM(self.connection, '1') self.mock.StubOutWithMock(mock_libvirtVm, 'processVmDeletes') mock_libvirtVm.processVmDeletes([], []).AndRaise(Exception) self.mock.ReplayAll() self.assertEquals(self.libvirtVM.processUpdates(), None) self.assertRaises(Exception, LibvirtVM) self.mock.stubs.UnsetAll()
def test_process_updates_for_updated_VM(self): self.mock.StubOutWithMock(api, 'vm_save') api.vm_save(mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None) self.mock.StubOutWithMock(api, 'vm_delete_by_ids') api.vm_delete_by_ids(mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None) self.mock.StubOutWithMock(nova_db, 'service_get_all_by_topic') nova_db.service_get_all_by_topic( mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None) self.mock.StubOutWithMock( InventoryCacheManager, 'get_compute_conn_driver') InventoryCacheManager.get_compute_conn_driver( self.libvirtVM.compute_id, Constants.VmHost).AndReturn(fake.get_connection()) self.mock.ReplayAll() domainObj = libvirt.virDomain() self.assertEquals( self.libvirtVM.process_updates_for_updated_VM(domainObj), None) vm = InventoryCacheManager.get_object_from_cache( "25f04dd3-e924-02b2-9eac-876e3c943262", Constants.Vm) # self.assertEquals("TestVirtMgrVM7", vm.get_name()) self.assertEquals("1048576", str(vm.get_memorySize())) self.assertEquals("hd", str(vm.get_bootOrder()).strip()) self.mock.stubs.UnsetAll()
def test_vm_delete_none(self): # Initially insert a vm into db and check the length vm = Vm() vm.id = 'VM1-id' healthnmon_db_api.vm_save(get_admin_context(), vm) vms = healthnmon_db_api.vm_get_all(get_admin_context()) self.assertTrue(vms is not None) self.assertTrue(len(vms) == 1) # Now delete the None from db healthnmon_db_api.vm_delete_by_ids(get_admin_context(), None) vms = healthnmon_db_api.vm_get_all(get_admin_context()) self.assertTrue(vms is not None) self.assertTrue(len(vms) == 1)
def test_vm_delete_none(self): #Initially insert a vm into db and check the length vm = Vm() vm.id = 'VM1-id' healthnmon_db_api.vm_save(get_admin_context(), vm) vms = healthnmon_db_api.vm_get_all(get_admin_context()) self.assertTrue(vms is not None) self.assertTrue(len(vms) == 1) #Now delete the None from db healthnmon_db_api.vm_delete_by_ids(get_admin_context(), None) vms = healthnmon_db_api.vm_get_all(get_admin_context()) self.assertTrue(vms is not None) self.assertTrue(len(vms) == 1)
def test_vm_get_all_by_filters_not_deleted(self): # Create Vm vm_ids = ('VM1', 'VM2') vm_names = ('name1', 'name2') for i in range(len(vm_ids)): self.__create_vm(id=vm_ids[i], name=vm_names[i]) # Delete one vm healthnmon_db_api.vm_delete_by_ids(self.admin_context, [vm_ids[0]]) # Query with filter filters = {'deleted': False} vms = healthnmon_db_api.vm_get_all_by_filters( self.admin_context, filters, 'id', DbConstants.ORDER_ASC) self.assert_(vms is not None) self.assert_(len(vms) == 1) self.assert_(vms[0] is not None) self.assert_(vms[0].id == vm_ids[1])
def test_vm_get_all_by_filters_not_deleted(self): # Create Vm vm_ids = ('VM1', 'VM2') vm_names = ('name1', 'name2') for i in range(len(vm_ids)): self.__create_vm(id=vm_ids[i], name=vm_names[i]) # Delete one vm healthnmon_db_api.vm_delete_by_ids(self.admin_context, [vm_ids[0]]) # Query with filter filters = {'deleted': False} vms = healthnmon_db_api.vm_get_all_by_filters(self.admin_context, filters, 'id', DbConstants.ORDER_ASC) self.assert_(vms is not None) self.assert_(len(vms) == 1) self.assert_(vms[0] is not None) self.assert_(vms[0].id == vm_ids[1])
def test_vm_delete(self): vm = Vm() vm_id = 'VM1' vm.id = vm_id vmGlobalSettings = VmGlobalSettings() vmGlobalSettings.set_id(vm_id) vm.set_vmGlobalSettings(vmGlobalSettings) healthnmon_db_api.vm_save(get_admin_context(), vm) vms = healthnmon_db_api.vm_get_by_ids(get_admin_context(), [vm_id]) self.assertFalse(vms is None, 'VM get by id returned a none list') self.assertTrue( len(vms) > 0, 'VM get by id returned invalid number of list') healthnmon_db_api.vm_delete_by_ids(get_admin_context(), [vm_id]) vms = healthnmon_db_api.vm_get_by_ids(get_admin_context(), [vm_id]) self.assertTrue(vms is None or len(vms) == 0, 'VM not deleted')
def test_vm_delete(self): vm = Vm() vm_id = 'VM1' vm.id = vm_id vmGlobalSettings = VmGlobalSettings() vmGlobalSettings.set_id(vm_id) vm.set_vmGlobalSettings(vmGlobalSettings) healthnmon_db_api.vm_save(get_admin_context(), vm) vms = healthnmon_db_api.vm_get_by_ids(get_admin_context(), [vm_id]) self.assertFalse(vms is None, 'VM get by id returned a none list') self.assertTrue(len(vms) > 0, 'VM get by id returned invalid number of list') healthnmon_db_api.vm_delete_by_ids(get_admin_context(), [vm_id]) vms = healthnmon_db_api.vm_get_by_ids(get_admin_context(), [vm_id]) self.assertTrue(vms is None or len(vms) == 0, 'VM not deleted')
def test_process_incomplete_vms_with_retry(self): self.mock.StubOutWithMock(api, 'vm_save') api.vm_save(mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None) self.mock.StubOutWithMock(api, 'vm_delete_by_ids') api.vm_delete_by_ids(mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None) self.mock.StubOutWithMock(nova_db, 'service_get_all_by_topic') nova_db.service_get_all_by_topic(mox.IgnoreArg(), mox.IgnoreArg()).\ MultipleTimes().AndReturn(None) self.mock.StubOutWithMock( InventoryCacheManager, 'get_compute_conn_driver') InventoryCacheManager.get_compute_conn_driver( self.libvirtVM.compute_id, Constants.VmHost).AndReturn(fake.get_connection()) self.mock.StubOutWithMock( self.libvirtVM.libvirtconn, 'storageVolLookupByPath') self.libvirtVM.libvirtconn.storageVolLookupByPath( mox.IgnoreArg()).AndRaise(Exception) self.mock.ReplayAll() libvirt_inventorymonitor.incomplete_vms = \ {self.libvirtVM.compute_id: { '25f04dd3-e924-02b2-9eac-876e3c943262': 1}} self.libvirtVM.process_incomplete_vms() vm = InventoryCacheManager.get_object_from_cache( "25f04dd3-e924-02b2-9eac-876e3c943262", Constants.Vm) self.assert_(not(vm.get_vmDisks()), "VM disks should not be collected") self.assert_( libvirt_inventorymonitor.incomplete_vms[self.libvirtVM.compute_id][ '25f04dd3-e924-02b2-9eac-876e3c943262'] == 2, "incomplete_vms retry count not incremented") self.mock.stubs.UnsetAll()
def test_process_incomplete_vms_deletedvm(self): self.mock.StubOutWithMock(api, 'vm_save') api.vm_save(mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None) self.mock.StubOutWithMock(api, 'vm_delete_by_ids') api.vm_delete_by_ids(mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None) self.mock.StubOutWithMock(nova_db, 'service_get_all_by_topic') nova_db.service_get_all_by_topic(mox.IgnoreArg(), mox.IgnoreArg())\ .MultipleTimes().AndReturn(None) self.mock.StubOutWithMock( InventoryCacheManager, 'get_compute_conn_driver') InventoryCacheManager.get_compute_conn_driver( self.libvirtVM.compute_id, Constants.VmHost).AndReturn(fake.get_connection()) self.mock.StubOutWithMock( self.libvirtVM.libvirtconn, 'listDefinedDomains') self.libvirtVM.libvirtconn.listDefinedDomains().AndReturn([]) self.mock.StubOutWithMock(self.libvirtVM.libvirtconn, 'listDomainsID') self.libvirtVM.libvirtconn.listDomainsID().AndReturn([]) self.mock.ReplayAll() libvirt_inventorymonitor.incomplete_vms = \ {self.libvirtVM.compute_id: { '25f04dd3-e924-02b2-9eac-876e3c943262': 1}} self.libvirtVM.process_incomplete_vms() self.assert_( '25f04dd3-e924-02b2-9eac-876e3c943262' not in libvirt_inventorymonitor.incomplete_vms[ self.libvirtVM.compute_id], "Deleted VM id not removed from incomplete list") self.mock.stubs.UnsetAll()
def test_vm_get_all_by_filters_changessince(self): # Create Vm vm_ids = ('VM1', 'VM2', 'VM3') vm_names = ('name1', 'name2', 'name3') for i in range(len(vm_ids)): self.__create_vm(id=vm_ids[i], name=vm_names[i]) created_time = long(time.time() * 1000L) # Wait for 1 sec and update second vm and delete third vm time.sleep(1) second_vm = healthnmon_db_api.vm_get_by_ids(self.admin_context, [vm_ids[1]])[0] second_vm.name = 'New name' healthnmon_db_api.vm_save(self.admin_context, second_vm) healthnmon_db_api.vm_delete_by_ids(self.admin_context, [vm_ids[2]]) # Query with filter expected_updated_ids = [vm_ids[1], vm_ids[2]] filters = {'changes-since': created_time} vms = healthnmon_db_api.vm_get_all_by_filters(self.admin_context, filters, None, None) self.assert_(vms is not None) self.assert_(len(vms) == 2) for vm in vms: self.assert_(vm is not None) self.assert_(vm.id in expected_updated_ids)