Merge lp:~fwereade/pyjuju/cobbler-instance-ids into lp:pyjuju

Proposed by William Reade
Status: Merged
Approved by: Kapil Thangavelu
Approved revision: 318
Merged at revision: 292
Proposed branch: lp:~fwereade/pyjuju/cobbler-instance-ids
Merge into: lp:pyjuju
Prerequisite: lp:~fwereade/pyjuju/cobbler-connect-production
Diff against target: 113 lines (+23/-15)
3 files modified
ensemble/providers/orchestra/cobbler.py (+11/-9)
ensemble/providers/orchestra/launch.py (+4/-4)
ensemble/providers/orchestra/tests/test_bootstrap.py (+8/-2)
To merge this branch: bzr merge lp:~fwereade/pyjuju/cobbler-instance-ids
Reviewer Review Type Date Requested Status
Kapil Thangavelu (community) Approve
Gustavo Niemeyer Approve
Review via email: mp+68725@code.launchpad.net

Description of the change

Long-term, cobbler system names can change, and are therefore a bad choice for ensemble instance IDs. This uses cobbler UIDs as instance IDs instead, and should therefore be more reliable in general (we'll still have problems if system names change while we're manipulating them, but the window of opportunity is much smaller)

To post a comment you must log in.
Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

Looks good!

review: Approve
316. By William Reade

merge parent

317. By William Reade

merge parent

318. By William Reade

merge parent

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

LGTM, +1

review: Approve
319. By William Reade

merge latest trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ensemble/providers/orchestra/cobbler.py'
2--- ensemble/providers/orchestra/cobbler.py 2011-07-30 11:50:10 +0000
3+++ ensemble/providers/orchestra/cobbler.py 2011-08-03 06:19:24 +0000
4@@ -75,33 +75,35 @@
5 return call
6
7 @inlineCallbacks
8- def _set_on_system(self, name, key, value):
9+ def _set_on_system(self, instance_id, key, value):
10+ (name,) = yield self._call("find_system", ({"uid": instance_id},))
11 handle = yield self._call("get_system_handle", (name,), auth=True)
12 yield self._check_call("modify_system", (handle, key, value),
13 auth=True, expect=True)
14 yield self._check_call("save_system", (handle,), auth=True, expect=True)
15+ returnValue(name)
16
17 @inlineCallbacks
18 def acquire_system(self):
19 """Find a system marked as available and mark it as acquired.
20
21- @return: the name of the acquired system.
22+ @return: the instance id (cobbler uid) of the acquired system.
23
24 @raise: ProviderError if no suitable system can be found.
25 """
26 systems = yield self._call("get_systems")
27 system = _acceptable_system(systems, self._available_class)
28- name = system["name"]
29+ instance_id = system["uid"]
30 # TODO surely we should preserve unrelated management classes?
31- yield self._set_on_system(name, "mgmt_classes", [self._acquired_class])
32- returnValue(name)
33+ yield self._set_on_system(instance_id, "mgmt_classes", [self._acquired_class])
34+ returnValue(instance_id)
35
36- def set_system_ks_meta(self, name, ks_meta):
37- return self._set_on_system(name, "ks_meta", ks_meta)
38+ def set_system_ks_meta(self, instance_id, ks_meta):
39+ return self._set_on_system(instance_id, "ks_meta", ks_meta)
40
41 @inlineCallbacks
42- def start_system(self, name):
43- yield self._set_on_system(name, "netboot_enabled", True)
44+ def start_system(self, instance_id):
45+ name = yield self._set_on_system(instance_id, "netboot_enabled", True)
46 yield self._call("background_power_system",
47 ({"power": "on", "systems": [name]},),
48 auth=True)
49
50=== modified file 'ensemble/providers/orchestra/launch.py'
51--- ensemble/providers/orchestra/launch.py 2011-07-20 23:20:23 +0000
52+++ ensemble/providers/orchestra/launch.py 2011-08-03 06:19:24 +0000
53@@ -11,10 +11,10 @@
54
55 @inlineCallbacks
56 def start_machine(self, variables):
57- name = yield self._provider.cobbler.acquire_system()
58+ instance_id = yield self._provider.cobbler.acquire_system()
59 ks_meta = 'ENSEMBLE_LATE_COMMAND="true"'
60
61- yield self._provider.cobbler.set_system_ks_meta(name, ks_meta)
62- yield self._provider.cobbler.start_system(name)
63+ yield self._provider.cobbler.set_system_ks_meta(instance_id, ks_meta)
64+ yield self._provider.cobbler.start_system(instance_id)
65
66- returnValue([OrchestraMachine(name, name)])
67+ returnValue([OrchestraMachine(instance_id, instance_id)])
68
69=== modified file 'ensemble/providers/orchestra/tests/test_bootstrap.py'
70--- ensemble/providers/orchestra/tests/test_bootstrap.py 2011-08-01 20:02:18 +0000
71+++ ensemble/providers/orchestra/tests/test_bootstrap.py 2011-08-03 06:19:24 +0000
72@@ -34,12 +34,14 @@
73 systems.append(
74 {"mgmt_classes": ["available"], # relevant
75 "netboot_enabled": True,
76- "name": "winston"})
77+ "uid": "winston-uid"})
78
79 self.proxy_m.callRemote("get_systems")
80 self.mocker.result(succeed(systems))
81
82 def mock_acquire_system(self, unexpected_auth_error=None):
83+ self.proxy_m.callRemote("find_system", {"uid": "winston-uid"})
84+ self.mocker.result(succeed(["winston"]))
85 self.proxy_m.callRemote("get_system_handle", "winston", "")
86 if unexpected_auth_error is not None:
87 self.mocker.result(fail(unexpected_auth_error))
88@@ -56,6 +58,8 @@
89 self.mocker.result(succeed(True))
90
91 def mock_set_ks_meta(self, fail_modify=False, fail_save=False):
92+ self.proxy_m.callRemote("find_system", {"uid": "winston-uid"})
93+ self.mocker.result(succeed(["winston"]))
94 self.proxy_m.callRemote("get_system_handle", "winston", "TOKEN")
95 self.mocker.result(succeed("smith"))
96 # TODO: parameterise this match?
97@@ -73,6 +77,8 @@
98 self.mocker.result(succeed(True))
99
100 def mock_start_system(self):
101+ self.proxy_m.callRemote("find_system", {"uid": "winston-uid"})
102+ self.mocker.result(succeed(["winston"]))
103 self.proxy_m.callRemote("get_system_handle", "winston", "TOKEN")
104 self.mocker.result(succeed("smith"))
105 self.proxy_m.callRemote(
106@@ -138,6 +144,6 @@
107 def verify_machines(machines):
108 (machine,) = machines
109 self.assertTrue(isinstance(machine, OrchestraMachine))
110- self.assertEquals(machine.instance_id, "winston")
111+ self.assertEquals(machine.instance_id, "winston-uid")
112 d.addCallback(verify_machines)
113 return d

Subscribers

People subscribed via source and target branches

to status/vote changes: