Merge lp:~frankban/juju-deployer/guiserver-bundle-v4 into lp:juju-deployer

Proposed by Francesco Banconi
Status: Merged
Merged at revision: 154
Proposed branch: lp:~frankban/juju-deployer/guiserver-bundle-v4
Merge into: lp:juju-deployer
Diff against target: 118 lines (+22/-15)
4 files modified
deployer/action/importer.py (+3/-4)
deployer/guiserver.py (+12/-5)
deployer/tests/test_guiserver.py (+6/-5)
setup.py (+1/-1)
To merge this branch: bzr merge lp:~frankban/juju-deployer/guiserver-bundle-v4
Reviewer Review Type Date Requested Status
Tim Van Steenburgh (community) Approve
Brad Crittenden (community) code Approve
Madison Scott-Clary (community) code Approve
Review via email: mp+267540@code.launchpad.net

Description of the change

Allow deploying bundles with v4 syntax also from the GUI server/API side of the deployer.
Also fix the add_unit logic in the importer so that the expected result (of adding one single unit) is achieved also when using the juju-core API (GUIEnvironment) for deploying charms.

To post a comment you must log in.
Revision history for this message
Madison Scott-Clary (makyo) wrote :

Thanks Francesco, LGTM

review: Approve (code)
Revision history for this message
Brad Crittenden (bac) wrote :

Thanks

review: Approve (code)
Revision history for this message
Tim Van Steenburgh (tvansteenburgh) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'deployer/action/importer.py'
2--- deployer/action/importer.py 2015-08-06 14:16:54 +0000
3+++ deployer/action/importer.py 2015-08-10 15:51:53 +0000
4@@ -195,11 +195,10 @@
5 else:
6 num_units = svc.num_units
7
8- # Unset num_units if we are not adding units. This should be done
9- # after the above work to ensure that the status is still retrieved
10- # as necessary.
11+ # Only add a single unit if requested. This is done after the above
12+ # work to ensure that the status is still retrieved as necessary.
13 if not add_units:
14- num_units = None
15+ num_units = 1
16
17 placement = self.deployment.get_unit_placement(svc, env_status)
18
19
20=== modified file 'deployer/guiserver.py'
21--- deployer/guiserver.py 2014-12-17 13:06:49 +0000
22+++ deployer/guiserver.py 2015-08-10 15:51:53 +0000
23@@ -37,8 +37,8 @@
24 class GUIDeployment(Deployment):
25 """Handle bundle deployments requested by the GUI server."""
26
27- def __init__(self, name, data):
28- super(GUIDeployment, self).__init__(name, data, [])
29+ def __init__(self, name, data, version):
30+ super(GUIDeployment, self).__init__(name, data, [], version=version)
31
32 def _handle_feedback(self, feedback):
33 """Raise a DeploymentError if the given feedback includes errors.
34@@ -82,10 +82,17 @@
35 env.close()
36
37
38-def import_bundle(apiurl, username, password, name, bundle, options):
39- """Import a bundle."""
40+def import_bundle(apiurl, username, password, name, bundle, version, options):
41+ """Import a bundle.
42+
43+ To connect to the Juju environment, use the given API URL, user name and
44+ password. The name and bundle arguments are used to deploy the bundle. The
45+ version argument specifies whether the given bundle content uses the
46+ legacy v3 or the new v4 bundle syntax. The given options are used to
47+ start the bundle deployment process.
48+ """
49 env = GUIEnvironment(apiurl, username, password)
50- deployment = GUIDeployment(name, bundle)
51+ deployment = GUIDeployment(name, bundle, version=version)
52 importer = Importer(env, deployment, options)
53 env.connect()
54 # The Importer tries to retrieve the Juju home from the JUJU_HOME
55
56=== modified file 'deployer/tests/test_guiserver.py'
57--- deployer/tests/test_guiserver.py 2015-08-06 08:40:16 +0000
58+++ deployer/tests/test_guiserver.py 2015-08-10 15:51:53 +0000
59@@ -83,7 +83,7 @@
60
61 def setUp(self):
62 # Set up a GUIDeployment instance and a Feedback object.
63- self.deployment = guiserver.GUIDeployment('mybundle', 'mydata')
64+ self.deployment = guiserver.GUIDeployment('mybundle', 'mydata', 4)
65 self.feedback = Feedback()
66
67 def test_valid_deployment(self):
68@@ -213,11 +213,11 @@
69 finally:
70 del os.environ['JUJU_HOME']
71
72- def import_bundle(self):
73+ def import_bundle(self, version=4):
74 """Call the import_bundle function."""
75 guiserver.import_bundle(
76 self.apiurl, self.username, self.password, self.name, self.bundle,
77- self.options)
78+ version, self.options)
79
80 def cleanup_series_path(self):
81 """Remove the series path created by the Deployment object."""
82@@ -274,7 +274,7 @@
83 patch_env_status(mock_environment(), {'mysql': 1, 'wordpress': 1})
84 mock_environment.reset_mock()
85 with self.patch_juju_home():
86- self.import_bundle()
87+ self.import_bundle(version=3)
88 mock_sleep.assert_has_calls([mock.call(5.1), mock.call(60)])
89 # If any of the calls below fails, then we have to change the
90 # signatures of deployer.guiserver.GUIEnvironment methods.
91@@ -313,12 +313,13 @@
92 },
93 },
94 }
95+ version = 4
96 self.addCleanup(self.cleanup_series_path)
97 with self.patch_juju_home():
98 with self.assertRaises(guiserver.DeploymentError) as cm:
99 guiserver.import_bundle(
100 self.apiurl, self.username, self.password, self.name,
101- bundle, self.options)
102+ bundle, version, self.options)
103 expected_errors = set([
104 'Invalid config charm cs:precise/wordpress-20 no-such-option=42',
105 'Invalid config charm cs:precise/mysql-28 bad=wolf',
106
107=== modified file 'setup.py'
108--- setup.py 2015-08-06 09:19:32 +0000
109+++ setup.py 2015-08-10 15:51:53 +0000
110@@ -3,7 +3,7 @@
111
112 setup(
113 name="juju-deployer",
114- version="0.5.1",
115+ version="0.5.2",
116 description="A tool for deploying complex stacks with juju.",
117 long_description=open("README").read(),
118 author="Kapil Thangavelu",

Subscribers

People subscribed via source and target branches