Merge ~ltrager/maas:vmfs_preseed into maas:master
- Git
- lp:~ltrager/maas
- vmfs_preseed
- Merge into master
Status: | Merged |
---|---|
Approved by: | Lee Trager |
Approved revision: | c1f64a23a22929e47fb422b2dd96289e7ecd5413 |
Merge reported by: | MAAS Lander |
Merged at revision: | not available |
Proposed branch: | ~ltrager/maas:vmfs_preseed |
Merge into: | maas:master |
Prerequisite: | ~ltrager/maas:vmfs_layout |
Diff against target: |
328 lines (+200/-21) 3 files modified
src/maasserver/models/partition.py (+9/-3) src/maasserver/preseed_storage.py (+33/-17) src/maasserver/tests/test_preseed_storage.py (+158/-1) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
MAAS Lander | Needs Fixing | ||
Blake Rouse (community) | Approve | ||
Alberto Donato (community) | Approve | ||
MAAS Maintainers | Pending | ||
Review via email: mp+364199@code.launchpad.net |
Commit message
Modify the storage preseed for VMware ESXi datastores.
Description of the change
- 63b5c00... by Lee Trager
-
Fix query count
- 45029bd... by Lee Trager
-
Merge branch 'vmfs_layout' into vmfs_preseed
MAAS Lander (maas-lander) wrote : | # |
UNIT TESTS
-b vmfs_preseed lp:~ltrager/maas/+git/maas into -b master lp:~maas-committers/maas
STATUS: SUCCESS
COMMIT: 45029bd8c921cde
- 5a167a2... by Lee Trager
-
Set tags to empty list
- 2067784... by Lee Trager
-
Merge branch 'vmfs_layout' into vmfs_preseed
MAAS Lander (maas-lander) wrote : | # |
UNIT TESTS
-b vmfs_preseed lp:~ltrager/maas/+git/maas into -b master lp:~maas-committers/maas
STATUS: FAILED
LOG: http://
COMMIT: 20677840670b203
- 956b9fd... by Lee Trager
-
Cleanup comments
- aa0aa27... by Lee Trager
-
Merge branch 'vmfs_layout' into vmfs_preseed
- 6b69ad7... by Lee Trager
-
node.get_osystem() -> node.osystem
MAAS Lander (maas-lander) wrote : | # |
UNIT TESTS
-b vmfs_preseed lp:~ltrager/maas/+git/maas into -b master lp:~maas-committers/maas
STATUS: FAILED
LOG: http://
COMMIT: 6b69ad720b4d977
Blake Rouse (blake-rouse) wrote : | # |
No blockers just 2 comments.
- 1e75131... by Lee Trager
-
Merge branch 'master' into vmfs_layout
- 0a12c31... by Lee Trager
-
Use bulk_create
- b6f090d... by Lee Trager
-
Merge branch 'vmfs_layout' into vmfs_preseed
- eba6787... by Lee Trager
-
Set created, and updated time
- bc1ef7d... by Lee Trager
-
Merge branch 'vmfs_layout' into vmfs_preseed
- 875ec3b... by Lee Trager
-
Fix comments
MAAS Lander (maas-lander) wrote : | # |
UNIT TESTS
-b vmfs_preseed lp:~ltrager/maas/+git/maas into -b master lp:~maas-committers/maas
STATUS: FAILED
LOG: http://
COMMIT: 875ec3bbd43f814
- 35e6240... by Lee Trager
-
Merge branch 'master' into vmfs_layout
- fd76dc3... by Lee Trager
-
ack fix
- 84e3797... by Lee Trager
-
Merge branch 'vmfs_layout' into vmfs_preseed
MAAS Lander (maas-lander) wrote : | # |
UNIT TESTS
-b vmfs_preseed lp:~ltrager/maas/+git/maas into -b master lp:~maas-committers/maas
STATUS: FAILED
LOG: http://
COMMIT: 84e37975533e3d7
- c1f64a2... by Lee Trager
-
Fix lint and order VMFS6 devices
Preview Diff
1 | diff --git a/src/maasserver/models/partition.py b/src/maasserver/models/partition.py |
2 | index 44b93f2..2bd2ad7 100644 |
3 | --- a/src/maasserver/models/partition.py |
4 | +++ b/src/maasserver/models/partition.py |
5 | @@ -216,9 +216,15 @@ class Partition(CleanSave, TimestampedModel): |
6 | if (arch == "ppc64el" and block_device.id == boot_disk.id): |
7 | return idx + 2 |
8 | elif arch == "amd64" and bios_boot_method != "uefi": |
9 | - # Delay the `type` check because it can cause a query. Only |
10 | - # physical block devices get the bios_grub partition. |
11 | - if block_device.type == 'physical': |
12 | + if node.osystem == 'esxi': |
13 | + # VMware ESXi is a DD image but MAAS allows partitions to |
14 | + # be added to the end of the disk as well as resize the |
15 | + # datastore partition. The EFI partition is already in the |
16 | + # image so there is no reason to account for it. |
17 | + return idx + 1 |
18 | + elif block_device.type == 'physical': |
19 | + # Delay the `type` check because it can cause a query. Only |
20 | + # physical block devices get the bios_grub partition. |
21 | return idx + 2 |
22 | else: |
23 | return idx + 1 |
24 | diff --git a/src/maasserver/preseed_storage.py b/src/maasserver/preseed_storage.py |
25 | index b7daefd..f376f52 100644 |
26 | --- a/src/maasserver/preseed_storage.py |
27 | +++ b/src/maasserver/preseed_storage.py |
28 | @@ -1,4 +1,4 @@ |
29 | -# Copyright 2015-2016 Canonical Ltd. This software is licensed under the |
30 | +# Copyright 2015-2019 Canonical Ltd. This software is licensed under the |
31 | # GNU Affero General Public License version 3 (see the file LICENSE). |
32 | |
33 | """Preseed generation for curtin storage.""" |
34 | @@ -48,6 +48,7 @@ class CurtinStorageGenerator: |
35 | "lvm_partition": [], |
36 | "raid": [], |
37 | "bcache": [], |
38 | + "vmfs": [], |
39 | } |
40 | |
41 | def generate(self): |
42 | @@ -66,6 +67,7 @@ class CurtinStorageGenerator: |
43 | self._generate_logical_volume_operations() |
44 | self._generate_raid_operations() |
45 | self._generate_bcache_operations() |
46 | + self._generate_vmfs_operations() |
47 | self._generate_partition_operations() |
48 | self._generate_format_operations() |
49 | |
50 | @@ -110,6 +112,8 @@ class CurtinStorageGenerator: |
51 | self.operations["raid"].append(filesystem_group) |
52 | elif filesystem_group.is_bcache(): |
53 | self.operations["bcache"].append(filesystem_group) |
54 | + elif filesystem_group.is_vmfs(): |
55 | + self.operations["vmfs"].append(filesystem_group) |
56 | else: |
57 | raise ValueError( |
58 | "Unknown filesystem group type: %s" % ( |
59 | @@ -259,10 +263,12 @@ class CurtinStorageGenerator: |
60 | node_arch == "ppc64el" and |
61 | bios_boot_method in ("uefi", "powernv", "powerkvm")) |
62 | |
63 | - # always add a boot partition for GPT without UEFI |
64 | + # always add a boot partition for GPT without UEFI. ESXi doesn't |
65 | + # need a partition added as one is already in the DD format. |
66 | add_bios_grub_partition = ( |
67 | disk_operation.get("ptable") == "gpt" and |
68 | - node_arch == "amd64" and bios_boot_method != "uefi") |
69 | + node_arch == "amd64" and bios_boot_method != "uefi" and |
70 | + self.node.osystem != "esxi") |
71 | |
72 | # Set this disk to be the grub device if it's the boot disk and doesn't |
73 | # require a prep partition. When a prep partition is required grub |
74 | @@ -525,6 +531,24 @@ class CurtinStorageGenerator: |
75 | bcache_operation["ptable"] = self._get_ptable_type(partition_table) |
76 | self.storage_config.append(bcache_operation) |
77 | |
78 | + def _generate_vmfs_operations(self): |
79 | + """Generate all vmfs operations.""" |
80 | + for vmfs in self.operations["vmfs"]: |
81 | + self.storage_config.append({ |
82 | + "id": vmfs.name, |
83 | + "name": vmfs.name, |
84 | + "type": "vmfs6", |
85 | + "devices": sorted([ |
86 | + fs.get_parent().name for fs in vmfs.filesystems.all()]), |
87 | + }) |
88 | + |
89 | + def _reorder_devices(self, ids_above, operation): |
90 | + for device in operation["devices"]: |
91 | + if device not in ids_above: |
92 | + self._reorder_operation(operation, device) |
93 | + return True |
94 | + return False |
95 | + |
96 | def _order_config_dependency(self): |
97 | """Re-order the storage config so dependencies appear before |
98 | dependents.""" |
99 | @@ -548,13 +572,7 @@ class CurtinStorageGenerator: |
100 | self._reorder_operation(operation, volume) |
101 | break |
102 | elif operation_type == "lvm_volgroup": |
103 | - exit_early = False |
104 | - for device in operation["devices"]: |
105 | - if device not in ids_above: |
106 | - self._reorder_operation(operation, device) |
107 | - exit_early = True |
108 | - break |
109 | - if exit_early: |
110 | + if self._reorder_devices(ids_above, operation): |
111 | break |
112 | elif operation_type == "lvm_partition": |
113 | volgroup = operation["volgroup"] |
114 | @@ -562,14 +580,9 @@ class CurtinStorageGenerator: |
115 | self._reorder_operation(operation, volgroup) |
116 | break |
117 | elif operation_type == "raid": |
118 | - exit_early = False |
119 | - for device in operation["devices"]: |
120 | - if device not in ids_above: |
121 | - self._reorder_operation(operation, device) |
122 | - exit_early = True |
123 | - break |
124 | - if exit_early: |
125 | + if self._reorder_devices(ids_above, operation): |
126 | break |
127 | + exit_early = False |
128 | for device in operation["spare_devices"]: |
129 | if device not in ids_above: |
130 | self._reorder_operation(operation, device) |
131 | @@ -586,6 +599,9 @@ class CurtinStorageGenerator: |
132 | if cache_device not in ids_above: |
133 | self._reorder_operation(operation, cache_device) |
134 | break |
135 | + elif operation_type == "vmfs6": |
136 | + if self._reorder_devices(ids_above, operation): |
137 | + break |
138 | else: |
139 | raise ValueError( |
140 | "Unknown operation type: %s" % operation_type) |
141 | diff --git a/src/maasserver/tests/test_preseed_storage.py b/src/maasserver/tests/test_preseed_storage.py |
142 | index 390ff4c..819069c 100644 |
143 | --- a/src/maasserver/tests/test_preseed_storage.py |
144 | +++ b/src/maasserver/tests/test_preseed_storage.py |
145 | @@ -1,4 +1,4 @@ |
146 | -# Copyright 2015-2016 Canonical Ltd. This software is licensed under the |
147 | +# Copyright 2015-2019 Canonical Ltd. This software is licensed under the |
148 | # GNU Affero General Public License version 3 (see the file LICENSE). |
149 | |
150 | """Test `maasserver.preseed_storage`.""" |
151 | @@ -16,9 +16,11 @@ from maasserver.enum import ( |
152 | NODE_STATUS, |
153 | PARTITION_TABLE_TYPE, |
154 | ) |
155 | +from maasserver.models import Filesystem |
156 | from maasserver.models.filesystemgroup import ( |
157 | Bcache, |
158 | RAID, |
159 | + VMFS, |
160 | VolumeGroup, |
161 | ) |
162 | from maasserver.models.partitiontable import ( |
163 | @@ -27,6 +29,7 @@ from maasserver.models.partitiontable import ( |
164 | PREP_PARTITION_SIZE, |
165 | ) |
166 | from maasserver.preseed_storage import compose_curtin_storage_config |
167 | +from maasserver.storage_layouts import VMFS6Layout |
168 | from maasserver.testing.factory import factory |
169 | from maasserver.testing.testcase import MAASServerTestCase |
170 | from testtools.content import text_content |
171 | @@ -2069,3 +2072,157 @@ class TestBootableRaidLayoutGPTWithPartition( |
172 | node._create_acquired_filesystems() |
173 | config = compose_curtin_storage_config(node) |
174 | self.assertStorageConfig(self.STORAGE_CONFIG, config) |
175 | + |
176 | + |
177 | +class TestVMFS(MAASServerTestCase, AssertStorageConfigMixin): |
178 | + |
179 | + STORAGE_CONFIG = dedent("""\ |
180 | + config: |
181 | + - id: sda |
182 | + model: vendor |
183 | + name: sda |
184 | + ptable: gpt |
185 | + serial: serial-a |
186 | + type: disk |
187 | + wipe: superblock |
188 | + grub_device: true |
189 | + - id: sdb |
190 | + model: vendor |
191 | + name: sdb |
192 | + ptable: gpt |
193 | + serial: serial-b |
194 | + type: disk |
195 | + wipe: superblock |
196 | + - id: sdc |
197 | + model: vendor |
198 | + name: sdc |
199 | + ptable: gpt |
200 | + serial: serial-c |
201 | + type: disk |
202 | + wipe: superblock |
203 | + - id: sda-part1 |
204 | + name: sda-part1 |
205 | + device: sda |
206 | + number: 1 |
207 | + type: partition |
208 | + size: 3145728B |
209 | + uuid: 7f79841c-9f57-4ab7-ada2-b2774e3908a3 |
210 | + wipe: superblock |
211 | + flag: boot |
212 | + - id: sda-part2 |
213 | + name: sda-part2 |
214 | + device: sda |
215 | + number: 2 |
216 | + type: partition |
217 | + size: 4294967296B |
218 | + uuid: b1a04342-60a2-47ca-8773-32b3af24c73e |
219 | + wipe: superblock |
220 | + - id: sda-part3 |
221 | + name: sda-part3 |
222 | + device: sda |
223 | + number: 3 |
224 | + type: partition |
225 | + size: 99451142144B |
226 | + uuid: 54e698a9-e15d-409b-9e0a-2791374f6c12 |
227 | + wipe: superblock |
228 | + - id: sda-part4 |
229 | + name: sda-part4 |
230 | + device: sda |
231 | + number: 4 |
232 | + type: partition |
233 | + size: 261095424B |
234 | + uuid: af8404ca-5d62-402c-8f11-604dc0ba30a6 |
235 | + wipe: superblock |
236 | + - id: sda-part5 |
237 | + name: sda-part5 |
238 | + device: sda |
239 | + number: 5 |
240 | + type: partition |
241 | + size: 261095424B |
242 | + uuid: 34949af8-dc2f-4f9a-b81a-f26e12499f7b |
243 | + wipe: superblock |
244 | + - id: sda-part6 |
245 | + name: sda-part6 |
246 | + device: sda |
247 | + number: 6 |
248 | + type: partition |
249 | + size: 114294784B |
250 | + uuid: e29dd323-671e-4e8f-81fe-f1f71492f231 |
251 | + wipe: superblock |
252 | + - id: sda-part7 |
253 | + name: sda-part7 |
254 | + device: sda |
255 | + number: 7 |
256 | + type: partition |
257 | + size: 298844160B |
258 | + uuid: 817ddd58-f5af-4d9a-8896-c20c06cf0f7f |
259 | + wipe: superblock |
260 | + - id: sda-part8 |
261 | + name: sda-part8 |
262 | + device: sda |
263 | + number: 8 |
264 | + type: partition |
265 | + size: 2684354560B |
266 | + uuid: b5a745b6-7247-4397-a9a9-d484de69e35c |
267 | + wipe: superblock |
268 | + - id: sdb-part1 |
269 | + name: sdb-part1 |
270 | + device: sdb |
271 | + number: 1 |
272 | + type: partition |
273 | + offset: 4194304B |
274 | + size: 107365793792B |
275 | + uuid: e2565df0-8ec8-4d0e-88a6-92836fce3f58 |
276 | + wipe: superblock |
277 | + - id: datastore1 |
278 | + name: datastore1 |
279 | + type: vmfs6 |
280 | + devices: |
281 | + - sda-part3 |
282 | + - sdb-part1 |
283 | + - id: sdc-part1 |
284 | + name: sdc-part1 |
285 | + device: sdc |
286 | + number: 1 |
287 | + type: partition |
288 | + offset: 4194304B |
289 | + size: 107365793792B |
290 | + uuid: c803220b-7533-4276-a9b4-bfebb68813d0 |
291 | + wipe: superblock |
292 | + - id: datastore2 |
293 | + name: datastore2 |
294 | + type: vmfs6 |
295 | + devices: |
296 | + - sdc-part1 |
297 | + """) |
298 | + |
299 | + def test__renders_expected_output(self): |
300 | + node = factory.make_Node( |
301 | + status=NODE_STATUS.ALLOCATED, architecture="amd64/generic", |
302 | + osystem='esxi', distro_series='6.7', with_boot_disk=False) |
303 | + boot_disk = factory.make_PhysicalBlockDevice( |
304 | + node=node, size=100 * 1024 ** 3, name='sda', |
305 | + model='vendor', serial='serial-a') |
306 | + layout = VMFS6Layout(node) |
307 | + layout.configure() |
308 | + extra_disk = factory.make_PhysicalBlockDevice( |
309 | + node=node, size=100 * 1024 ** 3, name='sdb', model='vendor', |
310 | + serial='serial-b') |
311 | + for vmfs_part in boot_disk.get_partitiontable().partitions.all(): |
312 | + if 'part3' in vmfs_part.name: |
313 | + break |
314 | + vmfs = vmfs_part.get_effective_filesystem().filesystem_group |
315 | + partition = extra_disk.create_partition() |
316 | + Filesystem.objects.create( |
317 | + fstype=FILESYSTEM_TYPE.VMFS6, partition=partition, |
318 | + filesystem_group=vmfs) |
319 | + extra_datastore_disk = factory.make_PhysicalBlockDevice( |
320 | + node=node, size=100 * 1024 ** 3, name='sdc', model='vendor', |
321 | + serial='serial-c') |
322 | + extra_datastore_part = extra_datastore_disk.create_partition() |
323 | + VMFS.objects.create_vmfs( |
324 | + name="datastore2", partitions=[extra_datastore_part]) |
325 | + |
326 | + node._create_acquired_filesystems() |
327 | + config = compose_curtin_storage_config(node) |
328 | + self.assertStorageConfig(self.STORAGE_CONFIG, config, True) |
UNIT TESTS
-b vmfs_preseed lp:~ltrager/maas/+git/maas into -b master lp:~maas-committers/maas
STATUS: FAILED maas-ci- jenkins. internal: 8080/job/ maas/job/ branch- tester/ 5296/console c9df371c4d43a3e d264a56871
LOG: http://
COMMIT: b35ab37c66b3340