Search in sources :

Example 86 with Subnet

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet in project netvirt by opendaylight.

the class VpnInterfaceManager method removeGwMacAndArpResponderFlows.

private void removeGwMacAndArpResponderFlows(Adjacency nextHop, long vpnId, BigInteger dpnId, int lportTag, String gwMac, String interfaceName, WriteTransaction writeInvTxn) {
    final Uuid subnetId = nextHop.getSubnetId();
    if (nextHop.getSubnetGatewayMacAddress() == null) {
        // A valid mac-address was not available for this subnet-gateway-ip
        // So a connected-mac-address was used for this subnet and we need
        // to remove the flows for the same here from the L3_GW_MAC_TABLE.
        VpnUtil.setupGwMacIfExternalVpn(dataBroker, mdsalManager, dpnId, interfaceName, vpnId, writeInvTxn, NwConstants.DEL_FLOW, gwMac);
    }
    arpResponderHandler.removeArpResponderFlow(dpnId, lportTag, interfaceName, nextHop.getSubnetGatewayIp(), subnetId);
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)

Example 87 with Subnet

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet in project netvirt by opendaylight.

the class VpnUtil method getVpnSubnetGatewayIp.

public static Optional<String> getVpnSubnetGatewayIp(DataBroker dataBroker, final Uuid subnetUuid) {
    Optional<String> gwIpAddress = Optional.absent();
    final SubnetKey subnetkey = new SubnetKey(subnetUuid);
    final InstanceIdentifier<Subnet> subnetidentifier = InstanceIdentifier.create(Neutron.class).child(Subnets.class).child(Subnet.class, subnetkey);
    final Optional<Subnet> subnet = read(dataBroker, LogicalDatastoreType.CONFIGURATION, subnetidentifier);
    if (subnet.isPresent()) {
        Class<? extends IpVersionBase> ipVersionBase = subnet.get().getIpVersion();
        if (ipVersionBase.equals(IpVersionV4.class)) {
            LOG.trace("getVpnSubnetGatewayIp: Obtained subnet {} for vpn interface", subnet.get().getUuid().getValue());
            IpAddress gwIp = subnet.get().getGatewayIp();
            if (gwIp != null && gwIp.getIpv4Address() != null) {
                gwIpAddress = Optional.of(gwIp.getIpv4Address().getValue());
            }
        }
    }
    return gwIpAddress;
}
Also used : ExternalSubnets(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalSubnets) Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets) SubnetKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.SubnetKey) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Subnet(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet)

Example 88 with Subnet

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet in project netvirt by opendaylight.

the class VpnUtil method unlockSubnet.

// We store the cause, which is what we really care about
@SuppressWarnings("checkstyle:AvoidHidingCauseException")
public static void unlockSubnet(LockManagerService lockManager, String subnetId) {
    UnlockInput input = new UnlockInputBuilder().setLockName(subnetId).build();
    Future<RpcResult<Void>> result = lockManager.unlock(input);
    try {
        if (result != null && result.get().isSuccessful()) {
            LOG.debug("unlockSubnet: Unlocked {}", subnetId);
        } else {
            LOG.debug("unlockSubnet: Unable to unlock subnet {}", subnetId);
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("unlockSubnet: Unable to unlock subnet {}", subnetId);
        throw new RuntimeException(String.format("Unable to unlock subnetId %s", subnetId), e.getCause());
    }
}
Also used : UnlockInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.UnlockInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) UnlockInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.UnlockInputBuilder) ExecutionException(java.util.concurrent.ExecutionException)

Example 89 with Subnet

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet in project netvirt by opendaylight.

the class VpnSubnetRouteHandler method electNewDpnForSubnetRoute.

// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
private void electNewDpnForSubnetRoute(SubnetOpDataEntryBuilder subOpBuilder, BigInteger oldDpnId, Uuid subnetId, Uuid networkId, boolean isBgpVpn) {
    List<SubnetToDpn> subDpnList = null;
    boolean isRouteAdvertised = false;
    subDpnList = subOpBuilder.getSubnetToDpn();
    String rd = subOpBuilder.getVrfId();
    String subnetIp = subOpBuilder.getSubnetCidr();
    String vpnName = subOpBuilder.getVpnName();
    long elanTag = subOpBuilder.getElanTag();
    boolean isAlternateDpnSelected = false;
    long l3vni = 0;
    long label = 0;
    String networkName = networkId != null ? networkId.getValue() : null;
    LOG.info("{} electNewDpnForSubnetRoute: Handling subnet {} subnetIp {} vpn {} rd {} TaskState {}" + " lastTaskState {}", LOGGING_PREFIX, subnetId.getValue(), subnetIp, subOpBuilder.getVpnName(), subOpBuilder.getVrfId(), subOpBuilder.getRouteAdvState(), subOpBuilder.getLastAdvState());
    if (!isBgpVpn) {
        // blended more better into this design.
        if (VpnUtil.isL3VpnOverVxLan(subOpBuilder.getL3vni())) {
            l3vni = subOpBuilder.getL3vni();
        } else {
            label = getLabel(rd, subnetIp);
            subOpBuilder.setLabel(label);
        }
        isRouteAdvertised = addSubnetRouteToFib(rd, subnetIp, null, /* nhDpnId */
        null, /* nhTepIp */
        vpnName, elanTag, label, l3vni, subnetId, isBgpVpn, networkName);
        if (isRouteAdvertised) {
            subOpBuilder.setRouteAdvState(TaskState.Advertised);
        } else {
            LOG.error("{} electNewDpnForSubnetRoute: Unable to find TepIp for subnet {} subnetip {} vpnName {}" + " rd {}, attempt next dpn", LOGGING_PREFIX, subnetId.getValue(), subnetIp, vpnName, rd);
            subOpBuilder.setRouteAdvState(TaskState.PendingAdvertise);
        }
        return;
    }
    String nhTepIp = null;
    BigInteger nhDpnId = null;
    Iterator<SubnetToDpn> subnetDpnIter = subDpnList.iterator();
    while (subnetDpnIter.hasNext()) {
        SubnetToDpn subnetToDpn = subnetDpnIter.next();
        if (subnetToDpn.getDpnId().equals(oldDpnId)) {
            // Is this same is as input dpnId, then ignore it
            continue;
        }
        nhDpnId = subnetToDpn.getDpnId();
        if (vpnNodeListener.isConnectedNode(nhDpnId)) {
            // but does it have a TEP configured at all?
            try {
                nhTepIp = InterfaceUtils.getEndpointIpAddressForDPN(dataBroker, nhDpnId);
                if (nhTepIp != null) {
                    isAlternateDpnSelected = true;
                    break;
                }
            } catch (Exception e) {
                LOG.warn("{} electNewDpnForSubnetRoute: Unable to find TepIp for rd {} subnetroute subnetip {}" + " for dpnid {}, attempt next", LOGGING_PREFIX, rd, subnetIp, nhDpnId.toString(), e);
                continue;
            }
        }
    }
    if (!isAlternateDpnSelected) {
        // If no alternate Dpn is selected as nextHopDpn, withdraw the subnetroute if it had a nextHop already.
        if (isRouteAdvertised(subOpBuilder) && oldDpnId != null) {
            LOG.info("{} electNewDpnForSubnetRoute: No alternate DPN available for subnet {} subnetIp {} vpn {}" + " rd {} Prefix withdrawn from BGP", LOGGING_PREFIX, subnetId.getValue(), subnetIp, vpnName, rd);
            // Withdraw route from BGP for this subnet
            boolean routeWithdrawn = deleteSubnetRouteFromFib(rd, subnetIp, vpnName, isBgpVpn);
            subOpBuilder.setNhDpnId(null);
            subOpBuilder.setLastAdvState(subOpBuilder.getRouteAdvState());
            if (routeWithdrawn) {
                subOpBuilder.setRouteAdvState(TaskState.Withdrawn);
            } else {
                LOG.error("{} electNewDpnForSubnetRoute: Withdrawing NextHopDPN {} for subnet {} subnetIp {}" + " vpn {} rd {} from BGP failed", LOGGING_PREFIX, oldDpnId, subnetId.getValue(), subnetIp, vpnName, rd);
                subOpBuilder.setRouteAdvState(TaskState.PendingWithdraw);
            }
        }
    } else {
        // If alternate Dpn is selected as nextHopDpn, use that for subnetroute.
        subOpBuilder.setNhDpnId(nhDpnId);
        if (VpnUtil.isL3VpnOverVxLan(subOpBuilder.getL3vni())) {
            l3vni = subOpBuilder.getL3vni();
        } else {
            label = getLabel(rd, subnetIp);
            subOpBuilder.setLabel(label);
        }
        // update the VRF entry for the subnetroute.
        isRouteAdvertised = addSubnetRouteToFib(rd, subnetIp, nhDpnId, nhTepIp, vpnName, elanTag, label, l3vni, subnetId, isBgpVpn, networkName);
        subOpBuilder.setLastAdvState(subOpBuilder.getRouteAdvState());
        if (isRouteAdvertised) {
            subOpBuilder.setRouteAdvState(TaskState.Advertised);
        } else {
            LOG.error("{} electNewDpnForSubnetRoute: Swapping to add new NextHopDpn {} for subnet {} subnetIp {}" + " vpn {} rd {} failed", LOGGING_PREFIX, nhDpnId, subnetId.getValue(), subnetIp, vpnName, rd);
            subOpBuilder.setRouteAdvState(TaskState.PendingAdvertise);
        }
    }
}
Also used : BigInteger(java.math.BigInteger) SubnetToDpn(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.SubnetToDpn)

Example 90 with Subnet

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet in project netvirt by opendaylight.

the class VpnSubnetRouteHandler method onSubnetUpdatedInVpn.

public void onSubnetUpdatedInVpn(Subnetmap subnetmap, Long elanTag) {
    Uuid subnetId = subnetmap.getId();
    String vpnName = subnetmap.getVpnId().getValue();
    String subnetIp = subnetmap.getSubnetIp();
    Preconditions.checkNotNull(subnetId, LOGGING_PREFIX + " onSubnetUpdatedInVpn: SubnetId cannot be null or empty!");
    Preconditions.checkNotNull(subnetIp, LOGGING_PREFIX + " onSubnetUpdatedInVpn: SubnetPrefix cannot be null or empty!");
    Preconditions.checkNotNull(vpnName, LOGGING_PREFIX + " onSubnetUpdatedInVpn: VpnName cannot be null or empty!");
    Preconditions.checkNotNull(elanTag, LOGGING_PREFIX + " onSubnetUpdatedInVpn: ElanTag cannot be null or empty!");
    InstanceIdentifier<SubnetOpDataEntry> subOpIdentifier = InstanceIdentifier.builder(SubnetOpData.class).child(SubnetOpDataEntry.class, new SubnetOpDataEntryKey(subnetId)).build();
    Optional<SubnetOpDataEntry> optionalSubs = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, subOpIdentifier);
    if (optionalSubs.isPresent()) {
        onSubnetDeletedFromVpn(subnetmap, true);
    } else {
        onSubnetAddedToVpn(subnetmap, true, elanTag);
    }
    LOG.info("{} onSubnetUpdatedInVpn: subnet {} with Ip {} updated successfully for vpn {}", LOGGING_PREFIX, subnetId.getValue(), subnetIp, vpnName);
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) SubnetOpDataEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.SubnetOpDataEntryKey) SubnetOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.SubnetOpDataEntry)

Aggregations

Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)72 ArrayList (java.util.ArrayList)44 BigInteger (java.math.BigInteger)30 Subnetmap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)28 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)25 SubnetOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.SubnetOpDataEntry)17 Subnet (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet)15 SubnetOpDataEntryKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.SubnetOpDataEntryKey)13 List (java.util.List)12 ExecutionException (java.util.concurrent.ExecutionException)12 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)12 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)11 FixedIps (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps)11 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)10 UnknownHostException (java.net.UnknownHostException)10 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps)10 VpnInterface (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface)9 ExternalSubnets (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalSubnets)9 HashMap (java.util.HashMap)8 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)8