use of org.opendaylight.controller.config.util.capability.Capability in project controller by opendaylight.
the class ConfigPusherImplTest method testPersisterConflictingVersionException.
@Test
public void testPersisterConflictingVersionException() throws Exception {
doReturn(new TreeSet<>(Lists.newArrayList("namespace?module=module&revision=2012-12-12"))).when(mockedConfigSnapshot).getCapabilities();
final Capability cap = mock(Capability.class);
doReturn("namespace?module=module&revision=2012-12-12").when(cap).getCapabilityUri();
doReturn(Sets.newHashSet(cap)).when(facadeFactory).getCurrentCapabilities();
final ConfigExecution cfgExec = mock(ConfigExecution.class);
doReturn("cfg exec").when(cfgExec).toString();
doReturn(cfgExec).when(facade).getConfigExecution(any(Config.class), any(Element.class));
doNothing().when(facade).executeConfigExecution(any(ConfigExecution.class));
doThrow(ConflictingVersionException.class).when(facade).commitSilentTransaction();
doReturn(Sets.newHashSet(module)).when(yangStoreService).getModules();
final ConfigPusherImpl configPusher = new ConfigPusherImpl(facadeFactory, 0, 0);
configPusher.pushConfigs(Collections.singletonList(mockedConfigSnapshot));
try {
configPusher.processSingle(Lists.<AutoCloseable>newArrayList(), mBeanServer, mockedAggregator, true);
} catch (final IllegalStateException e) {
Throwable cause = Throwables.getRootCause(e);
assertTrue(cause instanceof ConflictingVersionException);
return;
}
fail();
}
use of org.opendaylight.controller.config.util.capability.Capability in project controller by opendaylight.
the class ConfigPusherImpl method waitForCapabilities.
private void waitForCapabilities(final Set<String> expectedCapabilities, final String idForReporting) {
Stopwatch stopwatch = Stopwatch.createStarted();
ConfigPusherException lastException;
do {
try {
final Set<Capability> currentCaps = facade.getCurrentCapabilities();
final Set<String> notFoundCapabilities = computeNotFoundCapabilities(expectedCapabilities, currentCaps);
if (notFoundCapabilities.isEmpty()) {
return;
} else {
LOG.debug("Netconf server did not provide required capabilities for {} ", idForReporting, "Expected but not found: {}, all expected {}, current {}", notFoundCapabilities, expectedCapabilities, currentCaps);
throw new NotEnoughCapabilitiesException("Not enough capabilities for " + idForReporting + ". Expected but not found: " + notFoundCapabilities, notFoundCapabilities);
}
} catch (final ConfigPusherException e) {
LOG.debug("Not enough capabilities: {}", e.toString());
lastException = e;
sleep();
}
} while (stopwatch.elapsed(TimeUnit.MILLISECONDS) < maxWaitForCapabilitiesMillis);
LOG.error("Unable to push configuration due to missing yang models." + " Yang models that are missing, but required by the configuration: {}." + " For each mentioned model check: " + " 1. that the mentioned yang model namespace/name/revision is identical to those in the yang model itself" + " 2. the yang file is present in the system" + " 3. the bundle with that yang file is present in the system and active" + " 4. the yang parser did not fail while attempting to parse that model", ((NotEnoughCapabilitiesException) lastException).getMissingCaps());
throw new IllegalStateException("Unable to push configuration due to missing yang models." + " Required yang models that are missing: " + ((NotEnoughCapabilitiesException) lastException).getMissingCaps(), lastException);
}
Aggregations