From 31e4f5553e652c7806447484a7611748a93d9588 Mon Sep 17 00:00:00 2001 From: Mike Hiretsky Date: Fri, 11 May 2012 09:34:04 +0400 Subject: [PATCH] Add clear disk from lvm method. --- install/variables/autopartition.py | 24 +++++++++++++++++++++++- install/variables/lvm.py | 23 ++++++++++++----------- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/install/variables/autopartition.py b/install/variables/autopartition.py index 0a606e8..72680a6 100644 --- a/install/variables/autopartition.py +++ b/install/variables/autopartition.py @@ -164,7 +164,7 @@ class AutoPartition: def _createPhisicalVolumes(self,devices): pvCreateProg = getProgPath('/sbin/pvcreate') - return process(pvCreateProg,*devices).success() + return process(pvCreateProg,"-ff",*devices).success() def _createVolumesGroup(self,vgname,disks): vgCreateProg = getProgPath('/sbin/vgcreate') @@ -186,6 +186,28 @@ class AutoPartition: return process(vgRemoveProg,vgname,"-f").success() or \ process(vgRemoveProg,vgname,"-f").success() + def clearLvm(self,devices,dv): + """ + Remove lvm physical volumes from devices + """ + vgRemoveProg = getProgPath('/sbin/vgremove') + pvRemoveProg = getProgPath('/sbin/pvremove') + lvRemoveProg = getProgPath('/sbin/lvremove') + disks = dv.Select('os_disk_dev',where='os_disk_parent',_in=devices) + for group, pair in groupby(dv.Select(['os_lvm_vgname','os_lvm_lvname'], + where='os_lvm_pvname',_in=disks), + key=operator.itemgetter(0)): + for vgname,lvname in pair: + process(lvRemoveProg,"%s/%s"%(vgname,lvname),"-f").success() + process(vgRemoveProg,group,"-f").success() + for pvname in list(set(disks)&set(dv.Get('os_lvm_pvname'))): + process(pvRemoveProg,pvname,"-ffy") + + def clearRaid(self,devices): + """ + Remove raid physical volumes from devices + """ + def recreateLvm(self,table,devices,data,vgname): """ Create GPT partition table by /sbin/gdisk diff --git a/install/variables/lvm.py b/install/variables/lvm.py index bcc397e..7ddb5f7 100644 --- a/install/variables/lvm.py +++ b/install/variables/lvm.py @@ -31,10 +31,21 @@ from calculate.install.fs_manager import FileSystemManager from calculate.lib.cl_lang import setLocalTranslate setLocalTranslate('cl_install3',sys.modules[__name__]) +class LvmHelper: + def getLvmData(self): + """Get route table, exclude specifed iface""" + pvDisplayProg = checkUtils('/sbin/pvdisplay') + pvDisplay = process(pvDisplayProg,"--noh","-Co", + "lv_name,vg_name,pv_name") + for line in pvDisplay: + line = line.split() + if len(line) == 3: + yield line + ####################################################### # Devices variables ####################################################### -class VariableOsLvmData(ReadonlyTableVariable): +class VariableOsLvmData(ReadonlyTableVariable,LvmHelper): """ Information about disk devices """ @@ -43,16 +54,6 @@ class VariableOsLvmData(ReadonlyTableVariable): 'os_lvm_vgname', 'os_lvm_pvname'] - def getLvmData(self): - """Get route table, exclude specifed iface""" - pvDisplayProg = checkUtils('/sbin/pvdisplay') - pvDisplay = process(pvDisplayProg,"--noh","-Co", - "lv_name,vg_name,pv_name") - for line in pvDisplay: - line = line.split() - if len(line) == 3: - yield line - def get(self,hr=False): """LVM hash""" return list(self.getLvmData()) or [[]]