launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #08046
[Merge] lp:~jtv/maas/power-type-assertion into lp:maas
Jeroen T. Vermeulen has proposed merging lp:~jtv/maas/power-type-assertion into lp:maas.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~jtv/maas/power-type-assertion/+merge/106563
We had a failing test in trunk, caused by an assertion in the regular non-test code. Because we only had two power types at the time, and no way to enumerate an enum, pserv had a hard-coded check for the power types available at the time.
In this branch I fix that failure by updating the assertion to use the enumeration as the canonical definition of valid power types. You may see some lint failures; those are unrelated to this branch and I have a separate MP up for them at the time of writing. Then, 8 tests error out for yet other unrelated changes in trunk. We'll have to work something out for those as well.
Jeroen
--
https://code.launchpad.net/~jtv/maas/power-type-assertion/+merge/106563
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/maas/power-type-assertion into lp:maas.
=== modified file 'src/provisioningserver/api.py'
--- src/provisioningserver/api.py 2012-04-17 09:20:48 +0000
+++ src/provisioningserver/api.py 2012-05-21 05:03:18 +0000
@@ -23,6 +23,7 @@
repeat,
)
+from maasserver.utils import map_enum
from provisioningserver.cobblerclient import (
CobblerDistro,
CobblerProfile,
@@ -38,6 +39,9 @@
from zope.interface import implements
+POWER_TYPE_VALUES = set(map_enum(POWER_TYPE).values())
+
+
def postprocess_mapping(mapping, function):
"""Apply `function` to each value in `mapping`, returned in a new dict."""
return {
@@ -203,7 +207,7 @@
assert isinstance(name, basestring)
assert isinstance(hostname, basestring)
assert isinstance(profile, basestring)
- assert power_type in (POWER_TYPE.VIRSH, POWER_TYPE.WAKE_ON_LAN)
+ assert power_type in POWER_TYPE_VALUES
assert isinstance(preseed_data, basestring)
attributes = {
"hostname": hostname,