use of org.opendaylight.yang.gen.v1.urn.opendaylight.coe.northbound.pod.rev170611.pod_attributes.Interface in project netvirt by opendaylight.
the class ElanServiceProvider method addEtreeInterface.
@Override
public void addEtreeInterface(String etreeInstanceName, String interfaceName, EtreeInterfaceType interfaceType, List<String> staticMacAddresses, String description) {
Optional<ElanInstance> existingElanInstance = elanInstanceCache.get(etreeInstanceName);
if (existingElanInstance.isPresent() && existingElanInstance.get().getAugmentation(EtreeInstance.class) != null) {
EtreeInterface etreeInterface = new EtreeInterfaceBuilder().setEtreeInterfaceType(interfaceType).build();
ElanInterface elanInterface;
if (staticMacAddresses == null) {
elanInterface = new ElanInterfaceBuilder().setElanInstanceName(etreeInstanceName).setDescription(description).setName(interfaceName).setKey(new ElanInterfaceKey(interfaceName)).addAugmentation(EtreeInterface.class, etreeInterface).build();
} else {
List<StaticMacEntries> staticMacEntries = ElanUtils.getStaticMacEntries(staticMacAddresses);
elanInterface = new ElanInterfaceBuilder().setElanInstanceName(etreeInstanceName).setDescription(description).setName(interfaceName).setStaticMacEntries(staticMacEntries).setKey(new ElanInterfaceKey(interfaceName)).addAugmentation(EtreeInterface.class, etreeInterface).build();
}
MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, ElanUtils.getElanInterfaceConfigurationDataPathId(interfaceName), elanInterface);
LOG.debug("Creating the new Etree Interface {}", elanInterface);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.coe.northbound.pod.rev170611.pod_attributes.Interface in project netvirt by opendaylight.
the class ElanSmacFlowEventListener method onFlowRemoved.
@Override
public void onFlowRemoved(FlowRemoved flowRemoved) {
short tableId = flowRemoved.getTableId();
if (tableId == NwConstants.ELAN_SMAC_TABLE) {
BigInteger metadata = flowRemoved.getMatch().getMetadata().getMetadata();
long elanTag = MetaDataUtil.getElanTagFromMetadata(metadata);
ElanTagName elanTagInfo = elanUtils.getElanInfoByElanTag(elanTag);
if (elanTagInfo == null) {
return;
}
final String srcMacAddress = flowRemoved.getMatch().getEthernetMatch().getEthernetSource().getAddress().getValue().toUpperCase(Locale.getDefault());
int portTag = MetaDataUtil.getLportFromMetadata(metadata).intValue();
if (portTag == 0) {
LOG.debug("Flow removed event on SMAC flow entry. But having port Tag as 0 ");
return;
}
Optional<IfIndexInterface> existingInterfaceInfo = elanUtils.getInterfaceInfoByInterfaceTag(portTag);
if (!existingInterfaceInfo.isPresent()) {
LOG.debug("Interface is not available for port Tag {}", portTag);
return;
}
String interfaceName = existingInterfaceInfo.get().getInterfaceName();
PhysAddress physAddress = new PhysAddress(srcMacAddress);
if (interfaceName == null) {
LOG.error("LPort record not found for tag {}", portTag);
return;
}
jobCoordinator.enqueueJob(ElanUtils.getElanInterfaceJobKey(interfaceName), () -> {
List<ListenableFuture<Void>> elanFutures = new ArrayList<>();
MacEntry macEntry = elanUtils.getInterfaceMacEntriesOperationalDataPath(interfaceName, physAddress);
InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(interfaceName);
String elanInstanceName = elanTagInfo.getName();
LOG.info("Deleting the Mac-Entry:{} present on ElanInstance:{}", macEntry, elanInstanceName);
if (macEntry != null && interfaceInfo != null) {
ListenableFuture<Void> result = txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> elanUtils.deleteMacFlows(elanInstanceCache.get(elanInstanceName).orNull(), interfaceInfo, macEntry, tx));
elanFutures.add(result);
addCallBack(result, srcMacAddress);
}
InstanceIdentifier<MacEntry> macEntryIdForElanInterface = ElanUtils.getInterfaceMacEntriesIdentifierOperationalDataPath(interfaceName, physAddress);
Optional<MacEntry> existingInterfaceMacEntry = ElanUtils.read(broker, LogicalDatastoreType.OPERATIONAL, macEntryIdForElanInterface);
if (existingInterfaceMacEntry.isPresent()) {
ListenableFuture<Void> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
tx.delete(LogicalDatastoreType.OPERATIONAL, macEntryIdForElanInterface);
MacEntry macEntryInElanInstance = elanUtils.getMacEntryForElanInstance(elanInstanceName, physAddress).orNull();
if (macEntryInElanInstance != null && macEntryInElanInstance.getInterface().equals(interfaceName)) {
InstanceIdentifier<MacEntry> macEntryIdForElanInstance = ElanUtils.getMacEntryOperationalDataPath(elanInstanceName, physAddress);
tx.delete(LogicalDatastoreType.OPERATIONAL, macEntryIdForElanInstance);
}
});
elanFutures.add(future);
addCallBack(future, srcMacAddress);
}
return elanFutures;
}, ElanConstants.JOB_MAX_RETRIES);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.coe.northbound.pod.rev170611.pod_attributes.Interface in project netvirt by opendaylight.
the class VpnElanInterfaceChangeListener method add.
@Override
protected void add(InstanceIdentifier<ElanInterface> key, ElanInterface elanInterface) {
String interfaceName = elanInterface.getName();
if (!elanService.isExternalInterface(interfaceName)) {
LOG.debug("add: Interface {} is not external. Ignoring", interfaceName);
return;
}
Uuid networkId;
try {
networkId = new Uuid(elanInterface.getElanInstanceName());
} catch (IllegalArgumentException e) {
LOG.debug("add: ELAN instance {} for interface {} is not Uuid", elanInterface.getElanInstanceName(), elanInterface.getName());
return;
}
Uuid vpnId = VpnUtil.getExternalNetworkVpnId(broker, networkId);
if (vpnId == null) {
LOG.debug("add: Network {} is not external or vpn-id missing. Ignoring interface {} on elan {}", networkId.getValue(), elanInterface.getName(), elanInterface.getElanInstanceName());
return;
}
VpnInstanceNames vpnInstance = VpnHelper.getVpnInterfaceVpnInstanceNames(vpnId.getValue(), AssociatedSubnetType.V4AndV6Subnets);
List<VpnInstanceNames> listVpn = new ArrayList<>();
listVpn.add(vpnInstance);
VpnInterface vpnInterface = new VpnInterfaceBuilder().setKey(new VpnInterfaceKey(interfaceName)).setVpnInstanceNames(listVpn).setScheduledForRemove(Boolean.FALSE).build();
InstanceIdentifier<VpnInterface> vpnInterfaceIdentifier = VpnUtil.getVpnInterfaceIdentifier(interfaceName);
VpnUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, vpnInterfaceIdentifier, vpnInterface);
LOG.info("add: Added VPN interface {} with VPN-id {} elanInstance {}", interfaceName, vpnId.getValue(), elanInterface.getElanInstanceName());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.coe.northbound.pod.rev170611.pod_attributes.Interface in project netvirt by opendaylight.
the class VpnInterfaceManager method removeAdjacencyFromBgpvpn.
private void removeAdjacencyFromBgpvpn(Adjacency nextHop, List<String> nhList, String vpnName, String primaryRd, BigInteger dpnId, String rd, String interfaceName, WriteTransaction writeConfigTxn) {
List<VpnInstanceOpDataEntry> vpnsToImportRoute = VpnUtil.getVpnsImportingMyRoute(dataBroker, vpnName);
nhList.forEach((nh) -> {
// IRT: remove routes from other vpns importing it
vpnManager.removePrefixFromBGP(primaryRd, rd, vpnName, nextHop.getIpAddress(), nextHop.getNextHopIpList().get(0), nh, dpnId, writeConfigTxn);
for (VpnInstanceOpDataEntry vpn : vpnsToImportRoute) {
String vpnRd = vpn.getVrfId();
if (vpnRd != null) {
fibManager.removeOrUpdateFibEntry(vpnRd, nextHop.getIpAddress(), nh, writeConfigTxn);
LOG.info("removeAdjacenciesFromVpn: Removed Exported route with rd {}" + " prefix {} nextHop {} from VPN {} parentVpn {}" + " for interface {} on dpn {}", vpnRd, nextHop.getIpAddress(), nh, vpn.getVpnInstanceName(), vpnName, interfaceName, dpnId);
}
}
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.coe.northbound.pod.rev170611.pod_attributes.Interface in project netvirt by opendaylight.
the class VpnInterfaceManager method updateVpnInterfaceOnTepAdd.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public void updateVpnInterfaceOnTepAdd(VpnInterfaceOpDataEntry vpnInterface, StateTunnelList stateTunnelList, WriteTransaction writeConfigTxn, WriteTransaction writeOperTxn) {
String srcTepIp = String.valueOf(stateTunnelList.getSrcInfo().getTepIp().getValue());
BigInteger srcDpnId = new BigInteger(stateTunnelList.getSrcInfo().getTepDeviceId());
AdjacenciesOp adjacencies = vpnInterface.getAugmentation(AdjacenciesOp.class);
List<Adjacency> adjList = adjacencies != null ? adjacencies.getAdjacency() : new ArrayList<>();
if (adjList.isEmpty()) {
LOG.trace("updateVpnInterfaceOnTepAdd: Adjacencies are empty for vpnInterface {} on dpn {}", vpnInterface, srcDpnId);
return;
}
String prefix = null;
long label = 0;
List<Adjacency> value = new ArrayList<>();
boolean isNextHopAddReqd = false;
String vpnName = vpnInterface.getVpnInstanceName();
long vpnId = VpnUtil.getVpnId(dataBroker, vpnName);
String primaryRd = VpnUtil.getPrimaryRd(dataBroker, vpnName);
LOG.info("updateVpnInterfaceOnTepAdd: AdjacencyList for interface {} on dpn {} vpn {} is {}", vpnInterface.getName(), vpnInterface.getDpnId(), vpnInterface.getVpnInstanceName(), adjList);
for (Adjacency adj : adjList) {
String rd = adj.getVrfId();
rd = rd != null ? rd : vpnName;
prefix = adj.getIpAddress();
label = adj.getLabel();
List<String> nhList = Collections.singletonList(srcTepIp);
List<String> nextHopList = adj.getNextHopIpList();
// Secondary adj nexthop is already pointing to primary adj IP address.
if (nextHopList != null && !nextHopList.isEmpty() && nextHopList.get(0).equalsIgnoreCase(srcTepIp)) {
/* everything right already */
} else {
isNextHopAddReqd = true;
}
if (adj.getAdjacencyType() == AdjacencyType.PrimaryAdjacency) {
value.add(new AdjacencyBuilder(adj).setNextHopIpList(nhList).build());
} else {
Optional<VrfEntry> vrfEntryOptional = FibHelper.getVrfEntry(dataBroker, primaryRd, prefix);
if (!vrfEntryOptional.isPresent()) {
continue;
}
nhList = FibHelper.getNextHopListFromRoutePaths(vrfEntryOptional.get());
if (!nhList.contains(srcTepIp)) {
nhList.add(srcTepIp);
isNextHopAddReqd = true;
}
value.add(adj);
}
if (isNextHopAddReqd) {
updateLabelMapper(label, nhList);
LOG.info("updateVpnInterfaceOnTepAdd: Updated label mapper : label {} dpn {} prefix {} nexthoplist {}" + " vpn {} vpnid {} rd {} interface {}", label, srcDpnId, prefix, nhList, vpnInterface.getVpnInstanceName(), vpnId, rd, vpnInterface.getName());
// Update the VRF entry with nextHop
fibManager.updateRoutePathForFibEntry(primaryRd, prefix, srcTepIp, label, true, writeConfigTxn);
// Get the list of VPN's importing this route(prefix) .
// Then update the VRF entry with nhList
List<VpnInstanceOpDataEntry> vpnsToImportRoute = VpnUtil.getVpnsImportingMyRoute(dataBroker, vpnName);
for (VpnInstanceOpDataEntry vpn : vpnsToImportRoute) {
String vpnRd = vpn.getVrfId();
if (vpnRd != null) {
fibManager.updateRoutePathForFibEntry(vpnRd, prefix, srcTepIp, label, true, writeConfigTxn);
LOG.info("updateVpnInterfaceOnTepAdd: Exported route with rd {} prefix {} nhList {} label {}" + " interface {} dpn {} from vpn {} to VPN {} vpnRd {}", rd, prefix, nhList, label, vpnInterface.getName(), srcDpnId, vpnName, vpn.getVpnInstanceName(), vpnRd);
}
}
// since there is a nexthop change.
try {
if (!rd.equalsIgnoreCase(vpnName)) {
bgpManager.advertisePrefix(rd, null, /*macAddress*/
prefix, nhList, VrfEntry.EncapType.Mplsgre, (int) label, 0, /*evi*/
0, /*l2vni*/
null);
}
LOG.info("updateVpnInterfaceOnTepAdd: Advertised rd {} prefix {} nhList {} label {}" + " for interface {} on dpn {} vpn {}", rd, prefix, nhList, label, vpnInterface.getName(), srcDpnId, vpnName);
} catch (Exception ex) {
LOG.error("updateVpnInterfaceOnTepAdd: Exception when advertising prefix {} nh {} label {}" + " on rd {} for interface {} on dpn {} vpn {}", prefix, nhList, label, rd, vpnInterface.getName(), srcDpnId, vpnName, ex);
}
}
}
AdjacenciesOp aug = VpnUtil.getVpnInterfaceOpDataEntryAugmentation(value);
VpnInterfaceOpDataEntry opInterface = new VpnInterfaceOpDataEntryBuilder(vpnInterface).setKey(new VpnInterfaceOpDataEntryKey(vpnInterface.getName(), vpnName)).addAugmentation(AdjacenciesOp.class, aug).build();
InstanceIdentifier<VpnInterfaceOpDataEntry> interfaceId = VpnUtil.getVpnInterfaceOpDataEntryIdentifier(vpnInterface.getName(), vpnName);
writeOperTxn.put(LogicalDatastoreType.OPERATIONAL, interfaceId, opInterface, WriteTransaction.CREATE_MISSING_PARENTS);
LOG.info("updateVpnInterfaceOnTepAdd: interface {} updated successully on tep add on dpn {} vpn {}", vpnInterface.getName(), srcDpnId, vpnName);
}
Aggregations