def _clean_up():
		#Clear out the testing PVs, but only if they contain stuff
		#this unit test created
		for vg_n in TestLvm._vg_names():
			TestLvm._remove_vg(vg_n)

		for d in TestLvm._get_pv_device_names():
			lvm.pvRemove(d)
			lvm.pvCreate(d)
Exemplo n.º 2
0
	def _clean_up():
		#Clear out the testing PVs, but only if they contain stuff
		#this unit test created
		for vg_n in TestLvm._vg_names():
			TestLvm._remove_vg(vg_n)

		for d in TestLvm._get_pv_device_names():
			lvm.pvRemove(d)
			lvm.pvCreate(d)
Exemplo n.º 3
0
def thinpool_LV():

    device = '/dev/sdd'
    vg_name = 'TEST_VG'
    lv_pool = 'TEST_POOL'
    lv_thin = 'TEST_THIN'

    lvm.pvCreate(device)

    vg = lvm.vgCreate(vg_name)

    vg.extend('/dev/sdd')

    pv_list = vg.listPVs()
    for pv in pv_list:
        print 'PV name: ', pv.getName(), ' ID: ', pv.getUuid(
        ), 'Size: ', pv.getSize()
    lv = vg.createLvThinpool(lv_pool, 1024 * 1024 * 1024)
    lv2 = vg.createLvThin(lv.getName(), lv_thin, 1024 * 1024 * 1024 * 1024)

    print lv2.deactivate()
    print lv2.getAttr()
    print lv.deactivate()
    print lv.getAttr()
    raw_input('acticate?')
    print lv.activate()
    print lv.getAttr()
    print lv2.activate()
    print lv2.getAttr()

    vg.close()
    raw_input('??')

    #vg.reduce('/dev/sdd')

    vg = lvm.vgOpen(vg_name, 'w')
    lv = vg.lvFromName(lv_thin)
    lv.remove()

    lv = vg.lvFromName(lv_pool)
    lv.remove()

    vg.remove()

    lvm.configReload()

    lvm.pvRemove(device)

    return True
Exemplo n.º 4
0
	def test_pv_empty_listing(self):
		#We had a bug where we would seg. fault if we had no PVs.

		l('testPVemptylisting entry')

		device_names = TestLvm._get_pv_device_names()

		for d in device_names:
			l("Removing %s" % d)
			lvm.pvRemove(d)

		count = 0

		with lvm.listPvs() as pvs:
			for p in pvs:
				count += 1
				l('pv= %s' % p.getName())

		self.assertTrue(count == 0)

		for d in device_names:
			lvm.pvCreate(d)
	def test_pv_empty_listing(self):
		#We had a bug where we would seg. fault if we had no PVs.

		l('testPVemptylisting entry')

		device_names = TestLvm._get_pv_device_names()

		for d in device_names:
			l("Removing %s" % d)
			lvm.pvRemove(d)

		count = 0

		with lvm.listPvs() as pvs:
			for p in pvs:
				count += 1
				l('pv= %s' % p.getName())

		self.assertTrue(count == 0)

		for d in device_names:
			lvm.pvCreate(d)
Exemplo n.º 6
0
	def test_vg_reduce(self):
		# Test the case where we try to reduce a vg where the last PV has
		# no metadata copies.  In this case the reduce should fail.
		vg_name = TestLvm.VG_P + 'reduce_test'

		device_names = TestLvm._get_pv_device_names()

		for d in device_names:
			lvm.pvRemove(d)

		lvm.pvCreate(device_names[0], 0, 0)  # Size all, pvmetadatacopies 0
		lvm.pvCreate(device_names[1])
		lvm.pvCreate(device_names[2])
		lvm.pvCreate(device_names[3])

		vg = lvm.vgCreate(vg_name)

		vg.extend(device_names[3])
		vg.extend(device_names[2])
		vg.extend(device_names[1])
		vg.extend(device_names[0])
		vg.close()

		vg = None

		vg = lvm.vgOpen(vg_name, 'w')

		vg.reduce(device_names[3])
		vg.reduce(device_names[2])

		self.assertRaises(lvm.LibLVMError, vg.reduce, device_names[1])

		vg.close()
		vg = None

		vg = lvm.vgOpen(vg_name, 'w')
		vg.remove()
		vg.close()
	def test_vg_reduce(self):
		# Test the case where we try to reduce a vg where the last PV has
		# no metadata copies.  In this case the reduce should fail.
		vg_name = TestLvm.VG_P + 'reduce_test'

		device_names = TestLvm._get_pv_device_names()

		for d in device_names:
			lvm.pvRemove(d)

		lvm.pvCreate(device_names[0], 0, 0)  # Size all, pvmetadatacopies 0
		lvm.pvCreate(device_names[1])
		lvm.pvCreate(device_names[2])
		lvm.pvCreate(device_names[3])

		vg = lvm.vgCreate(vg_name)

		vg.extend(device_names[3])
		vg.extend(device_names[2])
		vg.extend(device_names[1])
		vg.extend(device_names[0])
		vg.close()

		vg = None

		vg = lvm.vgOpen(vg_name, 'w')

		vg.reduce(device_names[3])
		vg.reduce(device_names[2])

		self.assertRaises(lvm.LibLVMError, vg.reduce, device_names[1])

		vg.close()
		vg = None

		vg = lvm.vgOpen(vg_name, 'w')
		vg.remove()
		vg.close()
Exemplo n.º 8
0
	def test_pv_life_cycle(self):
		"""
		Test removing and re-creating a PV
		"""
		target_name = None

		with AllowedPVS() as pvs:
			pv = pvs[0]
			target_name = pv.getName()
			lvm.pvRemove(target_name)

		with AllowedPVS() as pvs:
			for p in pvs:
				self.assertTrue(p.getName() != target_name)

		lvm.pvCreate(target_name, 0)

		with AllowedPVS() as pvs:
			found = False
			for p in pvs:
				if p.getName() == target_name:
					found = True

		self.assertTrue(found)
	def test_pv_create(self):
		size = [0, 1024 * 1024 * 4]
		pvmeta_copies = [0, 1, 2]
		pvmeta_size = [0, 255, 512, 1024]
		data_alignment = [0, 2048, 4096]
		zero = [0, 1]

		device_names = TestLvm._get_pv_device_names()

		for d in device_names:
			lvm.pvRemove(d)

		d = device_names[0]

		#Test some error cases
		self.assertRaises(TypeError, lvm.pvCreate, None)
		self.assertRaises(lvm.LibLVMError, lvm.pvCreate, '')
		self.assertRaises(lvm.LibLVMError, lvm.pvCreate, d, 4)
		self.assertRaises(lvm.LibLVMError, lvm.pvCreate, d, 0, 4)
		self.assertRaises(lvm.LibLVMError, lvm.pvCreate, d, 0, 0, 0, 2 ** 34)
		self.assertRaises(
			lvm.LibLVMError, lvm.pvCreate, d, 0, 0, 0, 4096, 2 ** 34)

		#Try a number of combinations and permutations
		for s in size:
			for copies in pvmeta_copies:
				for pv_size in pvmeta_size:
					for align in data_alignment:
						for z in zero:
							lvm.pvCreate(d, s, copies, pv_size, align,
								     align, z)
							lvm.pvRemove(d)

		#Restore
		for d in device_names:
			lvm.pvCreate(d)
	def test_pv_life_cycle(self):
		"""
		Test removing and re-creating a PV
		"""
		target_name = None

		with AllowedPVS() as pvs:
			pv = pvs[0]
			target_name = pv.getName()
			lvm.pvRemove(target_name)

		with AllowedPVS() as pvs:
			for p in pvs:
				self.assertTrue(p.getName() != target_name)

		lvm.pvCreate(target_name, 0)

		with AllowedPVS() as pvs:
			found = False
			for p in pvs:
				if p.getName() == target_name:
					found = True

		self.assertTrue(found)
Exemplo n.º 11
0
	def testPVlifecycle(self):
		"""
		Test removing and re-creating a PV
		"""
		target = None

		with lvm.listPvs() as pvs:
			pv = pvs[TestLvm.RESIZE_PV]
			target = pv.getName()
			lvm.pvRemove(target)

		with lvm.listPvs() as pvs:
			for p in pvs:
				self.assertTrue(p.getName() != target)

		lvm.pvCreate(target, 0)

		with lvm.listPvs() as pvs:
			found = False
			for p in pvs:
				if p.getName() == target:
					found = True

		self.assertTrue(found)
Exemplo n.º 12
0
def normal_LV():

    lvm.pvCreate(device)

    vg = lvm.vgCreate(vg_name)

    vg.extend('/dev/sdd')

    pv_list = vg.listPVs()
    for pv in pv_list:
        print 'PV name: ', pv.getName(), ' ID: ', pv.getUuid(
        ), 'Size: ', pv.getSize()
    lv = vg.createLvLinear(lv_name, 1024 * 1024 * 1024)

    print lv.deactivate()
    print lv.getAttr()
    raw_input('acticate?')
    print lv.activate()
    print lv.getAttr()

    vg.close()
    raw_input('??')

    #vg.reduce('/dev/sdd')

    vg = lvm.vgOpen(vg_name, 'w')
    lv = vg.lvFromName(lv_name)
    lv.remove()

    vg.remove()

    lvm.configReload()

    lvm.pvRemove(device)

    return True
Exemplo n.º 13
0
	def test_pv_create(self):
		size = [0, 1024 * 1024 * 8]
		pvmeta_copies = [0, 1, 2]
		pvmeta_size = [0, 255, 512, 1024]
		data_alignment = [0, 2048, 4096]
		zero = [0, 1]

		device_names = TestLvm._get_pv_device_names()

		for d in device_names:
			lvm.pvRemove(d)

		d = device_names[0]

		#Test some error cases
		self.assertRaises(TypeError, lvm.pvCreate, None)
		self.assertRaises(lvm.LibLVMError, lvm.pvCreate, '')
		self.assertRaises(lvm.LibLVMError, lvm.pvCreate, d, 4)
		self.assertRaises(lvm.LibLVMError, lvm.pvCreate, d, 0, 4)
		self.assertRaises(lvm.LibLVMError, lvm.pvCreate, d, 0, 0, 0, 2 ** 34)
		self.assertRaises(
			lvm.LibLVMError, lvm.pvCreate, d, 0, 0, 0, 4096, 2 ** 34)

		#Try a number of combinations and permutations
		for s in size:
			for copies in pvmeta_copies:
				for pv_size in pvmeta_size:
					for align in data_alignment:
						for z in zero:
							lvm.pvCreate(d, s, copies, pv_size, align,
								     align, z)
							lvm.pvRemove(d)

		#Restore
		for d in device_names:
			lvm.pvCreate(d)
Exemplo n.º 14
0
def pv_destroy(req, path):
    lvm.pvRemove(path)
    return [{}]