[PATCH 2/5] 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

(cherry picked from commit c4877713e77851f5ed6ab87a2dc1e1614055dad8)

Resolves: rhbz#663647
---
 iw/lvm_dialog_gui.py |   37 ++++++++++++++++++++++++++++++++++---
 kickstart.py         |    6 +++++-
 storage/devices.py   |   27 +++++++++++++++++++++++++--
 3 files changed, 64 insertions(+), 6 deletions(-)

diff --git a/iw/lvm_dialog_gui.py b/iw/lvm_dialog_gui.py
index 143b8a3..e6f70e3 100644
--- a/iw/lvm_dialog_gui.py
+++ b/iw/lvm_dialog_gui.py
@@ -65,7 +65,8 @@ class VolumeGroupEditor:
         vgsize = vg.size
         vgfree = vg.freeSpace
         vgused = vgsize - vgfree
-	return (vgsize, vgused, vgfree)
+        vgreserved = vg.reservedSpace
+        return (vgsize, vgused, vgfree, vgreserved)
 
     def getPVWastedRatio(self, newpe):
         """ given a new pe value, return percentage of smallest PV wasted
@@ -844,7 +845,7 @@ class VolumeGroupEditor:
                 custom_icon="error")
             return
 
-        (total, used, free) = self.computeSpaceValues()
+        (total, used, free, reserved) = self.computeSpaceValues()
 	if free <= 0:
 	    self.intf.messageWindow(_("No free space"),
 				    _("There is no room left in the "
@@ -950,7 +951,7 @@ class VolumeGroupEditor:
             self.logvolstore.set_value(iter, 2, "%Ld" % lv['size'])
 
     def updateVGSpaceLabels(self):
-        (total, used, free) = self.computeSpaceValues()
+        (total, used, free, reserved) = self.computeSpaceValues()
 
 	self.totalSpaceLabel.set_text("%10.2f MB" % (total,))
 	self.usedSpaceLabel.set_text("%10.2f MB" % (used,))
@@ -970,6 +971,15 @@ class VolumeGroupEditor:
 
 	self.freePercentLabel.set_text("(%4.1f %%)" % (freepercent,))
 
+        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
 #
@@ -1395,6 +1405,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/kickstart.py b/kickstart.py
index 1e39b11..961b2ee 100644
--- a/kickstart.py
+++ b/kickstart.py
@@ -1076,7 +1076,7 @@ class Upgrade(commands.upgrade.F11_Upgrade):
     def execute(self, anaconda):
         anaconda.id.setUpgrade(self.upgrade)
 
-class VolGroupData(commands.volgroup.FC3_VolGroupData):
+class VolGroupData(commands.volgroup.FC16_VolGroupData):
     def execute(self, anaconda):
         pvs = []
 
@@ -1122,6 +1122,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.F10_XConfig):
     def execute(self, anaconda):
diff --git a/storage/devices.py b/storage/devices.py
index 3810b24..7a2975e 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -1871,6 +1871,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 = []
@@ -1894,14 +1896,16 @@ 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,
                "peFree": self.peFree, "pvCount": self.pvCount,
                "lv_names": self.lv_names, "modified": self.isModified,
                "extents": self.extents, "freeSpace": self.freeSpace,
-               "freeExtents": self.freeExtents, "pvs": self.pvs, "lvs": self.lvs})
+               "freeExtents": self.freeExtents, "pvs": self.pvs, "lvs": self.lvs,
+               "rpct": self.reserved_percent, "res": self.reserved_space})
         return s
 
     @property
@@ -1916,6 +1920,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
 
@@ -1931,6 +1937,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)
@@ -2198,6 +2209,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
@@ -2225,6 +2247,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
-- 
1.7.7.6

_______________________________________________
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