Search in sources :

Example 1 with InterVpnLinks

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.InterVpnLinks in project netvirt by opendaylight.

the class InterVpnLinkCacheImpl method initialFeed.

@PostConstruct
public void initialFeed() {
    // Read all InterVpnLinks and InterVpnLinkStates from MD-SAL.
    InstanceIdentifier<InterVpnLinks> interVpnLinksIid = InstanceIdentifier.builder(InterVpnLinks.class).build();
    Optional<InterVpnLinks> optIVpnLinksOpData = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, interVpnLinksIid);
    if (!optIVpnLinksOpData.isPresent()) {
        // Nothing to be added to cache
        return;
    }
    InterVpnLinks interVpnLinks = optIVpnLinksOpData.get();
    for (InterVpnLink interVpnLink : interVpnLinks.getInterVpnLink()) {
        addInterVpnLinkToCaches(interVpnLink);
    }
    // Now the States
    InstanceIdentifier<InterVpnLinkStates> interVpnLinkStateIid = InstanceIdentifier.builder(InterVpnLinkStates.class).build();
    Optional<InterVpnLinkStates> optIVpnLinkStateOpData = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, interVpnLinkStateIid);
    if (!optIVpnLinkStateOpData.isPresent()) {
        return;
    }
    InterVpnLinkStates interVpnLinkStates = optIVpnLinkStateOpData.get();
    for (InterVpnLinkState interVpnLinkState : interVpnLinkStates.getInterVpnLinkState()) {
        addInterVpnLinkStateToCaches(interVpnLinkState);
    }
}
Also used : InterVpnLink(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.links.InterVpnLink) InterVpnLinkStates(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.InterVpnLinkStates) InterVpnLinkState(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.link.states.InterVpnLinkState) InterVpnLinks(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.InterVpnLinks) PostConstruct(javax.annotation.PostConstruct)

Example 2 with InterVpnLinks

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.InterVpnLinks in project netvirt by opendaylight.

the class InterVpnLinkLocatorTest method setUp.

@Before
public void setUp() throws Exception {
    dataBroker = getDataBroker();
    // Creating both empty containers: InterVpnLinks and InterVpnLinkStates
    WriteTransaction writeTx = dataBroker.newWriteOnlyTransaction();
    writeTx.merge(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.builder(InterVpnLinks.class).build(), new InterVpnLinksBuilder().setInterVpnLink(Collections.emptyList()).build(), true);
    writeTx.merge(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.builder(InterVpnLinkStates.class).build(), new InterVpnLinkStatesBuilder().setInterVpnLinkState(Collections.emptyList()).build(), true);
    writeTx.submit().checkedGet();
    interVpnLinkCache = new InterVpnLinkCacheImpl(dataBroker);
    interVpnLinkCache.initialFeed();
    // Prepare
    populateL3Vpns(dataBroker, L3VpnTestCatalog.ALL_VPNS);
    InterVpnLinkTestCatalog.populateIvpnLinks(dataBroker, ALL_IVPN_LINKS);
    for (InterVpnLinkDataComposite ivl : ALL_IVPN_LINKS) {
        interVpnLinkCache.addInterVpnLinkToCaches(ivl.getInterVpnLinkConfig());
        interVpnLinkCache.addInterVpnLinkStateToCaches(ivl.getInterVpnLinkState());
    }
    // SUT
    sut = new InterVpnLinkLocator(dataBroker, interVpnLinkCache);
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) InterVpnLinksBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.InterVpnLinksBuilder) InterVpnLinkStatesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.InterVpnLinkStatesBuilder) InterVpnLinkDataComposite(org.opendaylight.netvirt.vpnmanager.api.intervpnlink.InterVpnLinkDataComposite) Before(org.junit.Before)

Example 3 with InterVpnLinks

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.InterVpnLinks in project netvirt by opendaylight.

the class NeutronvpnUtils method getInterVpnLinkByEndpointIp.

/**
 * Returns an InterVpnLink by searching by one of its endpoint's IP.
 *
 * @param endpointIp IP to search for
 * @return a InterVpnLink
 */
public Optional<InterVpnLink> getInterVpnLinkByEndpointIp(String endpointIp) {
    InstanceIdentifier<InterVpnLinks> interVpnLinksIid = InstanceIdentifier.builder(InterVpnLinks.class).build();
    Optional<InterVpnLinks> interVpnLinksOpData = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, interVpnLinksIid);
    if (interVpnLinksOpData.isPresent()) {
        List<InterVpnLink> allInterVpnLinks = interVpnLinksOpData.get().getInterVpnLink();
        for (InterVpnLink interVpnLink : allInterVpnLinks) {
            if (interVpnLink.getFirstEndpoint().getIpAddress().getValue().equals(endpointIp) || interVpnLink.getSecondEndpoint().getIpAddress().getValue().equals(endpointIp)) {
                return Optional.of(interVpnLink);
            }
        }
    }
    return Optional.absent();
}
Also used : InterVpnLink(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.links.InterVpnLink) InterVpnLinks(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.InterVpnLinks)

Aggregations

InterVpnLinks (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.InterVpnLinks)2 InterVpnLink (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.links.InterVpnLink)2 PostConstruct (javax.annotation.PostConstruct)1 Before (org.junit.Before)1 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)1 InterVpnLinkDataComposite (org.opendaylight.netvirt.vpnmanager.api.intervpnlink.InterVpnLinkDataComposite)1 InterVpnLinkStates (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.InterVpnLinkStates)1 InterVpnLinkStatesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.InterVpnLinkStatesBuilder)1 InterVpnLinksBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.InterVpnLinksBuilder)1 InterVpnLinkState (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.link.states.InterVpnLinkState)1