use of org.opendaylight.genius.interfacemanager.globals.InterfaceInfo in project genius by opendaylight.
the class ItmTunnelAggregationHelper method getAggregatedOperStatus.
private OperStatus getAggregatedOperStatus(Interface ifaceState, InterfaceParentEntry parentEntry) {
String logicalTunnelName = parentEntry.getParentInterface();
if (!logicalTunnelName.equals(ifaceState.getName()) && ifaceState.getOperStatus() == OperStatus.Up) {
return OperStatus.Up;
}
List<InterfaceChildEntry> interfaceChildEntries = parentEntry.getInterfaceChildEntry();
if (interfaceChildEntries == null || interfaceChildEntries.isEmpty()) {
LOG.debug("MULTIPLE_VxLAN_TUNNELS: OperStatus is Down, because of the empty child list in group {}", parentEntry.getParentInterface());
return OperStatus.Down;
}
for (InterfaceChildEntry interfaceChildEntry : interfaceChildEntries) {
String curChildInterface = interfaceChildEntry.getChildInterface();
if (!curChildInterface.equals(ifaceState.getName())) {
InterfaceInfo ifInfo = interfaceManager.getInterfaceInfoFromOperationalDataStore(curChildInterface);
if (ifInfo != null && InterfaceInfo.InterfaceOpState.UP.equals(ifInfo.getOpState())) {
return OperStatus.Up;
}
}
}
return OperStatus.Down;
}
use of org.opendaylight.genius.interfacemanager.globals.InterfaceInfo in project genius by opendaylight.
the class ItmTunnelAggregationHelper method updateLogicalTunnelGroupOperStatus.
private void updateLogicalTunnelGroupOperStatus(String logicalTunnelIfaceName, Interface ifaceState, InterfaceParentEntry parentEntry, ReadWriteTransaction tx) throws ReadFailedException {
if (parentEntry == null) {
LOG.debug("MULTIPLE_VxLAN_TUNNELS: uninitialized parent entry {}", logicalTunnelIfaceName);
return;
}
OperStatus newOperStatus = getAggregatedOperStatus(ifaceState, parentEntry);
if (logicalTunnelIfaceName.equals(ifaceState.getName())) {
// the current interface is logical tunnel itself
if (ifaceState.getOperStatus() != newOperStatus) {
updateInterfaceOperStatus(logicalTunnelIfaceName, ifaceState, newOperStatus, tx);
}
} else {
InterfaceInfo ifLogicInfo = interfaceManager.getInterfaceInfoFromOperationalDataStore(logicalTunnelIfaceName);
if (isLogicalTunnelStateUpdateNeeded(newOperStatus, ifLogicInfo)) {
InstanceIdentifier<Interface> id = ItmUtils.buildStateInterfaceId(logicalTunnelIfaceName);
Optional<Interface> ifState = tx.read(LogicalDatastoreType.OPERATIONAL, id).checkedGet();
if (ifState.isPresent()) {
Interface ifStateLogicTunnel = ifState.get();
updateInterfaceOperStatus(logicalTunnelIfaceName, ifStateLogicTunnel, newOperStatus, tx);
}
}
}
}
use of org.opendaylight.genius.interfacemanager.globals.InterfaceInfo in project genius by opendaylight.
the class IfmUtil method getEgressActionInfosForInterface.
/**
* Returns a list of Actions to be taken when sending a packet over an
* interface.
*
* @param interfaceName
* name of the interface
* @param tunnelKey
* Optional.
* @param actionKeyStart
* action key
* @param interfaceUtils
* InterfaceManagerCommonUtils
* @return list of actions
*/
public static List<ActionInfo> getEgressActionInfosForInterface(String interfaceName, Long tunnelKey, int actionKeyStart, InterfaceManagerCommonUtils interfaceUtils, Boolean isDefaultEgress) {
Interface interfaceInfo = interfaceUtils.getInterfaceFromConfigDS(new InterfaceKey(interfaceName));
if (interfaceInfo == null) {
throw new NullPointerException("Interface information not present in config DS for " + interfaceName);
}
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = interfaceUtils.getInterfaceState(interfaceName);
if (ifState == null) {
throw new NullPointerException("Interface information not present in oper DS for " + interfaceName);
}
String lowerLayerIf = ifState.getLowerLayerIf().get(0);
NodeConnectorId nodeConnectorId = new NodeConnectorId(lowerLayerIf);
String portNo = IfmUtil.getPortNoFromNodeConnectorId(nodeConnectorId);
InterfaceInfo.InterfaceType ifaceType = getInterfaceType(interfaceInfo);
return getEgressActionInfosForInterface(interfaceInfo, portNo, ifaceType, tunnelKey, actionKeyStart, isDefaultEgress, ifState.getIfIndex(), 0);
}
use of org.opendaylight.genius.interfacemanager.globals.InterfaceInfo in project genius by opendaylight.
the class InterfacemgrProvider method getInterfaceInfo.
@Override
public InterfaceInfo getInterfaceInfo(String interfaceName) {
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = interfaceManagerCommonUtils.getInterfaceState(interfaceName);
if (ifState == null) {
LOG.debug("Interface {} is not present", interfaceName);
return null;
}
Interface intf = interfaceManagerCommonUtils.getInterfaceFromConfigDS(new InterfaceKey(interfaceName));
if (intf == null) {
LOG.error("Interface {} doesn't exist in config datastore", interfaceName);
return null;
}
NodeConnectorId ncId = FlowBasedServicesUtils.getNodeConnectorIdFromInterface(intf.getName(), interfaceManagerCommonUtils);
InterfaceInfo.InterfaceType interfaceType = IfmUtil.getInterfaceType(intf);
InterfaceInfo interfaceInfo = new InterfaceInfo(interfaceName);
BigInteger dpId = org.opendaylight.genius.interfacemanager.globals.IfmConstants.INVALID_DPID;
Integer portNo = org.opendaylight.genius.interfacemanager.globals.IfmConstants.INVALID_PORT_NO;
if (ncId != null) {
dpId = IfmUtil.getDpnFromNodeConnectorId(ncId);
portNo = Integer.parseInt(IfmUtil.getPortNoFromNodeConnectorId(ncId));
}
if (interfaceType == InterfaceInfo.InterfaceType.VLAN_INTERFACE) {
interfaceInfo = IfmUtil.getVlanInterfaceInfo(intf, dpId);
} else if (interfaceType == InterfaceInfo.InterfaceType.UNKNOWN_INTERFACE) {
LOG.error("Type of Interface {} is unknown", interfaceName);
return null;
}
interfaceInfo.setDpId(dpId);
interfaceInfo.setPortNo(portNo);
interfaceInfo.setAdminState(intf.isEnabled() ? InterfaceAdminState.ENABLED : InterfaceAdminState.DISABLED);
interfaceInfo.setInterfaceName(interfaceName);
Integer lportTag = ifState.getIfIndex();
interfaceInfo.setInterfaceTag(lportTag);
interfaceInfo.setInterfaceType(interfaceType);
interfaceInfo.setGroupId(IfmUtil.getGroupId(lportTag, interfaceType));
interfaceInfo.setOpState(InterfaceInfo.InterfaceOpState.fromModel(ifState.getOperStatus()));
PhysAddress phyAddress = ifState.getPhysAddress();
if (phyAddress != null) {
interfaceInfo.setMacAddress(ifState.getPhysAddress().getValue());
}
return interfaceInfo;
}
use of org.opendaylight.genius.interfacemanager.globals.InterfaceInfo in project genius by opendaylight.
the class InterfacemgrProvider method populateInterfaceInfo.
public InterfaceInfo populateInterfaceInfo(String interfaceName, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState) {
InterfaceInfo interfaceInfo = new InterfaceInfo(interfaceName);
NodeConnectorId ncId = IfmUtil.getNodeConnectorIdFromInterface(ifState);
if (ncId != null) {
if (Tunnel.class.equals(ifState.getType())) {
interfaceInfo.setPortName(interfaceName);
} else {
Interface iface = interfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceName);
if (iface != null) {
ParentRefs parentRefs = iface.getAugmentation(ParentRefs.class);
interfaceInfo.setPortName(parentRefs.getParentInterface());
}
}
interfaceInfo.setDpId(IfmUtil.getDpnFromNodeConnectorId(ncId));
interfaceInfo.setPortNo(Integer.parseInt(IfmUtil.getPortNoFromNodeConnectorId(ncId)));
}
interfaceInfo.setAdminState(ifState.getAdminStatus() == AdminStatus.Up ? InterfaceAdminState.ENABLED : InterfaceAdminState.DISABLED);
interfaceInfo.setInterfaceName(interfaceName);
Integer lportTag = ifState.getIfIndex();
if (lportTag != null) {
interfaceInfo.setInterfaceTag(lportTag);
}
interfaceInfo.setOpState(InterfaceInfo.InterfaceOpState.fromModel(ifState.getOperStatus()));
PhysAddress phyAddress = ifState.getPhysAddress();
if (phyAddress != null) {
interfaceInfo.setMacAddress(ifState.getPhysAddress().getValue());
}
return interfaceInfo;
}
Aggregations