use of org.opendaylight.controller.config.facade.xml.mapping.config.Config in project controller by opendaylight.
the class ConfigPusherImplTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
doReturn("content").when(yangStoreService).getModuleSource(any(SourceIdentifier.class));
doReturn("mocked snapshot").when(mockedConfigSnapshot).toString();
doReturn("<mocked-snapshot/>").when(mockedConfigSnapshot).getConfigSnapshot();
doReturn(Collections.<Module>emptySet()).when(yangStoreService).getModules();
final Config mock = mock(Config.class);
doReturn("mocked config").when(mock).toString();
doReturn(facade).when(facadeFactory).createFacade(anyString());
doReturn(Sets.newHashSet()).when(facadeFactory).getCurrentCapabilities();
doReturn(mock).when(facade).getConfigMapping();
doNothing().when(mBeanServer).addNotificationListener(any(ObjectName.class), any(NotificationListener.class), any(NotificationFilter.class), anyObject());
}
use of org.opendaylight.controller.config.facade.xml.mapping.config.Config in project controller by opendaylight.
the class BlueprintContainerRestartServiceImpl method restartConfigModules.
private void restartConfigModules(final List<Entry<String, ModuleIdentifier>> configModules, final ConfigSubsystemFacade configFacade) throws ParserConfigurationException, DocumentedException, ValidationException, ConflictingVersionException {
Document document = XmlUtil.newDocument();
Element dataElement = 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));
dataElement.appendChild(modulesElement);
Config configMapping = configFacade.getConfigMapping();
ConfigRegistry configRegistryClient = new ConfigRegistryJMXClient(ManagementFactory.getPlatformMBeanServer());
for (Entry<String, ModuleIdentifier> entry : configModules) {
String moduleNamespace = entry.getKey();
ModuleIdentifier moduleId = entry.getValue();
try {
ObjectName instanceON = configRegistryClient.lookupConfigBean(moduleId.getFactoryName(), moduleId.getInstanceName());
LOG.debug("Found config module instance ObjectName: {}", instanceON);
Element moduleElement = configMapping.moduleToXml(moduleNamespace, moduleId.getFactoryName(), moduleId.getInstanceName(), instanceON, document);
modulesElement.appendChild(moduleElement);
} catch (final InstanceNotFoundException e) {
LOG.warn("Error looking up config module: namespace {}, module name {}, instance {}", moduleNamespace, moduleId.getFactoryName(), moduleId.getInstanceName(), e);
}
}
if (LOG.isDebugEnabled()) {
LOG.debug("Pushing config xml: {}", XmlUtil.toString(dataElement));
}
ConfigExecution execution = new ConfigExecution(configMapping, XmlElement.fromDomElement(dataElement), TestOption.testThenSet, EditStrategyType.recreate);
configFacade.executeConfigExecution(execution);
configFacade.commitSilentTransaction();
}
use of org.opendaylight.controller.config.facade.xml.mapping.config.Config in project controller by opendaylight.
the class ConfigSubsystemFacade method getConfiguration.
public Element getConfiguration(final Document document, final Datastore source, final Optional<String> maybeNamespace) {
final ConfigTransactionClient registryClient;
// in case of candidate, get current transaction representing candidate
if (source == Datastore.running) {
final ObjectName readTx = transactionProvider.getOrCreateReadTransaction();
registryClient = configRegistryClient.getConfigTransactionClient(readTx);
} else {
registryClient = configRegistryClient.getConfigTransactionClient(transactionProvider.getOrCreateTransaction());
}
try {
Element dataElement = XmlUtil.createElement(document, XmlMappingConstants.DATA_KEY, Optional.<String>absent());
final Set<ObjectName> instances = Datastore.getInstanceQueryStrategy(source, this.transactionProvider).queryInstances(configRegistryClient);
final Config configMapping = new Config(transformMbeToModuleConfigs(yangStoreService.getModuleMXBeanEntryMap()), yangStoreService.getEnumResolver());
ServiceRegistryWrapper serviceTracker = new ServiceRegistryWrapper(registryClient);
dataElement = configMapping.toXml(instances, maybeNamespace, document, dataElement, serviceTracker);
return dataElement;
} finally {
if (source == Datastore.running) {
transactionProvider.closeReadTransaction();
}
}
}
use of org.opendaylight.controller.config.facade.xml.mapping.config.Config 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());
}
Aggregations