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);
}
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;
}
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());
}
}
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);
}
}
}
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);
}
Aggregations