~gandelman-a/charms/precise/keystone/utils_sync

« back to all changes in this revision

Viewing changes to hooks/lib/openstack_common.py

  • Committer: Adam Gandelman
  • Date: 2013-03-19 18:06:25 UTC
  • mfrom: (57.1.25 keystone)
  • Revision ID: adamg@canonical.com-20130319180625-ov50yaiiec32s15c
Big refactor and cleanup from James.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
    'oneiric': 'diablo',
14
14
    'precise': 'essex',
15
15
    'quantal': 'folsom',
16
 
    'raring' : 'grizzly',
 
16
    'raring': 'grizzly',
17
17
}
18
18
 
19
19
 
34
34
    '1.7.7': 'grizzly',
35
35
}
36
36
 
 
37
 
37
38
def juju_log(msg):
38
39
    subprocess.check_call(['juju-log', msg])
39
40
 
78
79
            if v in src:
79
80
                return v
80
81
 
 
82
 
81
83
def get_os_codename_version(vers):
82
84
    '''Determine OpenStack codename from version number.'''
83
85
    try:
136
138
    e = "Could not determine OpenStack version for package: %s" % pkg
137
139
    error_out(e)
138
140
 
 
141
 
139
142
def configure_installation_source(rel):
140
143
    '''Configure apt installation source.'''
141
144
 
154
157
        subprocess.check_call(["add-apt-repository", "-y", src])
155
158
    elif rel[:3] == "deb":
156
159
        l = len(rel.split('|'))
157
 
        if l ==  2:
 
160
        if l == 2:
158
161
            src, key = rel.split('|')
159
162
            juju_log("Importing PPA key from keyserver for %s" % src)
160
163
            _import_key(key)
211
214
HAPROXY_CONF = '/etc/haproxy/haproxy.cfg'
212
215
HAPROXY_DEFAULT = '/etc/default/haproxy'
213
216
 
 
217
 
214
218
def configure_haproxy(units, service_ports, template_dir=None):
215
219
    template_dir = template_dir or 'templates'
216
220
    import jinja2
229
233
    with open(HAPROXY_DEFAULT, 'w') as f:
230
234
        f.write('ENABLED=1')
231
235
 
 
236
 
232
237
def save_script_rc(script_path="scripts/scriptrc", **env_vars):
233
238
    """
234
239
    Write an rc file in the charm-delivered directory containing
238
243
    service changes.
239
244
    """
240
245
    unit_name = os.getenv('JUJU_UNIT_NAME').replace('/', '-')
241
 
    juju_rc_path="/var/lib/juju/units/%s/charm/%s" % (unit_name, script_path)
 
246
    juju_rc_path = "/var/lib/juju/units/%s/charm/%s" % (unit_name, script_path)
242
247
    with open(juju_rc_path, 'wb') as rc_script:
243
248
        rc_script.write(
244
249
            "#!/bin/bash\n")