use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId in project genius by opendaylight.
the class DirectTunnelUtils method isNodeConnectorPresent.
public boolean isNodeConnectorPresent(NodeConnectorId nodeConnectorId) throws ReadFailedException {
NodeId nodeId = getNodeIdFromNodeConnectorId(nodeConnectorId);
InstanceIdentifier<NodeConnector> ncIdentifier = InstanceIdentifier.builder(Nodes.class).child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node.class, new NodeKey(nodeId)).child(NodeConnector.class, new NodeConnectorKey(nodeConnectorId)).build();
return SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, ncIdentifier).isPresent();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId in project genius by opendaylight.
the class FlowBasedIngressServicesStateBindHelper method bindServiceOnVlan.
private void bindServiceOnVlan(WriteTransaction tx, List<BoundServices> allServices, Interface ifState) {
LOG.info("bind all ingress services for vlan port: {}", ifState.getName());
NodeConnectorId nodeConnectorId = FlowBasedServicesUtils.getNodeConnectorIdFromInterface(ifState);
BigInteger dpId = IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId);
allServices.sort(Comparator.comparing(BoundServices::getServicePriority));
BoundServices highestPriority = allServices.remove(0);
short nextServiceIndex = (short) (allServices.size() > 0 ? allServices.get(0).getServicePriority() : highestPriority.getServicePriority() + 1);
FlowBasedServicesUtils.installLPortDispatcherFlow(dpId, highestPriority, ifState.getName(), tx, ifState.getIfIndex(), NwConstants.DEFAULT_SERVICE_INDEX, nextServiceIndex);
BoundServices prev = null;
for (BoundServices boundService : allServices) {
if (prev != null) {
FlowBasedServicesUtils.installLPortDispatcherFlow(dpId, prev, ifState.getName(), tx, ifState.getIfIndex(), prev.getServicePriority(), boundService.getServicePriority());
}
prev = boundService;
}
if (prev != null) {
FlowBasedServicesUtils.installLPortDispatcherFlow(dpId, prev, ifState.getName(), tx, ifState.getIfIndex(), prev.getServicePriority(), (short) (prev.getServicePriority() + 1));
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId in project genius by opendaylight.
the class FlowBasedIngressServicesStateBindHelper method bindServiceOnTunnel.
private void bindServiceOnTunnel(WriteTransaction tx, List<BoundServices> allServices, Interface ifState) {
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface = interfaceManagerCommonUtils.getInterfaceFromConfigDS(ifState.getName());
NodeConnectorId nodeConnectorId = FlowBasedServicesUtils.getNodeConnectorIdFromInterface(ifState);
long portNo = IfmUtil.getPortNumberFromNodeConnectorId(nodeConnectorId);
BigInteger dpId = IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId);
List<MatchInfo> matches = FlowBasedServicesUtils.getMatchInfoForTunnelPortAtIngressTable(dpId, portNo);
BoundServices highestPriorityBoundService = FlowBasedServicesUtils.getHighestPriorityService(allServices);
FlowBasedServicesUtils.installInterfaceIngressFlow(dpId, iface, highestPriorityBoundService, tx, matches, ifState.getIfIndex(), NwConstants.VLAN_INTERFACE_INGRESS_TABLE);
for (BoundServices boundService : allServices) {
if (!boundService.equals(highestPriorityBoundService)) {
FlowBasedServicesUtils.installLPortDispatcherFlow(dpId, boundService, ifState.getName(), tx, ifState.getIfIndex(), boundService.getServicePriority(), (short) (boundService.getServicePriority() + 1));
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId 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.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId 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;
}
Aggregations