Merge lp:~allenap/maas/mpontillo--allow-commissioning-non-lts into lp:~maas-committers/maas/trunk

Proposed by Gavin Panella
Status: Rejected
Rejected by: MAAS Lander
Proposed branch: lp:~allenap/maas/mpontillo--allow-commissioning-non-lts
Merge into: lp:~maas-committers/maas/trunk
Prerequisite: lp:~mpontillo/maas/allow-commissioning-non-lts
Diff against target: 95 lines (+29/-12)
4 files modified
src/provisioningserver/config.py (+1/-1)
src/provisioningserver/drivers/osystem/tests/test_ubuntu.py (+0/-1)
src/provisioningserver/utils/config.py (+5/-4)
src/provisioningserver/utils/tests/test_config.py (+23/-6)
To merge this branch: bzr merge lp:~allenap/maas/mpontillo--allow-commissioning-non-lts
Reviewer Review Type Date Requested Status
MAAS Maintainers Pending
Review via email: mp+307918@code.launchpad.net
To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

Transitioned to Git.

lp:maas has now moved from Bzr to Git.
Please propose your branches with Launchpad using Git.

git clone https://git.launchpad.net/maas

Unmerged revisions

5462. By Gavin Panella

Fix lint.

5461. By Gavin Panella

Fix DirectoryString's validation.

5460. By Mike Pontillo

Fix tests, address incorrect assumption.

5459. By Mike Pontillo

Add configuraiton option for commissioning on a non-LTS release. Drive-by fix for a problem that prevented correct usage of python conversions in rackd.conf.

5458. By Mike Pontillo

Add a constant to allow commissioning non-LTS releases.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/provisioningserver/config.py'
2--- src/provisioningserver/config.py 2016-10-07 09:03:34 +0000
3+++ src/provisioningserver/config.py 2016-10-07 09:03:34 +0000
4@@ -770,7 +770,7 @@
5 tftp_root = ConfigurationOption(
6 "tftp_root", "The root directory for TFTP resources.",
7 DirectoryString(
8- if_missing=get_tentative_path(
9+ if_missing=get_tentative_path(
10 "/var/lib/maas/boot-resources/current")))
11
12 allow_commissioning_non_lts = ConfigurationOption(
13
14=== modified file 'src/provisioningserver/drivers/osystem/tests/test_ubuntu.py'
15--- src/provisioningserver/drivers/osystem/tests/test_ubuntu.py 2016-10-07 09:03:34 +0000
16+++ src/provisioningserver/drivers/osystem/tests/test_ubuntu.py 2016-10-07 09:03:34 +0000
17@@ -18,7 +18,6 @@
18 from testtools.matchers import Contains
19
20
21-
22 class TestUbuntuOS(MAASTestCase):
23
24 def get_lts_release(self):
25
26=== modified file 'src/provisioningserver/utils/config.py'
27--- src/provisioningserver/utils/config.py 2016-08-19 10:22:29 +0000
28+++ src/provisioningserver/utils/config.py 2016-10-07 09:03:34 +0000
29@@ -124,11 +124,12 @@
30 "notDir": "%(value)r does not exist or is not a directory",
31 }
32
33- def _validate_other(self, value, state=None):
34+ def from_python(self, value, state=None):
35 # Only validate on the way _in_; it's not the store's fault if it
36- # contains a directory which has since been removed.
37- if os.path.isdir(value):
38- return value
39+ # contains a directory which has since been removed. Check that the
40+ # original as-Python value represents a directory.
41+ if self.is_empty(value) or os.path.isdir(value):
42+ return super(DirectoryString, self).from_python(value, state)
43 else:
44 raise formencode.Invalid(
45 self.message("notDir", state, value=value),
46
47=== modified file 'src/provisioningserver/utils/tests/test_config.py'
48--- src/provisioningserver/utils/tests/test_config.py 2016-08-19 10:22:29 +0000
49+++ src/provisioningserver/utils/tests/test_config.py 2016-10-07 09:03:34 +0000
50@@ -146,22 +146,39 @@
51 class TestDirectory(MAASTestCase):
52 """Tests for `DirectoryString`."""
53
54- def test__validation_succeeds_when_directory_exists(self):
55+ def test__converting_succeeds_when_directory_exists(self):
56 directory = self.make_dir()
57- validator = config.DirectoryString(accept_python=False)
58+ validator = config.DirectoryString()
59 self.assertEqual(directory, validator.from_python(directory))
60 self.assertEqual(directory, validator.to_python(directory))
61
62- def test__validation_fails_when_directory_does_not_exist(self):
63+ def test__converting_from_python_fails_when_directory_not_exists(self):
64 directory = os.path.join(self.make_dir(), "not-here")
65- validator = config.DirectoryString(accept_python=False)
66+ validator = config.DirectoryString()
67 expected_exception = ExpectedException(
68 formencode.validators.Invalid, "^%s$" % re.escape(
69 "%r does not exist or is not a directory" % directory))
70 with expected_exception:
71 validator.from_python(directory)
72- with expected_exception:
73- validator.to_python(directory)
74+
75+ def test__converting_to_python_succeeds_when_directory_not_exists(self):
76+ directory = os.path.join(self.make_dir(), "not-here")
77+ validator = config.DirectoryString()
78+ self.assertEqual(directory, validator.to_python(directory))
79+
80+ def test__converting_succeeds_when_empty(self):
81+ validator = config.DirectoryString()
82+ self.assertIsNone(validator.from_python(None))
83+ self.assertIsNone(validator.to_python(None))
84+
85+ def test__converting_fails_when_empty_and_not_empty_set(self):
86+ validator = config.DirectoryString(not_empty=True)
87+ expected_exception = ExpectedException(
88+ formencode.validators.Invalid, "^Please enter a value$")
89+ with expected_exception:
90+ self.assertIsNone(validator.from_python(None))
91+ with expected_exception:
92+ self.assertIsNone(validator.to_python(None))
93
94
95 class TestExtendedURL(MAASTestCase):