Merge lp:~andreserl/maas/maas_fix_constraints_arch_mapping into lp:~maas-committers/maas/trunk

Proposed by Andres Rodriguez
Status: Rejected
Rejected by: Martin Packman
Proposed branch: lp:~andreserl/maas/maas_fix_constraints_arch_mapping
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 28 lines (+12/-1)
1 file modified
src/maasserver/api.py (+12/-1)
To merge this branch: bzr merge lp:~andreserl/maas/maas_fix_constraints_arch_mapping
Reviewer Review Type Date Requested Status
Gavin Panella (community) Needs Information
John A Meinel Pending
Review via email: mp+128338@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) wrote :

I think this is the wrong solution. If a subarch is not supplied I
would expect it to match any subarch. _constraints_arch_map is a
kludge to force this issue to go away, but I think it needs a
different fix. If we run out of time then I guess this is okay, but
I'd rather Blue Squad have a chance to comment first.

[1]

+_constraints_arch_map = {

Can you add a comment here, explaining to our future selves what the
purpose of this is?

[2]

+            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]

This could be simplified a little:

            constraint = request_params[request_name]
            constraint = _constraints_arch_map.get(constraint, constraint)
            constraints[db_name] = constraint

review: Needs Information
Revision history for this message
Julian Edwards (julian-edwards) wrote :

I agree with Gavin. Tests are also missing.

Revision history for this message
Robie Basak (racb) wrote :

I've just synced with Martin on how we want to amend this. Andres: please hold for now - I should have a merge proposal shortly.

Revision history for this message
Martin Packman (gz) wrote :

So, we've landed a more complete version of this fix now.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/api.py'
2--- src/maasserver/api.py 2012-10-05 08:04:58 +0000
3+++ src/maasserver/api.py 2012-10-08 00:36:23 +0000
4@@ -658,6 +658,15 @@
5 }
6
7
8+# Map the architecture constraint value as passed in the request to the value
9+# of the constraint in the database.
10+_constraints_arch_map = {
11+ 'i386': 'i386/generic',
12+ 'amd64': 'amd64/generic',
13+ 'armhf': 'armhf/highbank',
14+ }
15+
16+
17 def extract_constraints(request_params):
18 """Extract a dict of node allocation constraints from http parameters.
19
20@@ -670,7 +679,9 @@
21 for request_name in _constraints_map:
22 if request_name in request_params:
23 db_name = _constraints_map[request_name]
24- constraints[db_name] = request_params[request_name]
25+ constraint = request_params[request_name]
26+ constraint = _constraints_arch_map.get(constraint, constraint)
27+ constraints[db_name] = constraint
28 return constraints
29
30