Merge lp:~mpontillo/maas/recommission-storage-1575567-1.9 into lp:maas/1.9

Proposed by Mike Pontillo
Status: Merged
Approved by: Mike Pontillo
Approved revision: no longer in the source branch.
Merged at revision: 4573
Proposed branch: lp:~mpontillo/maas/recommission-storage-1575567-1.9
Merge into: lp:maas/1.9
Diff against target: 69 lines (+37/-0)
3 files modified
docs/changelog.rst (+10/-0)
src/metadataserver/models/commissioningscript.py (+9/-0)
src/metadataserver/models/tests/test_commissioningscript.py (+18/-0)
To merge this branch: bzr merge lp:~mpontillo/maas/recommission-storage-1575567-1.9
Reviewer Review Type Date Requested Status
Mike Pontillo (community) Approve
Review via email: mp+294302@code.launchpad.net

Commit message

Change commissioning script to handle the case where existing disks are renamed by the kernel (such as in some cases when a storage device is added).

Backport of revision 5010 from trunk.

To post a comment you must log in.
Revision history for this message
Mike Pontillo (mpontillo) wrote :

Self-approving approved backport.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'docs/changelog.rst'
2--- docs/changelog.rst 2016-04-28 16:45:07 +0000
3+++ docs/changelog.rst 2016-05-10 21:38:31 +0000
4@@ -2,6 +2,16 @@
5 Changelog
6 =========
7
8+1.9.3
9+=====
10+
11+See https://launchpad.net/maas/+milestone/1.9.3 for full details.
12+
13+Bug Fix Update
14+--------------
15+
16+LP: #1575567 Re-commissioning doesn't detect storage changes
17+
18
19 1.9.2
20 =====
21
22=== modified file 'src/metadataserver/models/commissioningscript.py'
23--- src/metadataserver/models/commissioningscript.py 2016-02-04 13:47:12 +0000
24+++ src/metadataserver/models/commissioningscript.py 2016-05-10 21:38:31 +0000
25@@ -628,6 +628,15 @@
26 block_device.tags = tags
27 block_device.save()
28 else:
29+ # First check if there is an existing device with the same name.
30+ # If so, we need to rename it. Its name will be changed back later,
31+ # when we loop around to it.
32+ existing = PhysicalBlockDevice.objects.filter(
33+ node=node, name=name).all()
34+ for device in existing:
35+ # Use the device ID to ensure a unique temporary name.
36+ device.name = "%s.%d" % (device.name, device.id)
37+ device.save()
38 # New block device. Create it on the node.
39 PhysicalBlockDevice.objects.create(
40 node=node,
41
42=== modified file 'src/metadataserver/models/tests/test_commissioningscript.py'
43--- src/metadataserver/models/tests/test_commissioningscript.py 2016-02-04 13:47:12 +0000
44+++ src/metadataserver/models/tests/test_commissioningscript.py 2016-05-10 21:38:31 +0000
45@@ -1248,6 +1248,24 @@
46 ]
47 self.assertItemsEqual(device_names, created_names)
48
49+ def test__handles_renamed_block_device(self):
50+ devices = [self.make_block_device(name='sda', serial='first')]
51+ node = factory.make_Node()
52+ json_output = json.dumps(devices).encode('utf-8')
53+ update_node_physical_block_devices(node, json_output, 0)
54+ devices = [
55+ self.make_block_device(name='sda', serial='second'),
56+ self.make_block_device(name='sdb', serial='first'),
57+ ]
58+ json_output = json.dumps(devices).encode('utf-8')
59+ update_node_physical_block_devices(node, json_output, 0)
60+ device_names = [device['NAME'] for device in devices]
61+ created_names = [
62+ device.name
63+ for device in PhysicalBlockDevice.objects.filter(node=node)
64+ ]
65+ self.assertItemsEqual(device_names, created_names)
66+
67 def test__only_updates_physical_block_devices(self):
68 devices = [self.make_block_device() for _ in range(3)]
69 node = factory.make_Node()

Subscribers

People subscribed via source and target branches