def _recoverExistingVms(self): start_time = utils.monotonic_time() try: self.log.debug('recovery: started') # Starting up libvirt might take long when host under high load, # we prefer running this code in external thread to avoid blocking # API response. mog = min(config.getint('vars', 'max_outgoing_migrations'), numa.cpu_topology().cores) migration.SourceThread.setMaxOutgoingMigrations(mog) recovery.all_vms(self) # recover stage 3: waiting for domains to go up self._waitForDomainsUp() recovery.clean_vm_files(self) self._recovery = False # Now if we have VMs to restore we should wait pool connection # and then prepare all volumes. # Actually, we need it just to get the resources for future # volumes manipulations self._waitForStoragePool() self._preparePathsForRecoveredVMs() self.log.info('recovery: completed in %is', utils.monotonic_time() - start_time) except: self.log.exception("recovery: failed") raise
def _recoverExistingVms(self): start_time = utils.monotonic_time() try: self.log.debug('recovery: started') # Starting up libvirt might take long when host under high load, # we prefer running this code in external thread to avoid blocking # API response. mog = min(config.getint('vars', 'max_outgoing_migrations'), caps.CpuTopology().cores()) migration.SourceThread.setMaxOutgoingMigrations(mog) recovery.all_vms(self) # recover stage 3: waiting for domains to go up self._waitForDomainsUp() recovery.clean_vm_files(self) self._recovery = False # Now if we have VMs to restore we should wait pool connection # and then prepare all volumes. # Actually, we need it just to get the resources for future # volumes manipulations self._waitForStoragePool() self._preparePathsForRecoveredVMs() self.log.info('recovery: completed in %is', utils.monotonic_time() - start_time) except: self.log.exception("recovery: failed") raise
def test_clean_vm_files(self): with fake.VM() as testvm, namedTemporaryDir() as tmpdir: with MonkeyPatchScope([(constants, 'P_VDSM_RUN', tmpdir + '/')]): stored = recovery.File(testvm.id) stored.save(testvm) loaded = recovery.File(testvm.id) fakecif = fake.ClientIF() loaded.load(fakecif) # we have one recovery file (just created) self.assertEqual(len(os.listdir(tmpdir)), 1) # ...but somehow ClientIF failed to create the VM. self.assertEqual(fakecif.vmContainer, {}) # ... so we can actually do our test. recovery.clean_vm_files(fakecif) self.assertEqual(os.listdir(tmpdir), [])