summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/kickstart/custom_commands/partition.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/wic/kickstart/custom_commands/partition.py')
-rw-r--r--scripts/lib/wic/kickstart/custom_commands/partition.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/scripts/lib/wic/kickstart/custom_commands/partition.py b/scripts/lib/wic/kickstart/custom_commands/partition.py
index 8bde1b80e1..44df20c58a 100644
--- a/scripts/lib/wic/kickstart/custom_commands/partition.py
+++ b/scripts/lib/wic/kickstart/custom_commands/partition.py
@@ -51,6 +51,7 @@ class Wic_PartData(Mic_PartData):
51 self.rootfs = kwargs.get("rootfs-dir", None) 51 self.rootfs = kwargs.get("rootfs-dir", None)
52 self.no_table = kwargs.get("no-table", False) 52 self.no_table = kwargs.get("no-table", False)
53 self.extra_space = kwargs.get("extra-space", "10M") 53 self.extra_space = kwargs.get("extra-space", "10M")
54 self.overhead_factor = kwargs.get("overhead-factor", 1.3)
54 self.source_file = "" 55 self.source_file = ""
55 self.size = 0 56 self.size = 0
56 57
@@ -66,6 +67,7 @@ class Wic_PartData(Mic_PartData):
66 if self.no_table: 67 if self.no_table:
67 retval += " --no-table" 68 retval += " --no-table"
68 retval += " --extra-space=%d" % self.extra_space 69 retval += " --extra-space=%d" % self.extra_space
70 retval += " --overhead-factor=%f" % self.overhead_factor
69 71
70 return retval 72 return retval
71 73
@@ -233,7 +235,7 @@ class Wic_PartData(Mic_PartData):
233 extra_blocks = self.extra_space 235 extra_blocks = self.extra_space
234 236
235 rootfs_size = actual_rootfs_size + extra_blocks 237 rootfs_size = actual_rootfs_size + extra_blocks
236 rootfs_size *= IMAGE_OVERHEAD_FACTOR 238 rootfs_size *= self.overhead_factor
237 239
238 msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \ 240 msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
239 (extra_blocks, self.mountpoint, rootfs_size)) 241 (extra_blocks, self.mountpoint, rootfs_size))
@@ -280,7 +282,7 @@ class Wic_PartData(Mic_PartData):
280 extra_blocks = self.extra_space 282 extra_blocks = self.extra_space
281 283
282 rootfs_size = actual_rootfs_size + extra_blocks 284 rootfs_size = actual_rootfs_size + extra_blocks
283 rootfs_size *= IMAGE_OVERHEAD_FACTOR 285 rootfs_size *= self.overhead_factor
284 286
285 msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \ 287 msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
286 (extra_blocks, self.mountpoint, rootfs_size)) 288 (extra_blocks, self.mountpoint, rootfs_size))
@@ -512,6 +514,11 @@ class Wic_Partition(Mic_Partition):
512 removedAttrs = Mic_Partition.removedAttrs 514 removedAttrs = Mic_Partition.removedAttrs
513 515
514 def _getParser(self): 516 def _getParser(self):
517 def overhead_cb (option, opt_str, value, parser):
518 if (value < 1):
519 raise OptionValueError("Option %s: invalid value: %r" % (option, value))
520 setattr(parser.values, option.dest, value)
521
515 op = Mic_Partition._getParser(self) 522 op = Mic_Partition._getParser(self)
516 # use specified source file to fill the partition 523 # use specified source file to fill the partition
517 # and calculate partition size 524 # and calculate partition size
@@ -529,4 +536,7 @@ class Wic_Partition(Mic_Partition):
529 # extra space beyond the partition size 536 # extra space beyond the partition size
530 op.add_option("--extra-space", dest="extra_space", action="store", 537 op.add_option("--extra-space", dest="extra_space", action="store",
531 type="size", nargs=1, default="10M") 538 type="size", nargs=1, default="10M")
539 op.add_option("--overhead-factor", dest="overhead_factor",
540 action="callback", callback=overhead_cb, type="float",
541 nargs=1, default=1.3)
532 return op 542 return op