def start(self): logging.info("Starting CT") logging.info("Running vzctl start") proc = subprocess.Popen( [vzctl_bin, "--skipowner", "--skiplock", "start", self._ctid], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) proc_output = proc.communicate()[0] util.log_subprocess_output(proc_output) self._fs_mounted = True
def umount(self): if self._fs_mounted: logging.info("Umounting CT root") logging.info("Running vzctl umount") proc = subprocess.Popen( [vzctl_bin, "--skipowner", "--skiplock", "umount", self._ctid], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) proc_output = proc.communicate()[0] util.log_subprocess_output(proc_output) self._fs_mounted = False
def mount(self): logging.info("Mounting CT root to %s", self._ct_root) logging.info("Running vzctl mount") proc = subprocess.Popen( [vzctl_bin, "--skipowner", "--skiplock", "mount", self._ctid], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) proc_output = proc.communicate()[0] util.log_subprocess_output(proc_output) self._fs_mounted = True return self._ct_root
def stop(self, umount): logging.info("Stopping CT") logging.info("Running vzctl stop") args = [vzctl_bin, "--skipowner", "--skiplock", "stop", self._ctid] if not umount: args.append("--skip-umount") proc = subprocess.Popen( args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) proc_output = proc.communicate()[0] util.log_subprocess_output(proc_output) self._fs_mounted = not umount
def start(self): logging.info("Starting CT") logging.info("Running vzctl start") proc = subprocess.Popen( [vzctl_bin, "--skipowner", "--skiplock", "start", self._ctid], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) proc_output = proc.communicate()[0] util.log_subprocess_output(proc_output) if proc.returncode != 0: raise Exception("Start failed ({0})".format(proc.returncode)) self._fs_mounted = True
def final_restore(self, img, connection): """Perform Virtuozzo-specific final restore""" try: # Setup restore extra arguments args_path = os.path.join(img.image_dir(), "restore-extra-args") self.__setup_restore_extra_args(args_path, img, connection) # Run vzctl restore logging.info("Starting vzctl restore") proc = subprocess.Popen([vzctl_bin, "--skipowner", "--skiplock", "restore", self._ctid, "--skip_arpdetect", "--dumpfile", img.image_dir()], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) proc_output = proc.communicate()[0] util.log_subprocess_output(proc_output) if proc.returncode != 0: raise Exception("Restore failed ({0})".format(proc.returncode)) finally: # Remove restore extra arguments self.__remove_restore_extra_args(args_path)