~openstack-charmers-next/charms/xenial/cinder/trunk

« back to all changes in this revision

Viewing changes to hooks/charmhelpers/contrib/storage/linux/ceph.py

  • Committer: Corey Bryant
  • Date: 2016-05-27 13:31:07 UTC
  • mto: This revision was merged to the branch mainline in revision 171.
  • Revision ID: corey.bryant@canonical.com-20160527133107-69ewzxuewvpimzs1
Add defaults for openstack-origin-git config option

openstack-origin-git currently only supports YAML that specifies
the git repositories to deploy from.

This adds support for default openstack-origin-git values. The
default values supported are: icehouse, kilo, liberty, mitaka,
and master.  For example: openstack-origin-git=master.

Change-Id: Iacd1103095985307394e472411e314c337044f4d

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
    CalledProcessError,
41
41
)
42
42
from charmhelpers.core.hookenv import (
 
43
    config,
43
44
    local_unit,
44
45
    relation_get,
45
46
    relation_ids,
64
65
)
65
66
 
66
67
from charmhelpers.core.kernel import modprobe
 
68
from charmhelpers.contrib.openstack.utils import config_flags_parser
67
69
 
68
70
KEYRING = '/etc/ceph/ceph.client.{}.keyring'
69
71
KEYFILE = '/etc/ceph/ceph.client.{}.key'
1204
1206
        for rid in relation_ids(relation):
1205
1207
            log('Sending request {}'.format(request.request_id), level=DEBUG)
1206
1208
            relation_set(relation_id=rid, broker_req=request.request)
 
1209
 
 
1210
 
 
1211
class CephConfContext(object):
 
1212
    """Ceph config (ceph.conf) context.
 
1213
 
 
1214
    Supports user-provided Ceph configuration settings. Use can provide a
 
1215
    dictionary as the value for the config-flags charm option containing
 
1216
    Ceph configuration settings keyede by their section in ceph.conf.
 
1217
    """
 
1218
    def __init__(self, permitted_sections=None):
 
1219
        self.permitted_sections = permitted_sections or []
 
1220
 
 
1221
    def __call__(self):
 
1222
        conf = config('config-flags')
 
1223
        if not conf:
 
1224
            return {}
 
1225
 
 
1226
        conf = config_flags_parser(conf)
 
1227
        if type(conf) != dict:
 
1228
            log("Provided config-flags is not a dictionary - ignoring",
 
1229
                level=WARNING)
 
1230
            return {}
 
1231
 
 
1232
        permitted = self.permitted_sections
 
1233
        if permitted:
 
1234
            diff = set(conf.keys()).symmetric_difference(set(permitted))
 
1235
            if diff:
 
1236
                log("Config-flags contains invalid keys '%s' - they will be "
 
1237
                    "ignored" % (', '.join(diff)), level=WARNING)
 
1238
 
 
1239
        ceph_conf = {}
 
1240
        for key in conf:
 
1241
            if permitted and key not in permitted:
 
1242
                log("Ignoring key '%s'" % key, level=WARNING)
 
1243
                continue
 
1244
 
 
1245
            ceph_conf[key] = conf[key]
 
1246
 
 
1247
        return ceph_conf