Search in sources :

Example 26 with Bgpvpn

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.bgpvpns.rev150903.bgpvpns.attributes.bgpvpns.Bgpvpn in project netvirt by opendaylight.

the class NeutronvpnManager method updateVpnInternetForSubnet.

protected void updateVpnInternetForSubnet(Subnetmap sm, Uuid vpn, boolean isBeingAssociated) {
    LOG.debug("updateVpnInternetForSubnet: {} subnet {} with BGPVPN Internet {} ", isBeingAssociated ? "associating" : "dissociating", sm.getSubnetIp(), vpn.getValue());
    Uuid internalVpnId = sm.getVpnId();
    if (internalVpnId == null) {
        LOG.error("updateVpnInternetForSubnet: can not find Internal or BGPVPN Id for subnet {}, bailing out", sm.getId().getValue());
        return;
    }
    if (isBeingAssociated) {
        updateSubnetNode(sm.getId(), null, sm.getVpnId(), vpn);
    } else {
        updateSubnetNode(sm.getId(), null, sm.getVpnId(), null);
    }
    jobCoordinator.enqueueJob("VPN-" + vpn.getValue(), () -> singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, wrtConfigTxn -> {
        if (isBeingAssociated) {
            updateVpnInterface(vpn, null, neutronvpnUtils.getNeutronPort(sm.getRouterInterfacePortId()), true, true, wrtConfigTxn, true);
        } else {
            removeInternetVpnFromVpnInterface(vpn, neutronvpnUtils.getNeutronPort(sm.getRouterInterfacePortId()), wrtConfigTxn, sm);
        }
    })));
    // Check for ports on this subnet and update association of
    // corresponding vpn-interfaces to internet vpn
    List<Uuid> portList = sm.getPortList();
    if (portList != null) {
        for (Uuid port : portList) {
            LOG.debug("Updating vpn-interface for port {} isBeingAssociated {}", port.getValue(), isBeingAssociated);
            jobCoordinator.enqueueJob("PORT-" + port.getValue(), () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
                if (isBeingAssociated) {
                    updateVpnInterface(vpn, null, neutronvpnUtils.getNeutronPort(port), true, false, tx, true);
                } else {
                    removeInternetVpnFromVpnInterface(vpn, neutronvpnUtils.getNeutronPort(port), tx, sm);
                }
            })));
        }
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)

Aggregations

Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)18 ArrayList (java.util.ArrayList)12 AcquireResult (org.opendaylight.infrautils.utils.concurrent.NamedSimpleReentrantLock.AcquireResult)7 Subnetmap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)7 HashSet (java.util.HashSet)5 VpnInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance)5 List (java.util.List)4 IpVersionChoice (org.opendaylight.netvirt.neutronvpn.api.enums.IpVersionChoice)4 VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)4 ExecutionException (java.util.concurrent.ExecutionException)3 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 Collections.emptyList (java.util.Collections.emptyList)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 PreDestroy (javax.annotation.PreDestroy)2 Inject (javax.inject.Inject)2 Singleton (javax.inject.Singleton)2 NonNull (org.eclipse.jdt.annotation.NonNull)2 Executors (org.opendaylight.infrautils.utils.concurrent.Executors)2 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)2