Search in sources :

Example 1 with Configs

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();
}
Also used : InOrder(org.mockito.InOrder) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) CountDownLatch(java.util.concurrent.CountDownLatch) SyncupEntry(org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry) Test(org.junit.Test)

Example 2 with Configs

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 ""
    }
}
Also used : Configs(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.dhcp.config.Configs)

Example 3 with Configs

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;
}
Also used : Neighbors(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.Neighbors) Bgp(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.Bgp)

Example 4 with Configs

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;
}
Also used : ConfigsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.dhcp.config.ConfigsBuilder) DhcpConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DhcpConfig) Configs(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.dhcp.config.Configs) DhcpConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DhcpConfigBuilder)

Aggregations

Configs (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.dhcp.config.Configs)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 ArrayList (java.util.ArrayList)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Test (org.junit.Test)1 InOrder (org.mockito.InOrder)1 SyncupEntry (org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry)1 Bgp (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.Bgp)1 Neighbors (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.Neighbors)1 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)1 DhcpConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DhcpConfig)1 DhcpConfigBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DhcpConfigBuilder)1 ConfigsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.dhcp.config.ConfigsBuilder)1