def testPVresize(self): with lvm.listPvs() as pvs: pv = pvs[TestLvm.RESIZE_PV] curr_size = pv.getSize() dev_size = pv.getDevSize() self.assertTrue(curr_size == dev_size) pv.resize(curr_size/2) with lvm.listPvs() as pvs: pv = pvs[TestLvm.RESIZE_PV] resized_size = pv.getSize() self.assertTrue(resized_size != curr_size) pv.resize(dev_size)
def _get_pv_devices(self): rc = [] with lvm.listPvs() as pvs: for p in pvs: name = p.getName() self.assertTrue(name is not None and len(name) > 0) rc.append(name) p = None return rc
def testPvMethods(self): with lvm.listPvs() as pvs: for p in pvs: p.getName() p.getUuid() p.getMdaCount() p.getSize() p.getDevSize() p.getFree() p = None
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)
def pv_list(req, params=None): output = [] pvlistobj = lvm.listPvs() pvlist = pvlistobj.open() for pv in pvlist: output.append( dict(name=pv.getName(), size=pv.getSize(), devsize=pv.getDevSize(), freesize=pv.getFree(), mdacount=pv.getMdaCount(), uuid=pv.getUuid())) pvlistobj.close() return output
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)
def __enter__(self): rc = [] allowed_dev = _get_allowed_devices() if allowed_dev: self.handle = lvm.listPvs() self.pvs_all = self.handle.open() for p in self.pvs_all: if p.getName() in allowed_dev: rc.append(p) #Sort them consistently rc.sort(key=lambda x: x.getName()) return rc
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 pv_get_free_devices(): rc = [] with lvm.listPvs() as pvs: for p in pvs: rc.append(p.getName()) return rc