~gnuoy/charms/trusty/neutron-openvswitch/workloadstatus

« back to all changes in this revision

Viewing changes to hooks/charmhelpers/contrib/openstack/context.py

  • Committer: Liam Young
  • Date: 2015-07-31 13:11:50 UTC
  • Revision ID: liam.young@canonical.com-20150731131150-yn26ia5o8jff118v
[gnuoy,trivial] Pre-release charmhelper sync to pickup cli module

Show diffs side-by-side

added added

removed removed

Lines of Context:
1051
1051
        :param config_file : Service's config file to query sections
1052
1052
        :param interface   : Subordinate interface to inspect
1053
1053
        """
1054
 
        self.service = service
1055
1054
        self.config_file = config_file
 
1055
        if isinstance(service, list):
 
1056
            self.services = service
 
1057
        else:
 
1058
            self.services = [service]
1056
1059
        if isinstance(interface, list):
1057
1060
            self.interfaces = interface
1058
1061
        else:
1075
1078
                            'setting from %s' % rid, level=ERROR)
1076
1079
                        continue
1077
1080
 
1078
 
                    if self.service not in sub_config:
1079
 
                        log('Found subordinate_config on %s but it contained'
1080
 
                            'nothing for %s service' % (rid, self.service),
1081
 
                            level=INFO)
1082
 
                        continue
1083
 
 
1084
 
                    sub_config = sub_config[self.service]
1085
 
                    if self.config_file not in sub_config:
1086
 
                        log('Found subordinate_config on %s but it contained'
1087
 
                            'nothing for %s' % (rid, self.config_file),
1088
 
                            level=INFO)
1089
 
                        continue
1090
 
 
1091
 
                    sub_config = sub_config[self.config_file]
1092
 
                    for k, v in six.iteritems(sub_config):
1093
 
                        if k == 'sections':
1094
 
                            for section, config_list in six.iteritems(v):
1095
 
                                log("adding section '%s'" % (section),
1096
 
                                    level=DEBUG)
1097
 
                                if ctxt[k].get(section):
1098
 
                                    ctxt[k][section].extend(config_list)
1099
 
                                else:
1100
 
                                    ctxt[k][section] = config_list
1101
 
                        else:
1102
 
                            ctxt[k] = v
 
1081
                    for service in self.services:
 
1082
                        if service not in sub_config:
 
1083
                            log('Found subordinate_config on %s but it contained'
 
1084
                                'nothing for %s service' % (rid, service),
 
1085
                                level=INFO)
 
1086
                            continue
 
1087
 
 
1088
                        sub_config = sub_config[service]
 
1089
                        if self.config_file not in sub_config:
 
1090
                            log('Found subordinate_config on %s but it contained'
 
1091
                                'nothing for %s' % (rid, self.config_file),
 
1092
                                level=INFO)
 
1093
                            continue
 
1094
 
 
1095
                        sub_config = sub_config[self.config_file]
 
1096
                        for k, v in six.iteritems(sub_config):
 
1097
                            if k == 'sections':
 
1098
                                for section, config_list in six.iteritems(v):
 
1099
                                    log("adding section '%s'" % (section),
 
1100
                                        level=DEBUG)
 
1101
                                    if ctxt[k].get(section):
 
1102
                                        ctxt[k][section].extend(config_list)
 
1103
                                    else:
 
1104
                                        ctxt[k][section] = config_list
 
1105
                            else:
 
1106
                                ctxt[k] = v
1103
1107
        log("%d section(s) found" % (len(ctxt['sections'])), level=DEBUG)
1104
1108
        return ctxt
1105
1109