use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface in project netvirt by opendaylight.
the class ElanStatisticsImpl method getElanInterfaceStatistics.
@Override
public Future<RpcResult<GetElanInterfaceStatisticsOutput>> getElanInterfaceStatistics(GetElanInterfaceStatisticsInput input) {
String interfaceName = input.getInterfaceName();
LOG.debug("getElanInterfaceStatistics is called for elan interface {}", interfaceName);
RpcResultBuilder<GetElanInterfaceStatisticsOutput> rpcResultBuilder = null;
if (interfaceName == null) {
rpcResultBuilder = RpcResultBuilder.failed();
return getFutureWithAppErrorMessage(rpcResultBuilder, "Interface name is not provided");
}
Optional<ElanInterface> elanInterface = elanInterfaceCache.get(interfaceName);
if (!elanInterface.isPresent()) {
rpcResultBuilder = RpcResultBuilder.failed();
return getFutureWithAppErrorMessage(rpcResultBuilder, String.format("Interface %s is not a ELAN interface", interfaceName));
}
String elanInstanceName = elanInterface.get().getElanInstanceName();
InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(interfaceName);
// FIXME [ELANBE] Get this API Later
short tableId = 0;
// }
if (!interfaceInfo.isOperational()) {
LOG.debug("interface {} is down and returning with no statistics", interfaceName);
rpcResultBuilder = RpcResultBuilder.success();
return Futures.immediateFuture(rpcResultBuilder.withResult(new GetElanInterfaceStatisticsOutputBuilder().setStatResult(new StatResultBuilder().setStatResultCode(ResultCode.NotFound).setByteRxCount(0L).setByteTxCount(0L).setPacketRxCount(0L).setPacketTxCount(0L).build()).build()).build());
}
rpcResultBuilder = RpcResultBuilder.success();
return Futures.immediateFuture(rpcResultBuilder.withResult(queryforElanInterfaceStatistics(tableId, elanInstanceName, interfaceInfo)).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface in project netvirt by opendaylight.
the class ElanUtils method getEgressActionsForInterface.
/**
* Returns the list of Actions to be taken when sending the packet through
* an Elan interface. Note that this interface can refer to an ElanInterface
* where the Elan VM is attached to a DPN or an ITM tunnel interface where
* Elan traffic can be sent through. In this latter case, the tunnelKey is
* mandatory and it can hold serviceId for internal tunnels or the VNI for
* external tunnels.
*
* @param ifName
* the if name
* @param tunnelKey
* the tunnel key
* @return the egress actions for interface
*/
@SuppressWarnings("checkstyle:IllegalCatch")
public List<Action> getEgressActionsForInterface(String ifName, Long tunnelKey) {
List<Action> listAction = new ArrayList<>();
try {
GetEgressActionsForInterfaceInput getEgressActionInput = new GetEgressActionsForInterfaceInputBuilder().setIntfName(ifName).setTunnelKey(tunnelKey).build();
Future<RpcResult<GetEgressActionsForInterfaceOutput>> result = interfaceManagerRpcService.getEgressActionsForInterface(getEgressActionInput);
RpcResult<GetEgressActionsForInterfaceOutput> rpcResult = result.get();
if (!rpcResult.isSuccessful()) {
LOG.debug("RPC Call to Get egress actions for interface {} returned with Errors {}", ifName, rpcResult.getErrors());
} else {
List<Action> actions = rpcResult.getResult().getAction();
listAction = actions;
}
} catch (Exception e) {
LOG.warn("Exception when egress actions for interface {}", ifName, e);
}
return listAction;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface in project netvirt by opendaylight.
the class ElanServiceProvider method addArpResponderFlow.
@Override
public void addArpResponderFlow(ArpResponderInput arpResponderInput) {
String ingressInterfaceName = arpResponderInput.getInterfaceName();
String macAddress = arpResponderInput.getSha();
String ipAddress = arpResponderInput.getSpa();
int lportTag = arpResponderInput.getLportTag();
BigInteger dpnId = arpResponderInput.getDpId();
LOG.info("Installing the ARP responder flow on DPN {} for Interface {} with MAC {} & IP {}", dpnId, ingressInterfaceName, macAddress, ipAddress);
Optional<ElanInterface> elanIface = elanInterfaceCache.get(ingressInterfaceName);
ElanInstance elanInstance = elanIface.isPresent() ? elanInstanceCache.get(elanIface.get().getElanInstanceName()).orNull() : null;
if (elanInstance == null) {
LOG.debug("addArpResponderFlow: elanInstance is null, Failed to install arp responder flow for dpnId {}" + "for Interface {} with MAC {} & IP {}", dpnId, ingressInterfaceName, macAddress, ipAddress);
return;
}
String flowId = ArpResponderUtil.getFlowId(lportTag, ipAddress);
ArpResponderUtil.installFlow(mdsalManager, dpnId, flowId, flowId, NwConstants.DEFAULT_ARP_FLOW_PRIORITY, ArpResponderUtil.generateCookie(lportTag, ipAddress), ArpResponderUtil.getMatchCriteria(lportTag, elanInstance, ipAddress), arpResponderInput.getInstructions());
LOG.info("Installed the ARP Responder flow for Interface {}", ingressInterfaceName);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface in project netvirt by opendaylight.
the class ElanServiceProvider method addStaticMacAddress.
@Override
public void addStaticMacAddress(String interfaceName, String macAddress) {
Optional<ElanInterface> existingElanInterface = elanInterfaceCache.get(interfaceName);
if (existingElanInterface.isPresent()) {
StaticMacEntriesBuilder staticMacEntriesBuilder = new StaticMacEntriesBuilder();
StaticMacEntries staticMacEntry = staticMacEntriesBuilder.setMacAddress(new PhysAddress(macAddress)).build();
InstanceIdentifier<StaticMacEntries> staticMacEntriesIdentifier = ElanUtils.getStaticMacEntriesCfgDataPathIdentifier(interfaceName, macAddress);
MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, staticMacEntriesIdentifier, staticMacEntry);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface in project netvirt by opendaylight.
the class ElanServiceProvider method getElanMacTable.
@Override
public Collection<MacEntry> getElanMacTable(String elanInstanceName) {
Elan elanInfo = ElanUtils.getElanByName(broker, elanInstanceName);
List<MacEntry> macAddress = new ArrayList<>();
if (elanInfo == null) {
return macAddress;
}
List<String> elanInterfaces = elanInfo.getElanInterfaces();
if (elanInterfaces != null && elanInterfaces.size() > 0) {
for (String elanInterface : elanInterfaces) {
ElanInterfaceMac elanInterfaceMac = elanUtils.getElanInterfaceMacByInterfaceName(elanInterface);
if (elanInterfaceMac != null && elanInterfaceMac.getMacEntry() != null && elanInterfaceMac.getMacEntry().size() > 0) {
macAddress.addAll(elanInterfaceMac.getMacEntry());
}
}
}
return macAddress;
}
Aggregations