private static int BLADE_ID;
static {
- String hostName;
try {
- hostName = InetAddress.getLocalHost().getHostName();
BLADE_ID = InetAddresses.coerceToInteger(InetAddress.getLocalHost());
- if (hostName.indexOf("-") > 0) {
- BLADE_ID = new Integer(hostName.split("-")[1].toString()).intValue();
- } else {
- LOGGER.error("Host name {} is not matching with the condition!! PL-X is expected", hostName);
- }
} catch (Exception e) {
LOGGER.error("IdManager - Exception - {}", e.getMessage());
}
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
import org.opendaylight.idmanager.IdManagerServiceProvider;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.lockmanager.rev150819.LockManagerService;
public class IdmanagerImplModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.idmanager.impl.rev150325.AbstractIdmanagerImplModule {
public IdmanagerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
@Override
public java.lang.AutoCloseable createInstance() {
+ LockManagerService lockManagerService = getRpcRegistryDependency().getRpcService(LockManagerService.class);
IdManagerServiceProvider provider = new IdManagerServiceProvider(getRpcRegistryDependency());
+ provider.setLockManager(lockManagerService);
getBrokerDependency().registerProvider(provider);
return provider;
}
private static final Logger LOG = LoggerFactory.getLogger(IdManagerTest.class);
private static int BLADE_ID;
static {
- String hostName;
try {
- hostName = InetAddress.getLocalHost().getHostName();
BLADE_ID = InetAddresses.coerceToInteger(InetAddress.getLocalHost());
- if (hostName.indexOf("-") > 0) {
- BLADE_ID = new Integer(hostName.split("-")[1].toString()).intValue();
- } else {
- LOG.error("Host name {} is not matching with the condition!! PL-X is expected", hostName);
- }
} catch (Exception e) {
LOG.error("IdManager - Exception - {}", e.getMessage());
}
}
}
}
+
+ container if-indexes-interface-map {
+ config false;
+ list if-index-interface {
+ key if-index;
+ leaf if-index {
+ type int32;
+ }
+ leaf interface-name {
+ type string;
+ }
+ }
+ }
}
\ No newline at end of file
}
}
}
+
+ rpc get-interface-from-if-index {
+ description "to get interface associated with an if-index";
+ input {
+ leaf if-index {
+ type int32;
+ }
+ }
+ output {
+ leaf interface-name {
+ type string;
+ }
+ }
+ }
}
\ No newline at end of file
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class IfmUtil {
-
+ private static final Logger LOG = LoggerFactory.getLogger(IfmUtil.class);
+ private static final int INVALID_ID = 0;
public static String getDpnFromNodeConnectorId(NodeConnectorId portId) {
/*
* NodeConnectorId is of form 'openflow:dpnid:portnum'
return new BigInteger[] { metadata, metadataMask };
}
+ public static Integer allocateId(IdManagerService idManager, String poolName, String idKey) {
+ AllocateIdInput getIdInput = new AllocateIdInputBuilder()
+ .setPoolName(poolName)
+ .setIdKey(idKey).build();
+ try {
+ Future<RpcResult<AllocateIdOutput>> result = idManager.allocateId(getIdInput);
+ RpcResult<AllocateIdOutput> rpcResult = result.get();
+ if(rpcResult.isSuccessful()) {
+ return rpcResult.getResult().getIdValue().intValue();
+ } else {
+ LOG.warn("RPC Call to Get Unique Id returned with Errors {}", rpcResult.getErrors());
+ }
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.warn("Exception when getting Unique Id",e);
+ }
+ return INVALID_ID;
+ }
-
+ public static void releaseId(IdManagerService idManager, String poolName, String idKey) {
+ ReleaseIdInput idInput = new ReleaseIdInputBuilder()
+ .setPoolName(poolName)
+ .setIdKey(idKey).build();
+ try {
+ Future<RpcResult<Void>> result = idManager.releaseId(idInput);
+ RpcResult<Void> rpcResult = result.get();
+ if(!rpcResult.isSuccessful()) {
+ LOG.warn("RPC Call to release Id {} with Key {} returned with Errors {}",
+ idKey, rpcResult.getErrors());
+ }
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.warn("Exception when releasing Id for key {}", idKey, e);
+ }
+ }
}
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.idmanager.IdManager;
import org.opendaylight.vpnservice.interfacemgr.listeners.InterfaceConfigListener;
import org.opendaylight.vpnservice.interfacemgr.listeners.InterfaceInventoryStateListener;
import org.opendaylight.vpnservice.interfacemgr.listeners.InterfaceTopologyStateListener;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.CreateIdPoolInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.CreateIdPoolInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.*;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.slf4j.Logger;
private static final Logger LOG = LoggerFactory.getLogger(InterfacemgrProvider.class);
private RpcProviderRegistry rpcProviderRegistry;
- private IdManager idManager;
+ private IdManagerService idManager;
private InterfaceConfigListener interfaceConfigListener;
private InterfaceTopologyStateListener topologyStateListener;
LOG.info("InterfacemgrProvider Session Initiated");
try {
final DataBroker dataBroker = session.getSALService(DataBroker.class);
- idManager = new IdManager(dataBroker);
+ idManager = rpcProviderRegistry.getRpcService(IdManagerService.class);
createIdPool();
interfaceManagerRpcService = new InterfaceManagerRpcService(dataBroker);
interfaceConfigListener = new InterfaceConfigListener(dataBroker, idManager);
interfaceConfigListener.registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker);
- interfaceInventoryStateListener = new InterfaceInventoryStateListener(dataBroker);
+ interfaceInventoryStateListener = new InterfaceInventoryStateListener(dataBroker, idManager);
interfaceInventoryStateListener.registerListener(LogicalDatastoreType.OPERATIONAL, dataBroker);
topologyStateListener = new InterfaceTopologyStateListener(dataBroker);
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.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.BridgeInterfaceInfo;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.BridgeRefInfo;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.IfIndexesInterfaceMap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.InterfaceChildInfo;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._if.indexes._interface.map.IfIndexInterface;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._if.indexes._interface.map.IfIndexInterfaceBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._if.indexes._interface.map.IfIndexInterfaceKey;
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;
}
return interfaceChildEntryOptional.get();
}
+
+ public static void createLportTagInterfaceMap(WriteTransaction t, String infName, Integer ifIndex) {
+ InstanceIdentifier<IfIndexInterface> id = InstanceIdentifier.builder(IfIndexesInterfaceMap.class).child(IfIndexInterface.class, new IfIndexInterfaceKey(ifIndex)).build();
+ IfIndexInterface ifIndexInterface = new IfIndexInterfaceBuilder().setIfIndex(ifIndex).setKey(new IfIndexInterfaceKey(ifIndex)).setInterfaceName(infName).build();
+ t.put(LogicalDatastoreType.OPERATIONAL, id, ifIndexInterface, true);
+ }
+
+ public static void removeLportTagInterfaceMap(WriteTransaction t, IdManagerService idManager, DataBroker broker, String infName, Integer ifIndex) {
+ InstanceIdentifier<IfIndexInterface> id = InstanceIdentifier.builder(IfIndexesInterfaceMap.class).child(IfIndexInterface.class, new IfIndexInterfaceKey(ifIndex)).build();
+ Optional<IfIndexInterface> ifIndexesInterface = IfmUtil.read(LogicalDatastoreType.OPERATIONAL, id, broker);
+ if(ifIndexesInterface.isPresent()) {
+ t.delete(LogicalDatastoreType.OPERATIONAL, id);
+ }
+ IfmUtil.releaseId(idManager, IfmConstants.IFM_IDPOOL_NAME, infName);
+ }
}
\ No newline at end of file
import org.opendaylight.vpnservice.interfacemgr.renderer.ovs.confighelpers.OvsInterfaceConfigUpdateHelper;
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.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.ParentRefs;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
public class InterfaceConfigListener extends AsyncDataTreeChangeListenerBase<Interface, InterfaceConfigListener> {
private static final Logger LOG = LoggerFactory.getLogger(InterfaceConfigListener.class);
private DataBroker dataBroker;
- private IdManager idManager;
+ private IdManagerService idManager;
- public InterfaceConfigListener(final DataBroker dataBroker, final IdManager idManager) {
+ public InterfaceConfigListener(final DataBroker dataBroker, final IdManagerService idManager) {
super(Interface.class, InterfaceConfigListener.class);
this.dataBroker = dataBroker;
this.idManager = idManager;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
+import org.opendaylight.idmanager.IdManager;
import org.opendaylight.vpnservice.datastoreutils.AsyncDataChangeListenerBase;
import org.opendaylight.vpnservice.datastoreutils.DataStoreJobCoordinator;
import org.opendaylight.vpnservice.interfacemgr.renderer.ovs.statehelpers.OvsInterfaceStateAddHelper;
import org.opendaylight.vpnservice.interfacemgr.renderer.ovs.statehelpers.OvsInterfaceStateRemoveHelper;
+import org.opendaylight.vpnservice.interfacemgr.renderer.ovs.statehelpers.OvsInterfaceStateRemoveHelper;
import org.opendaylight.vpnservice.interfacemgr.renderer.ovs.statehelpers.OvsInterfaceStateUpdateHelper;
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.Nodes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class InterfaceInventoryStateListener extends AsyncDataChangeListenerBase<FlowCapableNodeConnector, InterfaceInventoryStateListener> implements AutoCloseable{
private static final Logger LOG = LoggerFactory.getLogger(InterfaceInventoryStateListener.class);
private DataBroker dataBroker;
+ private IdManagerService idManager;
- public InterfaceInventoryStateListener(final DataBroker dataBroker) {
+ public InterfaceInventoryStateListener(final DataBroker dataBroker, final IdManagerService idManager) {
super(FlowCapableNodeConnector.class, InterfaceInventoryStateListener.class);
this.dataBroker = dataBroker;
+ this.idManager = idManager;
}
@Override
NodeConnectorId nodeConnectorId = InstanceIdentifier.keyOf(key.firstIdentifierOf(NodeConnector.class)).getId();
DataStoreJobCoordinator coordinator = DataStoreJobCoordinator.getInstance();
- InterfaceStateRemoveWorker interfaceStateRemoveWorker = new InterfaceStateRemoveWorker(key,
+ InterfaceStateRemoveWorker interfaceStateRemoveWorker = new InterfaceStateRemoveWorker(idManager, key,
flowCapableNodeConnectorOld, portName);
coordinator.enqueueJob(portName, interfaceStateRemoveWorker);
}
NodeConnectorId nodeConnectorId = InstanceIdentifier.keyOf(key.firstIdentifierOf(NodeConnector.class)).getId();
DataStoreJobCoordinator coordinator = DataStoreJobCoordinator.getInstance();
- InterfaceStateAddWorker ifStateAddWorker = new InterfaceStateAddWorker(nodeConnectorId,
+ InterfaceStateAddWorker ifStateAddWorker = new InterfaceStateAddWorker(idManager, nodeConnectorId,
fcNodeConnectorNew, portName);
coordinator.enqueueJob(portName, ifStateAddWorker);
}
private final NodeConnectorId nodeConnectorId;
private final FlowCapableNodeConnector fcNodeConnectorNew;
private final String portName;
+ private final IdManagerService idManager;
- public InterfaceStateAddWorker(NodeConnectorId nodeConnectorId,
+ public InterfaceStateAddWorker(IdManagerService idManager, NodeConnectorId nodeConnectorId,
FlowCapableNodeConnector fcNodeConnectorNew,
String portName) {
this.nodeConnectorId = nodeConnectorId;
this.fcNodeConnectorNew = fcNodeConnectorNew;
this.portName = portName;
+ this.idManager = idManager;
}
@Override
public Object call() throws Exception {
// If another renderer(for eg : CSS) needs to be supported, check can be performed here
// to call the respective helpers.
- return OvsInterfaceStateAddHelper.addState(dataBroker, nodeConnectorId,
+ return OvsInterfaceStateAddHelper.addState(dataBroker, idManager, nodeConnectorId,
portName, fcNodeConnectorNew);
}
InstanceIdentifier<FlowCapableNodeConnector> key;
FlowCapableNodeConnector fcNodeConnectorOld;
private final String portName;
+ private final IdManagerService idManager;
- public InterfaceStateRemoveWorker(InstanceIdentifier<FlowCapableNodeConnector> key,
+ public InterfaceStateRemoveWorker(IdManagerService idManager,
+ InstanceIdentifier<FlowCapableNodeConnector> key,
FlowCapableNodeConnector fcNodeConnectorOld,
String portName) {
this.key = key;
this.fcNodeConnectorOld = fcNodeConnectorOld;
this.portName = portName;
+ this.idManager = idManager;
}
@Override
public Object call() throws Exception {
// If another renderer(for eg : CSS) needs to be supported, check can be performed here
// to call the respective helpers.
- return OvsInterfaceStateRemoveHelper.removeState(key, dataBroker, portName, fcNodeConnectorOld);
+ return OvsInterfaceStateRemoveHelper.removeState(idManager, key, dataBroker, portName, fcNodeConnectorOld);
}
@Override
import org.opendaylight.vpnservice.interfacemgr.renderer.ovs.confighelpers.OvsVlanMemberConfigUpdateHelper;
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.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
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;
public class VlanMemberConfigListener extends AsyncDataTreeChangeListenerBase<Interface, VlanMemberConfigListener> {
private static final Logger LOG = LoggerFactory.getLogger(VlanMemberConfigListener.class);
private DataBroker dataBroker;
- private IdManager idManager;
+ private IdManagerService idManager;
- public VlanMemberConfigListener(final DataBroker dataBroker, final IdManager idManager) {
+ public VlanMemberConfigListener(final DataBroker dataBroker, final IdManagerService idManager) {
super(Interface.class, VlanMemberConfigListener.class);
this.dataBroker = dataBroker;
this.idManager = idManager;
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.InterfaceManagerCommonUtils;
import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceMetaUtils;
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.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;
private static final Logger LOG = LoggerFactory.getLogger(OvsInterfaceConfigAddHelper.class);
public static List<ListenableFuture<Void>> addConfiguration(DataBroker dataBroker, ParentRefs parentRefs,
- Interface interfaceNew, IdManager idManager) {
+ Interface interfaceNew, IdManagerService idManager) {
List<ListenableFuture<Void>> futures = new ArrayList<>();
IfTunnel ifTunnel = interfaceNew.getAugmentation(IfTunnel.class);
return futures;
}
- addVlanConfiguration(interfaceNew, dataBroker, futures);
+ addVlanConfiguration(interfaceNew, dataBroker, idManager, futures);
return futures;
}
- private static void addVlanConfiguration(Interface interfaceNew, DataBroker dataBroker,
+ private static void addVlanConfiguration(Interface interfaceNew, DataBroker dataBroker, IdManagerService idManager,
List<ListenableFuture<Void>> futures) {
WriteTransaction t = dataBroker.newWriteOnlyTransaction();
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState =
InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceNew.getName(), dataBroker);
+
if (ifState == null) {
return;
}
- updateStateEntry(interfaceNew, t, ifState);
+ updateStateEntry(interfaceNew, ifState.getIfIndex(), t, ifState);
IfL2vlan ifL2vlan = interfaceNew.getAugmentation(IfL2vlan.class);
if (ifL2vlan == null || ifL2vlan.getL2vlanMode() != IfL2vlan.L2vlanMode.Trunk) {
}
private static void addTunnelConfiguration(DataBroker dataBroker, ParentRefs parentRefs,
- Interface interfaceNew, IdManager idManager,
+ Interface interfaceNew, IdManagerService idManager,
List<ListenableFuture<Void>> futures) {
LOG.debug("adding tunnel configuration for {}", interfaceNew.getName());
WriteTransaction t = dataBroker.newWriteOnlyTransaction();
}
}
- private static void updateStateEntry(Interface interfaceNew, WriteTransaction t,
+ private static void updateStateEntry(Interface interfaceNew, Integer ifIndex, WriteTransaction t,
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState) {
- OperStatus operStatus;
+ 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) {
- operStatus = OperStatus.Down;
- 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(interfaceNew.getName()));
- t.merge(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build());
+ ifaceBuilder.setOperStatus(OperStatus.Down);
}
+ ifaceBuilder.setIfIndex(ifIndex);
+ ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceNew.getName()));
+ t.merge(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build());
}
}
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.node.NodeConnector;
+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;
private static final Logger LOG = LoggerFactory.getLogger(OvsInterfaceConfigRemoveHelper.class);
public static List<ListenableFuture<Void>> removeConfiguration(DataBroker dataBroker, Interface interfaceOld,
- IdManager idManager, ParentRefs parentRefs) {
+ IdManagerService idManager, ParentRefs parentRefs) {
List<ListenableFuture<Void>> futures = new ArrayList<>();
WriteTransaction t = dataBroker.newWriteOnlyTransaction();
IfTunnel ifTunnel = interfaceOld.getAugmentation(IfTunnel.class);
if (ifTunnel != null) {
removeTunnelConfiguration(parentRefs, dataBroker, interfaceOld, idManager, t);
- futures.add(t.submit());
- return futures;
+ }else {
+ removeVlanConfiguration(dataBroker, interfaceOld, t);
}
-
- removeVlanConfiguration(dataBroker, interfaceOld, t);
-
- /* FIXME: Deallocate ID from Idmanager. */
-
futures.add(t.submit());
return futures;
}
}
private static void removeTunnelConfiguration(ParentRefs parentRefs, DataBroker dataBroker, Interface interfaceOld,
- IdManager idManager, WriteTransaction t) {
+ IdManagerService idManager, WriteTransaction t) {
BigInteger dpId = null;
if (parentRefs != null) {
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.node.NodeConnector;
+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;
public class OvsInterfaceConfigUpdateHelper {
private static final Logger LOG = LoggerFactory.getLogger(OvsInterfaceConfigUpdateHelper.class);
- public static List<ListenableFuture<Void>> updateConfiguration(DataBroker dataBroker, IdManager idManager,
+ public static List<ListenableFuture<Void>> updateConfiguration(DataBroker dataBroker, IdManagerService idManager,
Interface interfaceNew, Interface interfaceOld) {
List<ListenableFuture<Void>> futures = new ArrayList<>();
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.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.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;
private static final Logger LOG = LoggerFactory.getLogger(OvsVlanMemberConfigAddHelper.class);
public static List<ListenableFuture<Void>> addConfiguration(DataBroker dataBroker, ParentRefs parentRefs,
Interface interfaceNew, IfL2vlan ifL2vlan,
- IdManager idManager) {
+ IdManagerService idManager) {
List<ListenableFuture<Void>> futures = new ArrayList<>();
WriteTransaction t = dataBroker.newWriteOnlyTransaction();
}
}
- private static long createInterfaceChildEntry(DataBroker dataBroker, IdManager idManager, WriteTransaction t,
+ private static long createInterfaceChildEntry(DataBroker dataBroker, IdManagerService idManager, WriteTransaction t,
InterfaceParentEntryKey interfaceParentEntryKey, String childInterface){
- //TODO FIXME
-// long lportTag = InterfaceManagerCommonUtils.getUniqueId(idManager, 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;
- return 0L;
+ 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;
}
}
import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils;
import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceMetaUtils;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
+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;
private static final Logger LOG = LoggerFactory.getLogger(OvsVlanMemberConfigRemoveHelper.class);
public static List<ListenableFuture<Void>> removeConfiguration(DataBroker dataBroker, ParentRefs parentRefs,
Interface interfaceOld, IfL2vlan ifL2vlan,
- IdManager idManager) {
+ IdManagerService idManager) {
List<ListenableFuture<Void>> futures = new ArrayList<>();
WriteTransaction t = dataBroker.newWriteOnlyTransaction();
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.state.Interface.OperStatus;
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.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
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.InterfaceChildEntryKey;
private static final Logger LOG = LoggerFactory.getLogger(OvsVlanMemberConfigUpdateHelper.class);
public static List<ListenableFuture<Void>> updateConfiguration(DataBroker dataBroker, ParentRefs parentRefsNew,
Interface interfaceOld, IfL2vlan ifL2vlanNew,
- Interface interfaceNew, IdManager idManager) {
+ Interface interfaceNew, IdManagerService idManager) {
List<ListenableFuture<Void>> futures = new ArrayList<>();
ParentRefs parentRefsOld = interfaceOld.getAugmentation(ParentRefs.class);
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.InterfaceManagerCommonUtils;
import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceMetaUtils;
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.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;
public class OvsInterfaceStateAddHelper {
private static final Logger LOG = LoggerFactory.getLogger(OvsInterfaceStateAddHelper.class);
- public static List<ListenableFuture<Void>> addState(DataBroker dataBroker, NodeConnectorId nodeConnectorId,
+ public static List<ListenableFuture<Void>> addState(DataBroker dataBroker, IdManagerService idManager, NodeConnectorId nodeConnectorId,
String portName, FlowCapableNodeConnector fcNodeConnectorNew) {
LOG.debug("Adding Interface State to Oper DS for port: {}", portName);
List<ListenableFuture<Void>> futures = new ArrayList<>();
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).setLowerLayerIf(lowerLayerIfList)
+ .setAdminStatus(adminStatus).setPhysAddress(physAddress).setIfIndex(ifIndex).setLowerLayerIf(lowerLayerIfList)
.setKey(IfmUtil.getStateInterfaceKeyFromName(portName));
t.put(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build(), true);
+ // allocate lport tag and set in if-index
+ InterfaceMetaUtils.createLportTagInterfaceMap(t, portName, ifIndex);
if (iface == null) {
futures.add(t.submit());
return futures;
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.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
+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;
public class OvsInterfaceStateRemoveHelper {
private static final Logger LOG = LoggerFactory.getLogger(OvsInterfaceStateRemoveHelper.class);
- public static List<ListenableFuture<Void>> removeState(InstanceIdentifier<FlowCapableNodeConnector> key,
+ public static List<ListenableFuture<Void>> removeState(IdManagerService idManager,
+ InstanceIdentifier<FlowCapableNodeConnector> key,
DataBroker dataBroker, String portName, FlowCapableNodeConnector fcNodeConnectorOld) {
LOG.debug("Removing interface-state for port: {}", portName);
List<ListenableFuture<Void>> futures = new ArrayList<>();
WriteTransaction t = dataBroker.newWriteOnlyTransaction();
InstanceIdentifier<Interface> ifStateId = IfmUtil.buildStateInterfaceId(portName);
+ /* Remove entry from if-index-interface-name map and deallocate Id from Idmanager. */
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface interfaceState =
+ InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(portName, dataBroker);
+ InterfaceMetaUtils.removeLportTagInterfaceMap(t, idManager, dataBroker, interfaceState.getName(), interfaceState.getIfIndex());
+
t.delete(LogicalDatastoreType.OPERATIONAL, ifStateId);
// For Vlan-Trunk Interface, remove the trunk-member operstates as well...
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
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.meta.rev151007.IfIndexesInterfaceMap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.InterfaceChildInfo;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._if.indexes._interface.map.IfIndexInterface;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._if.indexes._interface.map.IfIndexInterfaceKey;
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;
return Futures.immediateFuture(rpcResultBuilder.build());
}
+ @Override
+ public Future<RpcResult<GetInterfaceFromIfIndexOutput>> getInterfaceFromIfIndex(GetInterfaceFromIfIndexInput input) {
+ Integer ifIndex = input.getIfIndex();
+ RpcResultBuilder<GetInterfaceFromIfIndexOutput> rpcResultBuilder = null;
+ try {
+ InstanceIdentifier<IfIndexInterface> id = InstanceIdentifier.builder(IfIndexesInterfaceMap.class).child(IfIndexInterface.class, new IfIndexInterfaceKey(ifIndex)).build();
+ Optional<IfIndexInterface> ifIndexesInterface = IfmUtil.read(LogicalDatastoreType.OPERATIONAL, id, dataBroker);
+ if(ifIndexesInterface.isPresent()) {
+ String interfaceName = ifIndexesInterface.get().getInterfaceName();
+ GetInterfaceFromIfIndexOutputBuilder output = new GetInterfaceFromIfIndexOutputBuilder().setInterfaceName(interfaceName);
+ rpcResultBuilder = RpcResultBuilder.success();
+ rpcResultBuilder.withResult(output.build());
+ }
+ } catch (Exception e) {
+ LOG.error("Retrieval of interfaceName for the key {} failed due to {}", ifIndex, e);
+ rpcResultBuilder = RpcResultBuilder.failed();
+ }
+ return Futures.immediateFuture(rpcResultBuilder.build());
+ }
+
public List<ActionInfo> getEgressActionInfosForInterface(String interfaceName) {
Interface interfaceInfo = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(new InterfaceKey(interfaceName),
dataBroker);
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeGre;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
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.BridgeEntryKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.bridge.entry.BridgeInterfaceEntry;
TerminationPoint terminationPoint;
@Mock DataBroker dataBroker;
- @Mock IdManager idManager;
+ @Mock IdManagerService idManager;
@Mock ListenerRegistration<DataChangeListener> dataChangeListenerRegistration;
@Mock ReadOnlyTransaction mockReadTx;
@Mock WriteTransaction mockWriteTx;
private final DataBroker broker;
private IMdsalApiManager mdsalManager;
private IInterfaceManager interfaceManager;
- private IdManager idManager;
+ private IdManagerService idManager;
private static final short LPORT_INGRESS_TABLE = 0;
private static final short LFIB_TABLE = 20;
private static final short FIB_TABLE = 21;
this.mdsalManager = mdsalManager;
}
- public void setIdManager(IdManager idManager) {
+ public void setIdManager(IdManagerService idManager) {
this.idManager = idManager;
}
import org.opendaylight.vpnservice.nexthopmgr.NexthopManager;
import org.opendaylight.vpnservice.interfacemgr.interfaces.IInterfaceManager;
import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.l3nexthop.rev150409.L3nexthopService;
import org.opendaylight.idmanager.IdManager;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
private NexthopManager nhManager;
private IMdsalApiManager mdsalManager;
private IInterfaceManager interfaceManager;
- private IdManager idManager;
+ private IdManagerService idManager;
private RpcProviderRegistry rpcProviderRegistry;
public RpcProviderRegistry getRpcProviderRegistry() {
nhManager = new NexthopManager(dbx);
vpnIfListener = new VpnInterfaceChangeListener(dbx, nhManager);
odlIfListener = new OdlInterfaceChangeListener(dbx, nhManager, interfaceManager);
- idManager = new IdManager(dbx);
+ idManager = rpcProviderRegistry.getRpcService(IdManagerService.class);
final BindingAwareBroker.RpcRegistration<L3nexthopService> rpcRegistration = getRpcProviderRegistry().addRpcImplementation(L3nexthopService.class, nhManager);
nhManager.setMdsalManager(mdsalManager);
nhManager.setInterfaceManager(interfaceManager);