/usr/bin/juju was hard-coded. Made interoperability testing with
pre-release versions of juju difficult. This allows override with JUJU
environment var.
Affected files (+50, -5 lines):
A [revision details]
M quickstart/manage.py
M quickstart/platform_support.py
M quickstart/tests/test_manage.py
M quickstart/tests/test_platform_support.py
Index: quickstart/manage.py
=== modified file 'quickstart/manage.py'
--- quickstart/manage.py 2014-06-13 15:19:46 +0000
+++ quickstart/manage.py 2014-08-21 15:20:55 +0000
@@ -497,6 +497,12 @@ print('sudo privileges will be required to bootstrap the
environment')
# If the Juju version is less than 1.17.2 then use sudo for local
envs. requires_sudo = juju_version < (1, 17, 2)
+ if requires_sudo:
+ non_env_juju_command = platform_support.get_juju_command(
+ options.platform, True)
+ if non_env_juju_command != juju_command:
+ print("Warning: ignoring JUJU environment variable")
+ juju_command = non_env_juju_command
-def get_juju_command(platform):
+def get_juju_command(platform, ignore_env_var=False):
"""Return the path to the Juju command on the given platform.
If the platform does not have a novel location, the default will be
returned.
+
+ If the environment variable JUJU is set, then its value will be
+ returned.
"""
- return settings.JUJU_CMD_PATHS.get(
- platform,
- settings.JUJU_CMD_PATHS['default'])
+ juju_command = os.getenv('JUJU', '').strip()
+ if juju_command is not None and not ignore_env_var:
+ print("Warning: a customized juju is being used.")
+ return juju_command
+ else:
+ return settings.JUJU_CMD_PATHS.get(
+ platform,
+ settings.JUJU_CMD_PATHS['default'])
Reviewers: mp+227238_ code.launchpad. net,
Message:
Please take a look.
Description:
/usr/bin/juju was hard-coded. Made interoperability testing with
pre-release versions of juju difficult. This allows override with JUJU
environment var.
https:/ /code.launchpad .net/~evarlast/ juju-quickstart /which- juju/+merge/ 227238
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/132770043/
Affected files (+50, -5 lines): manage. py platform_ support. py tests/test_ manage. py tests/test_ platform_ support. py
A [revision details]
M quickstart/
M quickstart/
M quickstart/
M quickstart/
Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision:
<email address hidden>
+New revision: <email address hidden>
Index: quickstart/ manage. py manage. py' manage. py 2014-06-13 15:19:46 +0000 manage. py 2014-08-21 15:20:55 +0000
print( 'sudo privileges will be required to bootstrap the
requires_ sudo = juju_version < (1, 17, 2) juju_command = platform_ support. get_juju_ command( juju_command != juju_command: juju_command
=== modified file 'quickstart/
--- quickstart/
+++ quickstart/
@@ -497,6 +497,12 @@
environment')
# If the Juju version is less than 1.17.2 then use sudo for local
envs.
+ if requires_sudo:
+ non_env_
+ options.platform, True)
+ if non_env_
+ print("Warning: ignoring JUJU environment variable")
+ juju_command = non_env_
already_ bootstrapped, bootstrap_ node_series = app.bootstrap(
options. env_name, juju_command,
Index: quickstart/ platform_ support. py platform_ support. py' platform_ support. py 2014-06-13 14:36:30 +0000 platform_ support. py 2014-08-21 15:20:55 +0000
=== modified file 'quickstart/
--- quickstart/
+++ quickstart/
@@ -110,15 +110,23 @@
}
-def get_juju_ command( platform) : command( platform, ignore_ env_var= False):
+def get_juju_
"""Return the path to the Juju command on the given platform.
If the platform does not have a novel location, the default will be JUJU_CMD_ PATHS.get( JUJU_CMD_ PATHS[' default' ]) JUJU_CMD_ PATHS.get( JUJU_CMD_ PATHS[' default' ])
returned.
+
+ If the environment variable JUJU is set, then its value will be
+ returned.
"""
- return settings.
- platform,
- settings.
+ juju_command = os.getenv('JUJU', '').strip()
+ if juju_command is not None and not ignore_env_var:
+ print("Warning: a customized juju is being used.")
+ return juju_command
+ else:
+ return settings.
+ platform,
+ settings.
def get_juju_ installer( platform) :
Index: quickstart/ tests/test_ manage. py tests/test_ manage. py' tests/test_ manage. py 2014-06-13 15:19:46 +0000 tests/test_ manage. py 2014-08-21 15:20:55 +0000
mock_app. ensure_ dependencies. return_ value = version
'quickstart. manage. platform_ support. get_juju_ command' , [self.juju_ command] ): [self.juju_ command, self.juju_ command] ):
manage. run(options)
mock_app. bootstrap. assert_ called_ once_with(
options. env_name, self.juju_command, requires_sudo=True,
u'admin- secret not found in {}/environments /local. jenv ' yaml'.format( settings. JUJU_HOME) )
self. assertEqual( expected, context. exception. message) environ_ var_set( self, mock_app, mock_open): bootstrap. return_ value = (True, 'precise') check_environme nt.return_ value = ( juju-gui- 42', '0', None, None) options( env_type= 'aws') path/juju' 'os.environ' , {'JUJU': juju_command}): bootstrap. assert_ called_ once_with( sudo=False, debug) get_api_ url.assert_ called_ once_with(
=== modified file 'quickstart/
--- quickstart/
+++ quickstart/
@@ -898,7 +898,7 @@
with mock.patch(
- side_effect=
+ side_effect=
@@ -991,3 +991,17 @@
'or environments.
+
+ def test_juju_
+ mock_app.
+ mock_app.
+ 'cs:precise/
+ options = self.make_
+ juju_command = 'some/devel/
+ with mock.patch(
+ manage.run(options)
+ mock_app.
+ options.env_name, juju_command, requires_
+ debug=options.
+ mock_app.
+ options.env_name, juju_command)
Index: quickstart/ tests/test_ platform_ support. py tests/test_ platform_ support. py' tests/test_ platform_ support. py 2014-06-13 14:38:05 +0000 tests/test_ platform_ support. py 2014-08-21 15:20:55 +0000 apt_passes( self): support. validate_ platform( settings. LINUX_APT)
self. assertIsNone( result) and(unittest. TestCase) : succeeds( self): 'os.environ' , {'JUJU': expected}): support. get_juju_ command( None) ls(expected, actual) fails_when_ ignore_ env_var( self): 'os.environ' , {'JUJU': unexpected}): support. get_juju_ command( None, True) quals(unexpecte d, actual)
=== modified file 'quickstart/
--- quickstart/
+++ quickstart/
@@ -165,3 +165,18 @@
def test_linux_
result = platform_
+
+
+class TestGetJujuComm
+
+ def test_getenv_
+ expected = '/custom/juju'
+ with mock.patch(
+ actual = platform_
+ self.assertEqua
+
+ def test_getenv_
+ unexpected = '/custom/juju'
+ with mock.patch(
+ actual = platform_
+ self.assertNotE