[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[PATCH 4/5] Add support for --onpart, --ondrive, and --useexisting.
- From: Chris Lumens <clumens redhat com>
- To: anaconda-devel-list redhat com
- Cc:
- Subject: [PATCH 4/5] Add support for --onpart, --ondrive, and --useexisting.
- Date: Wed, 29 Apr 2009 14:02:42 -0400
---
storage/__init__.py | 14 +++++++++++++-
storage/devices.py | 27 ++++++++++++++++++++-------
2 files changed, 33 insertions(+), 8 deletions(-)
diff --git a/storage/__init__.py b/storage/__init__.py
index 5d25667..94b598a 100644
--- a/storage/__init__.py
+++ b/storage/__init__.py
@@ -939,6 +939,18 @@ class Storage(object):
self.zfcp.write(instPath)
def writeKS(self, f):
+ def useExisting(lst):
+ foundCreateDevice = False
+ foundCreateFormat = False
+
+ for l in lst:
+ if isinstance(l, ActionCreateDevice):
+ foundCreateDevice = True
+ elif isinstance(l, ActionCreateFormat):
+ foundCreateFormat = True
+
+ return (foundCreateFormat and not foundCreateDevice)
+
log.warning("Storage.writeKS not completely implemented")
f.write("# The following is the partition information you requested\n")
f.write("# Note that any partitions you deleted are not expressed\n")
@@ -981,7 +993,7 @@ class Storage(object):
for path in ordering:
for device in map(lambda x: x.device, dict[path]):
- device.writeKS(f)
+ device.writeKS(f, preexisting=useExisting(dict[path]))
f.write("\n")
self.iscsi.writeKS(f)
diff --git a/storage/devices.py b/storage/devices.py
index e6125f6..7310055 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -233,7 +233,7 @@ class Device(object):
"descr": self.description, "status": self.status})
return s
- def writeKS(self, f, s=None):
+ def writeKS(self, f, preexisting=False, s=None):
return
def removeChild(self):
@@ -962,7 +962,7 @@ class PartitionDevice(StorageDevice):
"partedPart": self.partedPartition, "disk": self.disk})
return s
- def writeKS(self, f, s=None):
+ def writeKS(self, f, preexisting=False, s=None):
args = []
if self.isExtended:
@@ -976,6 +976,11 @@ class PartitionDevice(StorageDevice):
args.append("--asprimary")
if self.req_size:
args.append("--size=%s" % self.req_size)
+ if preexisting:
+ if len(self.req_disks) == 1:
+ args.append("--ondisk=%s" % self.req_disks[0])
+ else:
+ args.append("--onpart=%s" % self.name)
f.write("#part ")
self.format.writeKS(f)
@@ -1448,8 +1453,8 @@ class LUKSDevice(DMCryptDevice):
parents=parents, sysfsPath=sysfsPath,
uuid=None, exists=exists)
- def writeKS(self, f, s=None):
- self.slave.writeKS(f)
+ def writeKS(self, f, preexisting=False, s=None):
+ self.slave.writeKS(f, preexisting=preexisting)
self.format.writeKS(f)
if s:
f.write(" %s" % s)
@@ -1602,13 +1607,16 @@ class LVMVolumeGroupDevice(DMDevice):
"freeExtents": self.freeExtents, "pvs": self.pvs, "lvs": self.lvs})
return s
- def writeKS(self, f, s=None):
+ def writeKS(self, f, preexisting=False, s=None):
args = ["--pesize=%s" % self.peSize]
pvs = []
for pv in self.pvs:
pvs.append("pv.%s" % pv.format.uuid)
+ if preexisting:
+ args.append("--useexisting")
+
f.write("#volgroup %s %s %s" % (self.name, " ".join(args), " ".join(pvs)))
if s:
f.write(" %s" % s)
@@ -1979,7 +1987,7 @@ class LVMLogicalVolumeDevice(DMDevice):
{"vgdev": self.vg, "percent": self.req_percent})
return s
- def writeKS(self, f, s=None):
+ def writeKS(self, f, preexisting=False, s=None):
args = ["--name=%s" % self.lvname,
"--vgname=%s "% self.vg.name]
@@ -1994,6 +2002,9 @@ class LVMLogicalVolumeDevice(DMDevice):
elif self.req_size > 0:
args.append("--size=%s" % self.req_size)
+ if preexisting:
+ args.append("--useexisting")
+
f.write("#logvol ")
self.format.writeKS(f)
f.write(" %s" % " ".join(args))
@@ -2233,13 +2244,15 @@ class MDRaidArrayDevice(StorageDevice):
"memberDevices": self.memberDevices, "totalDevices": self.totalDevices})
return s
- def writeKS(self, f, s=None):
+ def writeKS(self, f, preexisting=False, s=None):
args = ["--level=%s" % self.level,
"--device=%s" % self.name]
mems = []
if self.spares > 0:
args.append("--spares=%s" % self.spares)
+ if preexisting:
+ args.append("--useexisting")
for mem in self.parents:
mems.append("raid.%s" % mem.format.uuid)
--
1.6.1.3
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]