~hopem/charms/precise/ceph-radosgw/lp1273067

« back to all changes in this revision

Viewing changes to hooks/utils.py

  • Committer: Juan L. Negron
  • Date: 2012-11-22 01:09:01 UTC
  • mfrom: (6.1.1 ceph-radosgw)
  • Revision ID: juan.negron@canonical.com-20121122010901-96sn7dmdg63mu4j3
Support use of cloud: prefix to pull ceph from the Ubuntu cloud archive.  MP:133888

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
    return template.render(context)
52
52
 
53
53
 
 
54
CLOUD_ARCHIVE = \
 
55
""" # Ubuntu Cloud Archive
 
56
deb http://ubuntu-cloud.archive.canonical.com/ubuntu {} main
 
57
"""
 
58
 
 
59
 
54
60
def configure_source():
55
 
    source = config_get('source')
56
 
    if (source.startswith('ppa:') or
57
 
        source.startswith('cloud:') or
58
 
        source.startswith('http:')):
 
61
    source = str(config_get('source'))
 
62
    if not source:
 
63
        return
 
64
    if source.startswith('ppa:'):
59
65
        cmd = [
60
66
            'add-apt-repository',
61
67
            source
62
68
            ]
63
69
        subprocess.check_call(cmd)
 
70
    if source.startswith('cloud:'):
 
71
        install('ubuntu-cloud-keyring')
 
72
        pocket = source.split(':')[1]
 
73
        with open('/etc/apt/sources.list.d/cloud-archive.list', 'w') as apt:
 
74
            apt.write(CLOUD_ARCHIVE.format(pocket))
64
75
    if source.startswith('http:'):
 
76
        with open('/etc/apt/sources.list.d/quantum.list', 'w') as apt:
 
77
            apt.write("deb " + source + "\n")
65
78
        key = config_get('key')
66
 
        cmd = [
67
 
            'apt-key',
68
 
            'import',
69
 
            key
70
 
            ]
71
 
        subprocess.check_call(cmd)
 
79
        if key:
 
80
            cmd = [
 
81
                'apt-key',
 
82
                'adv', '--keyserver keyserver.ubuntu.com',
 
83
                '--recv-keys', key
 
84
                ]
 
85
            subprocess.check_call(cmd)
72
86
    cmd = [
73
87
        'apt-get',
74
88
        'update'