← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~allenap/maas/papi-no-kwargs into lp:maas

 

Gavin Panella has proposed merging lp:~allenap/maas/papi-no-kwargs into lp:maas.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~allenap/maas/papi-no-kwargs/+merge/97241
-- 
https://code.launchpad.net/~allenap/maas/papi-no-kwargs/+merge/97241
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~allenap/maas/papi-no-kwargs into lp:maas.
=== modified file 'src/maasserver/provisioning.py'
--- src/maasserver/provisioning.py	2012-03-13 04:38:28 +0000
+++ src/maasserver/provisioning.py	2012-03-13 15:25:21 +0000
@@ -94,9 +94,7 @@
     profile = select_profile_for_node(instance, papi)
     power_type = instance.get_effective_power_type()
     metadata = compose_metadata(instance)
-    papi.add_node(
-        name=instance.system_id, profile=profile, power_type=power_type,
-        metadata=metadata)
+    papi.add_node(instance.system_id, profile, power_type, metadata)
 
 
 def set_node_mac_addresses(node):

=== modified file 'src/provisioningserver/testing/fakeapi.py'
--- src/provisioningserver/testing/fakeapi.py	2012-03-13 04:35:58 +0000
+++ src/provisioningserver/testing/fakeapi.py	2012-03-13 15:25:21 +0000
@@ -30,6 +30,19 @@
 from zope.interface.interface import Method
 
 
+def prevent_keyword_args(func):
+    """Forbid use of keyword arguments.
+
+    The Provisioning API is meant to be used via XML-RPC, at least for now, so
+    we prevent all API methods from being used with keyword arguments, which
+    are not supported via XML-RPC.
+    """
+    @wraps(func)
+    def wrapper(*args):
+        return func(*args)
+    return wrapper
+
+
 class FakeProvisioningDatabase(dict):
 
     def __missing__(self, key):
@@ -84,15 +97,18 @@
         # happened most recently).
         self.power_status = {}
 
+    @prevent_keyword_args
     def add_distro(self, name, initrd, kernel):
         self.distros[name]["initrd"] = initrd
         self.distros[name]["kernel"] = kernel
         return name
 
+    @prevent_keyword_args
     def add_profile(self, name, distro):
         self.profiles[name]["distro"] = distro
         return name
 
+    @prevent_keyword_args
     def add_node(self, name, profile, power_type, metadata):
         self.nodes[name]["profile"] = profile
         self.nodes[name]["mac_addresses"] = []
@@ -100,52 +116,66 @@
         self.power_types[name] = power_type
         return name
 
+    @prevent_keyword_args
     def modify_distros(self, deltas):
         for name, delta in deltas.items():
             distro = self.distros[name]
             distro.update(delta)
 
+    @prevent_keyword_args
     def modify_profiles(self, deltas):
         for name, delta in deltas.items():
             profile = self.profiles[name]
             profile.update(delta)
 
+    @prevent_keyword_args
     def modify_nodes(self, deltas):
         for name, delta in deltas.items():
             node = self.nodes[name]
             node.update(delta)
 
+    @prevent_keyword_args
     def get_distros_by_name(self, names):
         return self.distros.select(names)
 
+    @prevent_keyword_args
     def get_profiles_by_name(self, names):
         return self.profiles.select(names)
 
+    @prevent_keyword_args
     def get_nodes_by_name(self, names):
         return self.nodes.select(names)
 
+    @prevent_keyword_args
     def delete_distros_by_name(self, names):
         return self.distros.delete(names)
 
+    @prevent_keyword_args
     def delete_profiles_by_name(self, names):
         return self.profiles.delete(names)
 
+    @prevent_keyword_args
     def delete_nodes_by_name(self, names):
         return self.nodes.delete(names)
 
+    @prevent_keyword_args
     def get_distros(self):
         return self.distros.dump()
 
+    @prevent_keyword_args
     def get_profiles(self):
         return self.profiles.dump()
 
+    @prevent_keyword_args
     def get_nodes(self):
         return self.nodes.dump()
 
+    @prevent_keyword_args
     def start_nodes(self, names):
         for name in names:
             self.power_status[name] = 'start'
 
+    @prevent_keyword_args
     def stop_nodes(self, names):
         for name in names:
             self.power_status[name] = 'stop'

=== modified file 'src/provisioningserver/tests/test_api.py'
--- src/provisioningserver/tests/test_api.py	2012-03-13 09:34:02 +0000
+++ src/provisioningserver/tests/test_api.py	2012-03-13 15:25:21 +0000
@@ -327,8 +327,7 @@
         if metadata is None:
             metadata = fake_node_metadata()
         node_name = yield papi.add_node(
-            name=name, profile=profile_name, power_type=power_type,
-            metadata=metadata)
+            name, profile_name, power_type, metadata)
         self.addCleanup(
             self.cleanup_objects,
             papi.delete_nodes_by_name,