import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
-
import org.opendaylight.controller.liblldp.NetUtils;
import org.opendaylight.controller.liblldp.Packet;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.NotificationService;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.vpnservice.interfacemgr.interfaces.IInterfaceManager;
import org.opendaylight.vpnservice.mdsalutil.MDSALUtil;
+import org.opendaylight.vpnservice.mdsalutil.MetaDataUtil;
import org.opendaylight.vpnservice.mdsalutil.NWUtil;
import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
import org.opendaylight.vpnservice.mdsalutil.packet.ARP;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata;
import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketInReason;
import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived;
import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.SendToController;
import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.arputil.rev151126.ArpRequestReceived;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.arputil.rev151126.ArpRequestReceivedBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.arputil.rev151126.ArpResponseReceivedBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.arputil.rev151126.GetMacInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.arputil.rev151126.SendArpResponseInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.arputil.rev151126.interfaces.InterfaceAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.BaseIds;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetInterfaceFromIfIndexInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetInterfaceFromIfIndexInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetInterfaceFromIfIndexOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetPortFromInterfaceInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetPortFromInterfaceInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetPortFromInterfaceOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.OdlInterfaceRpcService;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
private static final Logger LOGGER = LoggerFactory
.getLogger(ArpUtilImpl.class);
+ static OdlInterfaceRpcService intfRpc;
+
ExecutorService threadPool = Executors.newFixedThreadPool(1);
DataBroker dataBroker;
NotificationService notificationService;
IMdsalApiManager mdsalMgr;
+ RpcProviderRegistry rpc;
ListenerRegistration<ArpUtilImpl> listenerRegistration;
ConcurrentMap<String, String> macsDB = new ConcurrentHashMap<>();
PacketProcessingService packetProcessingService,
NotificationPublishService notificationPublishService,
NotificationService notificationService,
- IMdsalApiManager mdsalApiManager) {
+ IMdsalApiManager mdsalApiManager,
+ RpcProviderRegistry rpc) {
this.dataBroker = db;
this.packetProcessingService = packetProcessingService;
this.notificationPublishService = notificationPublishService;
this.mdsalMgr = mdsalApiManager;
this.notificationService = notificationService;
-
+ this.rpc = rpc;
listenerRegistration = notificationService
.registerNotificationListener(this);
LOGGER.info("ArpUtil Manager Initialized ");
}
+
+ OdlInterfaceRpcService getInterfaceRpcService() {
+ if (intfRpc == null ) {
+ intfRpc = rpc.getRpcService(OdlInterfaceRpcService.class);
+ }
+ return intfRpc;
+ }
@Override
public void close() throws Exception {
NodeConnectorId id = getNodeConnectorFromInterfaceName(interfaceName);
- dpnId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(id));
- Long portid = MDSALUtil.getOfPortNumberFromPortName(id);
+ GetPortFromInterfaceOutput portResult = getPortFromInterface(interfaceName);
+ //dpnId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(id));
+ //Long portid = MDSALUtil.getOfPortNumberFromPortName(id);
+ dpnId = portResult.getDpid();
+ Long portid = portResult.getPortno();
checkArgument(null != dpnId && BigInteger.ZERO != dpnId,
DPN_NOT_FOUND_ERROR, interfaceName);
LOGGER.trace("sent arp request for "
+ arpReqInput.getIpaddress());
}
- } catch (Exception e) {
+ } catch (Throwable e) {
LOGGER.trace("failed to send arp req for {} on interface {}",
arpReqInput.getIpaddress(), interfaceName);
try {
String interfaceName = input.getInterface();
- NodeConnectorId id = getNodeConnectorFromInterfaceName(interfaceName);
+ //NodeConnectorId id = getNodeConnectorFromInterfaceName(interfaceName);
+
+ //dpnId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(id));
+ //Long portid = MDSALUtil.getOfPortNumberFromPortName(id);
- dpnId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(id));
- Long portid = MDSALUtil.getOfPortNumberFromPortName(id);
+ GetPortFromInterfaceOutput portResult = getPortFromInterface(interfaceName);
+ //dpnId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(id));
+ //Long portid = MDSALUtil.getOfPortNumberFromPortName(id);
+ dpnId = portResult.getDpid();
+ Long portid = portResult.getPortno();
+
NodeConnectorRef ref = MDSALUtil.getNodeConnRef(dpnId,
portid.toString());
checkArgument(null != dpnId && BigInteger.ZERO != dpnId,
LOGGER.trace("sent the arp response for "
+ input.getSrcIpAddress());
}
- } catch (Exception e) {
+ } catch (Throwable e) {
LOGGER.trace("failed to send arp response for {} {}",
input.getSrcIpAddress(), e);
return RpcResultBuilder.<Void> failed()
NodeConnectorRef ref = packetReceived.getIngress();
- String interfaceName = MDSALUtil.getInterfaceName(ref, dataBroker);
-
+ Metadata i = packetReceived.getMatch().getMetadata();
+
+ //String interfaceName = MDSALUtil.getInterfaceName(ref, dataBroker);
+ String interfaceName = getInterfaceName(ref,i, dataBroker);
+
checkAndFireMacChangedNotification(interfaceName, srcInetAddr,
srcMac);
threadPool.submit(new MacResponderTask(arp));
}
- } catch (Exception e) {
+ } catch (Throwable e) {
LOGGER.trace("Failed to decode packet: {}", e);
}
}
}
- class MacResponderTask implements Runnable {
+ GetPortFromInterfaceOutput getPortFromInterface(String interfaceName) throws Throwable {
+ GetPortFromInterfaceInputBuilder x = new GetPortFromInterfaceInputBuilder();
+ x.setIntfName(interfaceName);;
+ Future<RpcResult<GetPortFromInterfaceOutput>> ft = intfRpc.getPortFromInterface(x.build());
+ GetPortFromInterfaceOutput result = ft.get().getResult();
+ LOGGER.trace("getPortFromInterface rpc result is {} ", result);
+ if (result != null) {
+ LOGGER.trace("getPortFromInterface rpc result is {} {} ", result.getDpid(), result.getPortno());
+ }
+ return result;
+ }
+
+ private String getInterfaceName(NodeConnectorRef ref, Metadata metadata, DataBroker dataBroker2) throws Throwable {
+ LOGGER.debug("metadata received is {} ", metadata);
+
+ GetInterfaceFromIfIndexInputBuilder ifIndexInputBuilder = new GetInterfaceFromIfIndexInputBuilder();
+ BigInteger lportTag = MetaDataUtil.getLportFromMetadata(metadata.getMetadata());
+
+ ifIndexInputBuilder.setIfIndex(lportTag.intValue());
+ GetInterfaceFromIfIndexInput input = ifIndexInputBuilder.build();
+ OdlInterfaceRpcService intfRpc = getInterfaceRpcService();
+
+ Future<RpcResult<GetInterfaceFromIfIndexOutput>> interfaceFromIfIndex = intfRpc.getInterfaceFromIfIndex(input);
+ GetInterfaceFromIfIndexOutput interfaceFromIfIndexOutput = interfaceFromIfIndex.get().getResult();
+ return interfaceFromIfIndexOutput.getInterfaceName();
+ }
+
+ class MacResponderTask implements Runnable {
ARP arp;
MacResponderTask(ARP arp) {
arpManager = new ArpUtilImpl( dataBroker, packetProcessingService,
notificationPublishService, notificationService,
- mdsalApiManager) ;
+ mdsalApiManager, rpcProviderRegistry) ;
rpcRegistration = rpcProviderRegistry.
addRpcImplementation(OdlArputilService.class, arpManager);
"The VLAN mode transparent.";
}
}
+ default "trunk";
}
}
<groupId>org.opendaylight.mdsal.model</groupId>
<artifactId>ietf-interfaces</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.vpnservice</groupId>
- <artifactId>vpnmanager-impl</artifactId>
- <version>${vpnservices.version}</version>
- </dependency>
<dependency>
<groupId>org.opendaylight.vpnservice</groupId>
<artifactId>mdsalutil-api</artifactId>
public static BigInteger getDpnId(DatapathId datapathId){
if (datapathId != null) {
+ // Adding logs for a random issue spotted during datapath id conversion
+ LOG.info("Received datapathId {}",datapathId.getValue());
String dpIdStr = datapathId.getValue().replace(":", "");
- return new BigInteger(dpIdStr, 16);
+ LOG.info("Received datapathId {}",dpIdStr);
+ BigInteger dpnId = new BigInteger(dpIdStr, 16);
+ LOG.info("After conversion datapathId {}",dpnId);
+ return dpnId;
}
return null;
}
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.idmanager.IdManager;
-import org.opendaylight.vpnservice.VpnConstants;
import org.opendaylight.vpnservice.interfacemgr.IfmConstants;
import org.opendaylight.vpnservice.interfacemgr.IfmUtil;
+import org.opendaylight.vpnservice.interfacemgr.servicebindings.flowbased.utilities.FlowBasedServicesUtils;
import org.opendaylight.vpnservice.mdsalutil.*;
import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntryKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info._interface.parent.entry.InterfaceChildEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info._interface.parent.entry.InterfaceChildEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info._interface.parent.entry.InterfaceChildEntryKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfTunnel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfTunnelBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.TunnelTypeMplsOverGre;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
public class InterfaceManagerCommonUtils {
private static final Logger LOG = LoggerFactory.getLogger(InterfaceManagerCommonUtils.class);
LOG.trace("Updating trunk interface {} in Config DS", interfaceName);
MDSALUtil.syncUpdate(broker, LogicalDatastoreType.OPERATIONAL, id, ifaceBuilder.build());
}
+
+ public static void createInterfaceParentEntryIfNotPresent(DataBroker dataBroker, WriteTransaction t,
+ String parentInterface){
+ InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(parentInterface);
+ InstanceIdentifier<InterfaceParentEntry> interfaceParentEntryIdentifier =
+ InterfaceMetaUtils.getInterfaceParentEntryIdentifier(interfaceParentEntryKey);
+ InterfaceParentEntry interfaceParentEntry =
+ InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryIdentifier, dataBroker);
+
+ if(interfaceParentEntry != null){
+ LOG.info("Not Found entry for Parent Interface: {} in Vlan Trunk-Member Interface Renderer ConfigDS. " +
+ "Creating...", parentInterface);
+ InterfaceParentEntryBuilder interfaceParentEntryBuilder = new InterfaceParentEntryBuilder()
+ .setKey(interfaceParentEntryKey).setParentInterface(parentInterface);
+ t.put(LogicalDatastoreType.CONFIGURATION, interfaceParentEntryIdentifier,
+ interfaceParentEntryBuilder.build(), true);
+ }
+ }
+
+ public static void createInterfaceChildEntry( WriteTransaction t,
+ String parentInterface, String childInterface){
+ InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(parentInterface);
+ InterfaceChildEntryKey interfaceChildEntryKey = new InterfaceChildEntryKey(childInterface);
+ InstanceIdentifier<InterfaceChildEntry> intfId =
+ InterfaceMetaUtils.getInterfaceChildEntryIdentifier(interfaceParentEntryKey, interfaceChildEntryKey);
+ InterfaceChildEntryBuilder entryBuilder = new InterfaceChildEntryBuilder().setKey(interfaceChildEntryKey)
+ .setChildInterface(childInterface);
+ t.put(LogicalDatastoreType.CONFIGURATION, intfId, entryBuilder.build(),true);
+ }
+
+ /*public static void updateStateEntry(Interface interfaceInfo, DataBroker dataBroker, WriteTransaction transaction,
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState) {
+ String ncStr = ifState.getLowerLayerIf().get(0);
+ NodeConnectorId nodeConnectorId = new NodeConnectorId(ncStr);
+ NodeConnector nodeConnector =
+ InterfaceManagerCommonUtils.getNodeConnectorFromInventoryOperDS(nodeConnectorId, dataBroker);
+ if(nodeConnector != null) {
+ FlowCapableNodeConnector flowCapableNodeConnector =
+ nodeConnector.getAugmentation(FlowCapableNodeConnector.class);
+ //State state = flowCapableNodeConnector.getState();
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus operStatus =
+ flowCapableNodeConnector == null ? org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Down : org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Up;
+
+ if (ifState.getOperStatus() != operStatus) {
+ InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId =
+ IfmUtil.buildStateInterfaceId(interfaceInfo.getName());
+ InterfaceBuilder ifaceBuilder = new InterfaceBuilder();
+ ifaceBuilder.setOperStatus(operStatus);
+ ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceInfo.getName()));
+ transaction.merge(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build());
+ }
+ }
+ }*/
+
+ public static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus
+ updateStateEntry(Interface interfaceNew, DataBroker dataBroker, WriteTransaction transaction,
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState) {
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.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 =
+ InterfaceManagerCommonUtils.getNodeConnectorFromInventoryOperDS(nodeConnectorId, dataBroker);
+ FlowCapableNodeConnector flowCapableNodeConnector =
+ nodeConnector.getAugmentation(FlowCapableNodeConnector.class);
+ //State state = flowCapableNodeConnector.getState();
+ operStatus = flowCapableNodeConnector == null ? org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Down : org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Up;
+ }
+
+ String ifName = interfaceNew.getName();
+ InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId =
+ IfmUtil.buildStateInterfaceId(interfaceNew.getName());
+ InterfaceBuilder ifaceBuilder = new InterfaceBuilder();
+ ifaceBuilder.setOperStatus(operStatus);
+ ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(ifName));
+ transaction.merge(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build());
+ return operStatus;
+ }
+
+ public static void updateOperStatus(String interfaceName, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus operStatus,
+ WriteTransaction transaction) {
+ InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifChildStateId =
+ IfmUtil.buildStateInterfaceId(interfaceName);
+ InterfaceBuilder ifaceBuilderChild = new InterfaceBuilder();
+ ifaceBuilderChild.setOperStatus(operStatus);
+ ifaceBuilderChild.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceName));
+ transaction.merge(LogicalDatastoreType.OPERATIONAL, ifChildStateId, ifaceBuilderChild.build());
+ }
+
+ public static void addStateEntry(String interfaceName, WriteTransaction transaction, DataBroker dataBroker, IdManagerService idManager,
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState) {
+ 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 =
+ InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
+
+ 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;
+ }
+
+ 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<>();
+ childLowerLayerIfList.add(0, nodeConnectorId.getValue());
+ //childLowerLayerIfList.add(1, interfaceName);
+ InterfaceBuilder ifaceBuilder = new InterfaceBuilder().setAdminStatus(adminStatus)
+ .setOperStatus(operStatus).setPhysAddress(physAddress).setLowerLayerIf(childLowerLayerIfList);
+
+ Integer ifIndex = IfmUtil.allocateId(idManager, IfmConstants.IFM_IDPOOL_NAME, interfaceName);
+ ifaceBuilder.setIfIndex(ifIndex);
+
+ if(interfaceInfo != null){
+ ifaceBuilder.setType(interfaceInfo.getType());
+ }
+ ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceInfo.getName()));
+ transaction.put(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build(), true);
+
+ // create lportTag Interface Map
+ InterfaceMetaUtils.createLportTagInterfaceMap(transaction, interfaceName, ifIndex);
+
+ // install ingress flow
+ BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
+ long portNo = Long.valueOf(IfmUtil.getPortNoFromNodeConnectorId(nodeConnectorId));
+ if(interfaceInfo.isEnabled() && ifState.getOperStatus() == org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Up) {
+ List<MatchInfo> matches = FlowBasedServicesUtils.getMatchInfoForVlanPortAtIngressTable(dpId, portNo, interfaceInfo);
+ FlowBasedServicesUtils.installVlanFlow(dpId, portNo, interfaceInfo, transaction, matches, ifIndex);
+ }
+ }
+
+ public static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface
+ addStateEntry(Interface interfaceInfo, String portName, WriteTransaction transaction, IdManagerService idManager,
+ PhysAddress physAddress, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus operStatus,
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.AdminStatus adminStatus,
+ NodeConnectorId nodeConnectorId) {
+ 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;
+ }
+ InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId =
+ IfmUtil.buildStateInterfaceId(portName);
+ List<String> childLowerLayerIfList = new ArrayList<>();
+ childLowerLayerIfList.add(0, nodeConnectorId.getValue());
+ //childLowerLayerIfList.add(1, interfaceInfo.getName());
+ InterfaceBuilder ifaceBuilder = new InterfaceBuilder().setAdminStatus(adminStatus)
+ .setOperStatus(operStatus).setPhysAddress(physAddress).setLowerLayerIf(childLowerLayerIfList);
+
+ Integer ifIndex = IfmUtil.allocateId(idManager, IfmConstants.IFM_IDPOOL_NAME, portName);
+ ifaceBuilder.setIfIndex(ifIndex);
+
+ if(interfaceInfo != null){
+ ifaceBuilder.setType(interfaceInfo.getType());
+ }
+ ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(portName));
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = ifaceBuilder.build();
+ transaction.put(LogicalDatastoreType.OPERATIONAL, ifStateId,ifState , true);
+
+ // allocate lport tag and set in if-index
+ InterfaceMetaUtils.createLportTagInterfaceMap(transaction, portName, ifIndex);
+ return ifState;
+ }
+
+ public static void deleteStateEntry(String interfaceName, WriteTransaction transaction) {
+ InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifChildStateId =
+ IfmUtil.buildStateInterfaceId(interfaceName);
+ transaction.delete(LogicalDatastoreType.OPERATIONAL, ifChildStateId);
+ }
}
\ No newline at end of file
String parentInterface = null;
ParentRefs parentRefs = interfaceOld.getAugmentation(ParentRefs.class);
- if (parentRefs != null) {
- parentInterface = parentRefs.getParentInterface();
+ /* parentInterface = parentRefs.getParentInterface();
if (parentInterface != null && !parentInterface.equals(ifName)) {
return;
}
if (parentRefs.getDatapathNodeIdentifier() == null) {
return;
}
- }
+ if(parentInterface == null){
+ LOG.error("parent interface not specified for {}",interfaceOld.getName());
+ }
+ }*/
DataStoreJobCoordinator coordinator = DataStoreJobCoordinator.getInstance();
RendererConfigRemoveWorker configWorker = new RendererConfigRemoveWorker(key, interfaceOld, ifName, parentRefs);
String ifNameNew = interfaceNew.getName();
String parentInterface = null;
- ParentRefs parentRefs = interfaceNew.getAugmentation(ParentRefs.class);
- if (parentRefs != null) {
- parentInterface = parentRefs.getParentInterface();
+ /*ParentRefs parentRefs = interfaceNew.getAugmentation(ParentRefs.class);
+ if (parentRefs == null) {
+ LOG.error("parent refs not specified for {}",interfaceNew.getName());
}
- if (parentInterface != null && !parentInterface.equals(ifNameNew)) {
+ if (parentInterface == null) {
+ LOG.error("parent interface not specified for {}",interfaceOld.getName());
return;
- }
+ }*/
DataStoreJobCoordinator coordinator = DataStoreJobCoordinator.getInstance();
RendererConfigUpdateWorker worker = new RendererConfigUpdateWorker(key, interfaceOld, interfaceNew, ifNameNew);
String parentInterface = null;
ParentRefs parentRefs = interfaceNew.getAugmentation(ParentRefs.class);
- if (parentRefs != null) {
- parentInterface = parentRefs.getParentInterface();
+ if (parentRefs == null) {
+ LOG.error("parent refs not specified for {}",interfaceNew.getName());
}
- if (parentInterface != null && !parentInterface.equals(ifName)) {
- return;
- }
+ /*if(parentInterface == null){
+ LOG.error("parent interface not specified for {}",interfaceNew.getName());
+ }*/
DataStoreJobCoordinator coordinator = DataStoreJobCoordinator.getInstance();
RendererConfigAddWorker configWorker = new RendererConfigAddWorker(key, interfaceNew, parentRefs, ifName);
@Override
protected void remove(InstanceIdentifier<Interface> key, Interface interfaceOld) {
IfL2vlan ifL2vlan = interfaceOld.getAugmentation(IfL2vlan.class);
- if (ifL2vlan == null) {
+ if (ifL2vlan == null || IfL2vlan.L2vlanMode.TrunkMember != ifL2vlan.getL2vlanMode()) {
return;
}
@Override
protected void update(InstanceIdentifier<Interface> key, Interface interfaceOld, Interface interfaceNew) {
IfL2vlan ifL2vlanNew = interfaceNew.getAugmentation(IfL2vlan.class);
- if (ifL2vlanNew == null) {
+ if (ifL2vlanNew == null || IfL2vlan.L2vlanMode.TrunkMember != ifL2vlanNew.getL2vlanMode()) {
return;
}
@Override
protected void add(InstanceIdentifier<Interface> key, Interface interfaceNew) {
IfL2vlan ifL2vlan = interfaceNew.getAugmentation(IfL2vlan.class);
- if (ifL2vlan == null) {
+ if (ifL2vlan == null || IfL2vlan.L2vlanMode.TrunkMember != ifL2vlan.getL2vlanMode()) {
return;
}
import com.google.common.base.Optional;
import com.google.common.util.concurrent.ListenableFuture;
-
-import org.eclipse.xtend.lib.annotations.Data;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.idmanager.IdManager;
-import org.opendaylight.vpnservice.interfacemgr.IfmConstants;
import org.opendaylight.vpnservice.interfacemgr.IfmUtil;
import org.opendaylight.vpnservice.interfacemgr.commons.AlivenessMonitorUtils;
import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils;
import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceMetaUtils;
-import org.opendaylight.vpnservice.interfacemgr.globals.InterfaceInfo;
import org.opendaylight.vpnservice.interfacemgr.renderer.ovs.utilities.SouthboundUtils;
-import org.opendaylight.vpnservice.interfacemgr.servicebindings.flowbased.utilities.FlowBasedServicesUtils;
-import org.opendaylight.vpnservice.mdsalutil.MatchInfo;
import org.opendaylight.vpnservice.mdsalutil.NwConstants;
import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddressBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.AdminStatus;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.*;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.monitor.params.SourceBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.monitor.start.input.ConfigBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.AlivenessMonitorService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntryKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info._interface.parent.entry.InterfaceChildEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.BridgeEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.BridgeEntryBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.BridgeEntryKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.bridge.entry.BridgeInterfaceEntryKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge.ref.info.BridgeRefEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge.ref.info.BridgeRefEntryKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.*;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfL2vlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfTunnel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.ParentRefs;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
public class OvsInterfaceConfigAddHelper {
private static final Logger LOG = LoggerFactory.getLogger(OvsInterfaceConfigAddHelper.class);
return futures;
}
- addVlanConfiguration(interfaceNew, dataBroker, idManager, futures);
+ addVlanConfiguration(interfaceNew, parentRefs, dataBroker, idManager, futures);
return futures;
}
- private static void addVlanConfiguration(Interface interfaceNew, DataBroker dataBroker, IdManagerService idManager,
+ private static void addVlanConfiguration(Interface interfaceNew, ParentRefs parentRefs, DataBroker dataBroker, IdManagerService idManager,
List<ListenableFuture<Void>> futures) {
+ IfL2vlan ifL2vlan = interfaceNew.getAugmentation(IfL2vlan.class);
+ if (ifL2vlan == null || IfL2vlan.L2vlanMode.Trunk != ifL2vlan.getL2vlanMode()) {
+ return;
+ }
WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
+ InterfaceManagerCommonUtils.createInterfaceChildEntry(transaction,
+ parentRefs.getParentInterface(), interfaceNew.getName());
+
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState =
- InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceNew.getName(), dataBroker);
+ InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(parentRefs.getParentInterface(), dataBroker);
if (ifState == null) {
- return;
- }
- updateStateEntry(interfaceNew, transaction, ifState);
-
- NodeConnectorId nodeConnectorId = new NodeConnectorId(ifState.getLowerLayerIf().get(0));
- BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
- long portNo = Long.valueOf(IfmUtil.getPortNoFromNodeConnectorId(nodeConnectorId));
- Integer ifIndex = IfmUtil.allocateId(idManager, IfmConstants.IFM_IDPOOL_NAME, interfaceNew.getName());
- IfL2vlan ifL2vlan = interfaceNew.getAugmentation(IfL2vlan.class);
- if (ifL2vlan == null) {
- futures.add(transaction.submit());
- return;
- }
- if(interfaceNew.isEnabled() && ifState.getOperStatus() == OperStatus.Up) {
- List<MatchInfo> matches = FlowBasedServicesUtils.getMatchInfoForVlanPortAtIngressTable(dpId, portNo, interfaceNew);
- FlowBasedServicesUtils.installVlanFlow(dpId, portNo, interfaceNew, transaction, matches, ifIndex);
- }
- if (ifL2vlan.getL2vlanMode() != IfL2vlan.L2vlanMode.Trunk) {
futures.add(transaction.submit());
return;
}
+ InterfaceManagerCommonUtils.addStateEntry(interfaceNew.getName(), transaction, dataBroker, idManager, ifState);
+
InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(interfaceNew.getName());
InterfaceParentEntry interfaceParentEntry =
InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryKey, dataBroker);
- if (interfaceParentEntry == null) {
+ if (interfaceParentEntry == null || interfaceParentEntry.getInterfaceChildEntry() == null) {
futures.add(transaction.submit());
return;
}
- List<InterfaceChildEntry> interfaceChildEntries = interfaceParentEntry.getInterfaceChildEntry();
- if (interfaceChildEntries == null) {
- return;
- }
-
- OperStatus operStatus = ifState.getOperStatus();
- PhysAddress physAddress = ifState.getPhysAddress();
- AdminStatus adminStatus = ifState.getAdminStatus();
-
//FIXME: If the no. of child entries exceeds 100, perform txn updates in batches of 100.
- for (InterfaceChildEntry interfaceChildEntry : interfaceChildEntries) {
- InterfaceKey childIfKey = new InterfaceKey(interfaceChildEntry.getChildInterface());
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface ifaceChild =
- InterfaceManagerCommonUtils.getInterfaceFromConfigDS(childIfKey, dataBroker);
-
- if (!ifaceChild.isEnabled()) {
- operStatus = OperStatus.Down;
- }
-
- InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifChildStateId =
- IfmUtil.buildStateInterfaceId(ifaceChild.getName());
- List<String> childLowerLayerIfList = new ArrayList<>();
- childLowerLayerIfList.add(0, nodeConnectorId.getValue());
- childLowerLayerIfList.add(1, interfaceNew.getName());
- ifIndex = IfmUtil.allocateId(idManager, IfmConstants.IFM_IDPOOL_NAME, ifaceChild.getName());
- InterfaceBuilder childIfaceBuilder = new InterfaceBuilder().setAdminStatus(adminStatus)
- .setOperStatus(operStatus).setPhysAddress(physAddress).setLowerLayerIf(childLowerLayerIfList);
- childIfaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(ifaceChild.getName()));
- transaction.put(LogicalDatastoreType.OPERATIONAL, ifChildStateId, childIfaceBuilder.build(), true);
- if (operStatus == OperStatus.Up) {
- List<MatchInfo> matches = FlowBasedServicesUtils.getMatchInfoForVlanPortAtIngressTable(dpId, portNo, ifaceChild);
- FlowBasedServicesUtils.installVlanFlow(dpId, portNo, ifaceChild, transaction, matches, ifIndex);
- }
+ for (InterfaceChildEntry interfaceChildEntry : interfaceParentEntry.getInterfaceChildEntry()) {
+ InterfaceManagerCommonUtils.addStateEntry(interfaceChildEntry.getChildInterface(), transaction, dataBroker, idManager,ifState);
}
futures.add(transaction.submit());
}
private static void addTunnelConfiguration(DataBroker dataBroker, ParentRefs parentRefs,
- Interface interfaceNew, IdManagerService idManager,
- AlivenessMonitorService alivenessMonitorService,
- IMdsalApiManager mdsalApiManager,
- List<ListenableFuture<Void>> futures) {
+ Interface interfaceNew, IdManagerService idManager,
+ AlivenessMonitorService alivenessMonitorService,
+ IMdsalApiManager mdsalApiManager,
+ List<ListenableFuture<Void>> futures) {
LOG.debug("adding tunnel configuration for {}", interfaceNew.getName());
WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
if (parentRefs == null) {
LOG.debug("creating bridge interfaceEntry in ConfigDS {}", bridgeEntryKey);
InterfaceMetaUtils.createBridgeInterfaceEntryInConfigDS(bridgeEntryKey, bridgeInterfaceEntryKey,
- interfaceNew.getName(), transaction);
+ interfaceNew.getName(), transaction);
futures.add(transaction.submit());
// create bridge on switch, if switch is connected
}
}
}
-
- private static void updateStateEntry(Interface interfaceNew, WriteTransaction transaction,
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState) {
- InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId =
- IfmUtil.buildStateInterfaceId(interfaceNew.getName());
- InterfaceBuilder ifaceBuilder = new InterfaceBuilder();
- if (!interfaceNew.isEnabled() && ifState.getOperStatus() != OperStatus.Down) {
- ifaceBuilder.setOperStatus(OperStatus.Down);
- ifaceBuilder.setType(interfaceNew.getType());
- ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceNew.getName()));
- transaction.merge(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build());
- }
- }
}
package org.opendaylight.vpnservice.interfacemgr.renderer.ovs.confighelpers;
import com.google.common.util.concurrent.ListenableFuture;
-
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
removeTunnelConfiguration(alivenessMonitorService, parentRefs, dataBroker, interfaceOld,
idManager, mdsalApiManager, futures);
}else {
- removeVlanConfiguration(dataBroker, interfaceOld, t);
+ removeVlanConfiguration(dataBroker, parentRefs, interfaceOld, t);
futures.add(t.submit());
}
return futures;
}
- private static void removeVlanConfiguration(DataBroker dataBroker, Interface interfaceOld, WriteTransaction t) {
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState =
- InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceOld.getName(), dataBroker);
- if (ifState == null) {
- return;
- }
-
- String ncStr = ifState.getLowerLayerIf().get(0);
- NodeConnectorId nodeConnectorId = new NodeConnectorId(ncStr);
- NodeConnector nodeConnector =
- InterfaceManagerCommonUtils.getNodeConnectorFromInventoryOperDS(nodeConnectorId, dataBroker);
- if(nodeConnector != null) {
- FlowCapableNodeConnector flowCapableNodeConnector =
- nodeConnector.getAugmentation(FlowCapableNodeConnector.class);
- //State state = flowCapableNodeConnector.getState();
- OperStatus operStatus = flowCapableNodeConnector == null ? OperStatus.Down : OperStatus.Up;
-
- if (ifState.getOperStatus() != operStatus) {
- InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId =
- IfmUtil.buildStateInterfaceId(interfaceOld.getName());
- InterfaceBuilder ifaceBuilder = new InterfaceBuilder();
- ifaceBuilder.setOperStatus(operStatus);
- ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceOld.getName()));
- t.merge(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build());
- }
- }
+ private static void removeVlanConfiguration(DataBroker dataBroker, ParentRefs parentRefs, Interface interfaceOld, WriteTransaction transaction) {
IfL2vlan ifL2vlan = interfaceOld.getAugmentation(IfL2vlan.class);
- if (ifL2vlan == null) {
+ if (ifL2vlan == null || ifL2vlan.getL2vlanMode() != IfL2vlan.L2vlanMode.Trunk) {
return;
}
- BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
- FlowBasedServicesUtils.removeIngressFlow(interfaceOld, dpId, t);
- if (ifL2vlan.getL2vlanMode() != IfL2vlan.L2vlanMode.Trunk) {
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState =
+ InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceOld.getName(), dataBroker);
+ if (ifState == null) {
return;
}
+ InterfaceManagerCommonUtils.updateOperStatus(interfaceOld.getName(), OperStatus.Down, transaction);
+ NodeConnectorId ncId = new NodeConnectorId(ifState.getLowerLayerIf().get(0));
+ BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(ncId));
+ FlowBasedServicesUtils.removeIngressFlow(interfaceOld.getName(), dpId, transaction);
// For Vlan-Trunk Interface, remove the trunk-member operstates as well...
- InterfaceKey interfaceKey = new InterfaceKey(interfaceOld.getName());
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface =
- InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
- if (iface == null) {
- return;
- }
- InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(iface.getName());
+ InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(interfaceOld.getName());
InterfaceParentEntry interfaceParentEntry =
InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryKey, dataBroker);
- if (interfaceParentEntry == null) {
- return;
- }
-
- List<InterfaceChildEntry> interfaceChildEntries = interfaceParentEntry.getInterfaceChildEntry();
- if (interfaceChildEntries == null) {
+ if (interfaceParentEntry == null || interfaceParentEntry.getInterfaceChildEntry() == null) {
return;
}
//FIXME: If the no. of child entries exceeds 100, perform txn updates in batches of 100.
- for (InterfaceChildEntry interfaceChildEntry : interfaceChildEntries) {
- InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifChildStateId =
- IfmUtil.buildStateInterfaceId(interfaceChildEntry.getChildInterface());
- t.delete(LogicalDatastoreType.OPERATIONAL, ifChildStateId);
- InterfaceKey childIfKey = new InterfaceKey(interfaceChildEntry.getChildInterface());
- FlowBasedServicesUtils.removeIngressFlow(InterfaceManagerCommonUtils.getInterfaceFromConfigDS(childIfKey, dataBroker), dpId, t);
+ for (InterfaceChildEntry interfaceChildEntry : interfaceParentEntry.getInterfaceChildEntry()) {
+ InterfaceManagerCommonUtils.deleteStateEntry(interfaceChildEntry.getChildInterface(), transaction);
+ FlowBasedServicesUtils.removeIngressFlow(interfaceChildEntry.getChildInterface(), dpId, transaction);
}
}
WriteTransaction t = dataBroker.newWriteOnlyTransaction();
if (interfaceNew.isEnabled() != interfaceOld.isEnabled()) {
- OperStatus operStatus;
- if (!interfaceNew.isEnabled()) {
- operStatus = OperStatus.Down;
- } else {
- String ncStr = ifState.getLowerLayerIf().get(0);
- NodeConnectorId nodeConnectorId = new NodeConnectorId(ncStr);
- NodeConnector nodeConnector =
- InterfaceManagerCommonUtils.getNodeConnectorFromInventoryOperDS(nodeConnectorId, dataBroker);
- FlowCapableNodeConnector flowCapableNodeConnector =
- nodeConnector.getAugmentation(FlowCapableNodeConnector.class);
- //State state = flowCapableNodeConnector.getState();
- operStatus = flowCapableNodeConnector == null ? OperStatus.Down : OperStatus.Up;
- }
-
- String ifName = interfaceNew.getName();
- InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId =
- IfmUtil.buildStateInterfaceId(interfaceNew.getName());
- InterfaceBuilder ifaceBuilder = new InterfaceBuilder();
- ifaceBuilder.setOperStatus(operStatus);
- ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(ifName));
- t.merge(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build());
+ OperStatus operStatus = InterfaceManagerCommonUtils.updateStateEntry(interfaceNew, dataBroker, t, ifState);
- IfL2vlan ifL2vlan = interfaceNew.getAugmentation(IfL2vlan.class);
- if (ifL2vlan == null || ifL2vlan.getL2vlanMode() != IfL2vlan.L2vlanMode.Trunk) {
- futures.add(t.submit());
+ IfTunnel ifTunnel = interfaceNew.getAugmentation(IfTunnel.class);
+ if(ifTunnel != null){
// stop tunnel monitoring if admin state is disabled for a vxlan trunk interface
if(!interfaceNew.isEnabled()){
AlivenessMonitorUtils.stopLLDPMonitoring(alivenessMonitorService, dataBroker, interfaceNew);
+ futures.add(t.submit());
+ return futures;
}
- return futures;
}
- InterfaceKey interfaceKey = new InterfaceKey(ifName);
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface =
- InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
- if (iface == null) {
+ IfL2vlan ifL2vlan = interfaceNew.getAugmentation(IfL2vlan.class);
+ if (ifL2vlan == null || ifL2vlan.getL2vlanMode() != IfL2vlan.L2vlanMode.Trunk) {
futures.add(t.submit());
return futures;
}
- InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(iface.getName());
+ InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(interfaceNew.getName());
InterfaceParentEntry interfaceParentEntry =
InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryKey, dataBroker);
- if (interfaceParentEntry == null) {
- futures.add(t.submit());
- return futures;
- }
-
- List<InterfaceChildEntry> interfaceChildEntries = interfaceParentEntry.getInterfaceChildEntry();
- if (interfaceChildEntries == null) {
+ if (interfaceParentEntry == null || interfaceParentEntry.getInterfaceChildEntry() == null) {
futures.add(t.submit());
return futures;
}
- for (InterfaceChildEntry interfaceChildEntry : interfaceChildEntries) {
- InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifChildStateId =
- IfmUtil.buildStateInterfaceId(interfaceChildEntry.getChildInterface());
- InterfaceBuilder ifaceBuilderChild = new InterfaceBuilder();
- ifaceBuilderChild.setOperStatus(operStatus);
- ifaceBuilderChild.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceChildEntry.getChildInterface()));
- t.merge(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilderChild.build());
+ for (InterfaceChildEntry interfaceChildEntry : interfaceParentEntry.getInterfaceChildEntry()) {
+ InterfaceManagerCommonUtils.updateOperStatus(interfaceChildEntry.getChildInterface(), operStatus, t);
}
}
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.idmanager.IdManager;
-import org.opendaylight.vpnservice.VpnUtil;
import org.opendaylight.vpnservice.interfacemgr.IfmConstants;
import org.opendaylight.vpnservice.interfacemgr.IfmUtil;
import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntryKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info._interface.parent.entry.InterfaceChildEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info._interface.parent.entry.InterfaceChildEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info._interface.parent.entry.InterfaceChildEntryKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfL2vlan;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.ParentRefs;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
List<ListenableFuture<Void>> futures = new ArrayList<>();
WriteTransaction t = dataBroker.newWriteOnlyTransaction();
- InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(parentRefs.getParentInterface());
- createInterfaceParentEntryIfNotPresent(dataBroker, t, interfaceParentEntryKey, parentRefs.getParentInterface());
- createInterfaceChildEntry(dataBroker, idManager, t, interfaceParentEntryKey, interfaceNew.getName());
+ InterfaceManagerCommonUtils.createInterfaceParentEntryIfNotPresent(dataBroker, t, parentRefs.getParentInterface());
+ InterfaceManagerCommonUtils.createInterfaceChildEntry(t, parentRefs.getParentInterface(), interfaceNew.getName());
InterfaceKey interfaceKey = new InterfaceKey(parentRefs.getParentInterface());
Interface ifaceParent = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
IfmUtil.buildStateInterfaceId(interfaceNew.getName());
List<String> lowerLayerIfList = new ArrayList<>();
lowerLayerIfList.add(ifState.getLowerLayerIf().get(0));
- lowerLayerIfList.add(parentRefs.getParentInterface());
+ //lowerLayerIfList.add(parentRefs.getParentInterface());
Integer ifIndex = IfmUtil.allocateId(idManager, IfmConstants.IFM_IDPOOL_NAME, interfaceNew.getName());
InterfaceBuilder ifaceBuilder = new InterfaceBuilder().setAdminStatus(adminStatus).setOperStatus(operStatus)
.setPhysAddress(physAddress).setLowerLayerIf(lowerLayerIfList).setIfIndex(ifIndex);
futures.add(t.submit());
return futures;
}
-
- private static void createInterfaceParentEntryIfNotPresent(DataBroker dataBroker, WriteTransaction t,
- InterfaceParentEntryKey interfaceParentEntryKey,
- String parentInterface){
- InstanceIdentifier<InterfaceParentEntry> interfaceParentEntryIdentifier =
- InterfaceMetaUtils.getInterfaceParentEntryIdentifier(interfaceParentEntryKey);
- InterfaceParentEntry interfaceParentEntry =
- InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryIdentifier, dataBroker);
-
- if(interfaceParentEntry != null){
- LOG.info("Not Found entry for Parent Interface: {} in Vlan Trunk-Member Interface Renderer ConfigDS. " +
- "Creating...", parentInterface);
- InterfaceParentEntryBuilder interfaceParentEntryBuilder = new InterfaceParentEntryBuilder()
- .setKey(interfaceParentEntryKey).setParentInterface(parentInterface);
- t.put(LogicalDatastoreType.CONFIGURATION, interfaceParentEntryIdentifier,
- interfaceParentEntryBuilder.build(), true);
- }
- }
-
- private static long createInterfaceChildEntry(DataBroker dataBroker, IdManagerService idManager, WriteTransaction t,
- InterfaceParentEntryKey interfaceParentEntryKey, String childInterface){
-
- long lportTag = IfmUtil.allocateId(idManager, IfmConstants.IFM_IDPOOL_NAME, childInterface);
- InterfaceChildEntryKey interfaceChildEntryKey = new InterfaceChildEntryKey(childInterface);
- InstanceIdentifier<InterfaceChildEntry> intfId =
- InterfaceMetaUtils.getInterfaceChildEntryIdentifier(interfaceParentEntryKey, interfaceChildEntryKey);
- InterfaceChildEntryBuilder entryBuilder = new InterfaceChildEntryBuilder().setKey(interfaceChildEntryKey)
- .setChildInterface(childInterface);
- t.put(LogicalDatastoreType.CONFIGURATION, intfId, entryBuilder.build(),true);
- return lportTag;
- }
}
InterfaceParentEntry interfaceParentEntry =
InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryIid, dataBroker);
+ if(interfaceParentEntry == null){
+ return futures;
+ }
+
List<InterfaceChildEntry> interfaceChildEntries = interfaceParentEntry.getInterfaceChildEntry();
if (interfaceChildEntries.size() <= 1) {
t.delete(LogicalDatastoreType.CONFIGURATION, interfaceParentEntryIid);
InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId =
IfmUtil.buildStateInterfaceId(interfaceOld.getName());
t.delete(LogicalDatastoreType.OPERATIONAL, ifStateId);
- FlowBasedServicesUtils.removeIngressFlow(interfaceOld, dpId, t);
+ FlowBasedServicesUtils.removeIngressFlow(interfaceOld.getName(), dpId, t);
}
futures.add(t.submit());
import com.google.common.util.concurrent.ListenableFuture;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.idmanager.IdManager;
-import org.opendaylight.vpnservice.VpnConstants;
import org.opendaylight.vpnservice.interfacemgr.IfmConstants;
import org.opendaylight.vpnservice.interfacemgr.IfmUtil;
import org.opendaylight.vpnservice.interfacemgr.commons.AlivenessMonitorUtils;
import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils;
import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceMetaUtils;
import org.opendaylight.vpnservice.interfacemgr.servicebindings.flowbased.utilities.FlowBasedServicesUtils;
-import org.opendaylight.vpnservice.mdsalutil.*;
+import org.opendaylight.vpnservice.mdsalutil.MatchInfo;
+import org.opendaylight.vpnservice.mdsalutil.NwConstants;
import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.AlivenessMonitorService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntryKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info._interface.parent.entry.InterfaceChildEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfL2vlan;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfTunnel;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.ParentRefs;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* This worker is responsible for adding the openflow-interfaces/of-port-info container
* in odl-interface-openflow yang.
* Where applicable:
- * Create the entries in Interface-State OperDS.
- * Create the entries in Inventory OperDS.
+ * Create the entries in Interface-State OperDS.
+ * Create the entries in Inventory OperDS.
*/
public class OvsInterfaceStateAddHelper {
*/
Interface.OperStatus operStatus = Interface.OperStatus.Up;
Interface.AdminStatus adminStatus = Interface.AdminStatus.Up;
+
+ // Fetch the interface name corresponding to the port Name
InterfaceKey interfaceKey = new InterfaceKey(portName);
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface =
InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
- if (iface != null && !iface.isEnabled()) {
- operStatus = Interface.OperStatus.Down;
- }
-
- List<String> lowerLayerIfList = new ArrayList<>();
- lowerLayerIfList.add(nodeConnectorId.getValue());
-
- Integer ifIndex = IfmUtil.allocateId(idManager, IfmConstants.IFM_IDPOOL_NAME, portName);
- InstanceIdentifier<Interface> ifStateId = IfmUtil.buildStateInterfaceId(portName);
- InterfaceBuilder ifaceBuilder = new InterfaceBuilder().setOperStatus(operStatus)
- .setAdminStatus(adminStatus).setPhysAddress(physAddress).setIfIndex(ifIndex).setLowerLayerIf(lowerLayerIfList)
- .setKey(IfmUtil.getStateInterfaceKeyFromName(portName));
- if(iface != null) {
- ifaceBuilder.setType(iface.getType());
- }
- transaction.put(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build(), true);
-
- // allocate lport tag and set in if-index
- InterfaceMetaUtils.createLportTagInterfaceMap(transaction, portName, ifIndex);
- if (iface == null) {
- futures.add(transaction.submit());
- return futures;
- }
-
+ Interface ifState = InterfaceManagerCommonUtils.addStateEntry(iface, portName, transaction, idManager,
+ physAddress, operStatus, adminStatus, nodeConnectorId);
BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
long portNo = Long.valueOf(IfmUtil.getPortNoFromNodeConnectorId(nodeConnectorId));
// If this interface is a tunnel interface, create the tunnel ingress flow
- IfTunnel tunnel = iface.getAugmentation(IfTunnel.class);
- if(tunnel != null){
- InterfaceManagerCommonUtils.makeTunnelIngressFlow(futures, mdsalApiManager, tunnel,dpId, portNo, iface,
- ifIndex, NwConstants.ADD_FLOW);
- futures.add(transaction.submit());
- AlivenessMonitorUtils.startLLDPMonitoring(alivenessMonitorService, dataBroker, iface);
- return futures;
+ if(iface != null) {
+ IfTunnel tunnel = iface.getAugmentation(IfTunnel.class);
+ if (tunnel != null) {
+ InterfaceManagerCommonUtils.makeTunnelIngressFlow(futures, mdsalApiManager, tunnel, dpId, portNo, iface,
+ ifState.getIfIndex(), NwConstants.ADD_FLOW);
+ futures.add(transaction.submit());
+ AlivenessMonitorUtils.startLLDPMonitoring(alivenessMonitorService, dataBroker, iface);
+ return futures;
+ }
}
- // If this interface maps to a Vlan trunk entity, operational states of all the vlan-trunk-members
- // should also be created here.
- IfL2vlan ifL2vlan = iface.getAugmentation(IfL2vlan.class);
- if (ifL2vlan == null) {
- futures.add(transaction.submit());
- return futures;
- }
- if(operStatus == Interface.OperStatus.Up) {
- List<MatchInfo> matches = FlowBasedServicesUtils.getMatchInfoForVlanPortAtIngressTable(dpId, portNo, iface);
- FlowBasedServicesUtils.installVlanFlow(dpId, portNo, iface, transaction, matches, ifIndex);
- }
- if (ifL2vlan.getL2vlanMode() != IfL2vlan.L2vlanMode.Trunk) {
- futures.add(transaction.submit());
- return futures;
- }
- InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(iface.getName());
+ // For all other interfaces except tunnel interfaces, interface name won't be same as port name.
+ // In that case fetch the interface corresponding to the portName, and update the state accordingly
+ InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(portName);
InterfaceParentEntry interfaceParentEntry =
InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryKey, dataBroker);
- if (interfaceParentEntry == null) {
- futures.add(transaction.submit());
- return futures;
- }
-
- List<InterfaceChildEntry> interfaceChildEntries = interfaceParentEntry.getInterfaceChildEntry();
- if (interfaceChildEntries == null) {
+ if (interfaceParentEntry == null || interfaceParentEntry.getInterfaceChildEntry() == null) {
futures.add(transaction.submit());
return futures;
}
//FIXME: If the no. of child entries exceeds 100, perform txn updates in batches of 100.
//List<Trunks> trunks = new ArrayList<>();
- for (InterfaceChildEntry interfaceChildEntry : interfaceChildEntries) {
- InterfaceKey childIfKey = new InterfaceKey(interfaceChildEntry.getChildInterface());
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface ifaceChild =
- InterfaceManagerCommonUtils.getInterfaceFromConfigDS(childIfKey, dataBroker);
- // IfL2vlan ifL2vlanChild = iface.getAugmentation(IfL2vlan.class);
- // trunks.add(new TrunksBuilder().setTrunk(ifL2vlanChild.getVlanId()).build());
+ String higherlayerChild = interfaceParentEntry.getInterfaceChildEntry().get(0).getChildInterface();
+ InterfaceManagerCommonUtils.addStateEntry(higherlayerChild, transaction, dataBroker, idManager,
+ ifState);
- if (!ifaceChild.isEnabled()) {
- operStatus = Interface.OperStatus.Down;
- }
- InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifChildStateId =
- IfmUtil.buildStateInterfaceId(ifaceChild.getName());
- List<String> childLowerLayerIfList = new ArrayList<>();
- childLowerLayerIfList.add(0, nodeConnectorId.getValue());
- childLowerLayerIfList.add(1, iface.getName());
- ifIndex = IfmUtil.allocateId(idManager, IfmConstants.IFM_IDPOOL_NAME, ifaceChild.getName());
- InterfaceBuilder childIfaceBuilder = new InterfaceBuilder().setAdminStatus(adminStatus).setOperStatus(operStatus)
- .setPhysAddress(physAddress).setLowerLayerIf(childLowerLayerIfList).setIfIndex(ifIndex);
- childIfaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(ifaceChild.getName())).setType(ifaceChild.getType());
- transaction.put(LogicalDatastoreType.OPERATIONAL, ifChildStateId, childIfaceBuilder.build(), true);
-
- // create lportTag Interface Map
- InterfaceMetaUtils.createLportTagInterfaceMap(transaction, ifaceChild.getName(), ifIndex);
- if (operStatus == Interface.OperStatus.Up) {
- List<MatchInfo> matches = FlowBasedServicesUtils.getMatchInfoForVlanPortAtIngressTable(dpId, portNo, ifaceChild);
- FlowBasedServicesUtils.installVlanFlow(dpId, portNo, ifaceChild, transaction, matches, ifIndex);
+ // If this interface maps to a Vlan trunk entity, operational states of all the vlan-trunk-members
+ // should also be created here.
+ InterfaceParentEntryKey higherLayerParentEntryKey = new InterfaceParentEntryKey(higherlayerChild);
+ InterfaceParentEntry higherLayerParent =
+ InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(higherLayerParentEntryKey, dataBroker);
+ if(higherLayerParent != null && higherLayerParent.getInterfaceChildEntry() != null) {
+ for (InterfaceChildEntry interfaceChildEntry : higherLayerParent.getInterfaceChildEntry()){
+ InterfaceManagerCommonUtils.addStateEntry(interfaceChildEntry.getChildInterface(), transaction, dataBroker, idManager,
+ ifState);
}
}
-
/** Below code will be needed if we want to update the vlan-trunks on the of-port
- if (trunks.isEmpty()) {
- futures.add(t.submit());
- return futures;
- }
-
- BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
-
- BridgeRefEntryKey BridgeRefEntryKey = new BridgeRefEntryKey(dpId);
- InstanceIdentifier<BridgeRefEntry> dpnBridgeEntryIid =
- InterfaceMetaUtils.getBridgeRefEntryIdentifier(BridgeRefEntryKey);
- BridgeRefEntry bridgeRefEntry =
- InterfaceMetaUtils.getBridgeRefEntryFromOperDS(dpnBridgeEntryIid, dataBroker);
- if (bridgeRefEntry == null) {
- futures.add(t.submit());
- return futures;
- }
-
- InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid =
- (InstanceIdentifier<OvsdbBridgeAugmentation>)bridgeRefEntry.getBridgeReference().getValue();
- VlanTrunkSouthboundUtils.addTerminationPointWithTrunks(bridgeIid, trunks, iface.getName(), t);
+ if (trunks.isEmpty()) {
+ futures.add(t.submit());
+ return futures;
+ }
+
+ BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
+
+ BridgeRefEntryKey BridgeRefEntryKey = new BridgeRefEntryKey(dpId);
+ InstanceIdentifier<BridgeRefEntry> dpnBridgeEntryIid =
+ InterfaceMetaUtils.getBridgeRefEntryIdentifier(BridgeRefEntryKey);
+ BridgeRefEntry bridgeRefEntry =
+ InterfaceMetaUtils.getBridgeRefEntryFromOperDS(dpnBridgeEntryIid, dataBroker);
+ if (bridgeRefEntry == null) {
+ futures.add(t.submit());
+ return futures;
+ }
+
+ InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid =
+ (InstanceIdentifier<OvsdbBridgeAugmentation>)bridgeRefEntry.getBridgeReference().getValue();
+ VlanTrunkSouthboundUtils.addTerminationPointWithTrunks(bridgeIid, trunks, iface.getName(), t);
*/
futures.add(transaction.submit());
transaction.delete(LogicalDatastoreType.OPERATIONAL, ifStateId);
- // For Vlan-Trunk Interface, remove the trunk-member operstates as well...
InterfaceKey interfaceKey = new InterfaceKey(portName);
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface =
InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
- if (iface == null) {
- futures.add(transaction.submit());
- return futures;
- }
NodeConnectorId nodeConnectorId = InstanceIdentifier.keyOf(key.firstIdentifierOf(NodeConnector.class)).getId();
BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
// If this interface is a tunnel interface, remove the tunnel ingress flow and stop lldp monitoring
- IfTunnel tunnel = iface.getAugmentation(IfTunnel.class);
- if(tunnel != null){
- long portNo = Long.valueOf(IfmUtil.getPortNoFromNodeConnectorId(nodeConnectorId));
- InterfaceManagerCommonUtils.makeTunnelIngressFlow(futures, mdsalApiManager, tunnel, dpId, portNo, iface, -1,
- NwConstants.DEL_FLOW);
- futures.add(transaction.submit());
- AlivenessMonitorUtils.stopLLDPMonitoring(alivenessMonitorService, dataBroker, iface);
- return futures;
- }
-
- IfL2vlan ifL2vlan = iface.getAugmentation(IfL2vlan.class);
- if (ifL2vlan == null) {
- futures.add(transaction.submit());
- return futures;
- }
- FlowBasedServicesUtils.removeIngressFlow(iface, dpId, transaction);
- if (ifL2vlan.getL2vlanMode() != IfL2vlan.L2vlanMode.Trunk) {
- futures.add(transaction.submit());
- return futures;
+ if(iface != null) {
+ IfTunnel tunnel = iface.getAugmentation(IfTunnel.class);
+ if (tunnel != null) {
+ long portNo = Long.valueOf(IfmUtil.getPortNoFromNodeConnectorId(nodeConnectorId));
+ InterfaceManagerCommonUtils.makeTunnelIngressFlow(futures, mdsalApiManager, tunnel, dpId, portNo, iface, -1,
+ NwConstants.DEL_FLOW);
+ futures.add(transaction.submit());
+ AlivenessMonitorUtils.stopLLDPMonitoring(alivenessMonitorService, dataBroker, iface);
+ return futures;
+ }
}
- InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(iface.getName());
+ InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(portName);
InterfaceParentEntry interfaceParentEntry =
InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryKey, dataBroker);
- if (interfaceParentEntry == null) {
- futures.add(transaction.submit());
- return futures;
- }
-
- List<InterfaceChildEntry> interfaceChildEntries = interfaceParentEntry.getInterfaceChildEntry();
- if (interfaceChildEntries == null) {
+ if (interfaceParentEntry == null || interfaceParentEntry.getInterfaceChildEntry() == null) {
futures.add(transaction.submit());
return futures;
}
//FIXME: If the no. of child entries exceeds 100, perform txn updates in batches of 100.
- for (InterfaceChildEntry interfaceChildEntry : interfaceChildEntries) {
- InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifChildStateId =
- IfmUtil.buildStateInterfaceId(interfaceChildEntry.getChildInterface());
- /* Remove entry from if-index-interface-name map and deallocate Id from Idmanager. */
- Interface childInterfaceState = InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceChildEntry.getChildInterface(), dataBroker);
- if(interfaceState != null) {
- InterfaceMetaUtils.removeLportTagInterfaceMap(transaction, idManager, dataBroker, childInterfaceState.getName(), childInterfaceState.getIfIndex());
- transaction.delete(LogicalDatastoreType.OPERATIONAL, ifChildStateId);
- InterfaceKey childIfKey = new InterfaceKey(interfaceChildEntry.getChildInterface());
- FlowBasedServicesUtils.removeIngressFlow(InterfaceManagerCommonUtils.getInterfaceFromConfigDS(childIfKey, dataBroker), dpId, transaction);
+ InterfaceChildEntry higherlayerChild = interfaceParentEntry.getInterfaceChildEntry().get(0);
+ InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface>
+ higerLayerChildIfStateId = IfmUtil.buildStateInterfaceId(higherlayerChild.getChildInterface());
+ /* Remove entry from if-index-interface-name map and deallocate Id from Idmanager. */
+ Interface higherLayerIfChildState = InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(higherlayerChild.getChildInterface(), dataBroker);
+ if (interfaceState != null) {
+ InterfaceMetaUtils.removeLportTagInterfaceMap(transaction, idManager, dataBroker, higherLayerIfChildState.getName(),
+ higherLayerIfChildState.getIfIndex());
+ transaction.delete(LogicalDatastoreType.OPERATIONAL, higerLayerChildIfStateId);
+ FlowBasedServicesUtils.removeIngressFlow(higherLayerIfChildState.getName(), dpId, transaction);
+ }
+ // If this interface maps to a Vlan trunk entity, operational states of all the vlan-trunk-members
+ // should also be created here.
+ InterfaceParentEntryKey higherLayerParentEntryKey = new InterfaceParentEntryKey(higherlayerChild.getChildInterface());
+ InterfaceParentEntry higherLayerParent =
+ InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(higherLayerParentEntryKey, dataBroker);
+
+ if(higherLayerParent != null && higherLayerParent.getInterfaceChildEntry() != null) {
+ for (InterfaceChildEntry interfaceChildEntry : higherLayerParent.getInterfaceChildEntry()) {
+ InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifChildStateId =
+ IfmUtil.buildStateInterfaceId(interfaceChildEntry.getChildInterface());
+ /* Remove entry from if-index-interface-name map and deallocate Id from Idmanager. */
+ Interface childInterfaceState = InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceChildEntry.getChildInterface(), dataBroker);
+ if (interfaceState != null) {
+ InterfaceMetaUtils.removeLportTagInterfaceMap(transaction, idManager, dataBroker, childInterfaceState.getName(), childInterfaceState.getIfIndex());
+ transaction.delete(LogicalDatastoreType.OPERATIONAL, ifChildStateId);
+ FlowBasedServicesUtils.removeIngressFlow(childInterfaceState.getName(), dpId, transaction);
+ }
}
}
+
/* Below code will be needed if we want to update the vlan-trunk in the of-port.
NodeConnectorId nodeConnectorId = InstanceIdentifier.keyOf(key.firstIdentifierOf(NodeConnector.class)).getId();
BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntryKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info._interface.parent.entry.InterfaceChildEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfTunnel;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(portName);
InterfaceParentEntry interfaceParentEntry =
InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryKey, dataBroker);
- if (interfaceParentEntry == null) {
+ if (interfaceParentEntry == null || interfaceParentEntry.getInterfaceChildEntry() == null) {
futures.add(t.submit());
// start/stop monitoring based on opState
- if(operStatusNew == Interface.OperStatus.Down )
- AlivenessMonitorUtils.stopLLDPMonitoring(alivenessMonitorService, dataBroker, iface);
- else
- AlivenessMonitorUtils.startLLDPMonitoring(alivenessMonitorService,dataBroker, iface);
+ IfTunnel ifTunnel = iface.getAugmentation(IfTunnel.class);
+ if(ifTunnel != null) {
+ if (operStatusNew == Interface.OperStatus.Down)
+ AlivenessMonitorUtils.stopLLDPMonitoring(alivenessMonitorService, dataBroker, iface);
+ else
+ AlivenessMonitorUtils.startLLDPMonitoring(alivenessMonitorService, dataBroker, iface);
+ }
return futures;
}
-
- List<InterfaceChildEntry> interfaceChildEntries = interfaceParentEntry.getInterfaceChildEntry();
- if (interfaceChildEntries == null) {
- futures.add(t.submit());
- return futures;
- }
-
- LOG.debug("Updating if-state entries for Vlan-Trunk Members for port: {}", portName);
- //FIXME: If the no. of child entries exceeds 100, perform txn updates in batches of 100.
- for (InterfaceChildEntry interfaceChildEntry : interfaceChildEntries) {
- InstanceIdentifier<Interface> ifChildStateId =
- IfmUtil.buildStateInterfaceId(interfaceChildEntry.getChildInterface());
- t.merge(LogicalDatastoreType.OPERATIONAL, ifChildStateId, ifaceBuilder.build());
+ for(InterfaceChildEntry higherlayerChild : interfaceParentEntry.getInterfaceChildEntry()) {
+ InstanceIdentifier<Interface> higherLayerIfChildStateId =
+ IfmUtil.buildStateInterfaceId(higherlayerChild.getChildInterface());
+ t.merge(LogicalDatastoreType.OPERATIONAL, higherLayerIfChildStateId, ifaceBuilder.build());
+ InterfaceParentEntryKey higherLayerParentEntryKey = new InterfaceParentEntryKey(higherlayerChild.getChildInterface());
+ InterfaceParentEntry higherLayerParent =
+ InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(higherLayerParentEntryKey, dataBroker);
+ if(higherLayerParent != null && higherLayerParent.getInterfaceChildEntry() != null) {
+ for (InterfaceChildEntry interfaceChildEntry : higherLayerParent.getInterfaceChildEntry()) {
+ LOG.debug("Updating if-state entries for Vlan-Trunk Members for port: {}", portName);
+ //FIXME: If the no. of child entries exceeds 100, perform txn updates in batches of 100.
+ InstanceIdentifier<Interface> ifChildStateId =
+ IfmUtil.buildStateInterfaceId(interfaceChildEntry.getChildInterface());
+ t.merge(LogicalDatastoreType.OPERATIONAL, ifChildStateId, ifaceBuilder.build());
+ }
+ }
}
}
List<ActionInfo> listActionInfo = new ArrayList<ActionInfo>();
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState =
InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceName, dataBroker);
-
- String lowerLayerIf = ifState.getLowerLayerIf().get(0);
- NodeConnectorId nodeConnectorId = new NodeConnectorId(lowerLayerIf);
- String portNo = IfmUtil.getPortNoFromNodeConnectorId(nodeConnectorId);
- Class<? extends InterfaceType> ifType = interfaceInfo.getType();
- if(L2vlan.class.equals(ifType)){
- IfL2vlan vlanIface = interfaceInfo.getAugmentation(IfL2vlan.class);
- LOG.trace("L2Vlan: {}",vlanIface);
- long vlanVid = 0;
- boolean isVlanTransparent = false;
- if (vlanIface != null) {
- vlanVid = vlanIface.getVlanId() == null ? 0 : vlanIface.getVlanId().getValue();
- isVlanTransparent = vlanIface.getL2vlanMode() == IfL2vlan.L2vlanMode.Transparent;
- }
- if (vlanVid != 0 && !isVlanTransparent) {
- listActionInfo.add(new ActionInfo(ActionType.push_vlan, new String[] {}));
- listActionInfo.add(new ActionInfo(ActionType.set_field_vlan_vid,
- new String[] { Long.toString(vlanVid) }));
+ if(ifState != null) {
+ String lowerLayerIf = ifState.getLowerLayerIf().get(0);
+ NodeConnectorId nodeConnectorId = new NodeConnectorId(lowerLayerIf);
+ String portNo = IfmUtil.getPortNoFromNodeConnectorId(nodeConnectorId);
+ Class<? extends InterfaceType> ifType = interfaceInfo.getType();
+ if (L2vlan.class.equals(ifType)) {
+ IfL2vlan vlanIface = interfaceInfo.getAugmentation(IfL2vlan.class);
+ LOG.trace("L2Vlan: {}", vlanIface);
+ long vlanVid = 0;
+ boolean isVlanTransparent = false;
+ if (vlanIface != null) {
+ vlanVid = vlanIface.getVlanId() == null ? 0 : vlanIface.getVlanId().getValue();
+ isVlanTransparent = vlanIface.getL2vlanMode() == IfL2vlan.L2vlanMode.Transparent;
+ }
+ if (vlanVid != 0 && !isVlanTransparent) {
+ listActionInfo.add(new ActionInfo(ActionType.push_vlan, new String[]{}));
+ listActionInfo.add(new ActionInfo(ActionType.set_field_vlan_vid,
+ new String[]{Long.toString(vlanVid)}));
+ }
+ listActionInfo.add(new ActionInfo(ActionType.output, new String[]{portNo}));
+ } else if (Tunnel.class.equals(ifType)) {
+ listActionInfo.add(new ActionInfo(ActionType.output, new String[]{portNo}));
}
- listActionInfo.add(new ActionInfo(ActionType.output, new String[] {portNo}));
- }else if(Tunnel.class.equals(ifType)){
- listActionInfo.add(new ActionInfo(ActionType.output, new String[] { portNo}));
}
return listActionInfo;
}
return String.format("%d:%s:%s", tableId, dpnId, infName);
}
- public static void removeIngressFlow(Interface iface, BigInteger dpId, WriteTransaction t) {
+ public static void removeIngressFlow(String interfaceName, BigInteger dpId, WriteTransaction t) {
LOG.debug("Removing Ingress Flows");
- String flowKeyStr = getFlowRef(IfmConstants.VLAN_INTERFACE_INGRESS_TABLE, dpId, iface.getName());
+ String flowKeyStr = getFlowRef(IfmConstants.VLAN_INTERFACE_INGRESS_TABLE, dpId, interfaceName);
FlowKey flowKey = new FlowKey(new FlowId(flowKeyStr));
Node nodeDpn = buildInventoryDpnNode(dpId);
InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class)
BigInteger dpn) {
InterfaceBuilder builder = new InterfaceBuilder().setKey(new InterfaceKey(ifName)).setName(ifName)
.setDescription(desc).setEnabled(enabled).setType((Class<? extends InterfaceType>) ifType);
- ParentRefs parentRefs = new ParentRefsBuilder().setDatapathNodeIdentifier(dpn).build();
+ ParentRefs parentRefs = new ParentRefsBuilder().setDatapathNodeIdentifier(dpn).setParentInterface(ifName).build();
builder.addAugmentation(ParentRefs.class, parentRefs);
if(ifType.equals(L2vlan.class)){
IfL2vlan l2vlan = new IfL2vlanBuilder().setVlanId(VlanId.getDefaultInstance("0"))
- .setL2vlanMode(IfL2vlan.L2vlanMode.Access).build();
+ .setL2vlanMode(IfL2vlan.L2vlanMode.Trunk).build();
builder.addAugmentation(IfL2vlan.class, l2vlan);
}else if(ifType.equals(IfTunnel.class)){
IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(null).setTunnelGateway(null).setTunnelSource(null)
InterfaceParentEntryKey interfaceParentEntryKey = null;
IfIndexInterface IfindexInterface = null;
InstanceIdentifier<Interface> interfaceInstanceIdentifier = null;
+ InstanceIdentifier<InterfaceParentEntry> interfaceParentEntryInstanceIdentifier = null;
InstanceIdentifier<FlowCapableNodeConnector> fcNodeConnectorId = null;
InstanceIdentifier<IfIndexInterface> ifIndexId =null;
InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> interfaceStateIdentifier = null;
doReturn(Futures.immediateCheckedFuture(expectedInterface)).when(mockReadTx).read(
LogicalDatastoreType.CONFIGURATION, interfaceInstanceIdentifier);
+ doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockReadTx).read(
+ LogicalDatastoreType.CONFIGURATION, interfaceParentEntryIdentifier);
AllocateIdInput getIdInput = new AllocateIdInputBuilder()
.setPoolName(IfmConstants.IFM_IDPOOL_NAME)
.setIdKey(InterfaceManagerTestUtil.interfaceName).build();
LogicalDatastoreType.OPERATIONAL, interfaceStateIdentifier);
doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockReadTx).read(
LogicalDatastoreType.CONFIGURATION, interfaceInstanceIdentifier);
+ doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockReadTx).read(
+ LogicalDatastoreType.CONFIGURATION, interfaceParentEntryIdentifier);
ReleaseIdInput getIdInput = new ReleaseIdInputBuilder()
.setPoolName(IfmConstants.IFM_IDPOOL_NAME)
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.idmanager.IdManager;
import org.opendaylight.vpnservice.interfacemgr.IfmUtil;
+import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceMetaUtils;
import org.opendaylight.vpnservice.interfacemgr.renderer.ovs.confighelpers.OvsInterfaceConfigAddHelper;
import org.opendaylight.vpnservice.interfacemgr.renderer.ovs.confighelpers.OvsInterfaceConfigRemoveHelper;
import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.AllocateIdInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.AllocateIdOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.AllocateIdOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntryKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info._interface.parent.entry.InterfaceChildEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info._interface.parent.entry.InterfaceChildEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info._interface.parent.entry.InterfaceChildEntryKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.ParentRefs;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcResult;
Interface vlanInterfaceDisabled;
InstanceIdentifier<Interface> interfaceInstanceIdentifier;
InstanceIdentifier<NodeConnector> nodeConnectorInstanceIdentifier;
+ InstanceIdentifier<InterfaceParentEntry> interfaceParentEntryIdentifier = null;
+ InterfaceChildEntry interfaceChildEntry = null;
+ InstanceIdentifier<InterfaceChildEntry> interfaceChildEntryInstanceIdentifier;
InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> interfaceStateIdentifier;
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface stateInterface;
RpcResultBuilder<AllocateIdOutput> allocateIdRpcBuilder = RpcResultBuilder.success();
allocateIdRpcBuilder.withResult(output);
ListenableFuture<RpcResult<AllocateIdOutput>> future = Futures.immediateFuture(allocateIdRpcBuilder.build());
-
+ interfaceParentEntryIdentifier = InterfaceMetaUtils.getInterfaceParentEntryIdentifier(
+ new InterfaceParentEntryKey(InterfaceManagerTestUtil.interfaceName));
+ interfaceChildEntryInstanceIdentifier = InterfaceMetaUtils.getInterfaceChildEntryIdentifier(new InterfaceParentEntryKey("s1-eth1"),
+ new InterfaceChildEntryKey(vlanInterfaceEnabled.getName()));
+ interfaceChildEntry = new InterfaceChildEntryBuilder().setKey(new InterfaceChildEntryKey(vlanInterfaceEnabled.getName())).
+ setChildInterface(vlanInterfaceEnabled.getName()).build();
// Setup mocks
when(dataBroker.newReadOnlyTransaction()).thenReturn(mockReadTx);
when(dataBroker.newWriteOnlyTransaction()).thenReturn(mockWriteTx);
LogicalDatastoreType.CONFIGURATION, interfaceInstanceIdentifier);
doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockReadTx).read(
LogicalDatastoreType.OPERATIONAL, interfaceStateIdentifier);
+ doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockReadTx).read(
+ LogicalDatastoreType.CONFIGURATION, interfaceParentEntryIdentifier);
- addHelper.addConfiguration(dataBroker, null, vlanInterfaceEnabled, idManager,
+ addHelper.addConfiguration(dataBroker, vlanInterfaceEnabled.getAugmentation(ParentRefs.class), vlanInterfaceEnabled, idManager,
alivenessMonitorService, mdsalApiManager);
//Nothing to verify, since when switch is not connected we don't do any datastore operation
@Test
public void testAddVlanInterfaceWhenSwitchIsConnected() {
Optional<Interface> expectedInterface = Optional.of(vlanInterfaceEnabled);
- Optional<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> expectedStateInterface = Optional.of(stateInterface);
+ Optional<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface>
+ expectedStateInterface = Optional.of(stateInterface);
doReturn(Futures.immediateCheckedFuture(expectedInterface)).when(mockReadTx).read(
LogicalDatastoreType.CONFIGURATION, interfaceInstanceIdentifier);
doReturn(Futures.immediateCheckedFuture(expectedStateInterface)).when(mockReadTx).read(
LogicalDatastoreType.OPERATIONAL, interfaceStateIdentifier);
+ doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockReadTx).read(
+ LogicalDatastoreType.CONFIGURATION, interfaceParentEntryIdentifier);
- addHelper.addConfiguration(dataBroker, null, vlanInterfaceEnabled, idManager,
+ addHelper.addConfiguration(dataBroker, vlanInterfaceEnabled.getAugmentation(ParentRefs.class), vlanInterfaceEnabled, idManager,
alivenessMonitorService, mdsalApiManager);
//Nothing to verify, since when adminstate is enabled and switch opstate is already up,
LogicalDatastoreType.CONFIGURATION, interfaceInstanceIdentifier);
doReturn(Futures.immediateCheckedFuture(expectedStateInterface)).when(mockReadTx).read(
LogicalDatastoreType.OPERATIONAL, interfaceStateIdentifier);
+ doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockReadTx).read(
+ LogicalDatastoreType.CONFIGURATION, interfaceParentEntryIdentifier);
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder ifaceBuilder = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder();
ifaceBuilder.setOperStatus(OperStatus.Down);
ifaceBuilder.setType(L2vlan.class);
stateInterface = ifaceBuilder.build();
- addHelper.addConfiguration(dataBroker, null, vlanInterfaceDisabled, idManager,
+ addHelper.addConfiguration(dataBroker, vlanInterfaceDisabled.getAugmentation(ParentRefs.class), vlanInterfaceDisabled, idManager,
alivenessMonitorService, mdsalApiManager);
//verification
- verify(mockWriteTx).merge(LogicalDatastoreType.OPERATIONAL, interfaceStateIdentifier, stateInterface);
+ verify(mockWriteTx).put(LogicalDatastoreType.CONFIGURATION, interfaceChildEntryInstanceIdentifier, interfaceChildEntry, true);
}
@Test
LogicalDatastoreType.OPERATIONAL, nodeConnectorInstanceIdentifier);
doReturn(Futures.immediateCheckedFuture(expectedStateIf)).when(mockReadTx).read(
LogicalDatastoreType.OPERATIONAL, interfaceStateIdentifier);
+ doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockReadTx).read(
+ LogicalDatastoreType.CONFIGURATION, interfaceParentEntryIdentifier);
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder ifaceBuilder = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder();
ifaceBuilder.setOperStatus(OperStatus.Down);
stateInterface = ifaceBuilder.build();
removeHelper.removeConfiguration(dataBroker,alivenessMonitorService, vlanInterfaceEnabled, idManager,
- mdsalApiManager, null);
+ mdsalApiManager, vlanInterfaceEnabled.getAugmentation(ParentRefs.class));
//verification
verify(mockWriteTx).merge(LogicalDatastoreType.OPERATIONAL, interfaceStateIdentifier, stateInterface);