use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state._interface.StatisticsBuilder in project genius by opendaylight.
the class InterfaceManagerCommonUtils method addStateEntry.
public void addStateEntry(String interfaceName, WriteTransaction interfaceOperShardTransaction, List<ListenableFuture<Void>> futures, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState) {
// allocate lport tag and create interface-if-index map.
// This is done even if interface-state is not present, so that there is
// no throttling
// on id allocation even when multiple southbound port_up events come in
// one shot
Integer ifIndex = IfmUtil.allocateId(idManager, IfmConstants.IFM_IDPOOL_NAME, interfaceName);
interfaceMetaUtils.createLportTagInterfaceMap(interfaceName, ifIndex);
if (ifState == null) {
LOG.debug("could not retrieve interface state corresponding to {}, processing will be resumed when " + "interface-state is available", interfaceName);
return;
}
LOG.debug("adding interface state for {}", interfaceName);
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus operStatus = ifState.getOperStatus();
PhysAddress physAddress = ifState.getPhysAddress();
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.AdminStatus adminStatus = ifState.getAdminStatus();
NodeConnectorId nodeConnectorId = new NodeConnectorId(ifState.getLowerLayerIf().get(0));
InterfaceKey interfaceKey = new InterfaceKey(interfaceName);
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface interfaceInfo = getInterfaceFromConfigDS(interfaceKey);
if (interfaceInfo != null && !interfaceInfo.isEnabled()) {
operStatus = org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Down;
}
List<String> childLowerLayerIfList = new ArrayList<>();
childLowerLayerIfList.add(0, nodeConnectorId.getValue());
InterfaceBuilder ifaceBuilder = new InterfaceBuilder().setAdminStatus(adminStatus).setOperStatus(operStatus).setPhysAddress(physAddress).setLowerLayerIf(childLowerLayerIfList);
ifaceBuilder.setIfIndex(ifIndex).setType(Other.class);
Class<? extends InterfaceType> interfaceType = null;
if (interfaceInfo != null) {
interfaceType = interfaceInfo.getType();
ifaceBuilder.setType(interfaceType);
}
ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceName));
ifaceBuilder.setStatistics(new StatisticsBuilder().setDiscontinuityTime(DateAndTime.getDefaultInstance(ZonedDateTime.now().format(DateTimeFormatter.ISO_INSTANT))).build());
InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId = IfmUtil.buildStateInterfaceId(interfaceName);
interfaceOperShardTransaction.put(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build(), true);
// install ingress flow
BigInteger dpId = IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId);
long portNo = IfmUtil.getPortNumberFromNodeConnectorId(nodeConnectorId);
if (interfaceInfo != null && interfaceInfo.isEnabled() && ifState.getOperStatus() == org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Up) {
FlowBasedServicesUtils.installLportIngressFlow(dpId, portNo, interfaceInfo, futures, txRunner, ifIndex);
futures.add(FlowBasedServicesUtils.bindDefaultEgressDispatcherService(txRunner, interfaceInfo, Long.toString(portNo), interfaceName, ifIndex));
}
// Update the DpnToInterfaceList OpDS
createOrUpdateDpnToInterface(dpId, interfaceName, interfaceType);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state._interface.StatisticsBuilder in project genius by opendaylight.
the class InterfaceStateHelper method buildStateFromInterfaceInfo.
public static Interface buildStateFromInterfaceInfo(InterfaceInfo interfaceInfo) {
BigInteger dpId = interfaceInfo.getDpId();
int portno = interfaceInfo.getPortNo();
NodeConnectorId nodeConnectorId = new NodeConnectorId("openflow:" + dpId.toString() + ":" + portno);
return new InterfaceBuilder().setType(Other.class).setIfIndex(interfaceInfo.getInterfaceTag()).setAdminStatus(AdminStatus.Up).setOperStatus(OperStatus.Up).setLowerLayerIf(Lists.newArrayList(nodeConnectorId.getValue())).setPhysAddress(new PhysAddress(interfaceInfo.getMacAddress())).setKey(new InterfaceKey(interfaceInfo.getInterfaceName())).setStatistics(new StatisticsBuilder().setDiscontinuityTime(new DateAndTime(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(ZonedDateTime.now()))).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state._interface.StatisticsBuilder in project openflowplugin by opendaylight.
the class MultipartReplyTranslatorUtil method translateTable.
private static MultipartReplyFlowTableStats translateTable(final MultipartReply msg) {
MultipartReplyFlowTableStatsBuilder message = new MultipartReplyFlowTableStatsBuilder();
MultipartReplyTableCase caseBody = (MultipartReplyTableCase) msg.getMultipartReplyBody();
MultipartReplyTable replyBody = caseBody.getMultipartReplyTable();
List<TableStats> swTablesStats = replyBody.getTableStats();
List<FlowTableAndStatisticsMap> salFlowStats = new ArrayList<>();
// TODO: Duplicate code: look at OpendaylightFlowTableStatisticsServiceImpl method transformToNotification
for (TableStats swTableStats : swTablesStats) {
FlowTableAndStatisticsMapBuilder statisticsBuilder = new FlowTableAndStatisticsMapBuilder();
statisticsBuilder.setActiveFlows(new Counter32(swTableStats.getActiveCount()));
statisticsBuilder.setPacketsLookedUp(new Counter64(swTableStats.getLookupCount()));
statisticsBuilder.setPacketsMatched(new Counter64(swTableStats.getMatchedCount()));
statisticsBuilder.setTableId(new TableId(swTableStats.getTableId()));
salFlowStats.add(statisticsBuilder.build());
}
message.setFlowTableAndStatisticsMap(salFlowStats);
return message.build();
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state._interface.StatisticsBuilder in project openflowplugin by opendaylight.
the class OpendaylightFlowTableStatisticsServiceImpl method transformToNotification.
@Override
public FlowTableStatisticsUpdate transformToNotification(List<MultipartReply> mpReplyList, TransactionId emulatedTxId) {
FlowTableStatisticsUpdateBuilder notification = new FlowTableStatisticsUpdateBuilder();
notification.setId(getDeviceInfo().getNodeId());
notification.setMoreReplies(Boolean.FALSE);
notification.setTransactionId(emulatedTxId);
final List<FlowTableAndStatisticsMap> salFlowStats = new ArrayList<>();
notification.setFlowTableAndStatisticsMap(salFlowStats);
for (MultipartReply mpReply : mpReplyList) {
MultipartReplyTableCase caseBody = (MultipartReplyTableCase) mpReply.getMultipartReplyBody();
MultipartReplyTable replyBody = caseBody.getMultipartReplyTable();
List<TableStats> swTablesStats = replyBody.getTableStats();
// TODO: Duplicate code: look at MultiReplyTranslatorUtil method translateTable
for (TableStats swTableStats : swTablesStats) {
FlowTableAndStatisticsMapBuilder statisticsBuilder = new FlowTableAndStatisticsMapBuilder();
statisticsBuilder.setActiveFlows(new Counter32(swTableStats.getActiveCount()));
statisticsBuilder.setPacketsLookedUp(new Counter64(swTableStats.getLookupCount()));
statisticsBuilder.setPacketsMatched(new Counter64(swTableStats.getMatchedCount()));
statisticsBuilder.setTableId(new TableId(swTableStats.getTableId()));
salFlowStats.add(statisticsBuilder.build());
}
}
return notification.build();
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state._interface.StatisticsBuilder 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;
}
Aggregations