use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.dhcp.config.Configs in project openflowplugin by opendaylight.
the class SyncReactorFutureZipDecoratorTest method testSyncupWithOptimizedConfigDeltaCompression.
@Test
public void testSyncupWithOptimizedConfigDeltaCompression() throws Exception {
final FlowCapableNode dataBefore = Mockito.mock(FlowCapableNode.class);
final FlowCapableNode dataAfter = Mockito.mock(FlowCapableNode.class);
final FlowCapableNode dataAfter2 = Mockito.mock(FlowCapableNode.class);
final CountDownLatch latchForFirst = new CountDownLatch(1);
final CountDownLatch latchForNext = new CountDownLatch(1);
final SyncupEntry first = new SyncupEntry(dataBefore, configDS, null, operationalDS);
final SyncupEntry second = new SyncupEntry(dataAfter, configDS, dataBefore, configDS);
final SyncupEntry third = new SyncupEntry(null, configDS, dataAfter, configDS);
final SyncupEntry fourth = new SyncupEntry(dataAfter2, configDS, null, configDS);
final SyncupEntry zipped = new SyncupEntry(dataAfter2, configDS, dataBefore, configDS);
final List<ListenableFuture<Boolean>> allResults = new ArrayList<>();
Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Mockito.eq(first))).thenAnswer(invocationOnMock -> {
LOG.info("unlocking next configs");
latchForNext.countDown();
latchForFirst.await();
LOG.info("unlocking first delegate");
return Futures.immediateFuture(Boolean.TRUE);
});
allResults.add(reactor.syncup(fcNodePath, first));
latchForNext.await();
mockSyncupWithEntry(second);
allResults.add(reactor.syncup(fcNodePath, second));
mockSyncupWithEntry(third);
allResults.add(reactor.syncup(fcNodePath, third));
mockSyncupWithEntry(fourth);
allResults.add(reactor.syncup(fcNodePath, fourth));
latchForFirst.countDown();
Futures.allAsList(allResults).get(1, TimeUnit.SECONDS);
LOG.info("all configs done");
syncThreadPool.shutdown();
boolean terminated = syncThreadPool.awaitTermination(1, TimeUnit.SECONDS);
if (!terminated) {
LOG.info("thread pool not terminated.");
syncThreadPool.shutdownNow();
}
final InOrder inOrder = Mockito.inOrder(delegate);
inOrder.verify(delegate).syncup(fcNodePath, first);
inOrder.verify(delegate).syncup(fcNodePath, zipped);
inOrder.verifyNoMoreInteractions();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.dhcp.config.Configs in project netvirt by opendaylight.
the class DhcpConfigListener method updateConfig.
private void updateConfig(DhcpConfig update) {
// TODO: Update operational with actual values
if (update == null || update.getConfigs() == null || update.getConfigs().isEmpty()) {
dhcpManager.setLeaseDuration(DhcpMConstants.DEFAULT_LEASE_TIME);
dhcpManager.setDefaultDomain(DhcpMConstants.DEFAULT_DOMAIN_NAME);
return;
}
Configs config = update.getConfigs().get(0);
if (config.getLeaseDuration() != null) {
dhcpManager.setLeaseDuration(config.getLeaseDuration());
}
if (config.getDefaultDomain() != null) {
dhcpManager.setDefaultDomain(config.getDefaultDomain());
// TODO: What to do if string is ""
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.dhcp.config.Configs in project netvirt by opendaylight.
the class Router method doExecute.
@Override
protected Object doExecute() {
switch(action) {
case "add":
// check: rtr already running?
long asn = 0;
int stalePath = 0;
boolean fb = false;
if (asNum == null) {
session.getConsole().println("error: " + AS + " is needed");
return null;
}
if (!Commands.isValid(session.getConsole(), asNum, Commands.Validators.INT, AS)) {
return null;
}
asn = Long.parseLong(asNum);
if (rid != null && !Commands.isValid(session.getConsole(), rid, Commands.Validators.IPADDR, RID)) {
return null;
}
if (spt != null) {
if (!Commands.isValid(session.getConsole(), spt, Commands.Validators.INT, SP)) {
return null;
} else {
stalePath = Integer.parseInt(spt);
}
}
if (fbit != null) {
switch(fbit) {
case "on":
fb = true;
break;
case "off":
fb = false;
break;
default:
session.getConsole().println("error: " + FB + " must be on or off");
return null;
}
}
bgpManager.startBgp(asn, rid, stalePath, fb);
break;
case "del":
// check: nothing to stop?
if (asNum != null || rid != null || spt != null || fbit != null) {
session.getConsole().println("note: option(s) not needed; ignored");
}
Bgp conf = bgpManager.getConfig();
if (conf == null) {
session.getConsole().println("error : no BGP configs present");
break;
}
List<Neighbors> nbrs = conf.getNeighbors();
if (nbrs != null && nbrs.size() > 0) {
session.getConsole().println("error: all BGP congiguration must be deleted " + "before stopping the router instance");
break;
}
bgpManager.stopBgp();
break;
default:
return usage();
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.dhcp.config.Configs in project netvirt by opendaylight.
the class DhcpConfigureCommand method doExecute.
@Override
protected Object doExecute() throws Exception {
if (defaultDomain == null && leaseDuration == null) {
session.getConsole().println(getHelp());
return null;
}
Integer currLeaseDuration = DhcpMConstants.DEFAULT_LEASE_TIME;
String currDefDomain = DhcpMConstants.DEFAULT_DOMAIN_NAME;
ConfigsBuilder dccBuilder = new ConfigsBuilder();
InstanceIdentifier<DhcpConfig> iid = InstanceIdentifier.create(DhcpConfig.class);
DhcpConfig currentConfig = SingleTransactionDataBroker.syncRead(dataBroker, CONFIGURATION, iid);
if (currentConfig != null && currentConfig.getConfigs() != null && !currentConfig.getConfigs().isEmpty()) {
Configs dhcpConfig = currentConfig.getConfigs().get(0);
if (dhcpConfig.getLeaseDuration() != null) {
currLeaseDuration = dhcpConfig.getLeaseDuration();
}
if (dhcpConfig.getDefaultDomain() != null) {
currDefDomain = dhcpConfig.getDefaultDomain();
}
}
dccBuilder.setLeaseDuration(leaseDuration == null ? currLeaseDuration : leaseDuration);
dccBuilder.setDefaultDomain(defaultDomain == null ? currDefDomain : defaultDomain);
List<Configs> configList = Collections.singletonList(dccBuilder.build());
DhcpConfigBuilder dcBuilder = new DhcpConfigBuilder();
dcBuilder.setConfigs(configList);
SingleTransactionDataBroker.syncWrite(dataBroker, CONFIGURATION, iid, dcBuilder.build());
return null;
}
Aggregations