[Thincrust-devel] [PATCH 4/4] Add Logical Volume Management to ApplianceImageCreator
Yongjun Wei
weiyj.lk at gmail.com
Fri Dec 16 10:03:05 UTC 2011
This patch add Logical Volume Management to ApplianceImageCreator.
Only grub is support now. grub2 support will be added later.
Signed-off-by: Wei Yongjun <yongjun_wei at trendmicro.com.cn>
diff --git a/appcreate/appliance.py b/appcreate/appliance.py
index f9fc784..2f1854c 100644
--- a/appcreate/appliance.py
+++ b/appcreate/appliance.py
@@ -74,13 +74,21 @@ class ApplianceImageCreator(ImageCreator):
s = ""
for mp in self.__instloop.mountOrder:
p = None
+ device = None
for p1 in self.__instloop.partitions:
if p1['mountpoint'] == mp:
+ device = "/dev/%s%-d" % (p1['disk'], p1['num'])
p = p1
break
+ for v in self.__instloop.volumes:
+ if v['mountpoint'] == mp:
+ device = "/dev/mapper/%s-%s" % (v['vgname'], v['name'])
+ p = v
+ break
+
s += "%(device)s %(mountpoint)s %(fstype)s defaults,noatime 0 0\n" % {
- 'device': "/dev/%s%-d" % (p['disk'], p['num']),
+ 'device': device,
'mountpoint': p['mountpoint'],
'fstype': p['fstype'] }
@@ -120,6 +128,8 @@ class ApplianceImageCreator(ImageCreator):
#list of partitions from kickstart file
parts = kickstart.get_partitions(self.ks)
+ groups = self.ks.handler.volgroup.vgList
+ volumes = self.ks.handler.logvol.lvList
#list of disks where a disk is an dict with name: and size
disks = []
@@ -173,6 +183,13 @@ class ApplianceImageCreator(ImageCreator):
for p in parts:
self.__instloop.add_partition(int(p.size), p.disk, p.mountpoint, p.fstype)
+ for g in groups:
+ self.__instloop.add_volume_groups(g.vgname, g.pesize, g.physvols)
+
+ for v in volumes:
+ self.__instloop.add_logical_volume(v.name, v.size, v.vgname,
+ v.mountpoint, v.fstype)
+
try:
self.__instloop.mount()
except MountError, e:
@@ -220,6 +237,10 @@ class ApplianceImageCreator(ImageCreator):
rootdevnum = p['num'] - 1
rootdev = "/dev/%s%-d" % (p['disk'], p['num'])
+ for v in self.__instloop.volumes:
+ if v['mountpoint'] == "/":
+ rootdev = "/dev/mapper/%s-%s" % (v['vgname'], v['name'])
+
prefix = ""
if bootdevnum == rootdevnum:
prefix = "/boot"
--
1.7.7.4
More information about the Thincrust-devel
mailing list