Merge lp:~frankban/juju-quickstart/new-juju-switch into lp:juju-quickstart
Proposed by
Francesco Banconi
Status: | Merged |
---|---|
Merged at revision: | 48 |
Proposed branch: | lp:~frankban/juju-quickstart/new-juju-switch |
Merge into: | lp:juju-quickstart |
Diff against target: |
81 lines (+23/-15) 2 files modified
quickstart/models/envs.py (+7/-4) quickstart/tests/models/test_envs.py (+16/-11) |
To merge this branch: | bzr merge lp:~frankban/juju-quickstart/new-juju-switch |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju GUI Hackers | Pending | ||
Review via email: mp+202299@code.launchpad.net |
Description of the change
Support the new juju switch behavior.
Quickstart is now able to retrieve the
default environment name in newer
versions of juju-core.
Tests: `make check`.
No QA required.
To post a comment you must log in.
Reviewers: mp+202299_ code.launchpad. net,
Message:
Please take a look.
Description:
Support the new juju switch behavior.
Quickstart is now able to retrieve the
default environment name in newer
versions of juju-core.
Tests: `make check`.
No QA required.
https:/ /code.launchpad .net/~frankban/ juju-quickstart /new-juju- switch/ +merge/ 202299
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/54560043/
Affected files (+25, -15 lines): models/ envs.py tests/models/ test_envs. py
A [revision details]
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/ models/ envs.py models/ envs.py' models/ envs.py 2014-01-16 12:41:47 +0000 models/ envs.py 2014-01-20 12:02:10 +0000 'JUJU_ENV' , '').strip() current- environment file. environments. yaml file. expression. match(output)
=== modified file 'quickstart/
--- quickstart/
+++ quickstart/
@@ -111,19 +111,22 @@
env_name = os.getenv(
if env_name:
return env_name
- # XXX 2013-10-16 frankban bug=1193244:
- # Support the new behavior of juju-switch, currently under
development:
- # the command will just output the environment name, or exit with
an
- # error if no default environment is configured.
# The "juju switch" command parses ~/.juju/
If the
# environment name is not found there, then it tries to retrieve the
name
# from the "default" section of the ~/.juju/
retcode, output, _ = utils.call('juju', 'switch')
+ # Before juju-core 1.17, the "juju switch" command returns a human
readable
+ # output. Newer releases just output the environment name, or exit
with an
+ # error if no default environment is configured.
if retcode:
return None
+ # Use a regular expression to check if "juju switch" returned a human
+ # readable output.
match = _juju_switch_
if match is not None:
return match.groups()[0]
+ # At this point we can safely assume we are using the newer "juju
switch".
+ return output.strip()
def create_ empty_env_ db():
Index: quickstart/ tests/models/ test_envs. py tests/models/ test_envs. py' tests/models/ test_envs. py 2014-01-16 12:41:47 +0000 tests/models/ test_envs. py 2014-01-20 12:02:10 +0000
env_ name = envs.get_ default_ env_name( )
self. assertIsNone( env_name)
=== modified file 'quickstart/
--- quickstart/
+++ quickstart/
@@ -58,9 +58,10 @@
- def test_juju_ switch( self): switch_ old_behavior( self):
- # The environment name is successfully returned if previously set
using
- # the "juju switch" command.
+ def test_juju_
+ # The environment name is successfully returned if retrievable
using
+ # the "juju switch" command. This test exercises the old "juju
switch"
+ # returning a human readable output.
output = 'Current e...