launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #06345
[Merge] lp:~allenap/maas/pserv-papi-update-things into lp:maas
Gavin Panella has proposed merging lp:~allenap/maas/pserv-papi-update-things into lp:maas with lp:~allenap/maas/cobblerclient-modify as a prerequisite.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~allenap/maas/pserv-papi-update-things/+merge/92730
--
https://code.launchpad.net/~allenap/maas/pserv-papi-update-things/+merge/92730
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~allenap/maas/pserv-papi-update-things into lp:maas.
=== modified file 'src/provisioningserver/api.py'
--- src/provisioningserver/api.py 2012-02-10 20:54:16 +0000
+++ src/provisioningserver/api.py 2012-02-13 10:17:21 +0000
@@ -117,6 +117,21 @@
returnValue(system.name)
@inlineCallbacks
+ def modify_distros(self, deltas):
+ for name, delta in deltas.iteritems():
+ yield CobblerDistro(self.session, name).modify(delta)
+
+ @inlineCallbacks
+ def modify_profiles(self, deltas):
+ for name, delta in deltas.iteritems():
+ yield CobblerProfile(self.session, name).modify(delta)
+
+ @inlineCallbacks
+ def modify_nodes(self, deltas):
+ for name, delta in deltas.iteritems():
+ yield CobblerSystem(self.session, name).modify(delta)
+
+ @inlineCallbacks
def get_objects_by_name(self, object_type, names):
"""Get `object_type` objects by name.
=== modified file 'src/provisioningserver/cobblerclient.py'
--- src/provisioningserver/cobblerclient.py 2012-02-13 10:17:21 +0000
+++ src/provisioningserver/cobblerclient.py 2012-02-13 10:17:21 +0000
@@ -548,6 +548,9 @@
'name',
'distro',
]
+ modification_attributes = [
+ 'distro',
+ ]
class CobblerImage(CobblerObject):
@@ -680,6 +683,9 @@
'name',
'profile',
]
+ modification_attributes = [
+ 'profile',
+ ]
# The modify_interface dict can contain:
# * "macaddress-eth0" etc.
=== modified file 'src/provisioningserver/interfaces.py'
--- src/provisioningserver/interfaces.py 2012-02-08 18:19:56 +0000
+++ src/provisioningserver/interfaces.py 2012-02-13 10:17:21 +0000
@@ -47,6 +47,28 @@
def add_node(name, profile):
"""Add a node with the given `name`, and `profile`."""
+ def modify_distros(deltas):
+ """Apply deltas to existing distros.
+
+ :param deltas: A dict, with each key identifying an existing distro by
+ name, and each value being a dict of modifications to apply to it.
+ """
+
+ def modify_profiles(deltas):
+ """Apply deltas to existing profiles.
+
+ :param deltas: A dict, with each key identifying an existing profile
+ by name, and each value being a dict of modifications to apply to
+ it.
+ """
+
+ def modify_nodes(deltas):
+ """Apply deltas to existing nodes.
+
+ :param deltas: A dict, with each key identifying an existing node by
+ name, and each value being a dict of modifications to apply to it.
+ """
+
def get_distros_by_name(names):
"""List distros with the given `names`."""
=== modified file 'src/provisioningserver/testing/fakeapi.py'
--- src/provisioningserver/testing/fakeapi.py 2012-02-10 16:49:35 +0000
+++ src/provisioningserver/testing/fakeapi.py 2012-02-13 10:17:21 +0000
@@ -88,6 +88,24 @@
self.nodes[name]["mac_addresses"] = []
return name
+ def modify_distros(self, deltas):
+ for name, delta in deltas.iteritems():
+ distro = self.distros[name]
+ for attribute, value in delta.iteritems():
+ distro[attribute] = value
+
+ def modify_profiles(self, deltas):
+ for name, delta in deltas.iteritems():
+ profile = self.profiles[name]
+ for attribute, value in delta.iteritems():
+ profile[attribute] = value
+
+ def modify_nodes(self, deltas):
+ for name, delta in deltas.iteritems():
+ node = self.nodes[name]
+ for attribute, value in delta.iteritems():
+ node[attribute] = value
+
def get_distros_by_name(self, names):
return self.distros.select(names)
=== modified file 'src/provisioningserver/tests/test_api.py'
--- src/provisioningserver/tests/test_api.py 2012-02-10 20:54:16 +0000
+++ src/provisioningserver/tests/test_api.py 2012-02-13 10:17:21 +0000
@@ -146,6 +146,41 @@
self.assertEqual("node", node)
@inlineCallbacks
+ def test_modify_distros(self):
+ papi = self.get_provisioning_api()
+ distro = yield papi.add_distro(
+ "distro", "an_initrd", "a_kernel")
+ yield papi.modify_distros(
+ {distro: {"initrd": "zig", "kernel": "zag"}})
+ values = yield papi.get_distros_by_name([distro])
+ self.assertEqual("zig", values[distro]["initrd"])
+ self.assertEqual("zag", values[distro]["kernel"])
+
+ @inlineCallbacks
+ def test_modify_profiles(self):
+ papi = self.get_provisioning_api()
+ distro1 = yield papi.add_distro(
+ "distro1", "an_initrd", "a_kernel")
+ distro2 = yield papi.add_distro(
+ "distro2", "an_initrd", "a_kernel")
+ profile = yield papi.add_profile("profile", distro1)
+ yield papi.modify_profiles({profile: {"distro": distro2}})
+ values = yield papi.get_profiles_by_name([profile])
+ self.assertEqual(distro2, values[profile]["distro"])
+
+ @inlineCallbacks
+ def test_modify_nodes(self):
+ papi = self.get_provisioning_api()
+ distro = yield papi.add_distro(
+ "distro", "an_initrd", "a_kernel")
+ profile1 = yield papi.add_profile("profile1", distro)
+ profile2 = yield papi.add_profile("profile2", distro)
+ node = yield papi.add_node("node", profile1)
+ yield papi.modify_nodes({node: {"profile": profile2}})
+ values = yield papi.get_nodes_by_name([node])
+ self.assertEqual(profile2, values[node]["profile"])
+
+ @inlineCallbacks
def test_delete_distros_by_name(self):
# Create a distro via the Provisioning API.
papi = self.get_provisioning_api()