Merge lp:~gz/pyjuju/os_scheduler_hints_json_fix into lp:pyjuju

Proposed by Martin Packman
Status: Merged
Approved by: Kapil Thangavelu
Approved revision: 617
Merged at revision: 617
Proposed branch: lp:~gz/pyjuju/os_scheduler_hints_json_fix
Merge into: lp:pyjuju
Diff against target: 37 lines (+6/-4)
2 files modified
juju/providers/openstack/client.py (+3/-2)
juju/providers/openstack/tests/test_client.py (+3/-2)
To merge this branch: bzr merge lp:~gz/pyjuju/os_scheduler_hints_json_fix
Reviewer Review Type Date Requested Status
Kapil Thangavelu (community) Approve
John A Meinel Approve
Review via email: mp+149028@code.launchpad.net

Description of the change

Fix format of the scheduler hints passed in the json dict when creating a server.

This is the juju part of getting hints working, see the mailing list post:

<https://lists.ubuntu.com/archives/juju/2013-February/002112.html>

There is some discussion about designing a neater abstraction, this is just fixing the existing code in the interim.

To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote :

Matches my understanding of how this should work.

review: Approve
Revision history for this message
Kapil Thangavelu (hazmat) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'juju/providers/openstack/client.py'
--- juju/providers/openstack/client.py 2013-01-06 17:44:45 +0000
+++ juju/providers/openstack/client.py 2013-02-18 11:45:27 +0000
@@ -397,14 +397,15 @@
397 'flavorRef': flavor_id,397 'flavorRef': flavor_id,
398 'imageRef': image_id,398 'imageRef': image_id,
399 }399 }
400 post_dict = {"server": server}
400 if user_data is not None:401 if user_data is not None:
401 server["user_data"] = base64.b64encode(user_data)402 server["user_data"] = base64.b64encode(user_data)
402 if security_group_names is not None:403 if security_group_names is not None:
403 server["security_groups"] = [{'name': n}404 server["security_groups"] = [{'name': n}
404 for n in security_group_names]405 for n in security_group_names]
405 if scheduler_hints is not None:406 if scheduler_hints is not None:
406 server["OS-SCH-HNT:scheduler_hints"] = scheduler_hints407 post_dict["OS-SCH-HNT:scheduler_hints"] = scheduler_hints
407 return self.post(["servers"], {'server': server},408 return self.post(["servers"], post_dict,
408 root="server", code=202)409 root="server", code=202)
409410
410 def get_server_security_groups(self, server_id):411 def get_server_security_groups(self, server_id):
411412
=== modified file 'juju/providers/openstack/tests/test_client.py'
--- juju/providers/openstack/tests/test_client.py 2012-10-26 14:52:35 +0000
+++ juju/providers/openstack/tests/test_client.py 2013-02-18 11:45:27 +0000
@@ -204,8 +204,9 @@
204 "imageRef": "an-image",204 "imageRef": "an-image",
205 "flavorRef": "a-flavor",205 "flavorRef": "a-flavor",
206 "name": "Test",206 "name": "Test",
207 "OS-SCH-HNT:scheduler_hints": {"hint-key": "hint-val"},207 },
208 }}, obj)208 "OS-SCH-HNT:scheduler_hints": {"hint-key": "hint-val"},
209 }, obj)
209 return True210 return True
210211
211 @defer.inlineCallbacks212 @defer.inlineCallbacks

Subscribers

People subscribed via source and target branches

to status/vote changes: