Merge lp:~blake-rouse/maas/fix-1393953 into lp:~maas-committers/maas/trunk

Proposed by Blake Rouse
Status: Merged
Approved by: Blake Rouse
Approved revision: no longer in the source branch.
Merged at revision: 3408
Proposed branch: lp:~blake-rouse/maas/fix-1393953
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 80 lines (+41/-0)
2 files modified
src/provisioningserver/drivers/osystem/custom.py (+12/-0)
src/provisioningserver/drivers/osystem/tests/test_custom.py (+29/-0)
To merge this branch: bzr merge lp:~blake-rouse/maas/fix-1393953
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+244063@code.launchpad.net

Commit message

Return the correct filename and type for custom image that was imported on the cluster.

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) wrote :

Looks good. One question.

review: Approve
Revision history for this message
Blake Rouse (blake-rouse) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/provisioningserver/drivers/osystem/custom.py'
2--- src/provisioningserver/drivers/osystem/custom.py 2014-09-24 18:47:58 +0000
3+++ src/provisioningserver/drivers/osystem/custom.py 2014-12-08 22:51:52 +0000
4@@ -16,6 +16,9 @@
5 "CustomOS",
6 ]
7
8+import os
9+
10+from provisioningserver.config import BOOT_RESOURCES_STORAGE
11 from provisioningserver.drivers.osystem import (
12 BOOT_IMAGE_PURPOSE,
13 OperatingSystem,
14@@ -49,3 +52,12 @@
15 # Return the same name, since the cluster does not know about the
16 # title of the image. The region will fix the title for the UI.
17 return release
18+
19+ def get_xinstall_parameters(self, arch, subarch, release, label):
20+ """Returns the xinstall image name and type for given image."""
21+ path = os.path.join(
22+ BOOT_RESOURCES_STORAGE, 'custom', arch, subarch, release, label)
23+ if os.path.exists(os.path.join(path, 'root-dd')):
24+ return "root-dd", "dd-tgz"
25+ else:
26+ return "root-tgz", "tgz"
27
28=== modified file 'src/provisioningserver/drivers/osystem/tests/test_custom.py'
29--- src/provisioningserver/drivers/osystem/tests/test_custom.py 2014-09-23 20:44:48 +0000
30+++ src/provisioningserver/drivers/osystem/tests/test_custom.py 2014-12-08 22:51:52 +0000
31@@ -15,9 +15,11 @@
32 __all__ = []
33
34 from itertools import product
35+import os
36
37 from maastesting.factory import factory
38 from maastesting.testcase import MAASTestCase
39+from provisioningserver.drivers.osystem import custom
40 from provisioningserver.drivers.osystem.custom import (
41 BOOT_IMAGE_PURPOSE,
42 CustomOS,
43@@ -26,6 +28,19 @@
44
45 class TestCustomOS(MAASTestCase):
46
47+ def make_resource_path(self, filename):
48+ tmpdir = self.make_dir()
49+ arch = factory.make_name('arch')
50+ subarch = factory.make_name('subarch')
51+ release = factory.make_name('release')
52+ label = factory.make_name('label')
53+ dirpath = os.path.join(
54+ tmpdir, 'custom', arch, subarch, release, label)
55+ os.makedirs(dirpath)
56+ factory.make_file(dirpath, filename)
57+ self.patch(custom, 'BOOT_RESOURCES_STORAGE', tmpdir)
58+ return arch, subarch, release, label
59+
60 def test_get_boot_image_purposes(self):
61 osystem = CustomOS()
62 archs = [factory.make_name('arch') for _ in range(2)]
63@@ -58,3 +73,17 @@
64 osystem = CustomOS()
65 release = factory.make_name('release')
66 self.assertEqual(release, osystem.get_release_title(release))
67+
68+ def test_get_xinstall_parameters_returns_root_tgz_tgz(self):
69+ osystem = CustomOS()
70+ arch, subarch, release, label = self.make_resource_path('root-tgz')
71+ self.assertItemsEqual(
72+ ('root-tgz', 'tgz'),
73+ osystem.get_xinstall_parameters(arch, subarch, release, label))
74+
75+ def test_get_xinstall_parameters_returns_root_dd_dd_tgz(self):
76+ osystem = CustomOS()
77+ arch, subarch, release, label = self.make_resource_path('root-dd')
78+ self.assertItemsEqual(
79+ ('root-dd', 'dd-tgz'),
80+ osystem.get_xinstall_parameters(arch, subarch, release, label))