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());
}
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;
}
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;
}
Aggregations