Exemplo n.º 1
0
	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
Exemplo n.º 2
0
	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
Exemplo n.º 3
0
	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
Exemplo n.º 4
0
	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
Exemplo n.º 5
0
	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
Exemplo n.º 6
0
 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
Exemplo n.º 7
0
	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
Exemplo n.º 8
0
	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
Exemplo n.º 9
0
	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
Exemplo n.º 10
0
	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
Exemplo n.º 11
0
	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)
Exemplo n.º 12
0
	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)