[PATCH 3/9] Use parents consistently in Device constructors.
David Lehman
dlehman at redhat.com
Wed Jul 25 21:48:28 UTC 2012
---
pyanaconda/kickstart.py | 8 ++++----
pyanaconda/storage/__init__.py | 15 +++------------
pyanaconda/storage/devices.py | 14 +++++++-------
pyanaconda/storage/partitioning.py | 10 ++++------
4 files changed, 18 insertions(+), 29 deletions(-)
diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py
index e6eafc5..7e2022a 100644
--- a/pyanaconda/kickstart.py
+++ b/pyanaconda/kickstart.py
@@ -651,7 +651,7 @@ class LogVolData(commands.logvol.F17_LogVolData):
request = storage.newLV(format=format,
name=self.name,
- vg=vg,
+ parents=[vg],
size=self.size,
grow=self.grow,
maxsize=self.maxSizeMB,
@@ -990,12 +990,12 @@ class PartitionData(commands.partition.F17_PartData):
should_clear = storage.shouldClear(disk)
if disk and (disk.partitioned or should_clear):
- kwargs["disks"] = [disk]
+ kwargs["parents"] = [disk]
break
elif disk:
raise KickstartValueError, formatErrorMsg(self.lineno, msg="Specified unpartitioned disk %s in partition command" % self.disk)
- if not kwargs["disks"]:
+ if not kwargs["parents"]:
raise KickstartValueError, formatErrorMsg(self.lineno, msg="Specified nonexistent disk %s in partition command" % self.disk)
kwargs["grow"] = self.grow
@@ -1300,7 +1300,7 @@ class VolGroupData(commands.volgroup.FC16_VolGroupData):
elif self.vgname in [vg.name for vg in storage.vgs]:
raise KickstartValueError(formatErrorMsg(self.lineno, msg="The volume group name \"%s\" is already in use." % self.vgname))
else:
- request = storage.newVG(pvs=pvs,
+ request = storage.newVG(parents=pvs,
name=self.vgname,
peSize=self.pesize/1024.0)
diff --git a/pyanaconda/storage/__init__.py b/pyanaconda/storage/__init__.py
index 1ad5b97..38424b7 100644
--- a/pyanaconda/storage/__init__.py
+++ b/pyanaconda/storage/__init__.py
@@ -1080,13 +1080,6 @@ class Storage(object):
None),
**kwargs.pop("fmt_args", {}))
- if kwargs.has_key("disks"):
- parents = kwargs.pop("disks")
- if isinstance(parents, Device):
- kwargs["parents"] = [parents]
- else:
- kwargs["parents"] = parents
-
if kwargs.has_key("name"):
name = kwargs.pop("name")
else:
@@ -1115,7 +1108,7 @@ class Storage(object):
def newVG(self, *args, **kwargs):
""" Return a new LVMVolumeGroupDevice instance. """
- pvs = kwargs.pop("pvs", [])
+ pvs = kwargs.pop("parents", [])
for pv in pvs:
if pv not in self.devices:
raise ValueError("pv is not in the device tree")
@@ -1139,9 +1132,7 @@ class Storage(object):
def newLV(self, *args, **kwargs):
""" Return a new LVMLogicalVolumeDevice instance. """
- if kwargs.has_key("vg"):
- vg = kwargs.pop("vg")
-
+ vg = kwargs.get("parents")[0]
mountpoint = kwargs.pop("mountpoint", None)
if kwargs.has_key("fmt_type"):
kwargs["format"] = getFormat(kwargs.pop("fmt_type"),
@@ -1162,7 +1153,7 @@ class Storage(object):
if name in self.names:
raise ValueError("name already in use")
- return LVMLogicalVolumeDevice(name, vg, *args, **kwargs)
+ return LVMLogicalVolumeDevice(name, *args, **kwargs)
def newBTRFS(self, *args, **kwargs):
""" Return a new BTRFSVolumeDevice or BRFSSubVolumeDevice. """
diff --git a/pyanaconda/storage/devices.py b/pyanaconda/storage/devices.py
index 8c2713b..8552179 100644
--- a/pyanaconda/storage/devices.py
+++ b/pyanaconda/storage/devices.py
@@ -1964,7 +1964,7 @@ class LVMVolumeGroupDevice(DMDevice):
_type = "lvmvg"
_packages = ["lvm2"]
- def __init__(self, name, parents, size=None, free=None,
+ def __init__(self, name, parents=None, size=None, free=None,
peSize=None, peCount=None, peFree=None, pvCount=None,
uuid=None, exists=False, sysfsPath=''):
""" Create a LVMVolumeGroupDevice instance.
@@ -2387,7 +2387,7 @@ class LVMLogicalVolumeDevice(DMDevice):
_resizable = True
_packages = ["lvm2"]
- def __init__(self, name, vgdev, size=None, uuid=None,
+ def __init__(self, name, parents=None, size=None, uuid=None,
stripes=1, logSize=0, snapshotSpace=0,
format=None, exists=False, sysfsPath='',
grow=None, maxsize=None, percent=None,
@@ -2418,15 +2418,15 @@ class LVMLogicalVolumeDevice(DMDevice):
percent -- percent of VG space to take
"""
- if isinstance(vgdev, list):
- if len(vgdev) != 1:
+ if isinstance(parents, list):
+ if len(parents) != 1:
raise ValueError("constructor requires a single LVMVolumeGroupDevice instance")
- elif not isinstance(vgdev[0], LVMVolumeGroupDevice):
+ elif not isinstance(parents[0], LVMVolumeGroupDevice):
raise ValueError("constructor requires a LVMVolumeGroupDevice instance")
- elif not isinstance(vgdev, LVMVolumeGroupDevice):
+ elif not isinstance(parents, LVMVolumeGroupDevice):
raise ValueError("constructor requires a LVMVolumeGroupDevice instance")
DMDevice.__init__(self, name, size=size, format=format,
- sysfsPath=sysfsPath, parents=vgdev,
+ sysfsPath=sysfsPath, parents=parents,
exists=exists)
self.singlePVerr = ("%(mountpoint)s is restricted to a single "
diff --git a/pyanaconda/storage/partitioning.py b/pyanaconda/storage/partitioning.py
index 62e0c14..48967c8 100644
--- a/pyanaconda/storage/partitioning.py
+++ b/pyanaconda/storage/partitioning.py
@@ -87,7 +87,7 @@ def _scheduleImplicitPartitions(storage, disks):
part = storage.newPartition(fmt_type=fmt_type,
fmt_args=fmt_args,
grow=True,
- disks=[disk])
+ parents=[disk])
storage.createDevice(part)
devs.append(part)
@@ -171,7 +171,7 @@ def _schedulePartitions(storage, disks):
grow=request.grow,
maxsize=request.maxSize,
mountpoint=request.mountpoint,
- disks=disks,
+ parents=disks,
weight=request.weight)
# schedule the device for creation
@@ -199,12 +199,10 @@ def _scheduleVolumes(storage, devs):
new_container = storage.newVG
new_volume = storage.newLV
format_name = "lvmpv"
- parent_kw = "pvs"
else:
new_container = storage.newBTRFS
new_volume = storage.newBTRFS
format_name = "btrfs"
- parent_kw = "parents"
if storage.encryptedAutoPart:
pvs = []
@@ -219,7 +217,7 @@ def _scheduleVolumes(storage, devs):
pvs = devs
# create a vg containing all of the autopart pvs
- container = new_container(**{parent_kw: pvs})
+ container = new_container(parents=pvs)
storage.createDevice(container)
#
@@ -258,7 +256,7 @@ def _scheduleVolumes(storage, devs):
kwargs = {"mountpoint": request.mountpoint,
"fmt_type": request.fstype}
if lv:
- kwargs.update({"vg": container,
+ kwargs.update({"parents": [container],
"grow": request.grow,
"maxsize": request.maxSize,
"size": request.size,
--
1.7.7.6
More information about the anaconda-patches
mailing list