Beispiel #1
0
def _list_vg_names():
    try:
        names = lvm.listVgNames()
    except LibLVMError:
        # Try to use the lvm binary instead
        names = []

    if not names:  # Could be just broken...
        p = subprocess.Popen(["/sbin/lvm", "vgs", "-o", "vg_name"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        err = p.wait()
        if err:
            raise _ResultError(_("Failed to obtain volume group names"))

        output = p.communicate()[0]
        output = output.split("\n")
        if not output:
            return []
        header = output[0].strip()
        if header != "VG":
            return []
        names = []
        for name in output[1:]:
            if not name:
                break
            names.append(name.strip())

    return names
Beispiel #2
0
def do_remove_storage(_):
    """Destroys logical volume and volume group created for local storage.
    Returns tuple of success flag and list of devices which were used in
    destroyed VG.
    Result of the function will be additionally processed, so it does not
    return readable statuses of performed operation.

    """
    all_names = lvm.listVgNames()
    if KD_VG_NAME not in all_names:
        return True, []
    vg = lvm.vgOpen(KD_VG_NAME, 'w')
    try:
        silent_call(['umount', '-f', LOCAL_STORAGE_MOUNT_POINT])
        pvs = [item.getName() for item in vg.listPVs()]
        for lv in vg.listLVs():
            lv.deactivate()
            lv.remove()
        vg.remove()
        remove_ls_mount()
        return True, pvs
    except Exception as err:
        return False, u'Exception: {}'.format(err)
    finally:
        vg.close()
	def test_vg_uuids(self):

		device_names = TestLvm._get_pv_device_names()
		TestLvm._create_thin_lv(device_names[0:2], 'thin')
		TestLvm._create_thick_lv(device_names[2:4], 'thick')

		vgs_uuids = lvm.listVgUuids()

		self.assertTrue(len(vgs_uuids) > 0)
		self.assertTrue(isinstance(vgs_uuids, tuple))

		vgs_uuids = list(vgs_uuids)
		vgs_names = lvm.listVgNames()

		for vg_name in vgs_names:
			vg = lvm.vgOpen(vg_name, "r")

			#TODO Write/fix BUG, vg uuid don't match between
			#lvm.listVgUuids and vg.getUuid()
			vg_uuid_search = vg.getUuid().replace('-', '')

			self.assertTrue(vg_uuid_search in vgs_uuids)
			vgs_uuids.remove(vg_uuid_search)
			vg.close()

		self.assertTrue(len(vgs_uuids) == 0)
Beispiel #4
0
	def test_vg_uuids(self):

		device_names = TestLvm._get_pv_device_names()
		TestLvm._create_thin_lv(device_names[0:2], 'thin')
		TestLvm._create_thick_lv(device_names[2:4], 'thick')

		vgs_uuids = lvm.listVgUuids()

		self.assertTrue(len(vgs_uuids) > 0)
		self.assertTrue(isinstance(vgs_uuids, tuple))

		vgs_uuids = list(vgs_uuids)
		vgs_names = lvm.listVgNames()

		for vg_name in vgs_names:
			vg = lvm.vgOpen(vg_name, "r")

			#TODO Write/fix BUG, vg uuid don't match between
			#lvm.listVgUuids and vg.getUuid()
			vg_uuid_search = vg.getUuid().replace('-', '')

			self.assertTrue(vg_uuid_search in vgs_uuids)
			vgs_uuids.remove(vg_uuid_search)
			vg.close()

		self.assertTrue(len(vgs_uuids) == 0)
Beispiel #5
0
def _list_vg_names():
    names = lvm.listVgNames()

    if not names: # Could be just broken...
        if not os.path.exists("/sbin/lvm"):
            return [] # Minimal install etc.

        p = subprocess.Popen(["/sbin/lvm", "vgs", "-o", "vg_name"],
                             stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        err = p.wait()
        if err:
            return [] # Meh.

        output = p.communicate()[0]
        output = output.split('\n')
        if not output:
            return []
        header = output[0].strip()
        if header != 'VG':
            return []
        names = []
        for name in output[1:]:
            if not name:
                break
            names.append(name.strip())

    return names
Beispiel #6
0
    def testVgTags(self):
        vg_name_list = lvm.listVgNames()

        for vg_name in vg_name_list:
            vg = lvm.vgOpen(vg_name, 'w')
            self._testTags(vg)
            vg.close()
Beispiel #7
0
def _list_vg_names():
    names = lvm.listVgNames()

    if not names:  # Could be just broken...
        if not os.path.exists("/sbin/lvm"):
            return []  # Minimal install etc.

        p = subprocess.Popen(["/sbin/lvm", "vgs", "-o", "vg_name"],
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE)
        err = p.wait()
        if err:
            return []  # Meh.

        output = p.communicate()[0]
        output = output.split('\n')
        if not output:
            return []
        header = output[0].strip()
        if header != 'VG':
            return []
        names = []
        for name in output[1:]:
            if not name:
                break
            names.append(name.strip())

    return names
Beispiel #8
0
def _list_vg_names():
    try:
        names = lvm.listVgNames()
    except LibLVMError:
        # Try to use the lvm binary instead
        names = []

    if not names:  # Could be just broken...
        p = subprocess.Popen(["/sbin/lvm", "vgs", "-o", "vg_name"],
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE)
        err = p.wait()
        if err:
            raise _ResultError(_("Failed to obtain volume group names"))

        output = p.communicate()[0]
        output = output.split('\n')
        if not output:
            return []
        header = output[0].strip()
        if header != 'VG':
            return []
        names = []
        for name in output[1:]:
            if not name:
                break
            names.append(name.strip())

    return names
Beispiel #9
0
    def testVgGetName(self):
        vgname_list = lvm.listVgNames()

        for vg_name in vgname_list:
            vg = lvm.vgOpen(vg_name, 'r')
            self.assertEqual(vg.getName(), vg_name)
            vg.close()
Beispiel #10
0
	def testVgTags(self):
		vg_name_list = lvm.listVgNames()

		for vg_name in vg_name_list:
			vg = lvm.vgOpen(vg_name, 'w')
			self._testTags(vg)
			vg.close()
Beispiel #11
0
	def testVgGetName(self):
		vgname_list = lvm.listVgNames()

		for vg_name in vgname_list:
			vg = lvm.vgOpen(vg_name, 'r')
			self.assertEqual(vg.getName(), vg_name)
			vg.close()
Beispiel #12
0
	def testPvLookupFromVG(self):
		vg_names = lvm.listVgNames()

		for vg_name in vg_names:
			vg = lvm.vgOpen(vg_name, 'w')
			pvs = vg.listPVs()

			for p in pvs:
				name = p.getName()
				uuid = p.getUuid()

				pv_name_lookup = vg.pvFromName(name)
				pv_uuid_lookup = vg.pvFromUuid(uuid)

				self.assertTrue(pv_name_lookup.getName() == \
						pv_uuid_lookup.getName())
				self.assertTrue(pv_name_lookup.getUuid() == \
						pv_uuid_lookup.getUuid())

				self.assertTrue(name == pv_name_lookup.getName())
				self.assertTrue(uuid == pv_uuid_lookup.getUuid())

				pv_name_lookup = None
				pv_uuid_lookup = None
				p = None

			pvs = None
			vg.close()
Beispiel #13
0
 def _get_pv_test(self, mode='r'):
     vg_name_list = lvm.listVgNames()
     for vgname in vg_name_list:
         vg = lvm.vgOpen(vgname, mode)
         pvs = vg.listPVs()
         if len(pvs):
             return pvs[0]
     return None
Beispiel #14
0
	def _get_pv_test(self, mode='r'):
		vg_name_list = lvm.listVgNames()
		for vgname in vg_name_list:
			vg = lvm.vgOpen(vgname, mode)
			pvs = vg.listPVs()
			if len(pvs):
				return pvs[0]
		return None
Beispiel #15
0
	def _get_pv_test(self):
		vg_name_list = lvm.listVgNames()
		for vgname in vg_name_list:
			vg = lvm.vgOpen(vgname, "w")
			pvs = vg.listPVs()
			if len(pvs):
				return pvs[0], vg
		return None, None
Beispiel #16
0
	def testVgGetUuid(self):
		vgname_list = lvm.listVgNames()

		for vg_name in vgname_list:
			vg = lvm.vgOpen(vg_name, 'r')
			uuid = vg.getUuid()
			self.assertNotEqual(uuid, None)
			self.assertTrue(len(uuid) > 0)
			vg.close()
Beispiel #17
0
    def testVgGetUuid(self):
        vgname_list = lvm.listVgNames()

        for vg_name in vgname_list:
            vg = lvm.vgOpen(vg_name, 'r')
            uuid = vg.getUuid()
            self.assertNotEqual(uuid, None)
            self.assertTrue(len(uuid) > 0)
            vg.close()
Beispiel #18
0
	def _vg_names():
		rc = []
		vg_names = lvm.listVgNames()

		for i in vg_names:
			if i[0:len(TestLvm.VG_P)] == TestLvm.VG_P:
				rc.append(i)

		return rc
	def _vg_names():
		rc = []
		vg_names = lvm.listVgNames()

		for i in vg_names:
			if i[0:len(TestLvm.VG_P)] == TestLvm.VG_P:
				rc.append(i)

		return rc
Beispiel #20
0
def add_devices_to_localstorage(devices):
    """Initializes KD volume group: Creates vg if it not exists, activates it
    if not active. Adds devices to VG.
    """
    all_names = lvm.listVgNames()
    if KD_VG_NAME not in all_names:
        vg = lvm.vgCreate(KD_VG_NAME)
    else:
        vg = lvm.vgOpen(KD_VG_NAME, 'w')
    try:
        pvs = {item.getName(): item for item in vg.listPVs()}
        lv = None
        for dev in devices:
            if dev in pvs:
                continue
            lvm.pvCreate(dev)
            vg.extend(dev)
            new_pv = [
                item for item in vg.listPVs() if item.getName() == dev
            ][0]
            pvs[dev] = new_pv
        for item in vg.listLVs():
            if item.getName() == KD_LV_NAME:
                lv = item
                break
        #dev = os.path.join('/dev', KD_VG_NAME, KD_LV_NAME)
        if not os.path.isdir(LOCAL_STORAGE_MOUNT_POINT):
            os.makedirs(LOCAL_STORAGE_MOUNT_POINT)

        if not lv:
            lv = vg.createLvLinear(KD_LV_NAME, vg.getFreeSize())
            dev = lv.getProperty('lv_path')[0]
            ok, message = make_fs(dev)
            if not ok:
                return ERROR, {'message': message}
        else:
            dev = lv.getProperty('lv_path')[0]
            if vg.getFreeSize():
                lv.resize(lv.getSize() + vg.getFreeSize())
        if not is_mounted(LOCAL_STORAGE_MOUNT_POINT):
            ok, message = mount(dev, LOCAL_STORAGE_MOUNT_POINT)
            if not ok:
                return ERROR, {'message': message}
        extend_fs_size(LOCAL_STORAGE_MOUNT_POINT)
        pv_info = {
            key: {'size': item.getDevSize()}
            for key, item in pvs.iteritems()
        }

    finally:
        vg.close()
    make_permanent_mount(dev, LOCAL_STORAGE_MOUNT_POINT)

    return OK, {
        'lsUsage': get_fs_usage(LOCAL_STORAGE_MOUNT_POINT),
        'PV': pv_info
    }
Beispiel #21
0
def print_lvm_stuff():
    vg_names = lvm.listVgNames()
    for vg_name in vg_names:
        vg = lvm.vgOpen(vg_name, 'r')
        print '=================================='

        print\
        'VG name:{}\nID:{}\nSize:{}\nExtentCount:{}\nExtentSize:{}\nFreeExtentCount:{}\nFreeSize:{}\nMaxLv:{}\nMaxPv:{}\nPvCount:{}\nSeqno:{}\nClustered:{}\nExported:{}\nPartial:{}'.format(
        vg.getName(),
        vg.getUuid(),
        vg.getSize(),
        vg.getExtentCount(),
        vg.getExtentSize(),
        vg.getFreeExtentCount(),
        vg.getFreeSize(),
        vg.getMaxLv(),
        vg.getMaxPv(),
        vg.getPvCount(),
        vg.getSeqno(),
        vg.isClustered(),
        vg.isExported(),
        vg.isPartial()
        )

        print '\\\\\\\\\\\\\\\\PVs\\\\\\\\\\\\\\\\\\\\\\\\\\'
        pv_list = vg.listPVs()
        for pv in pv_list:
            print\
            'PV name:{}\nID:{}\nSize:{}\nMdaCount:{}\nFree:{}\nDevSize:{}\n'.format(
            pv.getName(),
            pv.getUuid(),
            pv.getSize(),
            pv.getMdaCount(),
            pv.getFree(),
            pv.getDevSize()
            )
        print '\\\\\\\\\\\\\\\\PVs\\\\\\\\\\\\\\\\\\\\\\\\\\'

        print '\\\\\\\\\\\\\\\\LVs\\\\\\\\\\\\\\\\\\\\\\\\\\'
        lv_list = vg.listLVs()
        for lv in lv_list:
            print\
            'LV name:{}\nID:{}\nSize:{}\nAttr:{}\nOrigin:{}\nActive:{}\nSuspended:{}'.format(
            lv.getName(),
            lv.getUuid(),
            lv.getSize(),
            lv.getAttr(),
            lv.getOrigin(),
            lv.isActive(),
            lv.isSuspended()
            )
        print '\\\\\\\\\\\\\\\\LVs\\\\\\\\\\\\\\\\\\\\\\\\\\'

        vg.close()

        return True
Beispiel #22
0
    def testLvMisc(self):
        #Need to look at lack of vg_write in vg create

        #For this to work cleanly we will remove an existing lv & vg and then
        #put it back so that the test framework can clean it up.
        vg_name_list = lvm.listVgNames()

        if len(vg_name_list):
            vg_name = vg_name_list[0]

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

            vg_mda_copies = vg.getProperty('vg_mda_copies')
            vg.setProperty('vg_mda_copies', vg_mda_copies[0])

            pvs = vg.listPVs()
            lvs = vg.listLVs()

            pe_devices = []
            for p in pvs:
                pe_devices.append(p.getName())

            self.assertEquals(len(lvs), 1)

            lv = lvs[0]

            lv_name = lv.getName()
            lv_size = lv.getSize()

            lv.remove()
            lv = None

            vg.reduce(pe_devices[0])

            vg.remove()
            vg.close()

            nvg = lvm.vgCreate(vg_name)
            for p in pe_devices:
                nvg.extend(p)

            #2MiB extent size
            new_extent = 1024 * 1024 * 2

            nvg.setExtentSize(new_extent)
            self.assertEqual(nvg.getExtentSize(), new_extent)

            v = nvg.createLvLinear(lv_name, lv_size)

            lv_find_name = nvg.lvFromName(lv_name)
            lv_find_uuid = nvg.lvFromUuid(v.getUuid())

            self.assertTrue(lv_find_name.getName() == v.getName())
            self.assertTrue(lv_find_uuid.getUuid() == v.getUuid())

            nvg.close()
Beispiel #23
0
	def testLvMisc(self):
		#Need to look at lack of vg_write in vg create

		#For this to work cleanly we will remove an existing lv & vg and then
		#put it back so that the test framework can clean it up.
		vg_name_list = lvm.listVgNames()

		if len(vg_name_list):
			vg_name = vg_name_list[0]

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

			vg_mda_copies = vg.getProperty('vg_mda_copies')
			vg.setProperty('vg_mda_copies', vg_mda_copies[0])

			pvs = vg.listPVs()
			lvs = vg.listLVs()

			pe_devices = []
			for p in pvs:
				pe_devices.append(p.getName())

			self.assertEquals(len(lvs), 1)

			lv = lvs[0]

			lv_name = lv.getName()
			lv_size = lv.getSize()

			lv.remove()
			lv = None

			vg.reduce(pe_devices[0])

			vg.remove()
			vg.close()

			nvg = lvm.vgCreate(vg_name)
			for p in pe_devices:
				nvg.extend(p)

			#2MiB extent size
			new_extent = 1024 * 1024 * 2

			nvg.setExtentSize(new_extent)
			self.assertEqual(nvg.getExtentSize(), new_extent)

			v = nvg.createLvLinear(lv_name, lv_size)

			lv_find_name = nvg.lvFromName(lv_name)
			lv_find_uuid = nvg.lvFromUuid(v.getUuid())

			self.assertTrue(lv_find_name.getName() == v.getName())
			self.assertTrue(lv_find_uuid.getUuid() == v.getUuid())

			nvg.close()
Beispiel #24
0
    def testVgFromPVLookups(self):
        vgname_list = lvm.listVgNames()
        for vg_name in vgname_list:
            vg = lvm.vgOpen(vg_name, 'r')

            vg_name = vg.getName()

            pv_list = vg.listPVs()
            for pv in pv_list:
                vg_name_from_pv = lvm.vgNameFromPvid(pv.getUuid())
                self.assertEquals(vg_name, vg_name_from_pv)
                self.assertEqual(vg_name, lvm.vgNameFromDevice(pv.getName()))
            vg.close()
Beispiel #25
0
	def testVgFromPVLookups(self):
		vgname_list = lvm.listVgNames()
		for vg_name in vgname_list:
			vg = lvm.vgOpen(vg_name, 'r')

			vg_name = vg.getName()

			pv_list = vg.listPVs()
			for pv in pv_list:
				vg_name_from_pv = lvm.vgNameFromPvid(pv.getUuid())
				self.assertEquals(vg_name, vg_name_from_pv)
				self.assertEqual(vg_name, lvm.vgNameFromDevice(pv.getName()))
			vg.close()
	def test_listing():

		env = os.environ

		for k, v in env.items():
			l("%s:%s" % (k, v))

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

		l('Checking for VG')
		for v in lvm.listVgNames():
			l('vg= %s' % v)
Beispiel #27
0
def find_vg_with_free_space():
    free_space = 0
    rc = None

    vg_names = lvm.listVgNames()
    for v in vg_names:
        vg = lvm.vgOpen(v, 'r')
        c_free = vg.getFreeSize()
        if c_free > free_space:
            free_space = c_free
            rc = v
        vg.close()

    return rc
Beispiel #28
0
def find_vg_with_free_space():
    free_space = 0
    rc = None

    vg_names = lvm.listVgNames()
    for v in vg_names:
        vg = lvm.vgOpen(v, 'r')
        c_free = vg.getFreeSize()
        if c_free > free_space:
            free_space = c_free
            rc = v
        vg.close()

    return rc
Beispiel #29
0
	def test_listing():

		env = os.environ

		for k, v in env.items():
			l("%s:%s" % (k, v))

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

		l('Checking for VG')
		for v in lvm.listVgNames():
			l('vg= %s' % v)
Beispiel #30
0
	def testVgGetters(self):
		vg_name_list = lvm.listVgNames()

		for vg_name in vg_name_list:
			vg = lvm.vgOpen(vg_name, 'r')
			self.assertTrue(type(vg.isClustered()) == bool)
			self.assertTrue(type(vg.isExported()) == bool)
			self.assertTrue(type(vg.isPartial()) == bool)

			#Loop through the list invoking the method
			for method_name in TestLvm.RETURN_NUMERIC:
				method = getattr(vg, method_name)
				result = method()
				self.assertTrue(type(result) == int)

			vg.close()
Beispiel #31
0
    def testVgGetters(self):
        vg_name_list = lvm.listVgNames()

        for vg_name in vg_name_list:
            vg = lvm.vgOpen(vg_name, 'r')
            self.assertTrue(type(vg.isClustered()) == bool)
            self.assertTrue(type(vg.isExported()) == bool)
            self.assertTrue(type(vg.isPartial()) == bool)

            #Loop through the list invoking the method
            for method_name in TestLvm.RETURN_NUMERIC:
                method = getattr(vg, method_name)
                result = method()
                self.assertTrue(type(result) == int)

            vg.close()
Beispiel #32
0
	def _get_lv_test(self, lv_vol_type=None, lv_name=None):
		vg_name_list = lvm.listVgNames()
		for vgname in vg_name_list:
			vg = lvm.vgOpen(vgname, "w")
			lvs = vg.listLVs()

			for l in lvs:
				attr = l.getAttr()
				if lv_vol_type or lv_name:
					if lv_vol_type is not None and attr[0] == lv_vol_type:
						return l, vg
					elif lv_name is not None and lv_name == l.getName():
						return l, vg
				else:
					return l, vg
			vg.close()
		return None, None
Beispiel #33
0
def do_get_info(_):
    all_names = lvm.listVgNames()
    if KD_VG_NAME not in all_names:
        return ERROR, {'message': 'KD volume group not found on the host'}
    vg = lvm.vgOpen(KD_VG_NAME, 'r')
    try:
        pvs = {item.getName(): item for item in vg.listPVs()}
        pv_info = {
            key: {'size': item.getDevSize()}
            for key, item in pvs.iteritems()
        }
    finally:
        vg.close()

    return OK, {
        'lsUsage': get_fs_usage(LOCAL_STORAGE_MOUNT_POINT),
        'PV': pv_info
    }
Beispiel #34
0
    def testDupeLvCreate(self):
        """
		Try to create a lv with the same name expecting a failure
		Note: This was causing a seg. fault previously
		"""
        vgs = lvm.listVgNames()

        if len(vgs):
            vg_name = vgs[0]
            vg = lvm.vgOpen(vg_name, "w")

            lvs = vg.listLVs()

            if len(lvs):
                lv = lvs[0]
                lv_name = lv.getName()
                self.assertRaises(lvm.LibLVMError, vg.createLvLinear, lv_name,
                                  lv.getSize())
Beispiel #35
0
	def testDupeLvCreate(self):
		"""
		Try to create a lv with the same name expecting a failure
		Note: This was causing a seg. fault previously
		"""
		vgs = lvm.listVgNames()

		if len(vgs):
			vg_name = vgs[0]
			vg = lvm.vgOpen(vg_name, "w")

			lvs = vg.listLVs()

			if len(lvs):
				lv = lvs[0]
				lv_name = lv.getName()
				self.assertRaises(lvm.LibLVMError, vg.createLvLinear, lv_name,
					lv.getSize())
Beispiel #36
0
    def testVgUuids(self):
        vgs_uuids = lvm.listVgUuids()

        self.assertTrue(isinstance(vgs_uuids, tuple))

        vgs_uuids = list(vgs_uuids)

        vgs_names = lvm.listVgNames()

        for vg_name in vgs_names:
            vg = lvm.vgOpen(vg_name, "r")

            #TODO Write/fix BUG, vg uuid don't match between lvm.listVgUuids
            # and vg.getUuid()
            vg_uuid_search = vg.getUuid().replace('-', '')

            self.assertTrue(vg_uuid_search in vgs_uuids)
            vgs_uuids.remove(vg_uuid_search)

        self.assertTrue(len(vgs_uuids) == 0)
Beispiel #37
0
	def testVgUuids(self):
		vgs_uuids = lvm.listVgUuids()

		self.assertTrue(isinstance(vgs_uuids, tuple))

		vgs_uuids = list(vgs_uuids)

		vgs_names = lvm.listVgNames()

		for vg_name in vgs_names:
			vg = lvm.vgOpen(vg_name, "r")

			#TODO Write/fix BUG, vg uuid don't match between lvm.listVgUuids
			# and vg.getUuid()
			vg_uuid_search = vg.getUuid().replace('-', '')

			self.assertTrue(vg_uuid_search in vgs_uuids)
			vgs_uuids.remove(vg_uuid_search)

		self.assertTrue(len(vgs_uuids) == 0)
Beispiel #38
0
	def setUp(self):
		device_list = self._get_pv_devices()

		#Make sure our prepare script is doing as expected.
		self.assertTrue(len(device_list) >= 4)

		vg_names = lvm.listVgNames()

		#If we don't have any volume groups lets setup one for
		#those tests that are expecting one
		if len(vg_names) == 0:
			self._createThick([device_list[TestLvm.FULL_PV]])

			vg = lvm.vgCreate('thin_vg')
			vg.extend(device_list[TestLvm.THIN_PV_A])
			vg.extend(device_list[TestLvm.THIN_PV_B])
			vg.createLvThinpool('thin_pool', vg.getSize()/2, 0, 0,
					lvm.THIN_DISCARDS_PASSDOWN, 1)
			vg.createLvThin('thin_pool', 'thin_lv', vg.getSize()/3)
			vg.close()
			vg = None
Beispiel #39
0
            tags = lv.getTags()
            for t in tags:
                #Remove tag
                lv.removeTag(t)

            lv.deactivate()

            #Try to rename
            lv.rename("python_lvm_renamed")
            print('LV name= ', lv.getName())
            lv.remove()

        vg.close()
    else:
        print('No free space available to create demo lv!')


if __name__ == '__main__':
    #What version
    print('lvm version=', lvm.getVersion())

    #Get a list of volume group names
    vg_names = lvm.listVgNames()

    #For each volume group display some information about each of them
    for vg_i in vg_names:
        print_vg(vg_i)

    #Demo creating a logical volume
    create_delete_logical_volume()
Beispiel #40
0
	def test_vg_names(self):
		vg = lvm.listVgNames()
		self.assertTrue(isinstance(vg, tuple))
Beispiel #41
0
	def testVgOpen(self):
		vg_names = lvm.listVgNames()

		for i in vg_names:
			vg = lvm.vgOpen(i)
			vg.close()
Beispiel #42
0
    def testVgOpen(self):
        vg_names = lvm.listVgNames()

        for i in vg_names:
            vg = lvm.vgOpen(i)
            vg.close()
Beispiel #43
0
            tags = lv.getTags()
            for t in tags:
                #Remove tag
                lv.removeTag(t)

            lv.deactivate()

            #Try to rename
            lv.rename("python_lvm_renamed")
            print('LV name= ', lv.getName())
            lv.remove()

        vg.close()
    else:
        print('No free space available to create demo lv!')

if __name__ == '__main__':
    #What version
    print('lvm version=', lvm.getVersion())

    #Get a list of volume group names
    vg_names = lvm.listVgNames()

    #For each volume group display some information about each of them
    for vg_i in vg_names:
        print_vg(vg_i)

    #Demo creating a logical volume
    create_delete_logical_volume()

	def test_vg_names(self):
		vg = lvm.listVgNames()
		self.assertTrue(isinstance(vg, tuple))
Beispiel #45
0
def vg_list(req, params=None):
    output = lvm.listVgNames()
    return output