[PATCH] Add support for reserving space in lvm vgs via kickstart.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



reserved-space specifies reserved space in MB
reserved-percent specifies a percentage of total space to reserve

Resolves: rhbz#663647
---
 anaconda.spec.in                   |    2 +-
 pyanaconda/iw/lvm_dialog_gui.py    |   37 +++++++++++++++++++++++++++++++++--
 pyanaconda/kickstart.py            |    4 +++
 pyanaconda/storage/devices.py      |   25 +++++++++++++++++++++++-
 pyanaconda/storage/partitioning.py |    3 +-
 5 files changed, 65 insertions(+), 6 deletions(-)

diff --git a/anaconda.spec.in b/anaconda.spec.in
index 2d380c2..04a5ea6 100644
--- a/anaconda.spec.in
+++ b/anaconda.spec.in
@@ -28,7 +28,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 %define intltoolver 0.31.2-3
 %define libnlver 1.0
 %define libselinuxver 1.6
-%define pykickstartver 1.99.3
+%define pykickstartver 1.99.4
 %define rpmpythonver 4.2-0.61
 %define slangver 2.0.6-2
 %define yumver 2.9.2
diff --git a/pyanaconda/iw/lvm_dialog_gui.py b/pyanaconda/iw/lvm_dialog_gui.py
index 46587a2..349fafe 100644
--- a/pyanaconda/iw/lvm_dialog_gui.py
+++ b/pyanaconda/iw/lvm_dialog_gui.py
@@ -71,7 +71,8 @@ class VolumeGroupEditor:
         vgfree = vg.freeSpace
         vgused = vgsize - vgfree
         vgsnapshots = vg.snapshotSpace
-        return (vgsize, vgused, vgfree, vgsnapshots)
+        vgreserved = vg.reservedSpace
+        return (vgsize, vgused, vgfree, vgsnapshots, vgreserved)
 
     def getPVWastedRatio(self, newpe):
         """ given a new pe value, return percentage of smallest PV wasted
@@ -852,7 +853,7 @@ class VolumeGroupEditor:
                 custom_icon="error")
             return
 
-        (total, used, free, snapshots) = self.computeSpaceValues()
+        (total, used, free, snapshots, reserved) = self.computeSpaceValues()
 	if free <= 0:
 	    self.intf.messageWindow(_("No free space"),
 				    _("There is no room left in the "
@@ -958,7 +959,7 @@ class VolumeGroupEditor:
             self.logvolstore.set_value(iter, 2, "%Ld" % lv['size'])
 
     def updateVGSpaceLabels(self):
-        (total, used, free, snapshots) = self.computeSpaceValues()
+        (total, used, free, snapshots, reserved) = self.computeSpaceValues()
 
 	self.totalSpaceLabel.set_text("%10.2f MB" % (total,))
 	self.usedSpaceLabel.set_text("%10.2f MB" % (used,))
@@ -987,6 +988,15 @@ class VolumeGroupEditor:
 
             self.snapshotPercentLabel.set_text("(%4.1f %%)" % snapshotpercent)
 
+        if reserved:
+            self.reservedSpaceLabel.set_text("%10.2f MB" % reserved)
+            if total > 0:
+                reservedpercent = (100.0*reserved)/total
+            else:
+                reservedpercent = 0.0
+
+            self.reservedPercentLabel.set_text("(%4.1f %%)" % reservedpercent)
+
 #
 # run the VG editor we created
 #
@@ -1431,6 +1441,27 @@ class VolumeGroupEditor:
             maintable.set_row_spacing(row, 0)
             row = row + 1
 
+        if self.vg.reservedSpace:
+            maintable.attach(createAlignedLabel(_("Reserved Space:")),
+                             0, 1, row, row + 1, gtk.EXPAND|gtk.FILL,
+                             gtk.SHRINK)
+            lbox = gtk.HBox()
+            self.reservedSpaceLabel = gtk.Label("")
+            labelalign = gtk.Alignment()
+            labelalign.set(1.0, 0.5, 0.0, 0.0)
+            labelalign.add(self.reservedSpaceLabel)
+            lbox.pack_start(labelalign, False, False)
+            self.reservedPercentLabel = gtk.Label("")
+            labelalign = gtk.Alignment()
+            labelalign.set(1.0, 0.5, 0.0, 0.0)
+            labelalign.add(self.reservedPercentLabel)
+            lbox.pack_start(labelalign, False, False, padding=10)
+
+            maintable.attach(lbox, 1, 2, row, row + 1, gtk.EXPAND|gtk.FILL,
+                             gtk.SHRINK)
+            maintable.set_row_spacing(row, 0)
+            row = row + 1
+
         maintable.attach(createAlignedLabel(_("Free Space:")), 0, 1, row,
 			 row + 1, gtk.EXPAND|gtk.FILL, gtk.SHRINK)
 	lbox = gtk.HBox()
diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py
index cff041f..b85da28 100644
--- a/pyanaconda/kickstart.py
+++ b/pyanaconda/kickstart.py
@@ -1116,6 +1116,10 @@ class VolGroupData(commands.volgroup.FC3_VolGroupData):
                                     peSize=self.pesize/1024.0)
 
             storage.createDevice(request)
+            if self.reserved_space:
+                request.reserved_space = self.reserved_space
+            elif self.reserved_percent:
+                request.reserved_percent = self.reserved_percent
 
 class XConfig(commands.xconfig.F14_XConfig):
     def execute(self):
diff --git a/pyanaconda/storage/devices.py b/pyanaconda/storage/devices.py
index 0491e1c..9aa77a6 100644
--- a/pyanaconda/storage/devices.py
+++ b/pyanaconda/storage/devices.py
@@ -2007,6 +2007,8 @@ class LVMVolumeGroupDevice(DMDevice):
         self.lv_sizes = []
         self.lv_attr = []
         self.hasDuplicate = False
+        self.reserved_percent = 0
+        self.reserved_space = 0
 
         # circular references, here I come
         self._lvs = []
@@ -2028,7 +2030,8 @@ class LVMVolumeGroupDevice(DMDevice):
               "  PE Free = %(peFree)s  PV Count = %(pvCount)s\n"
               "  LV Names = %(lv_names)s  modified = %(modified)s\n"
               "  extents = %(extents)s  free space = %(freeSpace)s\n"
-              "  free extents = %(freeExtents)s\n"
+              "  free extents = %(freeExtents)s"
+              "  reserved percent = %(rpct)s  reserved space = %(res)s\n"
               "  PVs = %(pvs)s\n"
               "  LVs = %(lvs)s" %
               {"free": self.free, "peSize": self.peSize, "peCount": self.peCount,
@@ -2036,6 +2039,7 @@ class LVMVolumeGroupDevice(DMDevice):
                "lv_names": self.lv_names, "modified": self.isModified,
                "extents": self.extents, "freeSpace": self.freeSpace,
                "freeExtents": self.freeExtents,
+               "rpct": self.reserved_percent, "res": self.reserved_space,
                "pvs": pprint.pformat([str(p) for p in self.pvs]),
                "lvs": pprint.pformat([str(l) for l in self.lvs])})
         return s
@@ -2052,6 +2056,8 @@ class LVMVolumeGroupDevice(DMDevice):
                   "lv_uuids": self.lv_uuids,
                   "lv_sizes": self.lv_sizes,
                   "lv_attr": self.lv_attr,
+                  "reserved_percent": self.reserved_percent,
+                  "reserved_space": self.reserved_space,
                   "lvNames": [lv.name for lv in self.lvs]})
         return d
 
@@ -2067,6 +2073,11 @@ class LVMVolumeGroupDevice(DMDevice):
         if noformat:
             args.append("--noformat")
 
+        if self.reserved_space:
+            args.append("--reserved-space=%d" % self.reserved_space)
+        elif self.reserved_percent:
+            args.append("--reserved-percent=%d" % self.reserved_percent)
+
         f.write("#volgroup %s %s %s" % (self.name, " ".join(args), " ".join(pvs)))
         if s:
             f.write(" %s" % s)
@@ -2281,6 +2292,17 @@ class LVMVolumeGroupDevice(DMDevice):
         return used
 
     @property
+    def reservedSpace(self):
+        """ Reserved space in this VG, in MB """
+        reserved = 0
+        if self.reserved_percent > 0:
+            reserved = self.reserved_percent * 0.01 * self.size
+        elif self.reserved_space > 0:
+            reserved = self.reserved_space
+
+        return self.align(reserved, roundup=True)
+
+    @property
     def size(self):
         """ The size of this VG """
         # TODO: just ask lvm if isModified returns False
@@ -2307,6 +2329,7 @@ class LVMVolumeGroupDevice(DMDevice):
         # total the sizes of any LVs
         log.debug("%s size is %dMB" % (self.name, self.size))
         used = sum(lv.vgSpaceUsed for lv in self.lvs) + self.snapshotSpace
+        used += self.reservedSpace
         free = self.size - used
         log.debug("vg %s has %dMB free" % (self.name, free))
         return free
diff --git a/pyanaconda/storage/partitioning.py b/pyanaconda/storage/partitioning.py
index 82d35f5..537b38f 100644
--- a/pyanaconda/storage/partitioning.py
+++ b/pyanaconda/storage/partitioning.py
@@ -1647,7 +1647,8 @@ class VGChunk(Chunk):
         """
         self.vg = vg
         self.path = vg.path
-        super(VGChunk, self).__init__(self.vg.extents, requests=requests)
+        usable_extents = vg.extents - (vg.reservedSpace / vg.peSize)
+        super(VGChunk, self).__init__(usable_extents, requests=requests)
 
     def addRequest(self, req):
         """ Add a Request to this chunk. """
-- 
1.7.3.4

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux