Merge lp:~makyo/juju-quickstart/ssh-1-check-keys into lp:juju-quickstart
Proposed by
Madison Scott-Clary
Status: | Merged |
---|---|
Merged at revision: | 29 |
Proposed branch: | lp:~makyo/juju-quickstart/ssh-1-check-keys |
Merge into: | lp:juju-quickstart |
Diff against target: |
77 lines (+34/-0) 4 files modified
quickstart/app.py (+8/-0) quickstart/manage.py (+2/-0) quickstart/tests/test_app.py (+22/-0) quickstart/tests/test_manage.py (+2/-0) |
To merge this branch: | bzr merge lp:~makyo/juju-quickstart/ssh-1-check-keys |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju GUI Hackers | Pending | ||
Review via email:
|
Description of the change
SSH keys 1: abort if no keys
Juju needs ssh keys available to run. This ensures via ssh-add that there are keys available to the agent; if not, it exits with instructions on how to generate a key.
To test: make check
To QA:
1. mv ~/.ssh ~/.ssh.old
2. .venv/bin/python juju-quickstart # should produce error
3. mv ~/.ssh.old ~/.ssh
4. ssh-agent
5. ssh-add
6. .venv/bin/python juju-quickstart # should bootstrap
To post a comment you must log in.
Reviewers: mp+197959_ code.launchpad. net,
Message:
Please take a look.
Description:
SSH keys 1: abort if no keys
Juju needs ssh keys available to run. This ensures via ssh-add that
there are keys available to the agent; if not, it exits with
instructions on how to generate a key.
To test: make check
To QA:
1. mv ~/.ssh ~/.ssh.old
2. .venv/bin/python juju-quickstart # should produce error
3. mv ~/.ssh.old ~/.ssh
4. ssh-agent
5. ssh-add
6. .venv/bin/python juju-quickstart # should bootstrap
https:/ /code.launchpad .net/~makyo/ juju-quickstart /ssh-1- check-keys/ +merge/ 197959
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/37930043/
Affected files (+36, -0 lines): manage. py tests/test_ app.py tests/test_ manage. py
A [revision details]
M quickstart/app.py
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/app.py
=== modified file 'quickstart/app.py'
--- quickstart/app.py 2013-12-04 22:16:45 +0000
+++ quickstart/app.py 2013-12-05 19:54:20 +0000
@@ -79,6 +79,14 @@
raise ProgramExit(error)
+def ensure_ssh_keys(): '/usr/bin/ ssh-add' , '-l')[0] environments( ):
+ retcode = utils.call(
+ if retcode > 0:
+ raise ProgramExit('no ssh keys were found. Please run the
following: '
+ '`ssh-keygen -t rsa` and follow the
instructions '
+ 'before running quickstart again.')
+
+
def ensure_
"""Ensure that the environments file exists.
Index: quickstart/ manage. py manage. py' manage. py 2013-12-04 22:16:45 +0000 manage. py 2013-12-05 19:54:20 +0000 version) ) debug(' ensuring juju and lxc are installed') ensure_ dependencies( ) debug(' ensuring SSH keys are available') ssh_keys( ) 'bootstrapping the {} environment (type: {})'.format(
options. env_name, options.env_type))
=== modified file 'quickstart/
--- quickstart/
+++ quickstart/
@@ -269,6 +269,8 @@
print('juju quickstart v{}'.format(
logging.
app.
+ logging.
+ app.ensure_
print(
is_local = options.env_type == 'local'
Index: quickstart/ tests/test_ app.py tests/test_ app.py' tests/test_ app.py 2013-12-04 22:16:45 +0000 tests/test_ app.py 2013-12-05 19:54:20 +0000
self.assertEqua l(3, mock_call. call_count)
=== modified file 'quickstart/
--- quickstart/
+++ quickstart/
@@ -174,6 +174,28 @@
+class TestEnsureSSHKeys( CallTestsMixin, ProgramExitTest sMixin, unittest.TestCase): ssh_keys( ) assert_ has_calls( [ '/usr/bin/ ssh-add' , '-l')
+ helpers.
+
+ def test_success(self):
+ with self.patch_call(0) as mock_call:
+ app.ensure_
+ mock_call.
+ mock.call(
+ ])
+
+ def test_failure(self):
+ msg = 'no ssh keys were found. Please run the following: ' \
+ '`ssh-keygen -t rsa` and follow the instructions ' \
+ 'before ...