Merge lp:~blake-rouse/maas/fix-1509536-part3 into lp:maas/trunk

Proposed by Blake Rouse on 2015-10-27
Status: Merged
Approved by: Blake Rouse on 2015-10-28
Approved revision: 4423
Merged at revision: 4423
Proposed branch: lp:~blake-rouse/maas/fix-1509536-part3
Merge into: lp:maas/trunk
Prerequisite: lp:~blake-rouse/maas/fix-1509536-part2
Diff against target: 103 lines (+76/-3)
2 files modified
src/maasserver/preseed_storage.py (+9/-3)
src/maasserver/tests/test_preseed_storage.py (+67/-0)
To merge this branch: bzr merge lp:~blake-rouse/maas/fix-1509536-part3
Reviewer Review Type Date Requested Status
Mike Pontillo (community) Approve on 2015-10-28
Andres Rodriguez (community) 2015-10-27 Needs Information on 2015-10-27
Review via email: mp+275933@code.launchpad.net

Commit message

Always set ptable in the disk operation if the disk is the boot disk.

Description of the change

To post a comment you must log in.
Andres Rodriguez (andreserl) wrote :

does this show any UI notifications? or the buttons are not made available?

review: Needs Information
Blake Rouse (blake-rouse) wrote :

No this has nothing to do with the UI. That is in the following branch. Still finishing it.

4421. By Blake Rouse on 2015-10-28

Merged part2 into part3.

4422. By Blake Rouse on 2015-10-28

Merged part2 into part3.

4423. By Blake Rouse on 2015-10-28

Link bug.

Blake Rouse (blake-rouse) wrote :

Now that all the parts are together no UI is required for this bug. Its all automatic even for the API. If you go to create a bcache, cache set, volume group, or RAID and the boot disk is selected a partition will be created for the entire disk and be added to the operation. This make it very easy for the user, they don't need to know the details.

Mike Pontillo (mpontillo) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/preseed_storage.py'
2--- src/maasserver/preseed_storage.py 2015-09-24 16:22:12 +0000
3+++ src/maasserver/preseed_storage.py 2015-10-28 02:07:56 +0000
4@@ -177,13 +177,19 @@
5 disk_operation["serial"] = block_device.serial
6 else:
7 disk_operation["path"] = block_device.id_path
8- # When no partition table, then the superblock on the
9- # device should be wiped. This ensures that previous data is not
10- # available to newly deployed node.
11+
12+ # Set the partition table type if a partition table exists or if this
13+ # is the boot disk.
14 partition_table = block_device.get_partitiontable()
15 if partition_table is not None:
16 disk_operation["ptable"] = self._get_ptable_type(
17 partition_table)
18+ elif block_device.id == self.boot_disk.id:
19+ if self.node.get_bios_boot_method() == "uefi":
20+ disk_operation["ptable"] = "gpt"
21+ else:
22+ disk_operation["ptable"] = "msdos"
23+
24 # Set this disk to be the grub device if its the boot disk.
25 if self.boot_disk == block_device:
26 disk_operation["grub_device"] = True
27
28=== modified file 'src/maasserver/tests/test_preseed_storage.py'
29--- src/maasserver/tests/test_preseed_storage.py 2015-10-28 02:07:56 +0000
30+++ src/maasserver/tests/test_preseed_storage.py 2015-10-28 02:07:56 +0000
31@@ -411,6 +411,73 @@
32 self.assertStorageConfig(self.STORAGE_CONFIG, config)
33
34
35+class TestMBRWithBootDiskWithoutPartitionsLayout(
36+ MAASServerTestCase, AssertStorageConfigMixin):
37+
38+ STORAGE_CONFIG = dedent("""\
39+ config:
40+ - id: sda
41+ name: sda
42+ type: disk
43+ wipe: superblock
44+ ptable: msdos
45+ model: QEMU HARDDISK
46+ serial: QM00001
47+ - id: sdb
48+ name: sdb
49+ type: disk
50+ wipe: superblock
51+ ptable: msdos
52+ path: /dev/disk/by-id/wwn-0x55cd2e400009bf84
53+ grub_device: true
54+ - id: sda-part1
55+ name: sda-part1
56+ type: partition
57+ number: 1
58+ uuid: 6efc2c3d-bc9d-4ee5-a7ed-c6e1574d5398
59+ size: 8586788864B
60+ device: sda
61+ wipe: superblock
62+ offset: 2097152B
63+ - id: sda-part1_format
64+ type: format
65+ fstype: ext4
66+ label: root
67+ uuid: 90a69b22-e281-4c5b-8df9-b09514f27ba1
68+ volume: sda-part1
69+ - id: sda-part1_mount
70+ type: mount
71+ path: /
72+ device: sda-part1_format
73+ """)
74+
75+ def test__renders_expected_output(self):
76+ node = factory.make_Node(
77+ status=NODE_STATUS.ALLOCATED, with_boot_disk=False)
78+ first_disk = factory.make_PhysicalBlockDevice(
79+ node=node, size=8 * 1024 ** 3, name="sda",
80+ model="QEMU HARDDISK", serial="QM00001") # 8 GiB
81+ boot_disk = factory.make_PhysicalBlockDevice(
82+ node=node, size=8 * 1024 ** 3, name="sdb",
83+ id_path="/dev/disk/by-id/wwn-0x55cd2e400009bf84")
84+ node.boot_disk = boot_disk
85+ node.save()
86+ partition_table = factory.make_PartitionTable(
87+ table_type=PARTITION_TABLE_TYPE.MBR, block_device=first_disk)
88+ root_partition = factory.make_Partition(
89+ partition_table=partition_table,
90+ uuid="6efc2c3d-bc9d-4ee5-a7ed-c6e1574d5398",
91+ size=(8 * 1024 ** 3) - PARTITION_TABLE_EXTRA_SPACE,
92+ bootable=False)
93+ factory.make_Filesystem(
94+ partition=root_partition, fstype=FILESYSTEM_TYPE.EXT4,
95+ uuid="90a69b22-e281-4c5b-8df9-b09514f27ba1", label="root",
96+ mount_point="/")
97+ node._create_acquired_filesystems()
98+ config = compose_curtin_storage_config(node)
99+ self.assertStorageConfig(self.STORAGE_CONFIG, config)
100+
101+
102 class TestComplexDiskLayout(
103 MAASServerTestCase, AssertStorageConfigMixin):
104