Merge lp:~gz/pyjuju/maas_int_constraints_1061286 into lp:pyjuju
Proposed by
Martin Packman
Status: | Merged |
---|---|
Approved by: | Kapil Thangavelu |
Approved revision: | 589 |
Merged at revision: | 589 |
Proposed branch: | lp:~gz/pyjuju/maas_int_constraints_1061286 |
Merge into: | lp:pyjuju |
Diff against target: |
63 lines (+14/-9) 2 files modified
juju/providers/maas/maas.py (+12/-7) juju/providers/maas/tests/test_maas.py (+2/-2) |
To merge this branch: | bzr merge lp:~gz/pyjuju/maas_int_constraints_1061286 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+127987@code.launchpad.net |
Description of the change
Give integer maas constraints without decimal
Currently generic cpu and mem constraints are cast to float inside
juju, this isn't really useful for memory in MB or cpu count as used
by MaaS. It also happens to upset the current code. Giving the
integer form instead is reasonable.
To post a comment you must log in.
Reviewers: mp+127987_ code.launchpad. net,
Message:
Please take a look.
Description:
Give integer maas constraints without decimal
Currently generic cpu and mem constraints are cast to float inside
juju, this isn't really useful for memory in MB or cpu count as used
by MaaS. It also happens to upset the current code. Giving the
integer form instead is reasonable.
https:/ /code.launchpad .net/~gz/ juju/maas_ int_constraints _1061286/ +merge/ 127987
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/6601060/
Affected files: maas/maas. py maas/tests/ test_maas. py
A [revision details]
M juju/providers/
M juju/providers/
Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>
Index: juju/providers/ maas/maas. py /maas/maas. py' maas/maas. py 2012-09-28 11:50:35 +0000 maas/maas. py 2012-10-04 11:16:58 +0000 "system_ id")
=== modified file 'juju/providers
--- juju/providers/
+++ juju/providers/
@@ -42,14 +42,19 @@
return match.group(
+def _int_str(value): MAASOAuthConnec tion):
+ """Convert value to integer then string"""
+ return str(int(value))
+
+
class MAASClient(
_ handled_ constraints = (
- ("maas-name", "name"),
- ("maas-tags", "tags"),
- ("arch", "arch"),
- ("cpu", "cpu_count"),
- ("mem", "mem"),
+ ("maas-name", "name", str),
+ ("maas-tags", "tags", str),
+ ("arch", "arch", str),
+ ("cpu", "cpu_count", _int_str),
+ ("mem", "mem", _int_str),
)
def __init__(self, config): constraints: constraints:
value = constraints. get(key_ from, None)
if value is not None: "api/1. 0/nodes/ ", params)
@@ -127,10 +132,10 @@
"""
params = {"op": "acquire"}
if constraints is not None:
- for key_from, key_to in self._handled_
+ for key_from, key_to, translate in self._handled_
- params[key_to] = str(value)
+ params[key_to] = translate(value)
return self.post(
def start_node(self, resource_uri, ubuntu_series, user_data):
Index: juju/providers/ maas/tests/ test_maas. py /maas/tests/ test_maas. py' maas/tests/ test_maas. py 2012-09-28 11:50:35 +0000 maas/tests/ test_maas. py 2012-10-04 11:16:58 +0000
=== modified file 'juju/providers
--- juju/providers/
+++ juju/providers/
@@ -348,7 +348,7 @@
def test_acquire_ node_handles_ cpu_constraint( self): up_client_ with_fake( )
client. acquire_ node(constraint s)
client = self.set_
- constraints = {"cpu": 2}
+ constraints = {"cpu": 2.0}
cpu_count = client. post.params_ used.get( "cpu_count" )
@@ -356,7 +356,7 @@
def test_acquire_ node_handles_ mem_constraint( self): up_client_ with_fake( )
client. acquire_ node(constraint s)
client = self.set_
- constraints = {"mem": 2048}
+ constraints = {"mem": 2048.0}
mem =...