Search in sources :

Example 1 with ModuleConfig

use of org.opendaylight.controller.config.facade.xml.mapping.config.ModuleConfig in project controller by opendaylight.

the class ConfigSubsystemFacade method getConfigMapping.

public Config getConfigMapping() {
    final YangStoreContext snapshot = yangStoreService.getCurrentSnapshot();
    Map<String, Map<String, ModuleConfig>> factories = transformMbeToModuleConfigs(snapshot.getModuleMXBeanEntryMap());
    Map<String, Map<Optional<Revision>, IdentityMapping>> identitiesMap = transformIdentities(snapshot.getModules());
    return new Config(factories, identitiesMap, snapshot.getEnumResolver());
}
Also used : YangStoreContext(org.opendaylight.controller.config.facade.xml.osgi.YangStoreContext) Revision(org.opendaylight.yangtools.yang.common.Revision) ModuleConfig(org.opendaylight.controller.config.facade.xml.mapping.config.ModuleConfig) Config(org.opendaylight.controller.config.facade.xml.mapping.config.Config) InstanceConfig(org.opendaylight.controller.config.facade.xml.mapping.config.InstanceConfig) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with ModuleConfig

use of org.opendaylight.controller.config.facade.xml.mapping.config.ModuleConfig in project controller by opendaylight.

the class ConfigSubsystemFacade method transformMbeToModuleConfigs.

public Map<String, /* Namespace from yang file */
Map<String, /* Name of module entry from yang file */
ModuleConfig>> transformMbeToModuleConfigs(final BeanReader reader, final Map<String, /* Namespace from yang file */
Map<String, /* Name of module entry from yang file */
ModuleMXBeanEntry>> mbeanentries) {
    Map<String, Map<String, ModuleConfig>> namespaceToModuleNameToModuleConfig = new HashMap<>();
    for (Map.Entry<String, Map<String, ModuleMXBeanEntry>> namespaceToModuleToMbe : mbeanentries.entrySet()) {
        for (Map.Entry<String, ModuleMXBeanEntry> moduleNameToMbe : namespaceToModuleToMbe.getValue().entrySet()) {
            String moduleName = moduleNameToMbe.getKey();
            ModuleMXBeanEntry moduleMXBeanEntry = moduleNameToMbe.getValue();
            ModuleConfig moduleConfig = new ModuleConfig(moduleName, new InstanceConfig(reader, moduleMXBeanEntry.getAttributes(), moduleMXBeanEntry.getNullableDummyContainerName()));
            Map<String, ModuleConfig> moduleNameToModuleConfig = namespaceToModuleNameToModuleConfig.computeIfAbsent(namespaceToModuleToMbe.getKey(), k -> new HashMap<>());
            moduleNameToModuleConfig.put(moduleName, moduleConfig);
        }
    }
    return namespaceToModuleNameToModuleConfig;
}
Also used : InstanceConfig(org.opendaylight.controller.config.facade.xml.mapping.config.InstanceConfig) HashMap(java.util.HashMap) ModuleMXBeanEntry(org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry) ModuleConfig(org.opendaylight.controller.config.facade.xml.mapping.config.ModuleConfig) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with ModuleConfig

use of org.opendaylight.controller.config.facade.xml.mapping.config.ModuleConfig in project controller by opendaylight.

the class Runtime method toXml.

public Element toXml(Set<ObjectName> instancesToMap, Set<ObjectName> configBeans, Document document, final EnumResolver enumResolver) {
    Element root = XmlUtil.createElement(document, XmlMappingConstants.DATA_KEY, Optional.<String>absent());
    Element modulesElement = XmlUtil.createElement(document, XmlMappingConstants.MODULES_KEY, Optional.of(XmlMappingConstants.URN_OPENDAYLIGHT_PARAMS_XML_NS_YANG_CONTROLLER_CONFIG));
    root.appendChild(modulesElement);
    Map<String, Multimap<String, ObjectName>> moduleToRuntimeInstance = mapInstancesToModules(instancesToMap);
    Map<String, Map<String, Collection<ObjectName>>> moduleToConfigInstance = Config.getMappedInstances(configBeans, moduleConfigs);
    for (String localNamespace : moduleConfigs.keySet()) {
        Map<String, Collection<ObjectName>> instanceToMbe = moduleToConfigInstance.get(localNamespace);
        for (String moduleName : moduleConfigs.get(localNamespace).keySet()) {
            Multimap<String, ObjectName> instanceToRbe = moduleToRuntimeInstance.get(moduleName);
            for (ObjectName instanceON : instanceToMbe.get(moduleName)) {
                String instanceName = ObjectNameUtil.getInstanceName(instanceON);
                Element runtimeXml;
                ModuleConfig moduleConfig = moduleConfigs.get(localNamespace).get(moduleName);
                if (instanceToRbe == null || !instanceToRbe.containsKey(instanceName)) {
                    runtimeXml = moduleConfig.toXml(instanceON, document, localNamespace, enumResolver);
                } else {
                    ModuleRuntime moduleRuntime = moduleRuntimes.get(localNamespace).get(moduleName);
                    runtimeXml = moduleRuntime.toXml(localNamespace, instanceToRbe.get(instanceName), document, moduleConfig, instanceON, enumResolver);
                }
                modulesElement.appendChild(runtimeXml);
            }
        }
    }
    return root;
}
Also used : Multimap(com.google.common.collect.Multimap) HashMultimap(com.google.common.collect.HashMultimap) Element(org.w3c.dom.Element) Collection(java.util.Collection) ModuleConfig(org.opendaylight.controller.config.facade.xml.mapping.config.ModuleConfig) Map(java.util.Map) ObjectName(javax.management.ObjectName)

Aggregations

Map (java.util.Map)3 ModuleConfig (org.opendaylight.controller.config.facade.xml.mapping.config.ModuleConfig)3 HashMap (java.util.HashMap)2 InstanceConfig (org.opendaylight.controller.config.facade.xml.mapping.config.InstanceConfig)2 HashMultimap (com.google.common.collect.HashMultimap)1 Multimap (com.google.common.collect.Multimap)1 Collection (java.util.Collection)1 ObjectName (javax.management.ObjectName)1 Config (org.opendaylight.controller.config.facade.xml.mapping.config.Config)1 YangStoreContext (org.opendaylight.controller.config.facade.xml.osgi.YangStoreContext)1 ModuleMXBeanEntry (org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry)1 Revision (org.opendaylight.yangtools.yang.common.Revision)1 Element (org.w3c.dom.Element)1