launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #06228
[Merge] lp:~jtv/maas/cobbler-dealing-with-reality into lp:maas
Jeroen T. Vermeulen has proposed merging lp:~jtv/maas/cobbler-dealing-with-reality into lp:maas.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~jtv/maas/cobbler-dealing-with-reality/+merge/91272
Here we see the Cobbler client learning to deal with the horrible reality that apparently, Cobbler's xapi_object_edit call doesn't always raise failures as exceptions. It can also return False.
--
https://code.launchpad.net/~jtv/maas/cobbler-dealing-with-reality/+merge/91272
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/maas/cobbler-dealing-with-reality into lp:maas.
=== modified file 'src/provisioningserver/cobblerclient.py'
--- src/provisioningserver/cobblerclient.py 2012-02-02 12:46:04 +0000
+++ src/provisioningserver/cobblerclient.py 2012-02-02 13:50:58 +0000
@@ -345,9 +345,13 @@
# stored along with them. Its value doesn't matter.
args.setdefault('clobber', True)
- yield session.call(
+ success = yield session.call(
'xapi_object_edit', cls.object_type, name, 'add', args,
session.token_placeholder)
+ if not success:
+ raise RuntimeError(
+ "Cobbler refused to create %s '%s'. Attributes: %s"
+ % (cls.object_type, name, args))
returnValue(cls(session, name=name, values=args))
@inlineCallbacks
=== modified file 'src/provisioningserver/testing/fakecobbler.py'
--- src/provisioningserver/testing/fakecobbler.py 2012-02-02 12:46:04 +0000
+++ src/provisioningserver/testing/fakecobbler.py 2012-02-02 13:50:58 +0000
@@ -310,7 +310,7 @@
obj_dict = self.store[token][object_type][handle]
obj_dict.update(attrs)
obj_dict['name'] = name
- self._api_save_object(token, object_type, handle)
+ return self._api_save_object(token, object_type, handle)
else:
raise NotImplemented(
"xapi_object_edit(%s, ..., %s, ...)"
=== modified file 'src/provisioningserver/tests/test_fakecobbler.py'
--- src/provisioningserver/tests/test_fakecobbler.py 2012-02-02 11:16:14 +0000
+++ src/provisioningserver/tests/test_fakecobbler.py 2012-02-02 13:50:58 +0000
@@ -168,6 +168,17 @@
self.assertEqual(name, obj.name)
@inlineCallbacks
+ def test_create_object_fails_if_cobbler_returns_False(self):
+
+ def return_false(*args):
+ return False
+
+ session = yield fake_cobbler_session()
+ session.fake_proxy.fake_cobbler.xapi_object_edit = return_false
+ with ExpectedException(RuntimeError):
+ yield fake_cobbler_object(session, self.cobbler_class)
+
+ @inlineCallbacks
def test_find_returns_empty_list_if_no_match(self):
session = yield fake_cobbler_session()
name = self.make_name()