use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey 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.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey in project genius by opendaylight.
the class InterfaceManagerCommonUtils method getInterfaceFromConfigDS.
@Nullable
public Interface getInterfaceFromConfigDS(ReadTransaction tx, String interfaceName) throws ReadFailedException {
Interface iface = interfaceConfigMap.get(interfaceName);
if (iface != null) {
return iface;
}
InstanceIdentifier<Interface> interfaceId = getInterfaceIdentifier(new InterfaceKey(interfaceName));
Optional<Interface> interfaceOptional = tx.read(LogicalDatastoreType.CONFIGURATION, interfaceId).checkedGet();
if (interfaceOptional.isPresent()) {
iface = interfaceOptional.get();
interfaceConfigMap.put(iface.getName(), iface);
}
return iface;
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey in project genius by opendaylight.
the class OvsInterfaceStateAddHelper method addState.
private List<ListenableFuture<Void>> addState(NodeConnectorId nodeConnectorId, String interfaceName, long portNo, PhysAddress physAddress) {
LOG.info("Adding Interface State to Oper DS for interface: {}", interfaceName);
if (portNo == IfmConstants.INVALID_PORT_NO) {
LOG.trace("Cannot derive port number, not proceeding with Interface State " + "addition for interface: {}", interfaceName);
return null;
}
List<ListenableFuture<Void>> futures = new ArrayList<>();
Interface.OperStatus operStatus = Interface.OperStatus.Up;
Interface.AdminStatus adminStatus = Interface.AdminStatus.Up;
// Fetch the interface from config DS if exists
InterfaceKey interfaceKey = new InterfaceKey(interfaceName);
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface = interfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey);
if (InterfaceManagerCommonUtils.isTunnelPort(interfaceName) && !validateTunnelPortAttributes(nodeConnectorId, iface)) {
return futures;
}
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
Interface ifState = interfaceManagerCommonUtils.addStateEntry(iface, interfaceName, tx, physAddress, operStatus, adminStatus, nodeConnectorId);
// flow,and start tunnel monitoring
if (InterfaceManagerCommonUtils.isTunnelInterface(iface)) {
handleTunnelMonitoringAddition(futures, nodeConnectorId, ifState.getIfIndex(), iface, interfaceName, portNo);
return;
}
// install ingress flow if this is an l2vlan interface
if (InterfaceManagerCommonUtils.isVlanInterface(iface) && iface.isEnabled() && ifState.getOperStatus() == org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Up) {
BigInteger dpId = IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId);
FlowBasedServicesUtils.installLportIngressFlow(dpId, portNo, iface, futures, txRunner, ifState.getIfIndex());
futures.add(FlowBasedServicesUtils.bindDefaultEgressDispatcherService(txRunner, iface, Long.toString(portNo), interfaceName, ifState.getIfIndex()));
}
}));
return futures;
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey in project genius by opendaylight.
the class OvsInterfaceStateUpdateHelper method handleInterfaceStateUpdates.
private void handleInterfaceStateUpdates(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface, WriteTransaction transaction, InterfaceBuilder ifaceBuilder, boolean opStateModified, String interfaceName, String portName, Interface.OperStatus opState) {
// which have no corresponding config entries
if (iface == null && !interfaceName.equals(portName)) {
return;
}
final Interface interfaceState = interfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceName);
if (interfaceState == null || (interfaceState.getOperStatus() == opState)) {
LOG.warn("Ignoring: updating interface state for interface {}", interfaceName);
return;
}
LOG.debug("updating interface state entry for {}", interfaceName);
InstanceIdentifier<Interface> ifStateId = IfmUtil.buildStateInterfaceId(interfaceName);
ifaceBuilder.setKey(new InterfaceKey(interfaceName));
if (modifyOpState(iface, opStateModified)) {
LOG.debug("updating interface oper status as {} for {}", opState.name(), interfaceName);
ifaceBuilder.setOperStatus(opState);
}
transaction.merge(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build(), false);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey in project genius by opendaylight.
the class InterfaceManagerTestUtil method buildTunnelInterface.
static Interface buildTunnelInterface(BigInteger dpn, String ifName, String desc, boolean enabled, Class<? extends TunnelTypeBase> tunType, String remoteIpStr, String localIpStr) {
InterfaceBuilder builder = new InterfaceBuilder().setKey(new InterfaceKey(ifName)).setName(ifName).setDescription(desc).setEnabled(enabled).setType(Tunnel.class);
ParentRefs parentRefs = new ParentRefsBuilder().setDatapathNodeIdentifier(dpn).build();
builder.addAugmentation(ParentRefs.class, parentRefs);
IpAddress remoteIp = new IpAddress(Ipv4Address.getDefaultInstance(remoteIpStr));
IpAddress localIp = new IpAddress(Ipv4Address.getDefaultInstance(localIpStr));
IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(remoteIp).setTunnelGateway(localIp).setTunnelSource(localIp).setTunnelInterfaceType(tunType).setInternal(true).setMonitorEnabled(false).build();
builder.addAugmentation(IfTunnel.class, tunnel);
return builder.build();
}
Aggregations