partitionedfs: add disks while adding partitions
authorArtem Bityutskiy <artem.bityutskiy@intel.com>
Fri, 4 Jan 2013 09:02:16 +0000 (11:02 +0200)
committerArtem Bityutskiy <artem.bityutskiy@intel.com>
Thu, 10 Jan 2013 12:11:20 +0000 (14:11 +0200)
commit9685703697efc172c58fe72ad20a14eca84cdad8
treeca173e1f4395d1915c8d27461149d6a10522fee8
parentbb66518a47cb325bfa1fe1037f33be2dbdf1eefd
partitionedfs: add disks while adding partitions

The PartitionedMount class used to work as follows:

1. The user adds all partitions using 'add_partition()'. We create an internal
   list of partitions.
2. User adds all disks using 'add_disks()'. We create an internal list of
   disks. Additionally, 'add_disks()' provides the real disk object.

The problem with this is that in order to create the real disk object, we need
to know its size. But it is difficult to calculate it when complex options like
--align are used.

The real calculations happen in the '__format_disks()' method of
PartitionedMount.

What I want to do is to make things work this way:

1. The user adds all the partitions.
2. The user asks what disk size is required.
3. The user creates disk objects of the right size and adds them.

In order to achieve it, I need to separate out the partitions positioning from
the '_format_disks()' function, and do this before the user adds the disks.

However, the positioning code assumes we already have the internal disks
dictionaries (self.disks). But current code creates those dictionaries only in
'add_disks()', which is too late for our purposes.

This patch basically makes the inderal disks dictionaries while adding the
partitions, because the partition already contains the disk name (internal
target physical name). So we can create the disk dictionaries right away.

The only missing thing will be the host disk objects, which are added by
'add_disks()' later on.

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