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
=== modified file 'deployer/action/importer.py'
--- deployer/action/importer.py 2015-08-06 14:16:54 +0000
+++ deployer/action/importer.py 2015-08-10 15:51:53 +0000
@@ -195,11 +195,10 @@
195 else:195 else:
196 num_units = svc.num_units196 num_units = svc.num_units
197197
198 # Unset num_units if we are not adding units. This should be done198 # Only add a single unit if requested. This is done after the above
199 # after the above work to ensure that the status is still retrieved199 # work to ensure that the status is still retrieved as necessary.
200 # as necessary.
201 if not add_units:200 if not add_units:
202 num_units = None201 num_units = 1
203202
204 placement = self.deployment.get_unit_placement(svc, env_status)203 placement = self.deployment.get_unit_placement(svc, env_status)
205204
206205
=== modified file 'deployer/guiserver.py'
--- deployer/guiserver.py 2014-12-17 13:06:49 +0000
+++ deployer/guiserver.py 2015-08-10 15:51:53 +0000
@@ -37,8 +37,8 @@
37class GUIDeployment(Deployment):37class GUIDeployment(Deployment):
38 """Handle bundle deployments requested by the GUI server."""38 """Handle bundle deployments requested by the GUI server."""
3939
40 def __init__(self, name, data):40 def __init__(self, name, data, version):
41 super(GUIDeployment, self).__init__(name, data, [])41 super(GUIDeployment, self).__init__(name, data, [], version=version)
4242
43 def _handle_feedback(self, feedback):43 def _handle_feedback(self, feedback):
44 """Raise a DeploymentError if the given feedback includes errors.44 """Raise a DeploymentError if the given feedback includes errors.
@@ -82,10 +82,17 @@
82 env.close()82 env.close()
8383
8484
85def import_bundle(apiurl, username, password, name, bundle, options):85def import_bundle(apiurl, username, password, name, bundle, version, options):
86 """Import a bundle."""86 """Import a bundle.
87
88 To connect to the Juju environment, use the given API URL, user name and
89 password. The name and bundle arguments are used to deploy the bundle. The
90 version argument specifies whether the given bundle content uses the
91 legacy v3 or the new v4 bundle syntax. The given options are used to
92 start the bundle deployment process.
93 """
87 env = GUIEnvironment(apiurl, username, password)94 env = GUIEnvironment(apiurl, username, password)
88 deployment = GUIDeployment(name, bundle)95 deployment = GUIDeployment(name, bundle, version=version)
89 importer = Importer(env, deployment, options)96 importer = Importer(env, deployment, options)
90 env.connect()97 env.connect()
91 # The Importer tries to retrieve the Juju home from the JUJU_HOME98 # The Importer tries to retrieve the Juju home from the JUJU_HOME
9299
=== modified file 'deployer/tests/test_guiserver.py'
--- deployer/tests/test_guiserver.py 2015-08-06 08:40:16 +0000
+++ deployer/tests/test_guiserver.py 2015-08-10 15:51:53 +0000
@@ -83,7 +83,7 @@
8383
84 def setUp(self):84 def setUp(self):
85 # Set up a GUIDeployment instance and a Feedback object.85 # Set up a GUIDeployment instance and a Feedback object.
86 self.deployment = guiserver.GUIDeployment('mybundle', 'mydata')86 self.deployment = guiserver.GUIDeployment('mybundle', 'mydata', 4)
87 self.feedback = Feedback()87 self.feedback = Feedback()
8888
89 def test_valid_deployment(self):89 def test_valid_deployment(self):
@@ -213,11 +213,11 @@
213 finally:213 finally:
214 del os.environ['JUJU_HOME']214 del os.environ['JUJU_HOME']
215215
216 def import_bundle(self):216 def import_bundle(self, version=4):
217 """Call the import_bundle function."""217 """Call the import_bundle function."""
218 guiserver.import_bundle(218 guiserver.import_bundle(
219 self.apiurl, self.username, self.password, self.name, self.bundle,219 self.apiurl, self.username, self.password, self.name, self.bundle,
220 self.options)220 version, self.options)
221221
222 def cleanup_series_path(self):222 def cleanup_series_path(self):
223 """Remove the series path created by the Deployment object."""223 """Remove the series path created by the Deployment object."""
@@ -274,7 +274,7 @@
274 patch_env_status(mock_environment(), {'mysql': 1, 'wordpress': 1})274 patch_env_status(mock_environment(), {'mysql': 1, 'wordpress': 1})
275 mock_environment.reset_mock()275 mock_environment.reset_mock()
276 with self.patch_juju_home():276 with self.patch_juju_home():
277 self.import_bundle()277 self.import_bundle(version=3)
278 mock_sleep.assert_has_calls([mock.call(5.1), mock.call(60)])278 mock_sleep.assert_has_calls([mock.call(5.1), mock.call(60)])
279 # If any of the calls below fails, then we have to change the279 # If any of the calls below fails, then we have to change the
280 # signatures of deployer.guiserver.GUIEnvironment methods.280 # signatures of deployer.guiserver.GUIEnvironment methods.
@@ -313,12 +313,13 @@
313 },313 },
314 },314 },
315 }315 }
316 version = 4
316 self.addCleanup(self.cleanup_series_path)317 self.addCleanup(self.cleanup_series_path)
317 with self.patch_juju_home():318 with self.patch_juju_home():
318 with self.assertRaises(guiserver.DeploymentError) as cm:319 with self.assertRaises(guiserver.DeploymentError) as cm:
319 guiserver.import_bundle(320 guiserver.import_bundle(
320 self.apiurl, self.username, self.password, self.name,321 self.apiurl, self.username, self.password, self.name,
321 bundle, self.options)322 bundle, version, self.options)
322 expected_errors = set([323 expected_errors = set([
323 'Invalid config charm cs:precise/wordpress-20 no-such-option=42',324 'Invalid config charm cs:precise/wordpress-20 no-such-option=42',
324 'Invalid config charm cs:precise/mysql-28 bad=wolf',325 'Invalid config charm cs:precise/mysql-28 bad=wolf',
325326
=== modified file 'setup.py'
--- setup.py 2015-08-06 09:19:32 +0000
+++ setup.py 2015-08-10 15:51:53 +0000
@@ -3,7 +3,7 @@
33
4setup(4setup(
5 name="juju-deployer",5 name="juju-deployer",
6 version="0.5.1",6 version="0.5.2",
7 description="A tool for deploying complex stacks with juju.",7 description="A tool for deploying complex stacks with juju.",
8 long_description=open("README").read(),8 long_description=open("README").read(),
9 author="Kapil Thangavelu",9 author="Kapil Thangavelu",

Subscribers

People subscribed via source and target branches