use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.AdminStatus in project genius by opendaylight.
the class InterfaceManagerCommonUtils method addStateEntry.
public org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface addStateEntry(Interface interfaceInfo, String interfaceName, WriteTransaction transaction, PhysAddress physAddress, OperStatus operStatus, AdminStatus adminStatus, NodeConnectorId nodeConnectorId) {
LOG.debug("adding interface state for {}", interfaceName);
InterfaceBuilder ifaceBuilder = new InterfaceBuilder().setType(Other.class).setIfIndex(IfmConstants.DEFAULT_IFINDEX);
Integer ifIndex;
Class<? extends InterfaceType> interfaceType = null;
if (interfaceInfo != null) {
if (!interfaceInfo.isEnabled()) {
operStatus = OperStatus.Down;
}
interfaceType = interfaceInfo.getType();
ifaceBuilder.setType(interfaceType);
// retrieve if-index only for northbound configured interfaces
ifIndex = IfmUtil.allocateId(idManager, IfmConstants.IFM_IDPOOL_NAME, interfaceName);
ifaceBuilder.setIfIndex(ifIndex);
interfaceMetaUtils.createLportTagInterfaceMap(interfaceName, ifIndex);
}
InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId = IfmUtil.buildStateInterfaceId(interfaceName);
List<String> childLowerLayerIfList = new ArrayList<>();
if (nodeConnectorId != null) {
childLowerLayerIfList.add(0, nodeConnectorId.getValue());
} else {
// logical tunnel group doesn't have OF port
ParentRefs parentRefs = interfaceInfo.getAugmentation(ParentRefs.class);
if (parentRefs != null) {
BigInteger dpId = parentRefs.getDatapathNodeIdentifier();
String lowref = MDSALUtil.NODE_PREFIX + MDSALUtil.SEPARATOR + dpId + MDSALUtil.SEPARATOR + 0;
childLowerLayerIfList.add(0, lowref);
}
}
ifaceBuilder.setAdminStatus(adminStatus).setOperStatus(operStatus).setLowerLayerIf(childLowerLayerIfList);
if (physAddress != null) {
ifaceBuilder.setPhysAddress(physAddress);
}
ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceName));
ifaceBuilder.setStatistics(new StatisticsBuilder().setDiscontinuityTime(DateAndTime.getDefaultInstance(ZonedDateTime.now().format(DateTimeFormatter.ISO_INSTANT))).build());
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = ifaceBuilder.build();
boolean isTunnelInterface = InterfaceManagerCommonUtils.isTunnelInterface(interfaceInfo);
boolean isOfTunnelInterface = InterfaceManagerCommonUtils.isOfTunnelInterface(interfaceInfo);
if (isTunnelInterface && !isOfTunnelInterface) {
batchingUtils.write(ifStateId, ifState, BatchingUtils.EntityType.DEFAULT_OPERATIONAL);
} else {
transaction.put(LogicalDatastoreType.OPERATIONAL, ifStateId, ifState, true);
}
if (nodeConnectorId != null) {
BigInteger dpId = IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId);
// Update the DpnToInterfaceList OpDS
createOrUpdateDpnToInterface(dpId, interfaceName, interfaceType);
}
return ifState;
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.AdminStatus 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;
}
Aggregations