Merge lp:~fwereade/pyjuju/spike-catchup into lp:pyjuju

Proposed by William Reade
Status: Merged
Approved by: Kapil Thangavelu
Approved revision: 318
Merged at revision: 317
Proposed branch: lp:~fwereade/pyjuju/spike-catchup
Merge into: lp:pyjuju
Prerequisite: lp:~fwereade/pyjuju/hide-instances
Diff against target: 89 lines (+50/-1)
2 files modified
ensemble/providers/orchestra/__init__.py (+13/-1)
ensemble/providers/orchestra/tests/test_provider.py (+37/-0)
To merge this branch: bzr merge lp:~fwereade/pyjuju/spike-catchup
Reviewer Review Type Date Requested Status
Kapil Thangavelu (community) Approve
Gustavo Niemeyer Approve
Jim Baker (community) Approve
Review via email: mp+71269@code.launchpad.net

Description of the change

This just brings provider.get_serialization_data in line with the spiked version. (The prereq includes all the orchestra get_machine/get_machines stuff which was otherwise missing)

To post a comment you must log in.
Revision history for this message
Jim Baker (jimbaker) wrote :

+1, looks good to me!

review: Approve
lp:~fwereade/pyjuju/spike-catchup updated
315. By William Reade

merge parent

316. By William Reade

merge parent

317. By William Reade

merge parent

318. By William Reade

merge parent

Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

Looks good!

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

Looks good, +1

review: Approve
lp:~fwereade/pyjuju/spike-catchup updated
319. By William Reade

merge parent

320. By William Reade

null merge trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ensemble/providers/orchestra/__init__.py'
2--- ensemble/providers/orchestra/__init__.py 2011-08-12 19:54:54 +0000
3+++ ensemble/providers/orchestra/__init__.py 2011-08-17 09:23:53 +0000
4@@ -1,10 +1,13 @@
5+import copy
6 from operator import itemgetter
7
8 from twisted.internet.defer import inlineCallbacks, returnValue
9
10+from ensemble.environment.errors import EnvironmentsConfigError
11 from ensemble.providers.common.bootstrap import Bootstrap
12 from ensemble.providers.common.findzookeepers import find_zookeepers
13 from ensemble.providers.common.state import SaveState, LoadState
14+from ensemble.providers.common.utils import get_user_authorized_keys
15
16 from .cobbler import CobblerClient
17 from .files import FileStorage
18@@ -21,12 +24,21 @@
19 self.config = config
20 self.cobbler = CobblerClient(config)
21
22+ if ("authorized-keys-path" in config and
23+ "authorized-keys" in config):
24+ raise EnvironmentsConfigError(
25+ "Environment config cannot define both authorized-keys "
26+ "and authorized-keys-path. Pick one!")
27+
28 def get_serialization_data(self):
29 """Return a dictionary serialization of the provider configuration.
30
31 Additionally this extracts credential information from the environment.
32 """
33- raise NotImplementedError()
34+ data = copy.deepcopy(self.config)
35+ data["authorized-keys"] = get_user_authorized_keys(data)
36+ data.pop("authorized-keys-path", None)
37+ return data
38
39 def connect(self, share=False):
40 """
41
42=== modified file 'ensemble/providers/orchestra/tests/test_provider.py'
43--- ensemble/providers/orchestra/tests/test_provider.py 2011-08-12 19:54:54 +0000
44+++ ensemble/providers/orchestra/tests/test_provider.py 2011-08-17 09:23:53 +0000
45@@ -1,3 +1,4 @@
46+from ensemble.environment.errors import EnvironmentsConfigError
47 from ensemble.lib.testing import TestCase
48 from ensemble.providers.orchestra import MachineProvider
49
50@@ -15,3 +16,39 @@
51 "tetrascape", CONFIG)
52 self.assertEquals(provider.environment_name, "tetrascape")
53 self.assertEquals(provider.config, CONFIG)
54+
55+ def test_config_serialization(self):
56+ """
57+ The provider configuration can be serialized to yaml.
58+ """
59+ keys_path = self.makeFile("my-keys")
60+
61+ config = {"orchestra-user": "chaosmonkey",
62+ "orchestra-pass": "crash",
63+ "acquired-mgmt-class": "madeup-1",
64+ "available-mgmt-class": "madeup-2",
65+ "orchestra-server": "127.0.0.01",
66+ "authorized-keys-path": keys_path}
67+
68+ expected = {"orchestra-user": "chaosmonkey",
69+ "orchestra-pass": "crash",
70+ "acquired-mgmt-class": "madeup-1",
71+ "available-mgmt-class": "madeup-2",
72+ "orchestra-server": "127.0.0.01",
73+ "authorized-keys": "my-keys"}
74+
75+ provider = MachineProvider("tetrascape", config)
76+ serialized = provider.get_serialization_data()
77+ self.assertEqual(serialized, expected)
78+
79+ def test_conflicting_authorized_keys_options(self):
80+ """
81+ We can't handle two different authorized keys options, so deny
82+ constructing an environment that way.
83+ """
84+ config = CONFIG.copy()
85+ config["authorized-keys"] = "File content"
86+ config["authorized-keys-path"] = "File path"
87+ error = self.assertRaises(EnvironmentsConfigError,
88+ MachineProvider, "some-env-name", config)
89+ self.assertIn("authorized-keys", str(error))

Subscribers

People subscribed via source and target branches

to status/vote changes: