partitionedfs: preserve the KS partition number
authorArtem Bityutskiy <artem.bityutskiy@intel.com>
Mon, 24 Jun 2013 06:09:29 +0000 (09:09 +0300)
committerArtem Bityutskiy <artem.bityutskiy@intel.com>
Tue, 25 Jun 2013 08:49:55 +0000 (11:49 +0300)
The 'add_partition()' function takes partition from the KS file and processes
them. A commentary in 'add_partition()' says: "partitions have to be added in
the first-to-last order", so the order is important.

The order number is basically the partition entry number in the KS file.
Unfortunately, it is lost once the partition is added, and later on it is not
easy to match a partition from the KS file to the processed partition.

This patch teaches 'add_partition()' to preserve the KS file partition number
for later use. The new key 'ks_pnum' will be useful in the next patch, when we
export information about partitions and we want it to be in the KS file order.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
mic/utils/partitionedfs.py

index f1102d4..0475844 100644 (file)
@@ -99,6 +99,8 @@ class PartitionedMount(Mount):
         """ Add the next partition. Prtitions have to be added in the
         first-to-last order. """
 
+        ks_pnum = len(self.partitions)
+
         # Converting MB to sectors for parted
         size = size * 1024 * 1024 / self.sector_size
 
@@ -136,7 +138,8 @@ class PartitionedMount(Mount):
                         break
                 fsopts = ",".join(opts)
 
-            part = { 'size': size, # In sectors
+            part = { 'ks_pnum' : ks_pnum, # Partition number in the KS file
+                     'size': size, # In sectors
                      'mountpoint': mountpoint, # Mount relative to chroot
                      'fstype': fstype, # Filesystem type
                      'fsopts': fsopts, # Filesystem mount options