← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~andreserl/maas/maas_fix_constraints_arch_mapping into lp:maas

 

Andres Rodriguez has proposed merging lp:~andreserl/maas/maas_fix_constraints_arch_mapping into lp:maas.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1062605 in MAAS: "juju: No matching node is availble - Due to constraints lacking subarch"
  https://bugs.launchpad.net/maas/+bug/1062605

For more details, see:
https://code.launchpad.net/~andreserl/maas/maas_fix_constraints_arch_mapping/+merge/128338
-- 
https://code.launchpad.net/~andreserl/maas/maas_fix_constraints_arch_mapping/+merge/128338
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~andreserl/maas/maas_fix_constraints_arch_mapping into lp:maas.
=== modified file 'src/maasserver/api.py'
--- src/maasserver/api.py	2012-10-05 08:04:58 +0000
+++ src/maasserver/api.py	2012-10-06 02:40:25 +0000
@@ -658,6 +658,13 @@
     }
 
 
+_constraints_arch_map = {
+    'i386': 'i386/generic',
+    'amd64': 'amd64/generic',
+    'armhf': 'armhf/highbank',
+}
+
+
 def extract_constraints(request_params):
     """Extract a dict of node allocation constraints from http parameters.
 
@@ -670,7 +677,10 @@
     for request_name in _constraints_map:
         if request_name in request_params:
             db_name = _constraints_map[request_name]
-            constraints[db_name] = request_params[request_name]
+            if request_params[request_name] in _constraints_arch_map:
+                constraints[db_name] = _constraints_arch_map[request_params[request_name]]
+            else:
+                constraints[db_name] = request_params[request_name]
     return constraints