Search in sources :

Example 11 with VpnInterfaces

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.VpnInterfaces in project netvirt by opendaylight.

the class ShowVpn method doExecute.

@Override
@Nullable
protected Object doExecute() {
    Map<String, Integer> vpnNameToConfigInterfaceMap = new HashMap<>();
    Map<String, Integer> vpnNameToOperInterfaceMap = new HashMap<>();
    if (detail == null) {
        showVpn();
        Set<String> vpnInstances = new HashSet<>();
        for (VpnInterface vpnInterface : vpnInterfaceConfigList) {
            if (vpnInterface.getVpnInstanceNames() != null) {
                for (VpnInstanceNames vpnInterfaceVpnInstance : vpnInterface.getVpnInstanceNames().values()) {
                    String vpnName = vpnInterfaceVpnInstance.getVpnName();
                    if (vpnName != null) {
                        vpnInstances.add(vpnName);
                    }
                }
            }
        }
        for (String routerId : vpnInstances) {
            ifPresent = vpnNameToConfigInterfaceMap.get(routerId);
            if (ifPresent == null) {
                vpnNameToConfigInterfaceMap.put(routerId, 1);
            } else {
                vpnNameToConfigInterfaceMap.put(routerId, vpnNameToConfigInterfaceMap.get(routerId) + 1);
            }
        }
        for (VpnInterfaceOpDataEntry vpnInterfaceOp : vpnInterfaceOpList) {
            ifPresent = vpnNameToOperInterfaceMap.get(vpnInterfaceOp.getVpnInstanceName());
            if (ifPresent == null) {
                vpnNameToOperInterfaceMap.put(vpnInterfaceOp.getVpnInstanceName(), 1);
            } else {
                vpnNameToOperInterfaceMap.put(vpnInterfaceOp.getVpnInstanceName(), vpnNameToOperInterfaceMap.get(vpnInterfaceOp.getVpnInstanceName()) + 1);
            }
        }
        session.getConsole().println("-----------------------------------------------------------------------");
        session.getConsole().println(String.format("         %s   %14s  %5s  %5s", "VpnInstanceName", "RD", "Config Count", "Oper Count"));
        session.getConsole().println("\n-----------------------------------------------------------------------");
        for (VpnInstance vpnInstance : vpnInstanceList) {
            configCount = 0;
            operCount = 0;
            Integer count = vpnNameToConfigInterfaceMap.get(vpnInstance.getVpnInstanceName());
            if (count != null) {
                configCount = vpnNameToConfigInterfaceMap.get(vpnInstance.getVpnInstanceName());
                totalConfigCount = totalConfigCount + configCount;
            }
            count = vpnNameToOperInterfaceMap.get(vpnInstance.getVpnInstanceName());
            if (count != null) {
                operCount = vpnNameToOperInterfaceMap.get(vpnInstance.getVpnInstanceName());
                totalOperCount = totalOperCount + operCount;
            }
            session.getConsole().println(String.format("%-32s  %-10s  %-10s  %-10s", vpnInstance.getVpnInstanceName(), vpnInstance.getRouteDistinguisher(), configCount, operCount));
        }
        session.getConsole().println("-----------------------------------------------------------------------");
        session.getConsole().println(String.format("Total Count:                    %19s    %8s", totalConfigCount, totalOperCount));
        session.getConsole().println(getshowVpnCLIHelp());
    } else {
        showVpn();
        session.getConsole().println("Present Config VpnInterfaces are:");
        for (VpnInterface vpnInterface : vpnInterfaceConfigList) {
            if (vpnInterface.getVpnInstanceNames() != null && VpnHelper.doesVpnInterfaceBelongToVpnInstance(detail, new ArrayList<VpnInstanceNames>(vpnInterface.getVpnInstanceNames().values()))) {
                session.getConsole().println(vpnInterface.getName());
            }
        }
        session.getConsole().println("Present Oper VpnInterfaces are:");
        for (VpnInterfaceOpDataEntry vpnInterfaceOp : vpnInterfaceOpList) {
            if (Objects.equals(vpnInterfaceOp.getVpnInstanceName(), detail)) {
                session.getConsole().println(vpnInterfaceOp.getName());
            }
        }
    }
    return null;
}
Also used : VpnInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.interfaces.VpnInterface) VpnInstanceNames(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.interfaces.vpn._interface.VpnInstanceNames) HashMap(java.util.HashMap) VpnInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance) ArrayList(java.util.ArrayList) VpnInterfaceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry) HashSet(java.util.HashSet) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 12 with VpnInterfaces

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.VpnInterfaces in project netvirt by opendaylight.

the class VpnSubnetRouteHandler method onSubnetAddedToVpn.

// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public void onSubnetAddedToVpn(Subnetmap subnetmap, boolean isBgpVpn, Long elanTag) {
    Uuid subnetId = subnetmap.getId();
    String subnetIp = subnetmap.getSubnetIp();
    SubnetOpDataEntry subOpEntry = null;
    SubnetOpDataEntryBuilder subOpBuilder = null;
    InstanceIdentifier<SubnetOpDataEntry> subOpIdentifier = null;
    Optional<SubnetOpDataEntry> optionalSubs = null;
    Uint32 label;
    requireNonNull(subnetId, LOGGING_PREFIX + " onSubnetAddedToVpn: SubnetId cannot be null or empty!");
    requireNonNull(subnetIp, LOGGING_PREFIX + " onSubnetAddedToVpn: SubnetPrefix cannot be null or empty!");
    requireNonNull(elanTag, LOGGING_PREFIX + " onSubnetAddedToVpn: ElanTag cannot be null or empty!");
    if (subnetmap.getVpnId() == null) {
        LOG.error("onSubnetAddedToVpn: VpnId {} for subnet {} not found, bailing out", subnetmap.getVpnId(), subnetId);
        return;
    }
    String vpnName = subnetmap.getVpnId().getValue();
    Uint32 vpnId = waitAndGetVpnIdIfInvalid(vpnName);
    if (VpnConstants.INVALID_ID.equals(vpnId)) {
        LOG.error("{} onSubnetAddedToVpn: VpnInstance to VPNId mapping not yet available for VpnName {} " + "processing subnet {} with IP {}, bailing out now.", LOGGING_PREFIX, vpnName, subnetId, subnetIp);
        return;
    }
    String primaryRd = vpnUtil.getPrimaryRd(vpnName);
    VpnInstanceOpDataEntry vpnInstanceOpData = waitAndGetVpnInstanceOpDataIfNull(vpnName, primaryRd);
    if (vpnInstanceOpData == null) {
        LOG.error("{} onSubnetAddedToVpn: VpnInstanceOpData not yet available for VpnName {} " + "processing subnet {} with IP {}, bailing out now.", LOGGING_PREFIX, vpnName, subnetId, subnetIp);
        return;
    }
    LOG.info("{} onSubnetAddedToVpn: Subnet {} with IP {} being added to vpn {}", LOGGING_PREFIX, subnetId.getValue(), subnetIp, vpnName);
    // TODO(vivek): Change this to use more granularized lock at subnetId level
    try {
        vpnUtil.lockSubnet(subnetId.getValue());
        if (isBgpVpn) {
            InstanceIdentifier<Networks> netsIdentifier = InstanceIdentifier.builder(ExternalNetworks.class).child(Networks.class, new NetworksKey(subnetmap.getNetworkId())).build();
            Optional<Networks> optionalNets = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, netsIdentifier);
            if (optionalNets.isPresent()) {
                LOG.info("{} onSubnetAddedToVpn: subnet {} with IP {} is an external subnet on external " + "network {}, so ignoring this for SubnetRoute on vpn {}", LOGGING_PREFIX, subnetId.getValue(), subnetIp, subnetmap.getNetworkId().getValue(), vpnName);
                return;
            }
        }
        // Create and add SubnetOpDataEntry object for this subnet to the SubnetOpData container
        subOpIdentifier = InstanceIdentifier.builder(SubnetOpData.class).child(SubnetOpDataEntry.class, new SubnetOpDataEntryKey(subnetId)).build();
        optionalSubs = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, subOpIdentifier);
        if (optionalSubs.isPresent()) {
            LOG.error("{} onSubnetAddedToVpn: SubnetOpDataEntry for subnet {} with ip {} and vpn {} already" + " detected to be present", LOGGING_PREFIX, subnetId.getValue(), subnetIp, vpnName);
            return;
        }
        LOG.debug("{} onSubnetAddedToVpn: Creating new SubnetOpDataEntry node for subnet {} subnetIp {} " + "vpn {}", LOGGING_PREFIX, subnetId.getValue(), subnetIp, vpnName);
        subOpBuilder = new SubnetOpDataEntryBuilder().withKey(new SubnetOpDataEntryKey(subnetId));
        subOpBuilder.setSubnetId(subnetId);
        subOpBuilder.setSubnetCidr(subnetIp);
        if (isBgpVpn && !VpnUtil.isBgpVpn(vpnName, primaryRd)) {
            LOG.error("{} onSubnetAddedToVpn: The VPN Instance name {} does not have RD. Bailing out for" + " subnet {} subnetIp {} ", LOGGING_PREFIX, vpnName, subnetId.getValue(), subnetIp);
            return;
        }
        // Allocate MPLS label for subnet-route at the time SubnetOpDataEntry creation
        label = vpnUtil.getUniqueId(VpnConstants.VPN_IDPOOL_NAME, VpnUtil.getNextHopLabelKey(primaryRd, subnetIp));
        if (label == VpnConstants.INVALID_ID) {
            LOG.error("onSubnetAddedToVpn: Unable to retrieve label for rd {}, subnetIp {}", primaryRd, subnetIp);
            return;
        }
        subOpBuilder.setVrfId(primaryRd);
        subOpBuilder.setVpnName(vpnName);
        subOpBuilder.setSubnetToDpn(new ArrayList<>());
        subOpBuilder.setRouteAdvState(TaskState.Idle);
        subOpBuilder.setElanTag(elanTag);
        subOpBuilder.setLabel(label);
        Long l3Vni = vpnInstanceOpData.getL3vni() != null ? vpnInstanceOpData.getL3vni().toJava() : 0L;
        subOpBuilder.setL3vni(l3Vni);
        subOpEntry = subOpBuilder.build();
        SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL, subOpIdentifier, subOpEntry, VpnUtil.SINGLE_TRANSACTION_BROKER_NO_RETRY);
        LOG.info("{} onSubnetAddedToVpn: Added subnetopdataentry to OP Datastore for subnet {}", LOGGING_PREFIX, subnetId.getValue());
    } catch (TransactionCommitFailedException e) {
        LOG.error("{} Creation of SubnetOpDataEntry for subnet {} failed ", LOGGING_PREFIX, subnetId.getValue(), e);
        // The second part of this method depends on subnetmap being non-null so fail fast here.
        return;
    } catch (RuntimeException e) {
        // TODO: Avoid this
        LOG.error("{} onSubnetAddedToVpn: Unable to handle subnet {} with ip {} added to vpn {}", LOGGING_PREFIX, subnetId.getValue(), subnetIp, vpnName, e);
        return;
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("{} onSubnetAddedToVpn: Failed to read data store for subnet {} ip {} vpn {}", LOGGING_PREFIX, subnetId, subnetIp, vpnName);
        return;
    } finally {
        vpnUtil.unlockSubnet(subnetId.getValue());
    }
    try {
        // In second critical section , Port-Op-Data will be updated.
        vpnUtil.lockSubnet(subnetId.getValue());
        Uint64 dpnId = null;
        SubnetToDpn subDpn = null;
        Map<Uint64, SubnetToDpn> subDpnMap = new HashMap<>();
        optionalSubs = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, subOpIdentifier);
        subOpBuilder = new SubnetOpDataEntryBuilder(optionalSubs.get()).withKey(new SubnetOpDataEntryKey(subnetId));
        List<Uuid> portList = subnetmap.getPortList();
        if (portList != null) {
            for (Uuid port : portList) {
                Interface intfState = InterfaceUtils.getInterfaceStateFromOperDS(dataBroker, port.getValue());
                if (intfState != null) {
                    try {
                        dpnId = InterfaceUtils.getDpIdFromInterface(intfState);
                    } catch (Exception e) {
                        LOG.error("{} onSubnetAddedToVpn: Unable to obtain dpnId for interface {}," + " subnetroute inclusion for this interface for subnet {} subnetIp {} " + "vpn {} failed with exception", LOGGING_PREFIX, port.getValue(), subnetId.getValue(), subnetIp, vpnName, e);
                        continue;
                    }
                    if (dpnId.equals(Uint64.ZERO)) {
                        LOG.error("{} onSubnetAddedToVpn: Port {} is not assigned DPN yet," + " ignoring subnet {} subnetIP {} vpn {}", LOGGING_PREFIX, port.getValue(), subnetId.getValue(), subnetIp, vpnName);
                        continue;
                    }
                    subOpDpnManager.addPortOpDataEntry(port.getValue(), subnetId, dpnId);
                    if (intfState.getOperStatus() != OperStatus.Up) {
                        LOG.error("{} onSubnetAddedToVpn: Port {} is not UP yet, ignoring subnet {}" + " subnetIp {} vpn {}", LOGGING_PREFIX, port.getValue(), subnetId.getValue(), subnetIp, vpnName);
                        continue;
                    }
                    subDpn = subOpDpnManager.addInterfaceToDpn(subnetId, dpnId, port.getValue());
                    if (intfState.getOperStatus() == OperStatus.Up) {
                        // port is UP
                        subDpnMap.put(dpnId, subDpn);
                    }
                } else {
                    subOpDpnManager.addPortOpDataEntry(port.getValue(), subnetId, null);
                }
            }
            if (subDpnMap.size() > 0) {
                subOpBuilder.setSubnetToDpn(new ArrayList<>(subDpnMap.values()));
            }
        }
        electNewDpnForSubnetRoute(subOpBuilder, null, /* oldDpnId */
        subnetId, subnetmap.getNetworkId(), isBgpVpn, label);
        subOpEntry = subOpBuilder.build();
        SingleTransactionDataBroker.syncUpdate(dataBroker, LogicalDatastoreType.OPERATIONAL, subOpIdentifier, subOpEntry, VpnUtil.SINGLE_TRANSACTION_BROKER_NO_RETRY);
        LOG.info("{} onSubnetAddedToVpn: Added PortOpDataEntry and VpnInterfaces to SubnetOpData" + " for subnet {} subnetIp {} vpn {} TaskState {} lastTaskState {}", LOGGING_PREFIX, subnetId.getValue(), subnetIp, vpnName, subOpEntry.getRouteAdvState(), subOpEntry.getLastAdvState());
    } catch (RuntimeException e) {
        LOG.error("{} onSubnetAddedToVpn: Unable to handle subnet {} with ip {} added to vpn {}", LOGGING_PREFIX, subnetId.getValue(), subnetIp, vpnName, e);
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("{} onSubnetAddedToVpn: Failed to read data store for subnet {} ip {} vpn {}", LOGGING_PREFIX, subnetId, subnetIp, vpnName);
    } catch (TransactionCommitFailedException ex) {
        LOG.error("{} onSubnetAddedToVpn: Creation of SubnetOpDataEntry for subnet {} subnetIp {} vpn {} failed", LOGGING_PREFIX, subnetId.getValue(), subnetIp, vpnName, ex);
    } finally {
        vpnUtil.unlockSubnet(subnetId.getValue());
    }
}
Also used : Networks(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.Networks) ExternalNetworks(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalNetworks) HashMap(java.util.HashMap) SubnetOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.SubnetOpDataEntry) TransactionCommitFailedException(org.opendaylight.mdsal.common.api.TransactionCommitFailedException) ExecutionException(java.util.concurrent.ExecutionException) Uint32(org.opendaylight.yangtools.yang.common.Uint32) SubnetOpDataEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.SubnetOpDataEntryBuilder) SubnetOpData(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.SubnetOpData) TransactionCommitFailedException(org.opendaylight.mdsal.common.api.TransactionCommitFailedException) ExecutionException(java.util.concurrent.ExecutionException) SubnetToDpn(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.SubnetToDpn) NetworksKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.NetworksKey) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) SubnetOpDataEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.SubnetOpDataEntryKey) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 13 with VpnInterfaces

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.VpnInterfaces in project netvirt by opendaylight.

the class SubnetOpDpnManagerTest method testAddInterfaceToDpn.

@Ignore
@Test
public void testAddInterfaceToDpn() {
    subOpDpnManager.addInterfaceToDpn(subnetId, dpId, infName);
    List<VpnInterfaces> vpnIntfList = new ArrayList<>();
    VpnInterfaces vpnIntfs = new VpnInterfacesBuilder().withKey(new VpnInterfacesKey(infName)).setInterfaceName(infName).build();
    vpnIntfList.add(vpnIntfs);
    SubnetToDpn subnetToDpnLocal = new SubnetToDpnBuilder().setDpnId(dpId).withKey(new SubnetToDpnKey(dpId)).setVpnInterfaces(vpnIntfList).build();
    verify(mockWriteTx).mergeParentStructurePut(LogicalDatastoreType.OPERATIONAL, dpnOpId, subnetToDpnLocal);
}
Also used : SubnetToDpnBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.SubnetToDpnBuilder) VpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.subnet.to.dpn.VpnInterfaces) ArrayList(java.util.ArrayList) VpnInterfacesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.subnet.to.dpn.VpnInterfacesBuilder) VpnInterfacesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.subnet.to.dpn.VpnInterfacesKey) SubnetToDpnKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.SubnetToDpnKey) SubnetToDpn(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.SubnetToDpn) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 14 with VpnInterfaces

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.VpnInterfaces in project netvirt by opendaylight.

the class VPNServiceChainHandlerTest method stubReadVpnToDpnList.

private void stubReadVpnToDpnList(String rd, BigInteger dpnId, List<String> vpnIfacesOnDpn) throws Exception {
    List<VpnInterfaces> vpnIfacesList = vpnIfacesOnDpn.stream().map((ifaceName) -> new VpnInterfacesBuilder().withKey(new VpnInterfacesKey(ifaceName)).setInterfaceName(ifaceName).build()).collect(Collectors.toList());
    CheckedFuture chkdFuture = mock(CheckedFuture.class);
    when(chkdFuture.get()).thenReturn(Optional.of(vpnIfacesList));
    when(readTx.read(eq(LogicalDatastoreType.OPERATIONAL), eq(VpnServiceChainUtils.getVpnToDpnListIdentifier(rd, dpnId)))).thenReturn(chkdFuture);
}
Also used : ReadFailedException(org.opendaylight.mdsal.common.api.ReadFailedException) JobCoordinatorImpl(org.opendaylight.infrautils.jobcoordinator.internal.JobCoordinatorImpl) VpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfaces) LoggerFactory(org.slf4j.LoggerFactory) CheckedFuture(com.google.common.util.concurrent.CheckedFuture) VpnInterfacesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfacesKey) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) FlowEntityMatcher(org.opendaylight.netvirt.cloudservicechain.matchers.FlowEntityMatcher) NWUtil.getEtherTypeFromIpPrefix(org.opendaylight.genius.mdsalutil.NWUtil.getEtherTypeFromIpPrefix) ReadTransaction(org.opendaylight.mdsal.binding.api.ReadTransaction) Matchers.eq(org.mockito.Matchers.eq) After(org.junit.After) BigInteger(java.math.BigInteger) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) VpnToDpnListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnListKey) VrfTablesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesBuilder) AfterClass(org.junit.AfterClass) VpnInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.to.vpn.id.VpnInstance) BoundServices(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices) VpnServiceChainUtils(org.opendaylight.netvirt.cloudservicechain.utils.VpnServiceChainUtils) Collectors(java.util.stream.Collectors) TypeSafeMatcher(org.hamcrest.TypeSafeMatcher) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) List(java.util.List) TestMetricProviderImpl(org.opendaylight.infrautils.metrics.testimpl.TestMetricProviderImpl) Matchers.argThat(org.mockito.Matchers.argThat) RoutePaths(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) IpAddressesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.IpAddressesKey) Optional(java.util.Optional) VpnInstanceOpDataEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryKey) IVpnFootprintService(org.opendaylight.netvirt.vpnmanager.api.IVpnFootprintService) VpnInstanceOpData(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.VpnInstanceOpData) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Mockito.mock(org.mockito.Mockito.mock) FlowMatcher(org.opendaylight.netvirt.cloudservicechain.matchers.FlowMatcher) ServiceModeIngress(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceModeIngress) MetricProvider(org.opendaylight.infrautils.metrics.MetricProvider) BeforeClass(org.junit.BeforeClass) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) VpnInterfacesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfacesBuilder) InterfaceServiceUtil(org.opendaylight.genius.interfacemanager.globals.InterfaceServiceUtil) ArgumentCaptor(org.mockito.ArgumentCaptor) Matchers.anyObject(org.mockito.Matchers.anyObject) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) IInterfaceManager(org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager) Before(org.junit.Before) Description(org.hamcrest.Description) Logger(org.slf4j.Logger) VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) RouteOrigin(org.opendaylight.netvirt.fibmanager.api.RouteOrigin) WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) VpnToDpnListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnListBuilder) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) Mockito.times(org.mockito.Mockito.times) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) VpnInstanceOpDataEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryBuilder) Mockito.verify(org.mockito.Mockito.verify) Mockito.never(org.mockito.Mockito.never) VpnInstanceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.to.vpn.id.VpnInstanceKey) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) Matcher(org.hamcrest.Matcher) IMdsalApiManager(org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) VpnInstanceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.to.vpn.id.VpnInstanceBuilder) IpAddressesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.IpAddressesBuilder) Collections(java.util.Collections) FibHelper(org.opendaylight.netvirt.fibmanager.api.FibHelper) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) IpAddresses(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.IpAddresses) VpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfaces) VpnInterfacesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfacesBuilder) VpnInterfacesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfacesKey) CheckedFuture(com.google.common.util.concurrent.CheckedFuture)

Example 15 with VpnInterfaces

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.VpnInterfaces in project netvirt by opendaylight.

the class VPNServiceChainHandlerTest method stubGetVpnInstance.

private void stubGetVpnInstance(String rd, String ipAddress, String ifaceName) throws Exception {
    IpAddresses ipAddr = new IpAddressesBuilder().setIpAddress(ipAddress).withKey(new IpAddressesKey(ipAddress)).build();
    List<VpnInterfaces> ifacesList = Collections.singletonList(new VpnInterfacesBuilder().setInterfaceName(ifaceName).build());
    VpnToDpnListBuilder vtdlb = new VpnToDpnListBuilder().withKey(new VpnToDpnListKey(DPN_ID)).setDpnId(DPN_ID).setIpAddresses(Collections.singletonList(ipAddr)).setVpnInterfaces(ifacesList);
    VpnInstanceOpDataEntry vpnInstanceOpDataEntry = new VpnInstanceOpDataEntryBuilder().withKey(new VpnInstanceOpDataEntryKey(rd)).setVpnId(VPN_ID).setVpnToDpnList(Collections.singletonList(vtdlb.build())).setVrfId("1").build();
    CheckedFuture chkdFuture = mock(CheckedFuture.class);
    when(chkdFuture.get()).thenReturn(Optional.of(vpnInstanceOpDataEntry));
    when(readTx.read(eq(LogicalDatastoreType.OPERATIONAL), eq(VpnServiceChainUtils.getVpnInstanceOpDataIdentifier(rd)))).thenReturn(chkdFuture);
}
Also used : IpAddresses(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.IpAddresses) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) IpAddressesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.IpAddressesKey) VpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfaces) VpnInstanceOpDataEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryBuilder) IpAddressesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.IpAddressesBuilder) VpnInterfacesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfacesBuilder) VpnInstanceOpDataEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryKey) CheckedFuture(com.google.common.util.concurrent.CheckedFuture) VpnToDpnListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnListKey) VpnToDpnListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnListBuilder)

Aggregations

ArrayList (java.util.ArrayList)14 ExecutionException (java.util.concurrent.ExecutionException)13 VpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfaces)11 SubnetToDpn (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.SubnetToDpn)9 SubnetToDpnBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.SubnetToDpnBuilder)9 SubnetToDpnKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.SubnetToDpnKey)9 VpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.subnet.to.dpn.VpnInterfaces)9 SubnetOpDataEntryKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.SubnetOpDataEntryKey)8 VpnToDpnListBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnListBuilder)8 VpnToDpnList (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList)7 HashMap (java.util.HashMap)6 TransactionCommitFailedException (org.opendaylight.mdsal.common.api.TransactionCommitFailedException)6 SubnetOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.SubnetOpDataEntry)6 VpnInterfacesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.subnet.to.dpn.VpnInterfacesBuilder)6 IpAddresses (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.IpAddresses)6 VpnInterfacesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfacesBuilder)6 VpnInterfacesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.subnet.to.dpn.VpnInterfacesKey)5 IpAddressesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.IpAddressesKey)5 Collections (java.util.Collections)4 HashSet (java.util.HashSet)4