Merge lp:~abentley/charms/precise/juju-reports/no-lp-key into lp:~juju-qa/charms/precise/juju-reports/trunk

Proposed by Aaron Bentley
Status: Merged
Merged at revision: 27
Proposed branch: lp:~abentley/charms/precise/juju-reports/no-lp-key
Merge into: lp:~juju-qa/charms/precise/juju-reports/trunk
Diff against target: 51 lines (+15/-12)
1 file modified
hooks/common.py (+15/-12)
To merge this branch: bzr merge lp:~abentley/charms/precise/juju-reports/no-lp-key
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+219020@code.launchpad.net

Commit message

Don't require key for local deploys, don't set lp-login if no key.

Description of the change

This branch changes lp key handling so that an LP private key is not required if source is not an lp branch. If no private key is supplied, we do not set a launchpad user-id, and fall back to anonymous http usage.

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/common.py'
2--- hooks/common.py 2014-05-08 20:51:08 +0000
3+++ hooks/common.py 2014-05-09 16:26:42 +0000
4@@ -3,6 +3,7 @@
5 NoSectionError)
6 import errno
7 import os
8+import re
9 from StringIO import StringIO
10 import subprocess
11 import sys
12@@ -74,9 +75,11 @@
13
14 def get_config():
15 config = yaml.safe_load(StringIO(subprocess.check_output('config-get')))
16- for key in ['lp-key', 'source']:
17- if config[key] == '':
18- raise IncompleteConfig('%s not specified.' % key)
19+ if config['source'] == '':
20+ raise IncompleteConfig('source not specified.')
21+ if re.match('(lp:|.*://bazaar.launchpad.net/)', config['source']):
22+ if config['lp-key'] == '':
23+ raise IncompleteConfig('lp-key not specified.')
24 return config
25
26
27@@ -86,15 +89,15 @@
28
29 @in_juju_reports
30 def update_source(source_url, revno, ssh_key):
31- fd = os.open('/root/.ssh/lp_rsa', os.O_WRONLY | os.O_TRUNC | os.O_CREAT,
32- 0600)
33- try:
34- os.write(fd, ssh_key)
35- finally:
36- os.close(fd)
37- # Login to LP
38- bzr_cmd = ['bzr', 'lp-login', 'juju-qa-bot']
39- subprocess.check_call(bzr_cmd)
40+ if ssh_key != '':
41+ fd = os.open('/root/.ssh/lp_rsa', os.O_WRONLY | os.O_TRUNC |
42+ os.O_CREAT, 0600)
43+ try:
44+ os.write(fd, ssh_key)
45+ finally:
46+ os.close(fd)
47+ # Login to LP
48+ subprocess.check_call(['bzr', 'lp-login', 'juju-qa-bot'])
49
50 # Grab the code
51 revno = 'revno:%s' % revno

Subscribers

People subscribed via source and target branches

to all changes: