Merge lp:~ivoks/charm-helpers/multiple-origins-2 into lp:charm-helpers

Proposed by Ante Karamatić
Status: Work in progress
Proposed branch: lp:~ivoks/charm-helpers/multiple-origins-2
Merge into: lp:charm-helpers
Diff against target: 64 lines (+23/-6)
1 file modified
charmhelpers/contrib/openstack/utils.py (+23/-6)
To merge this branch: bzr merge lp:~ivoks/charm-helpers/multiple-origins-2
Reviewer Review Type Date Requested Status
James Page Needs Information
Review via email: mp+198612@code.launchpad.net

This proposal supersedes a proposal from 2013-12-11.

Description of the change

Allow adding multiple sources to an instance. By accepting this change, openstack-origin stays untouched, but new config option can be used in a charm, that would utilize new functionality in configure_installation_source(). Something like:

quantum-gateway:
 openstack-origin: 'cloud:precise-havana/updates'
 added-sources: 'ppa:ivoks/cool-neutron-ppa, ppa:joe/cool-openvswitch-ppa'

To post a comment you must log in.
Revision history for this message
Ante Karamatić (ivoks) wrote : Posted in a previous version of this proposal

Maybe a better approach would be to add additional 'additional-origins' or something, cause openstack-origin is used to guess the version of OpenStack that's being installed. That info is later on used to figure out stuff like Neutron or Quantum.

Revision history for this message
James Page (james-page) wrote :

OK _ so how about we add 'source:' to the charms like alot of other ones do and then just use the standard fetch helper to handle that parameter which already deals with having multiple sources to add?

        source:
          - "ppa:foo"
          - "http://example.com/repo precise main"
        keys:
          - null
          - "a1b2c3d4"

see charmhelpers/fetch/__init__.py (configure_sources)

review: Needs Information

Unmerged revisions

108. By Ante Karamatić

Allow adding additional archives to the instance

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/contrib/openstack/utils.py'
2--- charmhelpers/contrib/openstack/utils.py 2013-12-04 13:25:24 +0000
3+++ charmhelpers/contrib/openstack/utils.py 2013-12-11 16:53:32 +0000
4@@ -209,15 +209,19 @@
5 except subprocess.CalledProcessError:
6 error_out("Error importing repo key %s" % keyid)
7
8-
9-def configure_installation_source(rel):
10- '''Configure apt installation source.'''
11+def write_sources_file(rel, owerwrite=True):
12+ '''Write actuall sources file(s)'''
13+ if owerwrite == True:
14+ mode = 'w'
15+ else:
16+ mode = 'a'
17 if rel == 'distro':
18 return
19 elif rel == 'distro-proposed':
20 ubuntu_rel = lsb_release()['DISTRIB_CODENAME']
21- with open('/etc/apt/sources.list.d/juju_deb.list', 'w') as f:
22+ with open('/etc/apt/sources.list.d/juju_deb.list', mode) as f:
23 f.write(DISTRO_PROPOSED % ubuntu_rel)
24+ f.write('\n')
25 elif rel[:4] == "ppa:":
26 src = rel
27 subprocess.check_call(["add-apt-repository", "-y", src])
28@@ -229,8 +233,9 @@
29 import_key(key)
30 elif l == 1:
31 src = rel
32- with open('/etc/apt/sources.list.d/juju_deb.list', 'w') as f:
33+ with open('/etc/apt/sources.list.d/juju_deb.list', mode) as f:
34 f.write(src)
35+ f.write('\n')
36 elif rel[:6] == 'cloud:':
37 ubuntu_rel = lsb_release()['DISTRIB_CODENAME']
38 rel = rel.split(':')[1]
39@@ -275,12 +280,24 @@
40 src = "deb %s %s main" % (CLOUD_ARCHIVE_URL, pocket)
41 apt_install('ubuntu-cloud-keyring', fatal=True)
42
43- with open('/etc/apt/sources.list.d/cloud-archive.list', 'w') as f:
44+ with open('/etc/apt/sources.list.d/cloud-archive.list', mode) as f:
45 f.write(src)
46+ f.write('\n')
47 else:
48 error_out("Invalid openstack-release specified: %s" % rel)
49
50
51+def configure_installation_source(rel, added=None):
52+ '''Configure apt installation source.'''
53+ if rel:
54+ write_sources_file(rel)
55+ if added:
56+ sources = added.split(",")
57+ sources = [s.strip() for s in sources]
58+ for s in sources:
59+ write_sources_file(s, False)
60+
61+
62 def save_script_rc(script_path="scripts/scriptrc", **env_vars):
63 """
64 Write an rc file in the charm-delivered directory containing

Subscribers

People subscribed via source and target branches