Update charm-helpers config to point to upstream repo, re-sync helpers.
This commit is contained in:
		@@ -1,4 +1,4 @@
 | 
			
		||||
branch: lp:~openstack-charmers/charm-helpers/to_upstream
 | 
			
		||||
branch: lp:charm-helpers
 | 
			
		||||
destination: hooks/charmhelpers
 | 
			
		||||
include:
 | 
			
		||||
    - core
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
import json
 | 
			
		||||
import os
 | 
			
		||||
 | 
			
		||||
from base64 import b64decode
 | 
			
		||||
@@ -21,6 +22,7 @@ from charmhelpers.core.hookenv import (
 | 
			
		||||
    related_units,
 | 
			
		||||
    unit_get,
 | 
			
		||||
    unit_private_ip,
 | 
			
		||||
    ERROR,
 | 
			
		||||
    WARNING,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@@ -370,7 +372,7 @@ class NeutronContext(object):
 | 
			
		||||
        return None
 | 
			
		||||
 | 
			
		||||
    def _ensure_packages(self):
 | 
			
		||||
        ensure_packages(self.packages)
 | 
			
		||||
        [ensure_packages(pkgs) for pkgs in self.packages]
 | 
			
		||||
 | 
			
		||||
    def _save_flag_file(self):
 | 
			
		||||
        if self.network_manager == 'quantum':
 | 
			
		||||
@@ -431,3 +433,90 @@ class OSConfigFlagContext(OSContextGenerator):
 | 
			
		||||
                flags[k.strip()] = v
 | 
			
		||||
            ctxt = {'user_config_flags': flags}
 | 
			
		||||
            return ctxt
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class SubordinateConfigContext(OSContextGenerator):
 | 
			
		||||
    """
 | 
			
		||||
    Responsible for inspecting relations to subordinates that
 | 
			
		||||
    may be exporting required config via a json blob.
 | 
			
		||||
 | 
			
		||||
    The subordinate interface allows subordinates to export their
 | 
			
		||||
    configuration requirements to the principle for multiple config
 | 
			
		||||
    files and multiple serivces.  Ie, a subordinate that has interfaces
 | 
			
		||||
    to both glance and nova may export to following yaml blob as json:
 | 
			
		||||
 | 
			
		||||
        glance:
 | 
			
		||||
            /etc/glance/glance-api.conf:
 | 
			
		||||
                sections:
 | 
			
		||||
                    DEFAULT:
 | 
			
		||||
                        - [key1, value1]
 | 
			
		||||
            /etc/glance/glance-registry.conf:
 | 
			
		||||
                    MYSECTION:
 | 
			
		||||
                        - [key2, value2]
 | 
			
		||||
        nova:
 | 
			
		||||
            /etc/nova/nova.conf:
 | 
			
		||||
                sections:
 | 
			
		||||
                    DEFAULT:
 | 
			
		||||
                        - [key3, value3]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    It is then up to the principle charms to subscribe this context to
 | 
			
		||||
    the service+config file it is interestd in.  Configuration data will
 | 
			
		||||
    be available in the template context, in glance's case, as:
 | 
			
		||||
        ctxt = {
 | 
			
		||||
            ... other context ...
 | 
			
		||||
            'subordinate_config': {
 | 
			
		||||
                'DEFAULT': {
 | 
			
		||||
                    'key1': 'value1',
 | 
			
		||||
                },
 | 
			
		||||
                'MYSECTION': {
 | 
			
		||||
                    'key2': 'value2',
 | 
			
		||||
                },
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    """
 | 
			
		||||
    def __init__(self, service, config_file, interface):
 | 
			
		||||
        """
 | 
			
		||||
        :param service     : Service name key to query in any subordinate
 | 
			
		||||
                             data found
 | 
			
		||||
        :param config_file : Service's config file to query sections
 | 
			
		||||
        :param interface   : Subordinate interface to inspect
 | 
			
		||||
        """
 | 
			
		||||
        self.service = service
 | 
			
		||||
        self.config_file = config_file
 | 
			
		||||
        self.interface = interface
 | 
			
		||||
 | 
			
		||||
    def __call__(self):
 | 
			
		||||
        ctxt = {}
 | 
			
		||||
        for rid in relation_ids(self.interface):
 | 
			
		||||
            for unit in related_units(rid):
 | 
			
		||||
                sub_config = relation_get('subordinate_configuration',
 | 
			
		||||
                                          rid=rid, unit=unit)
 | 
			
		||||
                if sub_config and sub_config != '':
 | 
			
		||||
                    try:
 | 
			
		||||
                        sub_config = json.loads(sub_config)
 | 
			
		||||
                    except:
 | 
			
		||||
                        log('Could not parse JSON from subordinate_config '
 | 
			
		||||
                            'setting from %s' % rid, level=ERROR)
 | 
			
		||||
                        continue
 | 
			
		||||
 | 
			
		||||
                    if self.service not in sub_config:
 | 
			
		||||
                        log('Found subordinate_config on %s but it contained'
 | 
			
		||||
                            'nothing for %s service' % (rid, self.service))
 | 
			
		||||
                        continue
 | 
			
		||||
 | 
			
		||||
                    sub_config = sub_config[self.service]
 | 
			
		||||
                    if self.config_file not in sub_config:
 | 
			
		||||
                        log('Found subordinate_config on %s but it contained'
 | 
			
		||||
                            'nothing for %s' % (rid, self.config_file))
 | 
			
		||||
                        continue
 | 
			
		||||
 | 
			
		||||
                    sub_config = sub_config[self.config_file]
 | 
			
		||||
                    for k, v in sub_config.iteritems():
 | 
			
		||||
                        ctxt[k] = v
 | 
			
		||||
 | 
			
		||||
        if not ctxt:
 | 
			
		||||
            ctxt['sections'] = {}
 | 
			
		||||
 | 
			
		||||
        return ctxt
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,7 @@
 | 
			
		||||
# Various utilies for dealing with Neutron and the renaming from Quantum.
 | 
			
		||||
 | 
			
		||||
from subprocess import check_output
 | 
			
		||||
 | 
			
		||||
from charmhelpers.core.hookenv import (
 | 
			
		||||
    config,
 | 
			
		||||
    log,
 | 
			
		||||
@@ -9,6 +11,13 @@ from charmhelpers.core.hookenv import (
 | 
			
		||||
from charmhelpers.contrib.openstack.utils import os_release
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def headers_package():
 | 
			
		||||
    """Ensures correct linux-headers for running kernel are installed,
 | 
			
		||||
    for building DKMS package"""
 | 
			
		||||
    kver = check_output(['uname', '-r']).strip()
 | 
			
		||||
    return 'linux-headers-%s' % kver
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# legacy
 | 
			
		||||
def quantum_plugins():
 | 
			
		||||
    from charmhelpers.contrib.openstack import context
 | 
			
		||||
@@ -23,15 +32,15 @@ def quantum_plugins():
 | 
			
		||||
                                        database=config('neutron-database'),
 | 
			
		||||
                                        relation_prefix='neutron')],
 | 
			
		||||
            'services': ['quantum-plugin-openvswitch-agent'],
 | 
			
		||||
            'packages': ['quantum-plugin-openvswitch-agent',
 | 
			
		||||
                         'openvswitch-datapath-dkms'],
 | 
			
		||||
            'packages': [[headers_package(), 'openvswitch-datapath-dkms'],
 | 
			
		||||
                         ['quantum-plugin-openvswitch-agent']],
 | 
			
		||||
        },
 | 
			
		||||
        'nvp': {
 | 
			
		||||
            'config': '/etc/quantum/plugins/nicira/nvp.ini',
 | 
			
		||||
            'driver': 'quantum.plugins.nicira.nicira_nvp_plugin.'
 | 
			
		||||
                      'QuantumPlugin.NvpPluginV2',
 | 
			
		||||
            'services': [],
 | 
			
		||||
            'packages': ['quantum-plugin-nicira'],
 | 
			
		||||
            'packages': [],
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -49,15 +58,15 @@ def neutron_plugins():
 | 
			
		||||
                                        database=config('neutron-database'),
 | 
			
		||||
                                        relation_prefix='neutron')],
 | 
			
		||||
            'services': ['neutron-plugin-openvswitch-agent'],
 | 
			
		||||
            'packages': ['neutron-plugin-openvswitch-agent',
 | 
			
		||||
                         'openvswitch-datapath-dkms'],
 | 
			
		||||
            'packages': [[headers_package(), 'openvswitch-datapath-dkms'],
 | 
			
		||||
                         ['quantum-plugin-openvswitch-agent']],
 | 
			
		||||
        },
 | 
			
		||||
        'nvp': {
 | 
			
		||||
            'config': '/etc/neutron/plugins/nicira/nvp.ini',
 | 
			
		||||
            'driver': 'neutron.plugins.nicira.nicira_nvp_plugin.'
 | 
			
		||||
                      'NeutronPlugin.NvpPluginV2',
 | 
			
		||||
            'services': [],
 | 
			
		||||
            'packages': ['neutron-plugin-nicira'],
 | 
			
		||||
            'packages': [],
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -76,7 +85,7 @@ def neutron_plugin_attribute(plugin, attr, net_manager=None):
 | 
			
		||||
        _plugin = plugins[plugin]
 | 
			
		||||
    except KeyError:
 | 
			
		||||
        log('Unrecognised plugin for %s: %s' % (manager, plugin), level=ERROR)
 | 
			
		||||
        raise
 | 
			
		||||
        raise Exception
 | 
			
		||||
 | 
			
		||||
    try:
 | 
			
		||||
        return _plugin[attr]
 | 
			
		||||
@@ -99,7 +108,7 @@ def network_manager():
 | 
			
		||||
    if release in ['essex']:
 | 
			
		||||
        # E does not support neutron
 | 
			
		||||
        log('Neutron networking not supported in Essex.', level=ERROR)
 | 
			
		||||
        raise
 | 
			
		||||
        raise Exception
 | 
			
		||||
    elif release in ['folsom', 'grizzly']:
 | 
			
		||||
        # neutron is named quantum in F and G
 | 
			
		||||
        return 'quantum'
 | 
			
		||||
 
 | 
			
		||||
@@ -45,16 +45,17 @@ OPENSTACK_CODENAMES = OrderedDict([
 | 
			
		||||
])
 | 
			
		||||
 | 
			
		||||
# The ugly duckling
 | 
			
		||||
SWIFT_CODENAMES = {
 | 
			
		||||
    '1.4.3': 'diablo',
 | 
			
		||||
    '1.4.8': 'essex',
 | 
			
		||||
    '1.7.4': 'folsom',
 | 
			
		||||
    '1.7.6': 'grizzly',
 | 
			
		||||
    '1.7.7': 'grizzly',
 | 
			
		||||
    '1.8.0': 'grizzly',
 | 
			
		||||
    '1.9.0': 'havana',
 | 
			
		||||
    '1.9.1': 'havana',
 | 
			
		||||
}
 | 
			
		||||
SWIFT_CODENAMES = OrderedDict([
 | 
			
		||||
    ('1.4.3', 'diablo'),
 | 
			
		||||
    ('1.4.8', 'essex'),
 | 
			
		||||
    ('1.7.4', 'folsom'),
 | 
			
		||||
    ('1.8.0', 'grizzly'),
 | 
			
		||||
    ('1.7.7', 'grizzly'),
 | 
			
		||||
    ('1.7.6', 'grizzly'),
 | 
			
		||||
    ('1.10.0', 'havana'),
 | 
			
		||||
    ('1.9.1', 'havana'),
 | 
			
		||||
    ('1.9.0', 'havana'),
 | 
			
		||||
])
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def error_out(msg):
 | 
			
		||||
@@ -137,8 +138,11 @@ def get_os_codename_package(package, fatal=True):
 | 
			
		||||
 | 
			
		||||
    try:
 | 
			
		||||
        if 'swift' in pkg.name:
 | 
			
		||||
            vers = vers[:5]
 | 
			
		||||
            return SWIFT_CODENAMES[vers]
 | 
			
		||||
            swift_vers = vers[:5]
 | 
			
		||||
            if swift_vers not in SWIFT_CODENAMES:
 | 
			
		||||
                # Deal with 1.10.0 upward
 | 
			
		||||
                swift_vers = vers[:6]
 | 
			
		||||
            return SWIFT_CODENAMES[swift_vers]
 | 
			
		||||
        else:
 | 
			
		||||
            vers = vers[:6]
 | 
			
		||||
            return OPENSTACK_CODENAMES[vers]
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user