def _persistAlias(self, alias, conInfo): path = self._getConnectionFile(alias) tmpPath = path + ".tmp" with open(tmpPath, "w") as f: pickle.dump(conInfo, f) os.rename(tmpPath, path)
def _finishSuccessfully(self): self._progress = 100 if not self.hibernating: # TODO: We could use a timeout on the wait to be more robust # against "impossible" failures. But we don't have a good value to # use here now. self._vm.stopped_migrated_event_processed.wait() self._vm.setDownStatus(NORMAL, vmexitreason.MIGRATION_SUCCEEDED) self.status['status']['message'] = 'Migration done' if self._vm.post_copy == PostCopyPhase.RUNNING: self._vm.destroy() else: # don't pickle transient params for ignoreParam in ('displayIp', 'display', 'pid'): if ignoreParam in self._machineParams: del self._machineParams[ignoreParam] fname = self._vm.cif.prepareVolumePath(self._dstparams) try: # Use r+ to avoid truncating the file, see BZ#1282239 with open(fname, "r+") as f: pickle.dump(self._machineParams, f) finally: self._vm.cif.teardownVolumePath(self._dstparams) self._vm.setDownStatus(NORMAL, vmexitreason.SAVE_STATE_SUCCEEDED) self.status['status']['message'] = 'SaveState done'
def _dump(self, data): with tempfile.NamedTemporaryFile( dir=constants.P_VDSM_RUN, delete=False ) as f: pickle.dump(data, f) os.rename(f.name, self._path)
def _finishSuccessfully(self): self.status['progress'] = 100 if self._mode != 'file': self._vm.setDownStatus(NORMAL, vmexitreason.MIGRATION_SUCCEEDED) self.status['status']['message'] = 'Migration done' else: # don't pickle transient params for ignoreParam in ('displayIp', 'display', 'pid'): if ignoreParam in self._machineParams: del self._machineParams[ignoreParam] fname = self._vm.cif.prepareVolumePath(self._dstparams) try: with open(fname, "w") as f: pickle.dump(self._machineParams, f) finally: self._vm.cif.teardownVolumePath(self._dstparams) self._vm.setDownStatus(NORMAL, vmexitreason.SAVE_STATE_SUCCEEDED) self.status['status']['message'] = 'SaveState done'
def _finishSuccessfully(self): self._progress = 100 if not self.hibernating: self._vm.setDownStatus(NORMAL, vmexitreason.MIGRATION_SUCCEEDED) self.status['status']['message'] = 'Migration done' else: # don't pickle transient params for ignoreParam in ('displayIp', 'display', 'pid'): if ignoreParam in self._machineParams: del self._machineParams[ignoreParam] fname = self._vm.cif.prepareVolumePath(self._dstparams) try: with open(fname, "w") as f: pickle.dump(self._machineParams, f) finally: self._vm.cif.teardownVolumePath(self._dstparams) self._vm.setDownStatus(NORMAL, vmexitreason.SAVE_STATE_SUCCEEDED) self.status['status']['message'] = 'SaveState done'
def _finishSuccessfully(self): self._progress = 100 if not self.hibernating: self._vm.setDownStatus(NORMAL, vmexitreason.MIGRATION_SUCCEEDED) self.status['status']['message'] = 'Migration done' else: # don't pickle transient params for ignoreParam in ('displayIp', 'display', 'pid'): if ignoreParam in self._machineParams: del self._machineParams[ignoreParam] fname = self._vm.cif.prepareVolumePath(self._dstparams) try: # Use r+ to avoid truncating the file, see BZ#1282239 with open(fname, "r+") as f: pickle.dump(self._machineParams, f) finally: self._vm.cif.teardownVolumePath(self._dstparams) self._vm.setDownStatus(NORMAL, vmexitreason.SAVE_STATE_SUCCEEDED) self.status['status']['message'] = 'SaveState done'