Пример #1
0
 def __reload_lvs(self):
     self.lvs = list()
     self.lvs_paths = {}
     argv = list()
     argv.append(LVDISPLAY_BIN_PATH)
     argv.append("-c")
     (status, output) = process_call_argv(argv)
     if status != 0:
         logging.debug("error getting list of LV paths")
         return
     # parse command output
     lines = output.splitlines()
     for line in lines:
         line = line.strip()
         words = line.strip().split(":")
         vgname = words[1].strip()
         lvpath = words[0].strip()
         last_slash_index = lvpath.rfind("/") + 1
         lvname = lvpath[last_slash_index:]
         self.lvs_paths[vgname + '`' + lvname] = lvpath
     # lv query command
     argv = list()
     argv.append(LVM_BIN_PATH)
     argv.append("lvs")
     argv.append("--nosuffix")
     argv.append("--noheadings")
     argv.append("--units")
     argv.append("b")
     argv.append("--separator")
     argv.append(";")
     argv.append("-o")
     argv.append(
         "lv_name,vg_name,stripes,stripesize,lv_attr,lv_uuid,devices,origin,snap_percent,seg_start,seg_size,vg_extent_size,lv_size"
     )
     # execute command
     (status, output) = process_call_argv(argv)
     if status != 0:
         logging.debug("error getting list of LV")
         return
     # parse command output
     lines = output.splitlines()
     for line in lines:
         line = line.strip()
         words = line.split(";")
         lvname = words[0].strip()
         vgname = words[1].strip()
         attrs = words[4].strip()
         uuid = words[5].strip()
         extent_size = int(words[11])
         lv_size = int(words[12]) / extent_size
         if vgname == '': vgname = None
         lv = LogicalVolume(lvname, self.lvs_paths[vgname + '`' + lvname],
                            vgname, True, attrs, uuid, lv_size, extent_size)
         if vgname:
             self.__vgs[vgname].append_lv(lv)
Пример #2
0
	def __reload_lvs(self):
		self.lvs = list()
		self.lvs_paths = {}
		argv = list()
		argv.append(LVDISPLAY_BIN_PATH)
		argv.append("-c")
		(status, output) = process_call_argv(argv)
		if status != 0:
			logging.debug("error getting list of LV paths")
			return
		# parse command output
		lines = output.splitlines()
		for line in lines:
			line = line.strip()
			words = line.strip().split(":")
			vgname = words[1].strip()
			lvpath = words[0].strip()
			last_slash_index = lvpath.rfind("/") + 1
			lvname = lvpath[last_slash_index:]
			self.lvs_paths[vgname + '`' + lvname] = lvpath
		# lv query command
		argv = list()
		argv.append(LVM_BIN_PATH)
		argv.append("lvs")
		argv.append("--nosuffix")
		argv.append("--noheadings")
		argv.append("--units")
		argv.append("b")
		argv.append("--separator")
		argv.append(";")
		argv.append("-o")
		argv.append("lv_name,vg_name,stripes,stripesize,lv_attr,lv_uuid,devices,origin,snap_percent,seg_start,seg_size,vg_extent_size,lv_size")
		# execute command
		(status, output) = process_call_argv(argv)
		if status != 0:
			logging.debug("error getting list of LV")
			return
		# parse command output
		lines = output.splitlines()
		for line in lines:
			line = line.strip()
			words = line.split(";")
			lvname = words[0].strip()
			vgname = words[1].strip()
			attrs = words[4].strip()
			uuid = words[5].strip()
			extent_size = int(words[11])
			lv_size = int(words[12]) / extent_size
			if vgname == '': vgname = None
			lv = LogicalVolume(lvname, self.lvs_paths[vgname + '`' + lvname], vgname, True, attrs, uuid, lv_size, extent_size)
			if vgname:
				self.__vgs[vgname].append_lv(lv)
Пример #3
0
	def __reload_pvs(self):
		self.pvs = list()
		
		# pv query command
		argv = list()
		argv.append(LVM_BIN_PATH)
		argv.append("pvs")
		argv.append("--nosuffix")
		argv.append("--noheadings")
		argv.append("--units")
		argv.append("g")
		argv.append("--separator")
		argv.append(",")
		argv.append("-o")
		argv.append("+pv_pe_count,pv_pe_alloc_count")
		
		# execute command
		(status, output) = process_call_argv(argv)
		if status != 0:
			print "error getting list of PV"
			return
		
		# parse command output
		lines = output.splitlines()
		for line in lines:
			line = line.strip()
			words = line.split(",")
			
			vgname = words[1]
			if vgname == '': vgname = None				
			pv = PhysicalVolume(words[0], vgname, words[2], words[3], words[4], words[5], True, words[6], words[7])
			self.pvs.append(pv)
			if vgname:
				self.__vgs[vgname].append_pv(pv)
Пример #4
0
	def __reload_pvs(self):
		self.pvs = list()
		
		# pv query command
		argv = list()
		argv.append(LVM_BIN_PATH)
		argv.append("pvs")
		argv.append("--nosuffix")
		argv.append("--noheadings")
		argv.append("--units")
		argv.append("g")
		argv.append("--separator")
		argv.append(",")
		argv.append("-o")
		argv.append("+pv_pe_count,pv_pe_alloc_count")
		
		# execute command
		(status, output) = process_call_argv(argv)
		if status != 0:
			print "error getting list of PV"
			return
		
		# parse command output
		lines = output.splitlines()
		for line in lines:
			line = line.strip()
			words = line.split(",")
			
			vgname = words[1]
			if vgname == '': vgname = None				
			pv = PhysicalVolume(words[0], vgname, words[2], words[3], words[4], words[5], True, words[6], words[7])
			self.pvs.append(pv)
			if vgname:
				self.__vgs[vgname].append_pv(pv)
Пример #5
0
	def __reload_vgs(self):
		self.vgs = list()
		self.__vgs = {}
		argv = list()
		argv.append(LVM_BIN_PATH)
		argv.append("vgs")
		argv.append("--nosuffix")
		argv.append("--noheadings")
		argv.append("--units")
		argv.append("b")
		argv.append("--separator")
		argv.append(",")
		argv.append("-o")
		argv.append("vg_name,vg_attr,vg_size,vg_extent_size,vg_free_count,max_lv,max_pv")
		(status, output) = process_call_argv(argv)
		if status != 0:
			logging.debug("error getting list of VG")
			return
		lines = output.splitlines()
		for line in lines:
			line = line.strip()
			words = line.split(",")
			vgname = words[0].strip()
			extent_size = int(words[3])
			extents_total = int(words[2]) / extent_size
			extents_free = int(words[4])
			max_lvs = int(words[5])
			max_pvs = int(words[6])
			if max_lvs == 0: max_lvs = 256
			if max_pvs == 0: max_pvs = 256
			vg = VolumeGroup(vgname, words[1], extent_size, extents_total, extents_free, max_pvs, max_lvs)
			self.__vgs[vgname] = vg
			self.vgs.append(vg);
Пример #6
0
	def remove_lv(self, lv):
		argv = list()
		argv.append(LVREMOVE_BIN_PATH)
		argv.append("-f")
		argv.append(lv.path)
		(status, output) = process_call_argv(argv)
		if status != 0:
			logging.debug("error removing LV")
			return output
		logging.info(output)
		return None
Пример #7
0
 def remove_lv(self, lv):
     argv = list()
     argv.append(LVREMOVE_BIN_PATH)
     argv.append("-f")
     argv.append(lv.path)
     (status, output) = process_call_argv(argv)
     if status != 0:
         logging.debug("error removing LV")
         return output
     logging.info(output)
     return None
Пример #8
0
	def remove_lv(self, lv):
		# lv remove command
		argv = list()
		argv.append(LVREMOVE_BIN_PATH)
		#argv.append("-t")
		argv.append("-f")
		argv.append(lv.path)
		
		# execute command
		(status, output) = process_call_argv(argv)
		if status != 0:
			print "error removing LV"
			return output
		
		print output
		return None
Пример #9
0
	def remove_lv(self, lv):
		# lv remove command
		argv = list()
		argv.append(LVREMOVE_BIN_PATH)
		#argv.append("-t")
		argv.append("-f")
		argv.append(lv.path)
		
		# execute command
		(status, output) = process_call_argv(argv)
		if status != 0:
			print "error removing LV"
			return output
		
		print output
		return None
Пример #10
0
	def __reload_vgs(self):
		self.vgs = list()
		self.__vgs = {}
		
		# vg query command
		argv = list()
		argv.append(LVM_BIN_PATH)
		argv.append("vgs")
		argv.append("--nosuffix")
		argv.append("--noheadings")
		argv.append("--units")
		argv.append("b")
		argv.append("--separator")
		argv.append(",")
		argv.append("-o")
		argv.append("vg_name,vg_attr,vg_size,vg_extent_size,vg_free_count,max_lv,max_pv")
		
		# execute command
		(status, output) = process_call_argv(argv)
		if status != 0:
			print "error getting list of VG"
			return
		
		# parse command output
		lines = output.splitlines()
		for line in lines:
			line = line.strip()
			words = line.split(",")
			
			vgname = words[0].strip()
			extent_size = int(words[3])
			extents_total = int(words[2]) / extent_size
			extents_free = int(words[4])
			
			max_lvs = int(words[5])
			max_pvs = int(words[6])
			if max_lvs == 0: max_lvs = 256
			if max_pvs == 0: max_pvs = 256
			
			vg = VolumeGroup(vgname, words[1], extent_size, extents_total, extents_free, max_pvs, max_lvs)
			self.__vgs[vgname] = vg
			self.vgs.append(vg);
Пример #11
0
	def create_lv(self, vg, lvname, size):
		unit = size[-1:]
		if unit in LVM.SIZE_UNITS or unit in LVM.EXTENDS_UNITS:
			# lv create command
			argv = list()
			argv.append(LVCREATE_BIN_PATH)
			#argv.append("-t") #uncomment to give an error
			argv.append("-L" if unit in LVM.SIZE_UNITS else "-l")
			argv.append(size)
			argv.append("-n")		
			argv.append(lvname)
			argv.append(vg.name)
			# execute command
			(status, output) = process_call_argv(argv)
			if status != 0:
				logging.debug(output)
				return output
			logging.info(output)
			return None
		return "Invalid Size!"
Пример #12
0
 def create_lv(self, vg, lvname, size):
     unit = size[-1:]
     if unit in LVM.SIZE_UNITS or unit in LVM.EXTENDS_UNITS:
         # lv create command
         argv = list()
         argv.append(LVCREATE_BIN_PATH)
         #argv.append("-t") #uncomment to give an error
         argv.append("-L" if unit in LVM.SIZE_UNITS else "-l")
         argv.append(size)
         argv.append("-n")
         argv.append(lvname)
         argv.append(vg.name)
         # execute command
         (status, output) = process_call_argv(argv)
         if status != 0:
             logging.debug(output)
             return output
         logging.info(output)
         return None
     return "Invalid Size!"
Пример #13
0
			# lv create command
			argv = list()
			argv.append(LVCREATE_BIN_PATH)
			#argv.append("-t") #uncomment to give an error
			argv.append("-L" if unit in LVM.SIZE_UNITS else "-l")
			argv.append(size)
			argv.append("-n")		
			argv.append(lvname)
			if snapshot:
                argv.append('-s')
                argv.append(snapshot.path)
            else:
                argv.append(vg.name)
                
			# execute command
			(status, output) = process_call_argv(argv)
			if status != 0:
				print "error creating LV"
				return output
			
			print output
			return None
		return "Invalid Size!"
		
	def remove_lv(self, lv):
		# lv remove command
		argv = list()
		argv.append(LVREMOVE_BIN_PATH)
		#argv.append("-t")
		argv.append("-f")
		argv.append(lv.path)