~openstack-charmers/charms/precise/keystone/ha-support

« back to all changes in this revision

Viewing changes to hooks/lib/openstack_common.py

  • Committer: James Page
  • Date: 2013-01-18 09:53:13 UTC
  • mfrom: (45.1.1 keystone)
  • Revision ID: james.page@canonical.com-20130118095313-zz73a4nygvwuroze
Updated default ha port to avoid conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
    '2013.1': 'grizzly'
24
24
}
25
25
 
 
26
# The ugly duckling
 
27
swift_codenames = {
 
28
    '1.4.3': 'diablo',
 
29
    '1.4.8': 'essex',
 
30
    '1.7.4': 'folsom'
 
31
}
26
32
 
27
33
def juju_log(msg):
28
34
    subprocess.check_call(['juju-log', msg])
119
125
 
120
126
    vers = vers[:6]
121
127
    try:
122
 
        return openstack_codenames[vers]
 
128
        if 'swift' in pkg:
 
129
            vers = vers[:5]
 
130
            return swift_codenames[vers]
 
131
        else:
 
132
            vers = vers[:6]
 
133
            return openstack_codenames[vers]
123
134
    except KeyError:
124
135
        e = 'Could not determine OpenStack codename for version %s' % vers
125
136
        error_out(e)
126
137
 
127
138
 
 
139
def get_os_version_package(pkg):
 
140
    '''Derive OpenStack version number from an installed package.'''
 
141
    codename = get_os_codename_package(pkg)
 
142
 
 
143
    if 'swift' in pkg:
 
144
        vers_map = swift_codenames
 
145
    else:
 
146
        vers_map = openstack_codenames
 
147
 
 
148
    for version, cname in vers_map.iteritems():
 
149
        if cname == codename:
 
150
            return version
 
151
    e = "Could not determine OpenStack version for package: %s" % pkg
 
152
    error_out(e)
 
153
 
128
154
def configure_installation_source(rel):
129
155
    '''Configure apt installation source.'''
130
156
 
165
191
                'version (%s)' % (ca_rel, ubuntu_rel)
166
192
            error_out(e)
167
193
 
168
 
        if ca_rel == 'folsom/staging':
 
194
        if 'staging' in ca_rel:
169
195
            # staging is just a regular PPA.
170
 
            cmd = 'add-apt-repository -y ppa:ubuntu-cloud-archive/folsom-staging'
 
196
            os_rel = ca_rel.split('/')[0]
 
197
            ppa = 'ppa:ubuntu-cloud-archive/%s-staging' % os_rel
 
198
            cmd = 'add-apt-repository -y %s' % ppa
171
199
            subprocess.check_call(cmd.split(' '))
172
200
            return
173
201
 
175
203
        pockets = {
176
204
            'folsom': 'precise-updates/folsom',
177
205
            'folsom/updates': 'precise-updates/folsom',
178
 
            'folsom/proposed': 'precise-proposed/folsom'
 
206
            'folsom/proposed': 'precise-proposed/folsom',
 
207
            'grizzly': 'precise-updates/grizzly',
 
208
            'grizzly/updates': 'precise-updates/grizzly',
 
209
            'grizzly/proposed': 'precise-proposed/grizzly'
179
210
        }
180
211
 
181
212
        try:
192
223
    else:
193
224
        error_out("Invalid openstack-release specified: %s" % rel)
194
225
 
195
 
 
196
226
HAPROXY_CONF = '/etc/haproxy/haproxy.cfg'
197
227
HAPROXY_DEFAULT = '/etc/default/haproxy'
198
228
 
199
 
 
200
229
def configure_haproxy(units, service_ports, template_dir=None):
201
230
    template_dir = template_dir or 'templates'
202
231
    import jinja2