~gandelman-a/charms/precise/ceph/avoid_recreate_existing_dirs

« back to all changes in this revision

Viewing changes to hooks/utils.py

  • Committer: Juan L. Negron
  • Date: 2012-11-22 01:16:39 UTC
  • mfrom: (50.1.3 ceph)
  • Revision ID: juan.negron@canonical.com-20121122011639-le3enuq015s0da33
1) Support use of cloud: prefix to pull ceph from the Ubuntu cloud archive.

2) Better filesystem handling both of OSD devices and stealing the ephemeral mount in cloud instances

3) 'force' option to make the charm reformat devices which are not in use which might already be OSD devices.

Show diffs side-by-side

added added

removed removed

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