use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus 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.OperStatus in project genius by opendaylight.
the class InterfaceManagerCommonUtils method updateStateEntry.
public OperStatus updateStateEntry(Interface interfaceNew, WriteTransaction transaction, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState) {
final OperStatus operStatus;
if (!interfaceNew.isEnabled()) {
operStatus = org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Down;
} else {
String ncStr = ifState.getLowerLayerIf().get(0);
NodeConnectorId nodeConnectorId = new NodeConnectorId(ncStr);
NodeConnector nodeConnector = getNodeConnectorFromInventoryOperDS(nodeConnectorId);
FlowCapableNodeConnector flowCapableNodeConnector = nodeConnector.getAugmentation(FlowCapableNodeConnector.class);
operStatus = getOpState(flowCapableNodeConnector);
}
updateOperStatus(interfaceNew.getName(), operStatus, transaction);
return operStatus;
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus in project genius by opendaylight.
the class SouthboundUtils method addStateEntry.
public static void addStateEntry(Interface interfaceInfo, IfTunnel ifTunnel, WriteTransaction transaction) {
LOG.debug("adding tep interface state for {}", interfaceInfo);
if (interfaceInfo == null) {
return;
}
OperStatus operStatus = OperStatus.Up;
AdminStatus adminStatus = AdminStatus.Up;
if (!interfaceInfo.isEnabled()) {
operStatus = OperStatus.Down;
}
List<String> childLowerLayerIfList = new ArrayList<>();
childLowerLayerIfList.add(0, SouthboundUtils.getTerminationPointKeyString(ifTunnel.getTunnelDestination().getIpv4Address().getValue()));
InterfaceBuilder ifaceBuilder = new InterfaceBuilder().setAdminStatus(adminStatus).setOperStatus(operStatus).setLowerLayerIf(childLowerLayerIfList);
ifaceBuilder.setType(interfaceInfo.getType());
InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId = IfmUtil.buildStateInterfaceId(interfaceInfo.getName());
ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceInfo.getName()));
transaction.put(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build(), true);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus in project genius by opendaylight.
the class OvsInterfaceConfigUpdateHelper method handleInterfaceAdminStateUpdates.
private void handleInterfaceAdminStateUpdates(WriteTransaction transaction, Interface interfaceNew, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState) {
IfL2vlan ifL2vlan = interfaceNew.getAugmentation(IfL2vlan.class);
if (ifL2vlan == null || IfL2vlan.L2vlanMode.Trunk != ifL2vlan.getL2vlanMode() && IfL2vlan.L2vlanMode.Transparent != ifL2vlan.getL2vlanMode()) {
return;
}
LOG.info("admin-state modified for interface {}", interfaceNew.getName());
OperStatus operStatus = interfaceManagerCommonUtils.updateStateEntry(interfaceNew, transaction, ifState);
InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(interfaceNew.getName());
InterfaceParentEntry interfaceParentEntry = interfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryKey);
if (interfaceParentEntry == null || interfaceParentEntry.getInterfaceChildEntry() == null) {
return;
}
VlanMemberStateUpdateWorker vlanMemberStateUpdateWorker = new VlanMemberStateUpdateWorker(txRunner, operStatus, interfaceParentEntry.getInterfaceChildEntry());
coordinator.enqueueJob(interfaceNew.getName(), vlanMemberStateUpdateWorker, IfmConstants.JOB_MAX_RETRIES);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus in project genius by opendaylight.
the class InterfaceManagerCommonUtils method updateOpState.
/*
* update operational state of interface based on events like tunnel
* monitoring
*/
public static void updateOpState(WriteTransaction transaction, String interfaceName, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus operStatus) {
InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId = IfmUtil.buildStateInterfaceId(interfaceName);
LOG.debug("updating tep interface state as {} for {}", operStatus.name(), interfaceName);
InterfaceBuilder ifaceBuilder = new InterfaceBuilder().setOperStatus(operStatus);
ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceName));
transaction.merge(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build(), false);
}
Aggregations