Use OrderedDict for partitions instead of simple dictionary

The order of the partitions is important, it needs to be preserved.
If using a simple dict, this is not happening. As a consequence,
checks like 'primary partition being first' are failing because the
dictionary sorts the partitions randomly.
Switched to OrderedDict solved the problem, as it preserves the
ordering it gets from the yaml blob.

Change-Id: Icfa9bd95ffd0203d7c3f6af95de3a6f848c2a954
This commit is contained in:
Yolanda Robla 2017-03-07 14:36:21 +01:00
parent 866a06f92d
commit 96504a4de0
1 changed files with 2 additions and 1 deletions

View File

@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import collections
from diskimage_builder.block_device.blockdevicesetupexception \
import BlockDeviceSetupException
from diskimage_builder.block_device.level1.mbr import MBR
@ -109,7 +110,7 @@ class Partitioning(object):
if 'partitions' not in config:
self._config_error("Partitioning config needs 'partitions'")
self.partitions = {}
self.partitions = collections.OrderedDict()
for part_cfg in config['partitions']:
if 'name' not in part_cfg:
self.config_error("Missing 'name' in partition config")