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
=== modified file 'hooks/common.py'
--- hooks/common.py 2014-05-08 20:51:08 +0000
+++ hooks/common.py 2014-05-09 16:26:42 +0000
@@ -3,6 +3,7 @@
3 NoSectionError)3 NoSectionError)
4import errno4import errno
5import os5import os
6import re
6from StringIO import StringIO7from StringIO import StringIO
7import subprocess8import subprocess
8import sys9import sys
@@ -74,9 +75,11 @@
7475
75def get_config():76def get_config():
76 config = yaml.safe_load(StringIO(subprocess.check_output('config-get')))77 config = yaml.safe_load(StringIO(subprocess.check_output('config-get')))
77 for key in ['lp-key', 'source']:78 if config['source'] == '':
78 if config[key] == '':79 raise IncompleteConfig('source not specified.')
79 raise IncompleteConfig('%s not specified.' % key)80 if re.match('(lp:|.*://bazaar.launchpad.net/)', config['source']):
81 if config['lp-key'] == '':
82 raise IncompleteConfig('lp-key not specified.')
80 return config83 return config
8184
8285
@@ -86,15 +89,15 @@
8689
87@in_juju_reports90@in_juju_reports
88def update_source(source_url, revno, ssh_key):91def update_source(source_url, revno, ssh_key):
89 fd = os.open('/root/.ssh/lp_rsa', os.O_WRONLY | os.O_TRUNC | os.O_CREAT,92 if ssh_key != '':
90 0600)93 fd = os.open('/root/.ssh/lp_rsa', os.O_WRONLY | os.O_TRUNC |
91 try:94 os.O_CREAT, 0600)
92 os.write(fd, ssh_key)95 try:
93 finally:96 os.write(fd, ssh_key)
94 os.close(fd)97 finally:
95 # Login to LP98 os.close(fd)
96 bzr_cmd = ['bzr', 'lp-login', 'juju-qa-bot']99 # Login to LP
97 subprocess.check_call(bzr_cmd)100 subprocess.check_call(['bzr', 'lp-login', 'juju-qa-bot'])
98101
99 # Grab the code102 # Grab the code
100 revno = 'revno:%s' % revno103 revno = 'revno:%s' % revno

Subscribers

People subscribed via source and target branches

to all changes: