/*
- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetEgressActionsForInterfaceInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetEgressActionsForInterfaceInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetEgressActionsForInterfaceOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetEgressActionsInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetEgressActionsInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetEgressActionsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.OdlInterfaceRpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.TunnelList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.rpcs.rev151217.CreateTerminatingServiceActionsInput;
return actions;
}
if (tunnelInterfaceName != null && !tunnelInterfaceName.isEmpty()) {
- GetEgressActionsInput getEgressActionsForInterfaceInput = new GetEgressActionsInputBuilder().setServiceTag(Long.valueOf(serviceTag)).setIntfName(tunnelInterfaceName).build();
- Future<RpcResult<GetEgressActionsOutput>> egressActionsOutputFuture = interfaceManagerRpcService.getEgressActions(getEgressActionsForInterfaceInput);
- try {
- GetEgressActionsOutput egressActionsOutput = egressActionsOutputFuture.get().getResult();
- List<Action> outputAction = egressActionsOutput.getAction();
- return outputAction;
+ try{
+ GetEgressActionsForInterfaceInput getEgressActionInput =
+ new GetEgressActionsForInterfaceInputBuilder().setIntfName(tunnelInterfaceName).setTunnelKey(null).build();
+ Future<RpcResult<GetEgressActionsForInterfaceOutput>> result =
+ interfaceManagerRpcService.getEgressActionsForInterface(getEgressActionInput);
+ RpcResult<GetEgressActionsForInterfaceOutput> rpcResult = result.get();
+ if (!rpcResult.isSuccessful()) {
+ logger.warn("RPC Call to Get egress actions for interface {} returned with Errors {}",
+ tunnelInterfaceName, rpcResult.getErrors());
+ } else {
+ actions = rpcResult.getResult().getAction();
+ }
} catch (InterruptedException | ExecutionException e) {
logger.error("Error in RPC call getEgressActionsForInterface {}", e);
return actions;
<artifactId>interfacemgr-api</artifactId>
<version>${interfacemgr.version}</version>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>interfacemgr-shell</artifactId>
+ <version>${interfacemgr.version}</version>
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>elanmanager-impl</artifactId>
<bundle>mvn:org.opendaylight.vpnservice/mdsalutil-impl/{{VERSION}}</bundle>
<bundle>mvn:org.opendaylight.vpnservice/interfacemgr-api/{{VERSION}}</bundle>
<bundle>mvn:org.opendaylight.vpnservice/interfacemgr-impl/{{VERSION}}</bundle>
+ <bundle>mvn:org.opendaylight.vpnservice/interfacemgr-shell/{{VERSION}}</bundle>
<bundle>mvn:org.opendaylight.vpnservice/vpnmanager-impl/{{VERSION}}</bundle>
<bundle>mvn:org.opendaylight.vpnservice/fibmanager-impl/{{VERSION}}</bundle>
<bundle>mvn:org.opendaylight.vpnservice/fibmanager-shell/{{VERSION}}</bundle>
/*
- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
VXLAN_TRUNK_INTERFACE,
GRE_TRUNK_INTERFACE,
VXLAN_VNI_INTERFACE,
+ MPLS_OVER_GRE,
LOGICAL_GROUP_INTERFACE,
UNKNOWN_INTERFACE;
}
/*
- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.servicebinding.rev151015.service.bindings.services.info.BoundServices;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.servicebinding.rev151015.service.bindings.services.info.BoundServicesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.servicebinding.rev151015.ServiceTypeFlowBased;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.servicebinding.rev151015.StypeOpenflow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.servicebinding.rev151015.StypeOpenflowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.servicebinding.rev151015.service.bindings.services.info.BoundServicesKey;
import com.google.common.base.Optional;
return new ServicesInfoBuilder().setBoundServices(boundService).setKey(new ServicesInfoKey(serviceName)).build();
}
+ public static BoundServices getBoundServices(String serviceName, short servicePriority, int flowPriority,
+ BigInteger cookie, List<Instruction> instructions) {
+ StypeOpenflowBuilder augBuilder = new StypeOpenflowBuilder().setFlowCookie(cookie).setFlowPriority(flowPriority).setInstruction(instructions);
+ return new BoundServicesBuilder().setKey(new BoundServicesKey(servicePriority))
+ .setServiceName(serviceName).setServicePriority(servicePriority)
+ .setServiceType(ServiceTypeFlowBased.class).addAugmentation(StypeOpenflow.class, augBuilder.build()).build();
+ }
+
public static ServicesInfo buildServiceInfo(String serviceName, short serviceIndex, int servicePriority,
BigInteger cookie) {
List<BoundServices> boundService = new ArrayList<BoundServices>();
/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import java.math.BigInteger;
import java.util.List;
+import org.opendaylight.vpnservice.interfacemgr.exceptions.InterfaceAlreadyExistsException;
import org.opendaylight.vpnservice.interfacemgr.globals.InterfaceInfo;
import org.opendaylight.vpnservice.mdsalutil.ActionInfo;
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.params.xml.ns.yang.servicebinding.rev151015.service.bindings.ServicesInfo;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.servicebinding.rev151015.service.bindings.services.info.BoundServices;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfL2vlan;
@Deprecated
public interface IInterfaceManager {
public InterfaceInfo getInterfaceInfo(String intInfo);
public InterfaceInfo getInterfaceInfoFromOperationalDataStore(String interfaceName, InterfaceInfo.InterfaceType interfaceType);
+ public InterfaceInfo getInterfaceInfoFromOperationalDataStore(String interfaceName);
+
+ public void createVLANInterface(String interfaceName, String portName, BigInteger dpId, Integer vlanId,
+ String description, IfL2vlan.L2vlanMode l2vlanMode);
+ public void bindService(String interfaceName, BoundServices serviceInfo);
+ public void unbindService(String interfaceName, BoundServices serviceInfo);
+ List<Interface> getVlanInterfaces();
+ List<Interface> getVxlanInterfaces();
}
\ No newline at end of file
}
}
}
+
+ container tunnel-instance-interface-map {
+ config false;
+ list tunnel-instance-interface {
+ key tunnel-instance-identifier;
+ leaf tunnel-instance-identifier {
+ type string;
+ }
+ leaf interface-name {
+ type string;
+ }
+ }
+ }
}
\ No newline at end of file
input {
leaf intf-name {
type string;
+ mandatory true;
}
- }
- output {
- uses action:action-list;
- }
- }
- rpc get-egress-actions {
- description "used to retrieve group actions to use from interface name";
- input {
- leaf intf-name {
- type string;
- }
- leaf service-tag {
+ leaf tunnel-key {
+ description "It can be VNI for VxLAN tunnel ifaces, Gre Key for GRE tunnels, etc.";
type uint32;
+ mandatory false;
}
}
output {
input {
leaf intf-name {
type string;
+ mandatory true;
+ }
+
+ leaf tunnel-key {
+ description "It can be VNI for VxLAN tunnel ifaces, Gre Key for GRE tunnels, etc.";
+ type uint32;
+ mandatory false;
}
}
output {
description "an identifier of the dependant underlying configuration protocol";
leaf "topology-id" {
type string;
- description "A reference to the type of the network node.
- For example, an ovsdb node will take the format ovsdb:1";
+ description "can be ovsdb configuration protocol";
}
leaf "node-id" {
type string;
- description "A reference to a network node. A node can be
- of type ovsdb,hwvtep or openflow";
+ description "can be hwvtep configuration protocol";
}
}
}
public static final long VLAN_GROUP_START = 1000;
public static final long TRUNK_GROUP_START = 20000;
public static final long LOGICAL_GROUP_START = 100000;
- public static final short INTERNAL_TUNNEL_TABLE = 22;
- public static final short EXTERNAL_TUNNEL_TABLE = 23;
- public static final short LFIB_TABLE = 20;
public static final BigInteger COOKIE_VM_LFIB_TABLE = new BigInteger("8000002", 16);
public static final String TUNNEL_TABLE_FLOWID_PREFIX = "TUNNEL.";
public static final BigInteger TUNNEL_TABLE_COOKIE = new BigInteger("9000000", 16);
import org.opendaylight.vpnservice.mdsalutil.ActionType;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType;
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.InterfacesState;
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.opendaylight.action.types.rev131112.action.list.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadata;
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.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.NodeConnector;
+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.params.xml.ns.yang.ovsdb.rev150105.DatapathId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.AllocateIdInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.AllocateIdInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.ReleaseIdInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.id.pools.IdPool;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.id.pools.IdPoolKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.*;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfL2vlan.L2vlanMode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfTunnel;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfL2vlan;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.TunnelTypeGre;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.TunnelTypeVxlan;
import org.opendaylight.yangtools.yang.binding.DataObject;
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 result;
}
- public static List<Action> getEgressActions(String interfaceName, long serviceTag, DataBroker dataBroker) {
- List<ActionInfo> listActionInfo = new ArrayList<>();
- List<ActionInfo> interfaceActionList = IfmUtil.getEgressActionInfosForInterface(interfaceName, serviceTag, dataBroker);
- listActionInfo.addAll(interfaceActionList);
+ public static List<Action> getEgressActionsForInterface(String interfaceName, Long tunnelKey, DataBroker dataBroker) {
+ List<ActionInfo> listActionInfo = getEgressActionInfosForInterface(interfaceName, tunnelKey, 0, dataBroker);
List<Action> actionsList = new ArrayList<>();
for (ActionInfo actionInfo : listActionInfo) {
actionsList.add(actionInfo.buildAction());
return actionsList;
}
- public static List<Action> getEgressActionsForInterface(String interfaceName, DataBroker dataBroker) {
- List<ActionInfo> listActionInfo = getEgressActionInfosForInterface(interfaceName, 0, dataBroker);
- List<Action> actionsList = new ArrayList<>();
- for (ActionInfo actionInfo : listActionInfo) {
- actionsList.add(actionInfo.buildAction());
- }
- return actionsList;
+ public static List<ActionInfo> getEgressActionInfosForInterface(String interfaceName,
+ int actionKeyStart,
+ DataBroker dataBroker) {
+ return getEgressActionInfosForInterface(interfaceName, null, actionKeyStart, dataBroker);
}
- public static List<ActionInfo> getEgressActionInfosForInterface(String interfaceName, int actionKeyStart, DataBroker dataBroker) {
+ /**
+ * Returns a list of Actions to be taken when sending a packet over an interface
+ *
+ * @param interfaceName
+ * @param tunnelKey Optional.
+ * @param actionKeyStart
+ * @param dataBroker
+ * @return
+ */
+ public static List<ActionInfo> getEgressActionInfosForInterface(String interfaceName,
+ Long tunnelKey,
+ int actionKeyStart,
+ DataBroker dataBroker) {
+ List<ActionInfo> result = new ArrayList<ActionInfo>();
Interface interfaceInfo = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(new InterfaceKey(interfaceName),
dataBroker);
- 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 = (vlanIface == null) ? 0 :
- vlanIface.getVlanId() == null ? 0 : vlanIface.getVlanId().getValue();
- if (vlanVid != 0) {
- listActionInfo.add(new ActionInfo(ActionType.push_vlan, new String[] {}, actionKeyStart));
+ String portNo = IfmUtil.getPortNoFromInterfaceName(interfaceName, dataBroker);
+
+ InterfaceInfo.InterfaceType ifaceType = getInterfaceType(interfaceInfo);
+
+ switch (ifaceType ) {
+ case VLAN_INTERFACE:
+ IfL2vlan vlanIface = interfaceInfo.getAugmentation(IfL2vlan.class);
+ LOG.trace("L2Vlan: {}",vlanIface);
+ boolean isVlanTransparent = false;
+ long vlanVid = 0;
+ if (vlanIface != null) {
+ vlanVid = vlanIface.getVlanId() == null ? 0 : vlanIface.getVlanId().getValue();
+ isVlanTransparent = vlanIface.getL2vlanMode() == IfL2vlan.L2vlanMode.Transparent;
+ }
+ if (vlanVid != 0 && !isVlanTransparent) {
+ result.add(new ActionInfo(ActionType.push_vlan, new String[] {}, actionKeyStart));
+ actionKeyStart++;
+ result.add(new ActionInfo(ActionType.set_field_vlan_vid,
+ new String[] { Long.toString(vlanVid) }, actionKeyStart));
+ actionKeyStart++;
+ }
+ result.add(new ActionInfo(ActionType.output, new String[] {portNo}, actionKeyStart));
actionKeyStart++;
- listActionInfo.add(new ActionInfo(ActionType.set_field_vlan_vid,
- new String[] { Long.toString(vlanVid) }, actionKeyStart));
+ break;
+ case MPLS_OVER_GRE:
+ case VXLAN_TRUNK_INTERFACE:
+ case GRE_TRUNK_INTERFACE:
+ if(tunnelKey != null) {
+ result.add(new ActionInfo(ActionType.set_field_tunnel_id,
+ new BigInteger[] { BigInteger.valueOf(tunnelKey.longValue()) },
+ actionKeyStart) );
+ actionKeyStart++;
+ }
+
+ result.add(new ActionInfo(ActionType.output, new String[] { portNo}, actionKeyStart));
actionKeyStart++;
- }
- listActionInfo.add(new ActionInfo(ActionType.output, new String[] {portNo}, actionKeyStart));
- }else if(Tunnel.class.equals(ifType)){
- listActionInfo.add(new ActionInfo(ActionType.output, new String[] { portNo}, actionKeyStart));
+ break;
+
+ default:
+ LOG.warn("Interface Type {} not handled yet", ifaceType);
+ break;
}
- return listActionInfo;
+
+ return result;
}
- public static List<ActionInfo> getEgressActionInfosForInterface(String interfaceName, long serviceTag, DataBroker dataBroker) {
- int actionKey = 0;
- ActionInfo actionSetTunnel = new ActionInfo(ActionType.set_field_tunnel_id, new BigInteger[] {
- BigInteger.valueOf(serviceTag)}, actionKey) ;
- List<ActionInfo> listActionInfo = new ArrayList<ActionInfo>();
- listActionInfo.add(actionSetTunnel);
- actionKey++;
- listActionInfo.addAll(getEgressActionInfosForInterface(interfaceName, actionKey, dataBroker));
- return listActionInfo;
- }
public static NodeId getNodeIdFromNodeConnectorId(NodeConnectorId ncId) {
return new NodeId(ncId.getValue().substring(0,ncId.getValue().lastIndexOf(":")));
return FlowBasedServicesUtils.getNodeConnectorIdFromInterface(iface, dataBroker);
}
+ public static String getPortName(DataBroker dataBroker, NodeConnectorId ncId){
+ InstanceIdentifier<NodeConnector> ncIdentifier =
+ InstanceIdentifier.builder(Nodes.class)
+ .child(Node.class, new NodeKey(getNodeIdFromNodeConnectorId(ncId)))
+ .child(NodeConnector.class, new NodeConnectorKey(ncId)).build();
+ Optional<NodeConnector> optNc = read(LogicalDatastoreType.OPERATIONAL, ncIdentifier, dataBroker);
+ if(optNc.isPresent()) {
+ NodeConnector nc = optNc.get();
+ FlowCapableNodeConnector fcnc = nc.getAugmentation(FlowCapableNodeConnector.class);
+ return fcnc.getName();
+ }
+ return null;
+ }
+
public static NodeConnectorId getNodeConnectorIdFromInterface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState){
if(ifState != null) {
List<String> ofportIds = ifState.getLowerLayerIf();
interfaceType = InterfaceInfo.InterfaceType.VXLAN_TRUNK_INTERFACE;
} else if (tunnelType.isAssignableFrom(TunnelTypeGre.class)) {
interfaceType = InterfaceInfo.InterfaceType.GRE_TRUNK_INTERFACE;
+ } else if(tunnelType.isAssignableFrom(TunnelTypeMplsOverGre.class)){
+ interfaceType = InterfaceInfo.InterfaceType.MPLS_OVER_GRE;
}
}
// TODO: Check if the below condition is still needed/valid
*/
package org.opendaylight.vpnservice.interfacemgr;
-import java.math.BigInteger;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
+import com.google.common.base.Optional;
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.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.vpnservice.interfacemgr.globals.InterfaceInfo;
import org.opendaylight.vpnservice.interfacemgr.globals.InterfaceInfo.InterfaceAdminState;
import org.opendaylight.vpnservice.interfacemgr.interfaces.IInterfaceManager;
+import org.opendaylight.vpnservice.interfacemgr.listeners.AlivenessMonitorListener;
import org.opendaylight.vpnservice.interfacemgr.listeners.InterfaceConfigListener;
+import org.opendaylight.vpnservice.interfacemgr.listeners.HwVTEPConfigListener;
+import org.opendaylight.vpnservice.interfacemgr.listeners.HwVTEPTunnelsStateListener;
import org.opendaylight.vpnservice.interfacemgr.listeners.InterfaceInventoryStateListener;
+import org.opendaylight.vpnservice.interfacemgr.listeners.TerminationPointStateListener;
import org.opendaylight.vpnservice.interfacemgr.listeners.InterfaceTopologyStateListener;
import org.opendaylight.vpnservice.interfacemgr.listeners.VlanMemberConfigListener;
+import org.opendaylight.vpnservice.interfacemgr.pmcounters.NodeConnectorStatsImpl;
import org.opendaylight.vpnservice.interfacemgr.rpcservice.InterfaceManagerRpcService;
import org.opendaylight.vpnservice.interfacemgr.servicebindings.flowbased.listeners.FlowBasedServicesConfigListener;
import org.opendaylight.vpnservice.interfacemgr.servicebindings.flowbased.listeners.FlowBasedServicesInterfaceStateListener;
+import org.opendaylight.vpnservice.interfacemgr.statusanddiag.InterfaceStatusMonitor;
import org.opendaylight.vpnservice.mdsalutil.ActionInfo;
import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+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.InterfaceBuilder;
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.AdminStatus;
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.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.servicebinding.rev151015.ServiceBindings;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.servicebinding.rev151015.service.bindings.ServicesInfo;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.servicebinding.rev151015.service.bindings.ServicesInfoKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.servicebinding.rev151015.service.bindings.services.info.BoundServices;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.servicebinding.rev151015.service.bindings.services.info.BoundServicesKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.AlivenessMonitorService;
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.alivenessmonitor.rev150629.AlivenessMonitorService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetDpidFromInterfaceInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetDpidFromInterfaceInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetDpidFromInterfaceOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetEndpointIpForDpnInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetEndpointIpForDpnInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetEndpointIpForDpnOutput;
-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.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfL2vlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfL2vlanBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.ParentRefs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.ParentRefsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.*;
+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 InterfacemgrProvider implements BindingAwareProvider, AutoCloseable, IInterfaceManager {
private static final Logger LOG = LoggerFactory.getLogger(InterfacemgrProvider.class);
+ private static final InterfaceStatusMonitor interfaceStatusMonitor = InterfaceStatusMonitor.getInstance();
private RpcProviderRegistry rpcProviderRegistry;
private IdManagerService idManager;
private IMdsalApiManager mdsalManager;
private InterfaceConfigListener interfaceConfigListener;
private InterfaceTopologyStateListener topologyStateListener;
+ private TerminationPointStateListener terminationPointStateListener;
+ private HwVTEPTunnelsStateListener hwVTEPTunnelsStateListener;
private InterfaceInventoryStateListener interfaceInventoryStateListener;
private FlowBasedServicesInterfaceStateListener flowBasedServicesInterfaceStateListener;
private FlowBasedServicesConfigListener flowBasedServicesConfigListener;
private VlanMemberConfigListener vlanMemberConfigListener;
- private org.opendaylight.vpnservice.interfacemgr.listeners.AlivenessMonitorListener alivenessMonitorListener;
+ private HwVTEPConfigListener hwVTEPConfigListener;
+ private AlivenessMonitorListener alivenessMonitorListener;
private DataBroker dataBroker;
private InterfaceManagerRpcService interfaceManagerRpcService;
private BindingAwareBroker.RpcRegistration<OdlInterfaceRpcService> rpcRegistration;
+ private NodeConnectorStatsImpl nodeConnectorStatsManager;
public void setRpcProviderRegistry(RpcProviderRegistry rpcProviderRegistry) {
this.rpcProviderRegistry = rpcProviderRegistry;
+ interfaceStatusMonitor.registerMbean();
}
public void setMdsalManager(IMdsalApiManager mdsalManager) {
@Override
public void onSessionInitiated(ProviderContext session) {
LOG.info("InterfacemgrProvider Session Initiated");
+ interfaceStatusMonitor.reportStatus("STARTING");
try {
dataBroker = session.getSALService(DataBroker.class);
idManager = rpcProviderRegistry.getRpcService(IdManagerService.class);
topologyStateListener = new InterfaceTopologyStateListener(dataBroker);
topologyStateListener.registerListener(LogicalDatastoreType.OPERATIONAL, dataBroker);
+ hwVTEPTunnelsStateListener = new HwVTEPTunnelsStateListener(dataBroker);
+ hwVTEPTunnelsStateListener.registerListener(LogicalDatastoreType.OPERATIONAL,dataBroker);
+
+ //terminationPointStateListener = new TerminationPointStateListener(dataBroker);
+ //terminationPointStateListener.registerListener(LogicalDatastoreType.OPERATIONAL, dataBroker);
+
flowBasedServicesConfigListener = new FlowBasedServicesConfigListener(dataBroker);
flowBasedServicesConfigListener.registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker);
flowBasedServicesInterfaceStateListener.registerListener(LogicalDatastoreType.OPERATIONAL, dataBroker);
vlanMemberConfigListener =
- new VlanMemberConfigListener(dataBroker, idManager, alivenessManager,mdsalManager);
+ new VlanMemberConfigListener(dataBroker, idManager, alivenessManager,mdsalManager);
vlanMemberConfigListener.registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker);
+
+ hwVTEPConfigListener = new HwVTEPConfigListener(dataBroker);
+ hwVTEPConfigListener.registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker);
+
alivenessMonitorListener = new org.opendaylight.vpnservice.interfacemgr.listeners.AlivenessMonitorListener(dataBroker);
notificationService.registerNotificationListener(alivenessMonitorListener);
+
+ //Initialize nodeconnectorstatsimpl
+ nodeConnectorStatsManager = new NodeConnectorStatsImpl(dataBroker, notificationService,
+ session.getRpcService(OpendaylightPortStatisticsService.class), session.getRpcService(OpendaylightFlowTableStatisticsService.class));
+
+
+ interfaceStatusMonitor.reportStatus("OPERATIONAL");
} catch (Exception e) {
LOG.error("Error initializing services", e);
+ interfaceStatusMonitor.reportStatus("ERROR");
}
}
private void createIdPool() {
CreateIdPoolInput createPool = new CreateIdPoolInputBuilder()
- .setPoolName(IfmConstants.IFM_IDPOOL_NAME)
+ .setPoolName(IfmConstants.IFM_IDPOOL_NAME)
.setLow(IfmConstants.IFM_ID_POOL_START)
.setHigh(IfmConstants.IFM_ID_POOL_END)
- .build();
+ .build();
//TODO: Error handling
Future<RpcResult<Void>> result = idManager.createIdPool(createPool);
try {
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface
ifState = InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceName,dataBroker);
- if(ifState == null){
+ if(ifState == null) {
LOG.error("Interface {} is not present", interfaceName);
return null;
}
Integer lportTag = ifState.getIfIndex();
Interface intf = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(new InterfaceKey(interfaceName), dataBroker);
+ if (intf == null) {
+ LOG.error("Interface {} doesn't exist in config datastore", interfaceName);
+ return null;
+ }
NodeConnectorId ncId = IfmUtil.getNodeConnectorIdFromInterface(intf, dataBroker);
InterfaceInfo.InterfaceType interfaceType = IfmUtil.getInterfaceType(intf);
return interfaceInfo;
}
+ @Override
+ public InterfaceInfo getInterfaceInfoFromOperationalDataStore(String interfaceName) {
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = InterfaceManagerCommonUtils
+ .getInterfaceStateFromOperDS(interfaceName, dataBroker);
+ if (ifState == null) {
+ LOG.error("Interface {} is not present", interfaceName);
+ return null;
+ }
+ Integer lportTag = ifState.getIfIndex();
+ InterfaceInfo interfaceInfo = new InterfaceInfo(interfaceName);
+ NodeConnectorId ncId = IfmUtil.getNodeConnectorIdFromInterface(ifState);
+ if (ncId != null) {
+ interfaceInfo.setPortName(IfmUtil.getPortName(dataBroker, ncId));
+ interfaceInfo.setDpId(new BigInteger(IfmUtil.getDpnFromNodeConnectorId(ncId)));
+ interfaceInfo.setPortNo(Integer.parseInt(IfmUtil.getPortNoFromNodeConnectorId(ncId)));
+ }
+ interfaceInfo.setAdminState((ifState.getAdminStatus() == AdminStatus.Up) ? InterfaceAdminState.ENABLED : InterfaceAdminState.DISABLED);
+ interfaceInfo.setInterfaceName(interfaceName);
+ interfaceInfo.setInterfaceTag(lportTag);
+ interfaceInfo.setOpState((ifState.getOperStatus() == OperStatus.Up) ? InterfaceInfo.InterfaceOpState.UP : InterfaceInfo.InterfaceOpState.DOWN);
+ return interfaceInfo;
+ }
+
+ public void createVLANInterface(String interfaceName, String portName, BigInteger dpId, Integer vlanId,
+ String description, IfL2vlan.L2vlanMode l2vlanMode) {
+ LOG.info("Create VLAN interface : {}",interfaceName);
+ InstanceIdentifier<Interface> interfaceInstanceIdentifier = InterfaceManagerCommonUtils.
+ getInterfaceIdentifier(new InterfaceKey(interfaceName));
+ IfL2vlanBuilder l2vlanBuilder = new IfL2vlanBuilder().setL2vlanMode(l2vlanMode);
+ if(vlanId > 0){
+ l2vlanBuilder.setVlanId(new VlanId(vlanId));
+ }
+ ParentRefs parentRefs = new ParentRefsBuilder().setParentInterface(portName).build();
+ Interface inf = new InterfaceBuilder().setEnabled(true).setName(interfaceName).setType(L2vlan.class).
+ addAugmentation(IfL2vlan.class, l2vlanBuilder.build()).addAugmentation(ParentRefs.class, parentRefs).
+ setDescription(description).build();
+ WriteTransaction t = dataBroker.newWriteOnlyTransaction();
+ t.put(LogicalDatastoreType.CONFIGURATION, interfaceInstanceIdentifier, inf, true);
+ }
+
+ public void bindService(String interfaceName, BoundServices serviceInfo){
+ LOG.info("Binding Service : {}",interfaceName);
+ WriteTransaction t = dataBroker.newWriteOnlyTransaction();
+ InstanceIdentifier<BoundServices> boundServicesInstanceIdentifier = InstanceIdentifier.builder(ServiceBindings.class).child(ServicesInfo.class, new ServicesInfoKey(interfaceName))
+ .child(BoundServices.class, new BoundServicesKey(serviceInfo.getServicePriority())).build();
+ // List<BoundServices> services = (List<BoundServices>)serviceInfo.getBoundServices();
+ t.put(LogicalDatastoreType.CONFIGURATION, boundServicesInstanceIdentifier, serviceInfo, true);
+ t.submit();
+ }
+
+ public void unbindService(String interfaceName, BoundServices serviceInfo){
+ LOG.info("Unbinding Service : {}",interfaceName);
+ WriteTransaction t = dataBroker.newWriteOnlyTransaction();
+ InstanceIdentifier<BoundServices> boundServicesInstanceIdentifier = InstanceIdentifier.builder(ServiceBindings.class).child(ServicesInfo.class, new ServicesInfoKey(interfaceName))
+ .child(BoundServices.class, new BoundServicesKey(serviceInfo.getServicePriority())).build();
+ t.delete(LogicalDatastoreType.CONFIGURATION, boundServicesInstanceIdentifier);
+ t.submit();
+ }
+
@Override
public BigInteger getDpnForInterface(String ifName) {
GetDpidFromInterfaceInput input = new GetDpidFromInterfaceInputBuilder().setIntfName(ifName).build();
public BigInteger getDpnForInterface(Interface intrf) {
return getDpnForInterface(intrf.getName());
}
+
+ @Override
+ public List<Interface> getVlanInterfaces() {
+ List<Interface> vlanList = new ArrayList<Interface>();
+ InstanceIdentifier<Interfaces> interfacesInstanceIdentifier = InstanceIdentifier.builder(Interfaces.class).build();
+ Optional<Interfaces> interfacesOptional = IfmUtil.read(LogicalDatastoreType.CONFIGURATION, interfacesInstanceIdentifier, dataBroker);
+ if (!interfacesOptional.isPresent()) {
+ return vlanList;
+ }
+ Interfaces interfaces = interfacesOptional.get();
+ List<Interface> interfacesList = interfaces.getInterface();
+ for (Interface iface : interfacesList) {
+ if (IfmUtil.getInterfaceType(iface) == InterfaceInfo.InterfaceType.VLAN_INTERFACE) {
+ vlanList.add(iface);
+ }
+ }
+ return vlanList;
+ }
+
+ @Override
+ public List<Interface> getVxlanInterfaces() {
+ return InterfaceManagerCommonUtils.getAllTunnelInterfaces(dataBroker,
+ InterfaceInfo.InterfaceType.VXLAN_TRUNK_INTERFACE);
+ }
}
\ No newline at end of file
/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import com.google.common.base.Optional;
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.vpnservice.interfacemgr.IfmConstants;
import org.opendaylight.vpnservice.interfacemgr.IfmUtil;
import org.opendaylight.vpnservice.mdsalutil.MDSALUtil;
-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.opendaylight.vpnservice.alivenessmonitor.rev150629.*;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.endpoint.endpoint.type.IpAddress;
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.profile.create.input.Profile;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.monitor.profile.create.input.ProfileBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.monitor.start.input.ConfigBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.*;
-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;
-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.meta.rev151007._interface.monitor.id.map.InterfaceMonitorId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.monitor.id.map.InterfaceMonitorIdBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.monitor.id.map.InterfaceMonitorIdKey;
-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;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.bridge.entry.BridgeInterfaceEntryBuilder;
-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.meta.rev151007.monitor.id._interface.map.MonitorIdInterface;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.monitor.id._interface.map.MonitorIdInterfaceBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.monitor.id._interface.map.MonitorIdInterfaceKey;
public class AlivenessMonitorUtils {
private static final Logger LOG = LoggerFactory.getLogger(AlivenessMonitorUtils.class);
- private static final int FAILURE_THRESHOLD = 4;
- private static final int MONITORING_INTERVAL = 10000;
- private static final int MONITORING_WINDOW = 4;
+ private static final long FAILURE_THRESHOLD = 4;
+ private static final long MONITORING_INTERVAL = 10000;
+ private static final long MONITORING_WINDOW = 4;
public static void startLLDPMonitoring(AlivenessMonitorService alivenessMonitorService, DataBroker dataBroker,
Interface trunkInterface) {
//LLDP monitoring for the trunk interface
String trunkInterfaceName = trunkInterface.getName();
IfTunnel ifTunnel = trunkInterface.getAugmentation(IfTunnel.class);
- if(ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeVxlan.class)) {
- MonitorStartInput lldpMonitorInput = new MonitorStartInputBuilder().setConfig(new ConfigBuilder()
- .setSource(new SourceBuilder().setEndpointType(getInterfaceForMonitoring(trunkInterfaceName,
- ifTunnel.getTunnelSource())).build())
- .setMode(MonitoringMode.OneOne)
- .setProfileId(allocateProfile(alivenessMonitorService, FAILURE_THRESHOLD, MONITORING_INTERVAL, MONITORING_WINDOW,
- EtherTypes.Lldp)).build()).build();
+ if(ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeVxlan.class) && ifTunnel.isInternal()) {
+ MonitorStartInput lldpMonitorInput = new MonitorStartInputBuilder().setConfig(new ConfigBuilder()
+ .setSource(new SourceBuilder().setEndpointType(getInterfaceForMonitoring(trunkInterfaceName,
+ ifTunnel.getTunnelSource())).build())
+ .setMode(MonitoringMode.OneOne)
+ .setProfileId(allocateProfile(alivenessMonitorService, FAILURE_THRESHOLD, ifTunnel.getMonitorInterval(), MONITORING_WINDOW,
+ EtherTypes.Lldp)).build()).build();
try {
Future<RpcResult<MonitorStartOutput>> result = alivenessMonitorService.monitorStart(lldpMonitorInput);
RpcResult<MonitorStartOutput> rpcResult = result.get();
public static void stopLLDPMonitoring(AlivenessMonitorService alivenessMonitorService, DataBroker dataBroker,
Interface trunkInterface) {
IfTunnel ifTunnel = trunkInterface.getAugmentation(IfTunnel.class);
- if(!ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeVxlan.class)){
+ if(!(ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeVxlan.class)&& ifTunnel.isInternal())){
return;
}
List<Long> monitorIds = getMonitorIdForInterface(dataBroker, trunkInterface.getName());
endpoint.type.InterfaceBuilder().setInterfaceIp(ipAddress).setInterfaceName(interfaceName).build();
}
- protected void handleTunnelMonitorEnabledUpdates(AlivenessMonitorService alivenessMonitorService, DataBroker dataBroker,
- List<String> interfaceNames, boolean origMonitorEnabled, boolean updatedMonitorEnabled) {
- for (String interfaceName : interfaceNames) {
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface tunnelInterface =
- InterfaceManagerCommonUtils.getInterfaceFromConfigDS(new InterfaceKey(interfaceName), dataBroker);
- IfTunnel ifTunnel = tunnelInterface.getAugmentation(IfTunnel.class);
- InterfaceManagerCommonUtils.updateTunnelMonitorDetailsInConfigDS(dataBroker, interfaceName, updatedMonitorEnabled, 3);
- // Check if monitoring is started already
- if (getMonitorIdForInterface(dataBroker, interfaceName) != null) {
- // Get updated Interface details from Config DS
- if(ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeVxlan.class)) {
- if (updatedMonitorEnabled) {
- startLLDPMonitoring(alivenessMonitorService, dataBroker, tunnelInterface);
- } else {
- stopLLDPMonitoring(alivenessMonitorService, dataBroker, tunnelInterface);
- }
- }
- }
+ public static void handleTunnelMonitorUpdates(AlivenessMonitorService alivenessMonitorService, DataBroker dataBroker,
+ Interface interfaceOld, Interface interfaceNew) {
+ String interfaceName = interfaceNew.getName();
+ IfTunnel ifTunnelNew = interfaceNew.getAugmentation(IfTunnel.class);
+ if(!(ifTunnelNew.getTunnelInterfaceType().isAssignableFrom(TunnelTypeVxlan.class)&&
+ ifTunnelNew.isInternal())){
+ return;
}
- }
+ LOG.debug("handling tunnel monitoring updates for interface {}", interfaceName);
+ // Restart LLDP monitoring only if it's started already
+ List<Long> monitorIds = getMonitorIdForInterface(dataBroker, interfaceName);
+ if (monitorIds != null && monitorIds.size() > 1) {
+ stopLLDPMonitoring(alivenessMonitorService, dataBroker, interfaceOld);
+ if(ifTunnelNew.isMonitorEnabled()) {
+ startLLDPMonitoring(alivenessMonitorService, dataBroker, interfaceNew);
- protected void handleTunnelMonitorIntervalUpdates(AlivenessMonitorService alivenessMonitorService, DataBroker dataBroker,
- List<String> interfaceNames, long origMonitorInterval, long updatedMonitorInterval) {
- for (String interfaceName : interfaceNames) {
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface tunnelInterface =
- InterfaceManagerCommonUtils.getInterfaceFromConfigDS(new InterfaceKey(interfaceName), dataBroker);
- IfTunnel ifTunnel = tunnelInterface.getAugmentation(IfTunnel.class);
- InterfaceManagerCommonUtils.updateTunnelMonitorDetailsInConfigDS(dataBroker, interfaceName, ifTunnel.isMonitorEnabled(), updatedMonitorInterval);
- // Restart LLDP monitoring only if it's started already
- List<Long> monitorIds = getMonitorIdForInterface(dataBroker, interfaceName);
- if (monitorIds != null && monitorIds.size() > 1) {
- // Get updated Interface details from Config DS
- if(ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeVxlan.class)) {
- stopLLDPMonitoring(alivenessMonitorService, dataBroker, tunnelInterface);
- startLLDPMonitoring(alivenessMonitorService, dataBroker,tunnelInterface);
+ // Delete old profile from Aliveness Manager
+ IfTunnel ifTunnelOld = interfaceOld.getAugmentation(IfTunnel.class);
+ if(ifTunnelNew.getMonitorInterval() != ifTunnelOld.getMonitorInterval()) {
+ LOG.debug("deleting older monitor profile for interface {}", interfaceName);
+ long profileId = allocateProfile(alivenessMonitorService, FAILURE_THRESHOLD, ifTunnelOld.getMonitorInterval(), MONITORING_WINDOW, EtherTypes.Lldp);
+ MonitorProfileDeleteInput profileDeleteInput = new MonitorProfileDeleteInputBuilder().setProfileId(profileId).build();
+ alivenessMonitorService.monitorProfileDelete(profileDeleteInput);
+ }
}
}
- }
- // Delete old profile from Aliveness Manager
- if (origMonitorInterval > 0) {
- long profileId = allocateProfile(alivenessMonitorService, 4, origMonitorInterval, 4, EtherTypes.Lldp);
- MonitorProfileDeleteInput profileDeleteInput = new MonitorProfileDeleteInputBuilder().setProfileId(profileId).build();
- alivenessMonitorService.monitorProfileDelete(profileDeleteInput);
- }
}
return null;
}
- public static long allocateProfile(AlivenessMonitorService alivenessMonitor, long failureThreshold, long interval, long window, EtherTypes etherType ) {
- MonitorProfileCreateInput input = new MonitorProfileCreateInputBuilder().setProfile(new ProfileBuilder().setFailureThreshold(failureThreshold)
- .setMonitorInterval(interval).setMonitorWindow(window).setProtocolType(etherType).build()).build();
+ public static long createMonitorProfile(AlivenessMonitorService alivenessMonitor, MonitorProfileCreateInput monitorProfileCreateInput) {
try {
- Future<RpcResult<MonitorProfileCreateOutput>> result = alivenessMonitor.monitorProfileCreate(input);
+ Future<RpcResult<MonitorProfileCreateOutput>> result = alivenessMonitor.monitorProfileCreate(monitorProfileCreateInput);
RpcResult<MonitorProfileCreateOutput> rpcResult = result.get();
if(rpcResult.isSuccessful()) {
return rpcResult.getResult().getProfileId();
}
return 0;
}
+ public static long allocateProfile(AlivenessMonitorService alivenessMonitor, long FAILURE_THRESHOLD, long MONITORING_INTERVAL,
+ long MONITORING_WINDOW, EtherTypes etherTypes) {
+ MonitorProfileCreateInput input = new MonitorProfileCreateInputBuilder().
+ setProfile(new ProfileBuilder().setFailureThreshold(FAILURE_THRESHOLD)
+ .setMonitorInterval(MONITORING_INTERVAL).setMonitorWindow(MONITORING_WINDOW).
+ setProtocolType(etherTypes).build()).build();
+ return createMonitorProfile(alivenessMonitor, input);
+ }
+
+ public static long allocateDefaultProfile(AlivenessMonitorService alivenessMonitor, EtherTypes etherType ) {
+ MonitorProfileCreateInput input = new MonitorProfileCreateInputBuilder().
+ setProfile(getDefaultMonitorProfile(etherType)).build();
+ return createMonitorProfile(alivenessMonitor, input);
+ }
+
+ public static Profile getDefaultMonitorProfile(EtherTypes etherType) {
+ ProfileBuilder profileBuilder = new ProfileBuilder();
+ profileBuilder.setProtocolType(etherType);
+ profileBuilder.setFailureThreshold(FAILURE_THRESHOLD)
+ .setMonitorInterval(MONITORING_INTERVAL).setMonitorWindow(MONITORING_WINDOW).setProtocolType(etherType);
+ return profileBuilder.build();
+ }
}
\ No newline at end of file
/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.vpnservice.interfacemgr.IfmConstants;
import org.opendaylight.vpnservice.interfacemgr.IfmUtil;
+import org.opendaylight.vpnservice.interfacemgr.globals.InterfaceInfo;
import org.opendaylight.vpnservice.interfacemgr.servicebindings.flowbased.utilities.FlowBasedServicesUtils;
import org.opendaylight.vpnservice.mdsalutil.FlowEntity;
import org.opendaylight.vpnservice.mdsalutil.InstructionInfo;
import org.opendaylight.vpnservice.mdsalutil.MetaDataUtil;
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.InterfaceType;
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;
return interfaceInstanceIdentifierBuilder.build();
}
+ public static List<Interface> getAllTunnelInterfaces(DataBroker dataBroker, InterfaceInfo.InterfaceType interfaceType) {
+ List<Interface> vxlanList = new ArrayList<Interface>();
+ InstanceIdentifier<Interfaces> interfacesInstanceIdentifier = InstanceIdentifier.builder(Interfaces.class).build();
+ Optional<Interfaces> interfacesOptional = IfmUtil.read(LogicalDatastoreType.CONFIGURATION, interfacesInstanceIdentifier, dataBroker);
+ if (!interfacesOptional.isPresent()) {
+ return vxlanList;
+ }
+ Interfaces interfaces = interfacesOptional.get();
+ List<Interface> interfacesList = interfaces.getInterface();
+ for (Interface iface : interfacesList) {
+ if(IfmUtil.getInterfaceType(iface) == InterfaceInfo.InterfaceType.VXLAN_TRUNK_INTERFACE &&
+ iface.getAugmentation(IfTunnel.class).isInternal()) {
+ vxlanList.add(iface);
+ }
+ }
+ return vxlanList;
+ }
public static Interface getInterfaceFromConfigDS(InterfaceKey interfaceKey, DataBroker dataBroker) {
InstanceIdentifier<Interface> interfaceId = getInterfaceIdentifier(interfaceKey);
Optional<Interface> interfaceOptional = IfmUtil.read(LogicalDatastoreType.CONFIGURATION, interfaceId, dataBroker);
dpnId, BigInteger.valueOf(portNo) }));
mkInstructions.add(new InstructionInfo(
InstructionType.write_metadata, new BigInteger[] {
- MetaDataUtil.getLportTagMetaData(ifIndex),
- MetaDataUtil.METADATA_MASK_LPORT_TAG}));
+ MetaDataUtil.getLportTagMetaData(ifIndex).or(BigInteger.ONE),
+ MetaDataUtil.METADATA_MASK_LPORT_TAG_SH_FLAG}));
short tableId = tunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeMplsOverGre.class) ? NwConstants.L3_LFIB_TABLE :
- tunnel.isInternal() ? NwConstants.INTERNAL_TUNNEL_TABLE : NwConstants.EXTERNAL_TUNNEL_TABLE;
+ tunnel.isInternal() ? NwConstants.INTERNAL_TUNNEL_TABLE : NwConstants.DHCP_TABLE_EXTERNAL_TUNNEL;
mkInstructions.add(new InstructionInfo(InstructionType.goto_table, new long[] {tableId}));
}
return true;
}
+ public static void deleteInterfaceChildEntry(WriteTransaction transaction, DataBroker dataBroker, String parentInterface, String childInterface){
+ InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(parentInterface);
+ InstanceIdentifier<InterfaceParentEntry> interfaceParentEntryIid =
+ InterfaceMetaUtils.getInterfaceParentEntryIdentifier(interfaceParentEntryKey);
+ InterfaceParentEntry interfaceParentEntry =
+ InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryIid, dataBroker);
+
+ if(interfaceParentEntry == null){
+ return;
+ }
+
+ List<InterfaceChildEntry> interfaceChildEntries = interfaceParentEntry.getInterfaceChildEntry();
+ if (interfaceChildEntries.size() <= 1) {
+ transaction.delete(LogicalDatastoreType.CONFIGURATION, interfaceParentEntryIid);
+ } else {
+ InterfaceChildEntryKey interfaceChildEntryKey = new InterfaceChildEntryKey(childInterface);
+ InstanceIdentifier<InterfaceChildEntry> interfaceChildEntryIid =
+ InterfaceMetaUtils.getInterfaceChildEntryIdentifier(interfaceParentEntryKey, interfaceChildEntryKey);
+ transaction.delete(LogicalDatastoreType.CONFIGURATION, interfaceChildEntryIid);
+ }
+ }
+
+ /*
+ * update operational state of interface based on events like tunnel monitoring
+ */
+ public static void updateOpState(WriteTransaction transaction, String interfaceName,
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus operStatus){
+ LOG.debug("updating tep interface state for {}", interfaceName);
+ InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId =
+ IfmUtil.buildStateInterfaceId(interfaceName);
+ InterfaceBuilder ifaceBuilder = new InterfaceBuilder().setOperStatus(operStatus);
+ ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceName));
+ transaction.merge(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build());
+ }
+
}
\ No newline at end of file
/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
package org.opendaylight.vpnservice.interfacemgr.commons;
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.renderer.ovs.utilities.SouthboundUtils;
+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.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels;
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.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.*;
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.bridge.ref.info.BridgeRefEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge.ref.info.BridgeRefEntryBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge.ref.info.BridgeRefEntryKey;
-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.meta.rev151007.tunnel.instance._interface.map.TunnelInstanceInterface;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.tunnel.instance._interface.map.TunnelInstanceInterfaceBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.tunnel.instance._interface.map.TunnelInstanceInterfaceKey;
+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.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
public class InterfaceMetaUtils {
private static final Logger LOG = LoggerFactory.getLogger(InterfaceMetaUtils.class);
return bridgeRefEntryOptional.get();
}
+ public static BridgeRefEntry getBridgeReferenceForInterface(Interface interfaceInfo,
+ DataBroker dataBroker) {
+ ParentRefs parentRefs = interfaceInfo.getAugmentation(ParentRefs.class);
+ BigInteger dpn = parentRefs.getDatapathNodeIdentifier();
+ BridgeRefEntryKey BridgeRefEntryKey = new BridgeRefEntryKey(dpn);
+ InstanceIdentifier<BridgeRefEntry> dpnBridgeEntryIid = getBridgeRefEntryIdentifier(BridgeRefEntryKey);
+ BridgeRefEntry bridgeRefEntry = getBridgeRefEntryFromOperDS(dpnBridgeEntryIid, dataBroker);
+ return bridgeRefEntry;
+ }
+
+ public static boolean bridgeExists(BridgeRefEntry bridgeRefEntry,
+ DataBroker dataBroker) {
+ if (bridgeRefEntry != null && bridgeRefEntry.getBridgeReference() != null) {
+ InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid =
+ (InstanceIdentifier<OvsdbBridgeAugmentation>) bridgeRefEntry.getBridgeReference().getValue();
+ Optional<OvsdbBridgeAugmentation> bridgeNodeOptional =
+ IfmUtil.read(LogicalDatastoreType.OPERATIONAL, bridgeIid, dataBroker);
+ if (bridgeNodeOptional.isPresent()) {
+ return true;
+ }
+ }
+ return false;
+ }
public static InstanceIdentifier<BridgeEntry> getBridgeEntryIdentifier(BridgeEntryKey bridgeEntryKey) {
InstanceIdentifier.InstanceIdentifierBuilder<BridgeEntry> bridgeEntryIdBuilder =
InstanceIdentifier.builder(BridgeInterfaceInfo.class).child(BridgeEntry.class, bridgeEntryKey);
return bridgeEntryIdBuilder.build();
}
+ public static BridgeEntry getBridgeEntryFromConfigDS(BigInteger dpnId,
+ DataBroker dataBroker) {
+ BridgeEntryKey bridgeEntryKey = new BridgeEntryKey(dpnId);
+ InstanceIdentifier<BridgeEntry> bridgeEntryInstanceIdentifier =
+ InterfaceMetaUtils.getBridgeEntryIdentifier(bridgeEntryKey);
+ return getBridgeEntryFromConfigDS(bridgeEntryInstanceIdentifier,
+ dataBroker);
+ }
+
public static BridgeEntry getBridgeEntryFromConfigDS(InstanceIdentifier<BridgeEntry> bridgeEntryInstanceIdentifier,
DataBroker dataBroker) {
Optional<BridgeEntry> bridgeEntryOptional =
public static void createBridgeRefEntry(BigInteger dpnId, InstanceIdentifier<?> bridgeIid,
WriteTransaction tx){
+ LOG.debug("Creating bridge ref entry for dpn: {} bridge: {}",
+ dpnId, bridgeIid);
BridgeRefEntryKey bridgeRefEntryKey = new BridgeRefEntryKey(dpnId);
InstanceIdentifier<BridgeRefEntry> bridgeEntryId =
InterfaceMetaUtils.getBridgeRefEntryIdentifier(bridgeRefEntryKey);
.setBridgeReference(new OvsdbBridgeRef(bridgeIid));
tx.put(LogicalDatastoreType.OPERATIONAL, bridgeEntryId, tunnelDpnBridgeEntryBuilder.build(), true);
}
+ public static void deleteBridgeRefEntry(BigInteger dpnId,
+ WriteTransaction tx) {
+ LOG.debug("Deleting bridge ref entry for dpn: {}",
+ dpnId);
+ BridgeRefEntryKey bridgeRefEntryKey = new BridgeRefEntryKey(dpnId);
+ InstanceIdentifier<BridgeRefEntry> bridgeEntryId =
+ InterfaceMetaUtils.getBridgeRefEntryIdentifier(bridgeRefEntryKey);
+ tx.delete(LogicalDatastoreType.OPERATIONAL, bridgeEntryId);
+ }
+
+ public static void createTunnelToInterfaceMap(String tunnelInstanceId,
+ String infName,
+ WriteTransaction transaction) {
+ LOG.debug("creating tunnel instance identifier to interface map for {}",infName);
+ InstanceIdentifier<TunnelInstanceInterface> id = InstanceIdentifier.builder(TunnelInstanceInterfaceMap.class).
+ child(TunnelInstanceInterface.class, new TunnelInstanceInterfaceKey(tunnelInstanceId)).build();
+ TunnelInstanceInterface tunnelInstanceInterface = new TunnelInstanceInterfaceBuilder().
+ setTunnelInstanceIdentifier(tunnelInstanceId).setKey(new TunnelInstanceInterfaceKey(tunnelInstanceId)).setInterfaceName(infName).build();
+ transaction.put(LogicalDatastoreType.OPERATIONAL, id, tunnelInstanceInterface, true);
+
+ }
+
+ public static void createTunnelToInterfaceMap(String infName,InstanceIdentifier<Node> nodeId,
+ WriteTransaction transaction,
+ IfTunnel ifTunnel){
+ InstanceIdentifier<Tunnels> tunnelsInstanceIdentifier = org.opendaylight.vpnservice.interfacemgr.renderer.hwvtep.utilities.SouthboundUtils.
+ createTunnelsInstanceIdentifier(nodeId,
+ ifTunnel.getTunnelSource(), ifTunnel.getTunnelDestination());
+ createTunnelToInterfaceMap(tunnelsInstanceIdentifier.toString(), infName, transaction);
+ }
+
+ public static void removeTunnelToInterfaceMap(InstanceIdentifier<Node> nodeId,
+ WriteTransaction transaction,
+ IfTunnel ifTunnel){
+ InstanceIdentifier<Tunnels> tunnelsInstanceIdentifier = org.opendaylight.vpnservice.interfacemgr.renderer.hwvtep.utilities.SouthboundUtils.
+ createTunnelsInstanceIdentifier(nodeId,
+ ifTunnel.getTunnelSource(), ifTunnel.getTunnelDestination());
+ transaction.delete(LogicalDatastoreType.OPERATIONAL, tunnelsInstanceIdentifier);
+ }
+
+ public static String getInterfaceForTunnelInstanceIdentifier(String tunnelInstanceId,
+ DataBroker dataBroker) {
+ InstanceIdentifier<TunnelInstanceInterface> id = InstanceIdentifier.builder(TunnelInstanceInterfaceMap.class).
+ child(TunnelInstanceInterface.class, new TunnelInstanceInterfaceKey(tunnelInstanceId)).build();
+ Optional<TunnelInstanceInterface> tunnelInstanceInterfaceOptional = IfmUtil.read(LogicalDatastoreType.OPERATIONAL, id, dataBroker);
+ if(tunnelInstanceInterfaceOptional.isPresent()){
+ return tunnelInstanceInterfaceOptional.get().getInterfaceName();
+ }
+ return null;
+ }
+
}
\ No newline at end of file
import org.opendaylight.vpnservice.datastoreutils.DataStoreJobCoordinator;
import org.opendaylight.vpnservice.interfacemgr.renderer.hwvtep.confighelpers.HwVTEPConfigRemoveHelper;
import org.opendaylight.vpnservice.interfacemgr.renderer.hwvtep.confighelpers.HwVTEPInterfaceConfigAddHelper;
+import org.opendaylight.vpnservice.interfacemgr.renderer.hwvtep.confighelpers.HwVTEPInterfaceConfigUpdateHelper;
+import org.opendaylight.vpnservice.interfacemgr.renderer.hwvtep.utilities.SouthboundUtils;
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.interfacemgr.rev150331.IfL2vlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.AlivenessMonitorService;
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.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.TunnelTypeVxlan;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.interfaces._interface.NodeIdentifier;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
IfTunnel ifTunnel = interfaceOld.getAugmentation(IfTunnel.class);
if (ifTunnel != null && ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeVxlan.class)) {
ParentRefs parentRefs = interfaceOld.getAugmentation(ParentRefs.class);
- if (parentRefs != null) {
+ if (parentRefs != null && parentRefs.getNodeIdentifier() != null) {
for(NodeIdentifier nodeIdentifier : parentRefs.getNodeIdentifier()) {
- if(nodeIdentifier.getNodeId().equals("hwvtep:1")) {
+ if(SouthboundUtils.HWVTEP_TOPOLOGY.equals(nodeIdentifier.getTopologyId())) {
DataStoreJobCoordinator coordinator = DataStoreJobCoordinator.getInstance();
- RendererConfigRemoveWorker configWorker = new RendererConfigRemoveWorker(key, interfaceOld, parentRefs);
+ RendererConfigRemoveWorker configWorker = new RendererConfigRemoveWorker(key, interfaceOld,
+ SouthboundUtils.createPhysicalSwitchInstanceIdentifier(nodeIdentifier.getNodeId()),
+ SouthboundUtils.createGlobalNodeInstanceIdentifier(dataBroker, nodeIdentifier.getNodeId()));
coordinator.enqueueJob(interfaceOld.getName(), configWorker);
}
}
@Override
protected void update(InstanceIdentifier<Interface> key, Interface interfaceOld, Interface interfaceNew) {
- // TODO
+ // HwVTEPs support only vxlan
+ IfTunnel ifTunnel = interfaceNew.getAugmentation(IfTunnel.class);
+ if (ifTunnel != null && ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeVxlan.class)) {
+ ParentRefs parentRefs = interfaceNew.getAugmentation(ParentRefs.class);
+ if (parentRefs != null && parentRefs.getNodeIdentifier() != null) {
+ for(NodeIdentifier nodeIdentifier : parentRefs.getNodeIdentifier()) {
+ if(SouthboundUtils.HWVTEP_TOPOLOGY.equals(nodeIdentifier.getTopologyId())) {
+ DataStoreJobCoordinator coordinator = DataStoreJobCoordinator.getInstance();
+ RendererConfigUpdateWorker configWorker = new RendererConfigUpdateWorker(key, interfaceNew,
+ SouthboundUtils.createPhysicalSwitchInstanceIdentifier(nodeIdentifier.getNodeId()),
+ SouthboundUtils.createGlobalNodeInstanceIdentifier(dataBroker, nodeIdentifier.getNodeId()), ifTunnel);
+ coordinator.enqueueJob(interfaceNew.getName(), configWorker, 3);
+ }
+ }
+ }
+ }
}
@Override
IfTunnel ifTunnel = interfaceNew.getAugmentation(IfTunnel.class);
if (ifTunnel != null && ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeVxlan.class)) {
ParentRefs parentRefs = interfaceNew.getAugmentation(ParentRefs.class);
- if (parentRefs != null) {
+ if (parentRefs != null && parentRefs.getNodeIdentifier() != null) {
for(NodeIdentifier nodeIdentifier : parentRefs.getNodeIdentifier()) {
- if(nodeIdentifier.getNodeId().equals("hwvtep:1")) {
+ if(SouthboundUtils.HWVTEP_TOPOLOGY.equals(nodeIdentifier.getTopologyId())) {
DataStoreJobCoordinator coordinator = DataStoreJobCoordinator.getInstance();
- RendererConfigAddWorker configWorker = new RendererConfigAddWorker(key, interfaceNew, parentRefs);
- coordinator.enqueueJob(interfaceNew.getName(), configWorker);
+ RendererConfigAddWorker configWorker = new RendererConfigAddWorker(key, interfaceNew,
+ SouthboundUtils.createPhysicalSwitchInstanceIdentifier(nodeIdentifier.getNodeId()),
+ SouthboundUtils.createGlobalNodeInstanceIdentifier(dataBroker, nodeIdentifier.getNodeId()), ifTunnel);
+ coordinator.enqueueJob(interfaceNew.getName(), configWorker, 3);
}
}
}
private class RendererConfigAddWorker implements Callable<List<ListenableFuture<Void>>> {
InstanceIdentifier<Interface> key;
Interface interfaceNew;
- IfL2vlan ifL2vlan;
- ParentRefs parentRefs;
+ InstanceIdentifier<Node> physicalSwitchNodeId;
+ InstanceIdentifier<Node> globalNodeId;
+ IfTunnel ifTunnel;
public RendererConfigAddWorker(InstanceIdentifier<Interface> key, Interface interfaceNew,
- ParentRefs parentRefs) {
+ InstanceIdentifier<Node> physicalSwitchNodeId, InstanceIdentifier<Node> globalNodeId, IfTunnel ifTunnel) {
+ this.key = key;
+ this.interfaceNew = interfaceNew;
+ this.physicalSwitchNodeId = physicalSwitchNodeId;
+ this.globalNodeId = globalNodeId;
+ this.ifTunnel = ifTunnel;
+ }
+
+ @Override
+ public List<ListenableFuture<Void>> call() throws Exception {
+ return HwVTEPInterfaceConfigAddHelper.addConfiguration(dataBroker,
+ physicalSwitchNodeId, globalNodeId, interfaceNew, ifTunnel);
+ }
+ }
+
+ private class RendererConfigUpdateWorker implements Callable<List<ListenableFuture<Void>>> {
+ InstanceIdentifier<Interface> key;
+ Interface interfaceNew;
+ InstanceIdentifier<Node> globalNodeId;
+ InstanceIdentifier<Node> physicalSwitchNodeId;
+ IfTunnel ifTunnel;
+
+ public RendererConfigUpdateWorker(InstanceIdentifier<Interface> key, Interface interfaceNew,
+ InstanceIdentifier<Node> physicalSwitchNodeId, InstanceIdentifier<Node> globalNodeId, IfTunnel ifTunnel) {
this.key = key;
this.interfaceNew = interfaceNew;
- this.ifL2vlan = ifL2vlan;
- this.parentRefs = parentRefs;
+ this.physicalSwitchNodeId = physicalSwitchNodeId;
+ this.ifTunnel = ifTunnel;
+ this.globalNodeId = globalNodeId;
}
@Override
public List<ListenableFuture<Void>> call() throws Exception {
- return HwVTEPInterfaceConfigAddHelper.addConfiguration(dataBroker, parentRefs, interfaceNew);
+ return HwVTEPInterfaceConfigUpdateHelper.updateConfiguration(dataBroker,
+ physicalSwitchNodeId, globalNodeId, interfaceNew, ifTunnel);
}
}
private class RendererConfigRemoveWorker implements Callable<List<ListenableFuture<Void>>> {
InstanceIdentifier<Interface> key;
Interface interfaceOld;
- ParentRefs parentRefs;
+ InstanceIdentifier<Node> physicalSwitchNodeId;
+ InstanceIdentifier<Node> globalNodeId;
public RendererConfigRemoveWorker(InstanceIdentifier<Interface> key, Interface interfaceOld,
- ParentRefs parentRefs) {
+ InstanceIdentifier<Node> physicalSwitchNodeId, InstanceIdentifier<Node> globalNodeId) {
this.key = key;
this.interfaceOld = interfaceOld;
- this.parentRefs = parentRefs;
+ this.physicalSwitchNodeId = physicalSwitchNodeId;
+ this.globalNodeId = globalNodeId;
}
@Override
public List<ListenableFuture<Void>> call() throws Exception {
- return HwVTEPConfigRemoveHelper.removeConfiguration(dataBroker, interfaceOld, parentRefs);
+ return HwVTEPConfigRemoveHelper.removeConfiguration(dataBroker,
+ interfaceOld, globalNodeId, physicalSwitchNodeId);
}
}
}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.interfacemgr.listeners;
+
+import com.google.common.util.concurrent.ListenableFuture;
+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.vpnservice.datastoreutils.AsyncDataChangeListenerBase;
+import org.opendaylight.vpnservice.datastoreutils.DataStoreJobCoordinator;
+import org.opendaylight.vpnservice.interfacemgr.renderer.hwvtep.statehelpers.HwVTEPInterfaceStateUpdateHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.concurrent.Callable;
+
+public class HwVTEPTunnelsStateListener extends AsyncDataChangeListenerBase<Tunnels, HwVTEPTunnelsStateListener> {
+ private static final Logger LOG = LoggerFactory.getLogger(HwVTEPTunnelsStateListener.class);
+ private DataBroker dataBroker;
+
+ public HwVTEPTunnelsStateListener(DataBroker dataBroker) {
+ super(Tunnels.class, HwVTEPTunnelsStateListener.class);
+ this.dataBroker = dataBroker;
+ }
+
+ @Override
+ protected InstanceIdentifier<Tunnels> getWildCardPath() {
+ return InstanceIdentifier.builder(NetworkTopology.class).child(Topology.class)
+ .child(Node.class).augmentation(PhysicalSwitchAugmentation.class).child(Tunnels.class).build();
+ }
+
+ @Override
+ protected DataChangeListener getDataChangeListener() {
+ return HwVTEPTunnelsStateListener.this;
+ }
+
+ @Override
+ protected AsyncDataBroker.DataChangeScope getDataChangeScope() {
+ return AsyncDataBroker.DataChangeScope.BASE;
+ }
+
+ @Override
+ protected void remove(InstanceIdentifier<Tunnels> identifier, Tunnels tunnelOld) {
+ LOG.info("Received Remove DataChange Notification for identifier: {}, physicalSwitchAugmentation: {}",
+ identifier, tunnelOld);
+ }
+
+ @Override
+ protected void update(InstanceIdentifier<Tunnels> identifier, Tunnels tunnelOld,
+ Tunnels tunnelNew) {
+ LOG.info("Received Update Tunnel Update Notification for identifier: {}", identifier);
+ DataStoreJobCoordinator jobCoordinator = DataStoreJobCoordinator.getInstance();
+ RendererStateUpdateWorker rendererStateUpdateWorker = new RendererStateUpdateWorker(identifier, tunnelNew, tunnelOld);
+ jobCoordinator.enqueueJob(tunnelNew.getTunnelUuid().getValue(), rendererStateUpdateWorker);
+ }
+
+ @Override
+ protected void add(InstanceIdentifier<Tunnels> identifier, Tunnels tunnelNew) {
+ LOG.info("Received Add DataChange Notification for identifier: {}, tunnels: {}",
+ identifier, tunnelNew);
+ DataStoreJobCoordinator jobCoordinator = DataStoreJobCoordinator.getInstance();
+ RendererStateAddWorker rendererStateAddWorker = new RendererStateAddWorker(identifier, tunnelNew);
+ jobCoordinator.enqueueJob(tunnelNew.getTunnelUuid().getValue(), rendererStateAddWorker);
+ }
+
+ private class RendererStateUpdateWorker implements Callable<List<ListenableFuture<Void>>> {
+ InstanceIdentifier<Tunnels> instanceIdentifier;
+ Tunnels tunnelsNew;
+ Tunnels tunnelsOld;
+
+ public RendererStateUpdateWorker(InstanceIdentifier<Tunnels> instanceIdentifier,
+ Tunnels tunnelsNew, Tunnels tunnelsOld) {
+ this.instanceIdentifier = instanceIdentifier;
+ this.tunnelsNew = tunnelsNew;
+ this.tunnelsOld = tunnelsOld;
+ }
+
+ @Override
+ public List<ListenableFuture<Void>> call() throws Exception {
+ // If another renderer(for eg : CSS) needs to be supported, check can be performed here
+ // to call the respective helpers.
+ return HwVTEPInterfaceStateUpdateHelper.updatePhysicalSwitch(dataBroker,
+ instanceIdentifier, tunnelsOld, tunnelsNew);
+ }
+ }
+
+ private class RendererStateAddWorker implements Callable<List<ListenableFuture<Void>>> {
+ InstanceIdentifier<Tunnels> instanceIdentifier;
+ Tunnels tunnelsNew;
+
+ public RendererStateAddWorker(InstanceIdentifier<Tunnels> instanceIdentifier,
+ Tunnels tunnelsNew) {
+ this.instanceIdentifier = instanceIdentifier;
+ this.tunnelsNew = tunnelsNew;
+ }
+
+ @Override
+ public List<ListenableFuture<Void>> call() throws Exception {
+ // If another renderer(for eg : CSS) needs to be supported, check can be performed here
+ // to call the respective helpers.
+ return HwVTEPInterfaceStateUpdateHelper.startBfdMonitoring(dataBroker, instanceIdentifier, tunnelsNew);
+ }
+ }
+}
\ No newline at end of file
/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
private IdManagerService idManager;
private AlivenessMonitorService alivenessMonitorService;
private IMdsalApiManager mdsalApiManager;
+ private static final int MAX_RETRIES = 3;
public InterfaceConfigListener(final DataBroker dataBroker, final IdManagerService idManager,
final AlivenessMonitorService alivenessMonitorService,
ParentRefs parentRefs = interfaceOld.getAugmentation(ParentRefs.class);
DataStoreJobCoordinator coordinator = DataStoreJobCoordinator.getInstance();
RendererConfigRemoveWorker configWorker = new RendererConfigRemoveWorker(key, interfaceOld, ifName, parentRefs);
- coordinator.enqueueJob(ifName, configWorker);
+ coordinator.enqueueJob(ifName, configWorker, MAX_RETRIES);
}
@Override
protected void update(InstanceIdentifier<Interface> key, Interface interfaceOld, Interface interfaceNew) {
LOG.debug("Received Interface Update Event: {}, {}, {}", key, interfaceOld, interfaceNew);
String ifNameNew = interfaceNew.getName();
+ ParentRefs parentRefs = interfaceNew.getAugmentation(ParentRefs.class);
+ if (parentRefs == null || parentRefs.getDatapathNodeIdentifier() == null && parentRefs.getParentInterface() == null) {
+ LOG.error("parent refs not specified for {}",interfaceNew.getName());
+ return;
+ }
DataStoreJobCoordinator coordinator = DataStoreJobCoordinator.getInstance();
RendererConfigUpdateWorker worker = new RendererConfigUpdateWorker(key, interfaceOld, interfaceNew, ifNameNew);
- coordinator.enqueueJob(ifNameNew, worker);
+ coordinator.enqueueJob(ifNameNew, worker, MAX_RETRIES);
}
@Override
LOG.debug("Received Interface Add Event: {}, {}", key, interfaceNew);
String ifName = interfaceNew.getName();
ParentRefs parentRefs = interfaceNew.getAugmentation(ParentRefs.class);
- if (parentRefs == null) {
+ if (parentRefs == null || parentRefs.getDatapathNodeIdentifier() == null && parentRefs.getParentInterface() == null) {
LOG.error("parent refs not specified for {}",interfaceNew.getName());
+ return;
}
DataStoreJobCoordinator coordinator = DataStoreJobCoordinator.getInstance();
RendererConfigAddWorker configWorker = new RendererConfigAddWorker(key, interfaceNew, parentRefs, ifName);
- coordinator.enqueueJob(ifName, configWorker);
+ coordinator.enqueueJob(ifName, configWorker, MAX_RETRIES);
}
private class RendererConfigAddWorker implements Callable<List<ListenableFuture<Void>>> {
/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import org.opendaylight.vpnservice.datastoreutils.DataStoreJobCoordinator;
import org.opendaylight.vpnservice.interfacemgr.renderer.ovs.statehelpers.OvsInterfaceTopologyStateAddHelper;
import org.opendaylight.vpnservice.interfacemgr.renderer.ovs.statehelpers.OvsInterfaceTopologyStateRemoveHelper;
+import org.opendaylight.vpnservice.interfacemgr.renderer.ovs.statehelpers.OvsInterfaceTopologyStateUpdateHelper;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
@Override
protected AsyncDataBroker.DataChangeScope getDataChangeScope() {
- return AsyncDataBroker.DataChangeScope.BASE;
+ return AsyncDataBroker.DataChangeScope.ONE;
}
@Override
identifier, bridgeOld);
DataStoreJobCoordinator jobCoordinator = DataStoreJobCoordinator.getInstance();
RendererStateRemoveWorker rendererStateRemoveWorker = new RendererStateRemoveWorker(identifier, bridgeOld);
- jobCoordinator.enqueueJob(bridgeOld.getBridgeName().getValue() + bridgeOld.getDatapathId(), rendererStateRemoveWorker);
+ jobCoordinator.enqueueJob(bridgeOld.getBridgeName().getValue(), rendererStateRemoveWorker);
}
@Override
protected void update(InstanceIdentifier<OvsdbBridgeAugmentation> identifier, OvsdbBridgeAugmentation bridgeOld,
OvsdbBridgeAugmentation bridgeNew) {
- LOG.info("Received Update DataChange Notification for identifier: {}, ovsdbBridgeAugmentation old: {}, new: {}." +
- "No Action Performed.", identifier, bridgeOld, bridgeNew);
+ LOG.debug("Received Update DataChange Notification for identifier: {}, ovsdbBridgeAugmentation old: {}, new: {}.",
+ identifier, bridgeOld, bridgeNew);
+ if(bridgeOld.getDatapathId()== null && bridgeNew.getDatapathId()!= null){
+ DataStoreJobCoordinator jobCoordinator = DataStoreJobCoordinator.getInstance();
+ RendererStateAddWorker rendererStateAddWorker = new RendererStateAddWorker(identifier, bridgeNew);
+ jobCoordinator.enqueueJob(bridgeNew.getBridgeName().getValue(), rendererStateAddWorker);
+ } else if(!bridgeOld.getDatapathId().equals(bridgeNew.getDatapathId())){
+ DataStoreJobCoordinator jobCoordinator = DataStoreJobCoordinator.getInstance();
+ RendererStateUpdateWorker rendererStateAddWorker = new RendererStateUpdateWorker(identifier, bridgeNew, bridgeOld);
+ jobCoordinator.enqueueJob(bridgeNew.getBridgeName().getValue(), rendererStateAddWorker);
+ }
}
@Override
bridgeNew, dataBroker);
}
}
+ private class RendererStateUpdateWorker implements Callable<List<ListenableFuture<Void>>> {
+ InstanceIdentifier<OvsdbBridgeAugmentation> instanceIdentifier;
+ OvsdbBridgeAugmentation bridgeNew;
+ OvsdbBridgeAugmentation bridgeOld;
+
+
+ public RendererStateUpdateWorker(InstanceIdentifier<OvsdbBridgeAugmentation> instanceIdentifier,
+ OvsdbBridgeAugmentation bridgeNew, OvsdbBridgeAugmentation bridgeOld) {
+ this.instanceIdentifier = instanceIdentifier;
+ this.bridgeNew = bridgeNew;
+ this.bridgeOld = bridgeOld;
+ }
+
+ @Override
+ public List<ListenableFuture<Void>> call() throws Exception {
+ // If another renderer(for eg : CSS) needs to be supported, check can be performed here
+ // to call the respective helpers.
+ return OvsInterfaceTopologyStateUpdateHelper.updateBridgeRefEntry(instanceIdentifier,
+ bridgeNew, bridgeOld, dataBroker);
+ }
+ }
}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.interfacemgr.listeners;
+
+import com.google.common.util.concurrent.ListenableFuture;
+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.vpnservice.datastoreutils.AsyncDataChangeListenerBase;
+import org.opendaylight.vpnservice.datastoreutils.DataStoreJobCoordinator;
+import org.opendaylight.vpnservice.interfacemgr.renderer.ovs.statehelpers.OvsInterfaceTopologyStateUpdateHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
+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.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.concurrent.Callable;
+
+public class TerminationPointStateListener extends AsyncDataChangeListenerBase<OvsdbTerminationPointAugmentation, TerminationPointStateListener> {
+ private static final Logger LOG = LoggerFactory.getLogger(TerminationPointStateListener.class);
+ private DataBroker dataBroker;
+
+ public TerminationPointStateListener(DataBroker dataBroker) {
+ super(OvsdbTerminationPointAugmentation.class, TerminationPointStateListener.class);
+ this.dataBroker = dataBroker;
+ }
+
+ @Override
+ protected InstanceIdentifier<OvsdbTerminationPointAugmentation> getWildCardPath() {
+ return InstanceIdentifier.builder(NetworkTopology.class).child(Topology.class)
+ .child(Node.class).child(TerminationPoint.class).augmentation(OvsdbTerminationPointAugmentation.class).build();
+ }
+
+ @Override
+ protected DataChangeListener getDataChangeListener() {
+ return TerminationPointStateListener.this;
+ }
+
+ @Override
+ protected AsyncDataBroker.DataChangeScope getDataChangeScope() {
+ return AsyncDataBroker.DataChangeScope.ONE;
+ }
+
+ @Override
+ protected void remove(InstanceIdentifier<OvsdbTerminationPointAugmentation> identifier,
+ OvsdbTerminationPointAugmentation tpOld) {
+ }
+
+ @Override
+ protected void update(InstanceIdentifier<OvsdbTerminationPointAugmentation> identifier,
+ OvsdbTerminationPointAugmentation tpOld,
+ OvsdbTerminationPointAugmentation tpNew) {
+ LOG.debug("Received Update DataChange Notification for ovsdb termination point identifier: {}, old: {}, new: {}.",
+ identifier, tpOld, tpNew);
+ if (tpNew.getInterfaceBfdStatus() != null &&
+ !tpNew.getInterfaceBfdStatus().equals(tpOld.getInterfaceBfdStatus())) {
+ DataStoreJobCoordinator jobCoordinator = DataStoreJobCoordinator.getInstance();
+ RendererStateUpdateWorker rendererStateAddWorker = new RendererStateUpdateWorker(identifier, tpNew, tpOld);
+ jobCoordinator.enqueueJob(tpNew.getName(), rendererStateAddWorker);
+ }
+ }
+
+ @Override
+ protected void add(InstanceIdentifier<OvsdbTerminationPointAugmentation> identifier,
+ OvsdbTerminationPointAugmentation tpNew) {
+
+ }
+
+ private class RendererStateUpdateWorker implements Callable<List<ListenableFuture<Void>>> {
+ InstanceIdentifier<OvsdbTerminationPointAugmentation> instanceIdentifier;
+ OvsdbTerminationPointAugmentation terminationPointNew;
+ OvsdbTerminationPointAugmentation terminationPointOld;
+
+
+ public RendererStateUpdateWorker(InstanceIdentifier<OvsdbTerminationPointAugmentation> instanceIdentifier,
+ OvsdbTerminationPointAugmentation tpNew, OvsdbTerminationPointAugmentation tpOld) {
+ this.instanceIdentifier = instanceIdentifier;
+ this.terminationPointNew = tpNew;
+ this.terminationPointOld = tpOld;
+ }
+
+ @Override
+ public List<ListenableFuture<Void>> call() throws Exception {
+ // If another renderer(for eg : CSS) needs to be supported, check can be performed here
+ // to call the respective helpers.
+ return OvsInterfaceTopologyStateUpdateHelper.updateTunnelState(dataBroker,
+ terminationPointNew, terminationPointOld);
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.interfacemgr.pmcounters;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class CounterForEntriesPerOFTable implements CounterForEntriesPerOFTableMBean{
+
+ Map<String, Integer> counterCache = new HashMap<String, Integer>();
+ public static Map counterMap = new HashMap<String,String>();
+ public void invokePMManagedObjects(Map<String, Integer> map) {
+ setCounterDetails(map);
+ }
+
+ public Map<String, Integer> getCounterDetails() {
+ return counterCache;
+ }
+
+ public synchronized void setCounterDetails(Map<String, Integer> map) {
+ counterCache = map;
+ }
+
+ public Map<String, String> retrieveCounterMap(){
+ counterMap = (HashMap) counterCache;
+ return counterMap;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.interfacemgr.pmcounters;
+
+import java.util.Map;
+
+public interface CounterForEntriesPerOFTableMBean {
+ //-----------
+ // operations
+ //-----------
+ public void setCounterDetails(Map<String, Integer> map);
+ public Map<String, Integer> getCounterDetails();
+ //-----------
+ // attributes
+ //-----------
+ public void invokePMManagedObjects(Map<String, Integer> map);
+ public Map<String, String> retrieveCounterMap();
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.interfacemgr.pmcounters;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class CounterForOFPortBytesReceive implements CounterForOFPortBytesReceiveMBean{
+
+ Map<String, Integer> counterCache = new HashMap<String, Integer>();
+ public static Map counterMap = new HashMap<String,String>();
+ public void invokePMManagedObjects(Map<String, Integer> map) {
+ setCounterDetails(map);
+ }
+
+ public Map<String, Integer> getCounterDetails() {
+ return counterCache;
+ }
+
+ public synchronized void setCounterDetails(Map<String, Integer> map) {
+ counterCache = map;
+ }
+
+ public Map<String, String> retrieveCounterMap(){
+ counterMap = (HashMap) counterCache;
+ return counterMap;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.interfacemgr.pmcounters;
+
+import java.util.Map;
+
+public interface CounterForOFPortBytesReceiveMBean {
+ //-----------
+ // operations
+ //-----------
+ public void setCounterDetails(Map<String, Integer> map);
+ public Map<String, Integer> getCounterDetails();
+ //-----------
+ // attributes
+ //-----------
+ public void invokePMManagedObjects(Map<String, Integer> map);
+ public Map<String, String> retrieveCounterMap();
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.interfacemgr.pmcounters;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class CounterForOFPortBytesSent implements CounterForOFPortBytesSentMBean{
+
+ Map<String, Integer> counterCache = new HashMap<String, Integer>();
+ public static Map counterMap = new HashMap<String,String>();
+ public void invokePMManagedObjects(Map<String, Integer> map) {
+ setCounterDetails(map);
+ }
+
+ public Map<String, Integer> getCounterDetails() {
+ return counterCache;
+ }
+
+ public synchronized void setCounterDetails(Map<String, Integer> map) {
+ counterCache = map;
+ }
+
+ public Map<String, String> retrieveCounterMap(){
+ counterMap = (HashMap) counterCache;
+ return counterMap;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.interfacemgr.pmcounters;
+
+import java.util.Map;
+
+public interface CounterForOFPortBytesSentMBean {
+ //-----------
+ // operations
+ //-----------
+ public void setCounterDetails(Map<String, Integer> map);
+ public Map<String, Integer> getCounterDetails();
+ //-----------
+ // attributes
+ //-----------
+ public void invokePMManagedObjects(Map<String, Integer> map);
+ public Map<String, String> retrieveCounterMap();
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.interfacemgr.pmcounters;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class CounterForOFPortDuration implements CounterForOFPortDurationMBean{
+
+ Map<String, Integer> counterCache = new HashMap<String, Integer>();
+ public static Map counterMap = new HashMap<String,String>();
+ public void invokePMManagedObjects(Map<String, Integer> map) {
+ setCounterDetails(map);
+ }
+
+ public Map<String, Integer> getCounterDetails() {
+ return counterCache;
+ }
+
+ public synchronized void setCounterDetails(Map<String, Integer> map) {
+ counterCache = map;
+ }
+
+ public Map<String, String> retrieveCounterMap(){
+ counterMap = (HashMap) counterCache;
+ return counterMap;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.interfacemgr.pmcounters;
+
+import java.util.Map;
+
+public interface CounterForOFPortDurationMBean {
+ //-----------
+ // operations
+ //-----------
+ public void setCounterDetails(Map<String, Integer> map);
+ public Map<String, Integer> getCounterDetails();
+ //-----------
+ // attributes
+ //-----------
+ public void invokePMManagedObjects(Map<String, Integer> map);
+ public Map<String, String> retrieveCounterMap();
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.interfacemgr.pmcounters;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class CounterForOFPortPacketReceive implements CounterForOFPortPacketReceiveMBean{
+
+ Map<String, Integer> counterCache = new HashMap<String, Integer>();
+ public static Map counterMap = new HashMap<String,String>();
+ public void invokePMManagedObjects(Map<String, Integer> map) {
+ setCounterDetails(map);
+ }
+
+ public Map<String, Integer> getCounterDetails() {
+ return counterCache;
+ }
+
+ public synchronized void setCounterDetails(Map<String, Integer> map) {
+ counterCache = map;
+ }
+
+ public Map<String, String> retrieveCounterMap(){
+ counterMap = (HashMap) counterCache;
+ return counterMap;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.interfacemgr.pmcounters;
+
+import java.util.Map;
+
+public interface CounterForOFPortPacketReceiveMBean {
+ //-----------
+ // operations
+ //-----------
+ public void setCounterDetails(Map<String, Integer> map);
+ public Map<String, Integer> getCounterDetails();
+ //-----------
+ // attributes
+ //-----------
+ public void invokePMManagedObjects(Map<String, Integer> map);
+ public Map<String, String> retrieveCounterMap();
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.interfacemgr.pmcounters;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class CounterForOFPortPacketSent implements CounterForOFPortPacketSentMBean{
+
+ Map<String, Integer> counterCache = new HashMap<String, Integer>();
+ public static Map counterMap = new HashMap<String,String>();
+ public void invokePMManagedObjects(Map<String, Integer> map) {
+ setCounterDetails(map);
+ }
+
+ public Map<String, Integer> getCounterDetails() {
+ return counterCache;
+ }
+
+ public synchronized void setCounterDetails(Map<String, Integer> map) {
+ counterCache = map;
+ }
+
+ public Map<String, String> retrieveCounterMap(){
+ counterMap = (HashMap) counterCache;
+ return counterMap;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.interfacemgr.pmcounters;
+
+import java.util.Map;
+
+public interface CounterForOFPortPacketSentMBean {
+ //-----------
+ // operations
+ //-----------
+ public void setCounterDetails(Map<String, Integer> map);
+ public Map<String, Integer> getCounterDetails();
+ //-----------
+ // attributes
+ //-----------
+ public void invokePMManagedObjects(Map<String, Integer> map);
+ public Map<String, String> retrieveCounterMap();
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.interfacemgr.pmcounters;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class CounterForOFPortReceiveDrop implements CounterForOFPortReceiveDropMBean{
+
+ Map<String, Integer> counterCache = new HashMap<String, Integer>();
+ public static Map counterMap = new HashMap<String,String>();
+ public void invokePMManagedObjects(Map<String, Integer> map) {
+ setCounterDetails(map);
+ }
+
+ public Map<String, Integer> getCounterDetails() {
+ return counterCache;
+ }
+
+ public synchronized void setCounterDetails(Map<String, Integer> map) {
+ counterCache = map;
+ }
+
+ public Map<String, String> retrieveCounterMap(){
+ counterMap = (HashMap) counterCache;
+ return counterMap;
+ }
+
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.interfacemgr.pmcounters;
+
+import java.util.Map;
+
+public interface CounterForOFPortReceiveDropMBean {
+ //-----------
+ // operations
+ //-----------
+ public void setCounterDetails(Map<String, Integer> map);
+ public Map<String, Integer> getCounterDetails();
+ //-----------
+ // attributes
+ //-----------
+ public void invokePMManagedObjects(Map<String, Integer> map);
+ public Map<String, String> retrieveCounterMap();
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.interfacemgr.pmcounters;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class CounterForOFPortReceiveError implements CounterForOFPortReceiveErrorMBean{
+
+ Map<String, Integer> counterCache = new HashMap<String, Integer>();
+ public static Map counterMap = new HashMap<String,String>();
+ public void invokePMManagedObjects(Map<String, Integer> map) {
+ setCounterDetails(map);
+ }
+
+ public Map<String, Integer> getCounterDetails() {
+ return counterCache;
+ }
+
+ public synchronized void setCounterDetails(Map<String, Integer> map) {
+ counterCache = map;
+ }
+
+ public Map<String, String> retrieveCounterMap(){
+ counterMap = (HashMap) counterCache;
+ return counterMap;
+ }
+
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.interfacemgr.pmcounters;
+
+import java.util.Map;
+
+public interface CounterForOFPortReceiveErrorMBean {
+ //-----------
+ // operations
+ //-----------
+ public void setCounterDetails(Map<String, Integer> map);
+ public Map<String, Integer> getCounterDetails();
+ //-----------
+ // attributes
+ //-----------
+ public void invokePMManagedObjects(Map<String, Integer> map);
+ public Map<String, String> retrieveCounterMap();
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.interfacemgr.pmcounters;
+
+import java.lang.Thread.UncaughtExceptionHandler;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.NotificationService;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.vpnservice.mdsalutil.AbstractDataChangeListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdate;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMap;
+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.NodeRef;
+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.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdate;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+
+public class NodeConnectorStatsImpl extends AbstractDataChangeListener<Node>{
+
+ private static final Logger logger = LoggerFactory.getLogger(NodeConnectorStatsImpl.class);
+ private static final int THREAD_POOL_SIZE = 4;
+ private static final int NO_DELAY = 0;
+ public static final PMAgentForNodeConnectorCounters pmagent = new PMAgentForNodeConnectorCounters();
+ private PortRpcStatisticsListener portStatsListener = new PortRpcStatisticsListener();
+ private FlowRpcStatisticsListener flowTableStatsListener = new FlowRpcStatisticsListener();
+ private List<BigInteger> nodes = new ArrayList<>();
+ Map<String, Map<String, String>> nodeAndNcIdOFPortDurationMap = new ConcurrentHashMap<String, Map<String, String>>();
+ Map<String, Map<String, String>> nodeAndNcIdOFPortReceiveDropMap = new ConcurrentHashMap<String, Map<String, String>>();
+ Map<String, Map<String, String>> nodeAndNcIdOFPortReceiveError = new ConcurrentHashMap<String, Map<String, String>>();
+ Map<String, Map<String, String>> nodeAndNcIdPacketSentMap = new ConcurrentHashMap<String, Map<String, String>>();
+ Map<String, Map<String, String>> nodeAndNcIdPacketReceiveMap = new ConcurrentHashMap<String, Map<String, String>>();
+ Map<String, Map<String, String>> nodeAndNcIdBytesSentMap = new ConcurrentHashMap<String, Map<String, String>>();
+ Map<String, Map<String, String>> nodeAndNcIdBytesReceiveMap = new ConcurrentHashMap<String, Map<String, String>>();
+ Map<String, Map<String, String>> nodeAndEntriesPerOFTableMap = new ConcurrentHashMap<String, Map<String, String>>();
+ private ScheduledFuture<?> scheduledResult;
+ private OpendaylightPortStatisticsService statPortService;
+ private ScheduledExecutorService portStatExecutorService;
+ private OpendaylightFlowTableStatisticsService opendaylightFlowTableStatisticsService;
+ public NodeConnectorStatsImpl(DataBroker db, NotificationService notificationService, OpendaylightPortStatisticsService statPortService, OpendaylightFlowTableStatisticsService opendaylightFlowTableStatisticsService) {
+ super(Node.class);
+ this.statPortService = statPortService;
+ this.opendaylightFlowTableStatisticsService = opendaylightFlowTableStatisticsService;
+ registerListener(db);
+ portStatExecutorService = Executors.newScheduledThreadPool(THREAD_POOL_SIZE, getThreadFactory("Port Stats Request Task"));
+ notificationService.registerNotificationListener(portStatsListener);
+ notificationService.registerNotificationListener(flowTableStatsListener);
+ pmagent.registerMbean();
+ }
+
+ private void registerListener(final DataBroker db) {
+ try {
+ db.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+ getWildCardPath(), NodeConnectorStatsImpl.this, AsyncDataBroker.DataChangeScope.SUBTREE);
+ } catch (final Exception e) {
+ logger.error("NodeConnectorStatsImpl: DataChange listener registration fail!", e);
+ throw new IllegalStateException("NodeConnectorStatsImpl: registration Listener failed.", e);
+ }
+ }
+
+ private InstanceIdentifier<Node> getWildCardPath() {
+ return InstanceIdentifier.create(Nodes.class).child(Node.class);
+ }
+
+ /*
+ * PortStat request task is started when first DPN gets connected
+ */
+ private void schedulePortStatRequestTask() {
+ logger.info("Scheduling port statistics request");
+ PortStatRequestTask portStatRequestTask = new PortStatRequestTask();
+ scheduledResult = portStatExecutorService.scheduleAtFixedRate(portStatRequestTask, NO_DELAY, 10000, TimeUnit.MILLISECONDS);
+ }
+
+ /*
+ * PortStat request task is stopped when last DPN is removed.
+ */
+ private void stopPortStatRequestTask() {
+ if(scheduledResult != null) {
+ logger.info("Stopping port statistics request");
+ scheduledResult.cancel(true);
+ }
+ }
+
+ /*
+ * This task queries for node connector statistics as well as flowtables statistics every 10 secs.
+ * Minimum period which can be configured for PMJob is 10 secs.
+ */
+ private class PortStatRequestTask implements Runnable {
+
+ @Override
+ public void run() {
+ if(logger.isTraceEnabled()) {
+ logger.trace("Requesting port stats - {}");
+ }
+ for (BigInteger node : nodes) {
+ logger.trace("Requesting AllNodeConnectorStatistics for node - {}", node);
+ statPortService.getAllNodeConnectorsStatistics(buildGetAllNodeConnectorStatistics(node));
+ opendaylightFlowTableStatisticsService.getFlowTablesStatistics(buildGetFlowTablesStatistics(node));
+ }
+ }
+
+ private GetAllNodeConnectorsStatisticsInput buildGetAllNodeConnectorStatistics(BigInteger dpId) {
+ return new GetAllNodeConnectorsStatisticsInputBuilder()
+ .setNode(
+ new NodeRef(InstanceIdentifier.builder(Nodes.class)
+ .child(Node.class, new NodeKey(new NodeId("openflow:" + dpId.toString()))).build())).build();
+ }
+
+ private GetFlowTablesStatisticsInput buildGetFlowTablesStatistics(BigInteger dpId) {
+ return new GetFlowTablesStatisticsInputBuilder()
+ .setNode(
+ new NodeRef(InstanceIdentifier.builder(Nodes.class)
+ .child(Node.class, new NodeKey(new NodeId("openflow:" + dpId.toString()))).build())).build();
+ }
+
+ }
+
+ private ThreadFactory getThreadFactory(String threadNameFormat) {
+ ThreadFactoryBuilder builder = new ThreadFactoryBuilder();
+ builder.setNameFormat(threadNameFormat);
+ builder.setUncaughtExceptionHandler( new UncaughtExceptionHandler() {
+ @Override
+ public void uncaughtException(Thread t, Throwable e) {
+ logger.error("Received Uncaught Exception event in Thread: {}", t.getName(), e);
+ }
+ });
+ return builder.build();
+ }
+
+ /*
+ * PortRpcStatisticsListener listens for the NodeConnectorStatisticsUpdate and then update the corresponding counter map
+ */
+ class PortRpcStatisticsListener implements OpendaylightPortStatisticsListener {
+
+ @Override
+ public void onNodeConnectorStatisticsUpdate(NodeConnectorStatisticsUpdate ncStats) {
+ Map<String, String> ncIdOFPortDurationMap = new HashMap<String, String>();
+ Map<String, String> ncIdOFPortReceiveDropMap = new HashMap<String, String>();
+ Map<String, String> ncIdOFPortReceiveError = new HashMap<String, String>();
+ Map<String, String> ncIdPacketSentMap = new HashMap<String, String>();
+ Map<String, String> ncIdPacketReceiveMap = new HashMap<String, String>();
+ Map<String, String> ncIdBytesSentMap = new HashMap<String, String>();
+ Map<String, String> ncIdBytesReceiveMap = new HashMap<String, String>();
+ List<NodeConnectorStatisticsAndPortNumberMap> ncStatsAndPortMapList = ncStats.getNodeConnectorStatisticsAndPortNumberMap();
+ NodeId nodeId = ncStats.getId();
+ String node = nodeId.getValue().split(":")[1];
+ for (NodeConnectorStatisticsAndPortNumberMap ncStatsAndPortMap : ncStatsAndPortMapList) {
+ NodeConnectorId nodeConnector = ncStatsAndPortMap.getNodeConnectorId();
+ String port = nodeConnector.getValue().split(":")[2];
+ String nodePortStr = "dpnId_" + node + "_portNum_" + port;
+ ncIdOFPortDurationMap.put("OFPortDuration:" + nodePortStr + "_OFPortDuration", ncStatsAndPortMap.getDuration().getSecond().getValue().toString());
+ ncIdOFPortReceiveDropMap.put("PacketsPerOFPortReceiveDrop:" + nodePortStr + "_PacketsPerOFPortReceiveDrop", ncStatsAndPortMap.getReceiveDrops().toString());
+ ncIdOFPortReceiveError.put("PacketsPerOFPortReceiveError:" + nodePortStr + "_PacketsPerOFPortReceiveError", ncStatsAndPortMap.getReceiveErrors().toString());
+ ncIdPacketSentMap.put("PacketsPerOFPortSent:" + nodePortStr + "_PacketsPerOFPortSent", ncStatsAndPortMap.getPackets().getTransmitted().toString());
+ ncIdPacketReceiveMap.put("PacketsPerOFPortReceive:" + nodePortStr + "_PacketsPerOFPortReceive", ncStatsAndPortMap.getPackets().getReceived().toString());
+ ncIdBytesSentMap.put("BytesPerOFPortSent:" + nodePortStr + "_BytesPerOFPortSent", ncStatsAndPortMap.getBytes().getTransmitted().toString());
+ ncIdBytesReceiveMap.put("BytesPerOFPortReceive:" + nodePortStr + "_BytesPerOFPortReceive", ncStatsAndPortMap.getBytes().getReceived().toString());
+ }
+ logger.trace("Port Stats {}", ncStatsAndPortMapList);
+ //Storing allNodeConnectorStats(like ncIdOFPortDurationMap) in a map with key as node for easy removal and addition of allNodeConnectorStats.
+ nodeAndNcIdOFPortDurationMap.put(node, ncIdOFPortDurationMap);
+ nodeAndNcIdOFPortReceiveDropMap.put(node, ncIdOFPortReceiveDropMap);
+ nodeAndNcIdOFPortReceiveError.put(node, ncIdOFPortReceiveError);
+ nodeAndNcIdPacketSentMap.put(node, ncIdPacketSentMap);
+ nodeAndNcIdPacketReceiveMap.put(node, ncIdPacketReceiveMap);
+ nodeAndNcIdBytesSentMap.put(node, ncIdBytesSentMap);
+ nodeAndNcIdBytesReceiveMap.put(node, ncIdBytesReceiveMap);
+ //Combining the stats of all nodeconnectors in all nodes. This Map will be stored under MBean which will be queried as regular intervals.
+ ncIdOFPortDurationMap = combineAllNodesStats(nodeAndNcIdOFPortDurationMap);
+ ncIdOFPortReceiveDropMap = combineAllNodesStats(nodeAndNcIdOFPortReceiveDropMap);
+ ncIdOFPortReceiveError = combineAllNodesStats(nodeAndNcIdOFPortReceiveError);
+ ncIdPacketSentMap = combineAllNodesStats(nodeAndNcIdPacketSentMap);
+ ncIdPacketReceiveMap = combineAllNodesStats(nodeAndNcIdPacketReceiveMap);
+ ncIdBytesSentMap = combineAllNodesStats(nodeAndNcIdBytesSentMap);
+ ncIdBytesReceiveMap = combineAllNodesStats(nodeAndNcIdBytesReceiveMap);
+ pmagent.connectToPMAgent(ncIdOFPortDurationMap, ncIdOFPortReceiveDropMap, ncIdOFPortReceiveError, ncIdPacketSentMap, ncIdPacketReceiveMap, ncIdBytesSentMap, ncIdBytesReceiveMap);
+ }
+
+ /*
+ * Input allNodesStats contains statistics of all nodeConnectors of all nodes. Key is the node and values contains another map with key as node connector and value as statresult.
+ * Output will be a map with key as nodeconnector and value as the statresult. The key contains nodeconnectors of all the nodes.
+ */
+ }
+
+ private Map<String, String> combineAllNodesStats(Map<String, Map<String, String>> allNodesStats) {
+ Map<String, String> allNcsStatsMap = new HashMap<String, String>();
+ for (Map.Entry<String, Map<String, String>> entry : allNodesStats.entrySet()) {
+ Map<String, String> ncStatsMap = entry.getValue();
+ for (Map.Entry<String, String> statResult : ncStatsMap.entrySet()) {
+ allNcsStatsMap.put(statResult.getKey(), statResult.getValue());
+ }
+ }
+ return allNcsStatsMap;
+ }
+
+ /*
+ * FlowRpcStatisticsListener listens for the FlowTableStatisticsUpdate and then update the corresponding counter map
+ */
+ class FlowRpcStatisticsListener implements OpendaylightFlowTableStatisticsListener {
+
+ @Override
+ public void onFlowTableStatisticsUpdate(FlowTableStatisticsUpdate flowTableStats) {
+ String node = flowTableStats.getId().getValue().split(":")[1];
+ Map<String, String> entriesPerOFTableMap = new HashMap<String, String>();
+ List<FlowTableAndStatisticsMap> flowTableAndStatisticsMapList = flowTableStats.getFlowTableAndStatisticsMap();
+ for (FlowTableAndStatisticsMap flowTableAndStatisticsMap : flowTableAndStatisticsMapList) {
+ String nodeTableStr = "dpnId_" + node + "_table_" + flowTableAndStatisticsMap.getTableId().getValue().toString();
+ entriesPerOFTableMap.put("EntriesPerOFTable:" + nodeTableStr + "_EntriesPerOFTable", flowTableAndStatisticsMap.getActiveFlows().getValue().toString());
+ }
+ nodeAndEntriesPerOFTableMap.put(node, entriesPerOFTableMap);
+ entriesPerOFTableMap = combineAllNodesStats(nodeAndEntriesPerOFTableMap);
+ pmagent.connectToPMAgentAndInvokeEntriesPerOFTable(entriesPerOFTableMap);
+ }
+
+ }
+
+ @Override
+ protected void remove(InstanceIdentifier<Node> identifier, Node node) {
+ NodeId nodeId = node.getId();
+ String nodeVal = nodeId.getValue().split(":")[1];
+ BigInteger dpId = new BigInteger(nodeVal);
+ if (nodes.contains(dpId)) {
+ nodes.remove(dpId);
+ nodeAndNcIdOFPortDurationMap.remove(nodeVal);
+ nodeAndNcIdOFPortReceiveDropMap.remove(nodeVal);
+ nodeAndNcIdOFPortReceiveError.remove(nodeVal);
+ nodeAndNcIdPacketSentMap.remove(nodeVal);
+ nodeAndNcIdPacketReceiveMap.remove(nodeVal);
+ nodeAndNcIdBytesSentMap.remove(nodeVal);
+ nodeAndNcIdBytesReceiveMap.remove(nodeVal);
+ nodeAndEntriesPerOFTableMap.remove(nodeVal);
+ }
+ if (nodes.isEmpty()) {
+ stopPortStatRequestTask();
+ }
+ }
+
+ @Override
+ protected void update(InstanceIdentifier<Node> identifier, Node original,
+ Node update) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ protected void add(InstanceIdentifier<Node> identifier, Node node) {
+ NodeId nodeId = node.getId();
+ BigInteger dpId = new BigInteger(nodeId.getValue().split(":")[1]);
+ if (nodes.contains(dpId)) {
+ return;
+ }
+ nodes.add(dpId);
+ if (nodes.size() == 1) {
+ schedulePortStatRequestTask();
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.interfacemgr.pmcounters;
+
+import java.lang.management.ManagementFactory;
+import java.util.Map;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class PMAgentForNodeConnectorCounters {
+
+ private static Logger logger = LoggerFactory.getLogger(PMAgentForNodeConnectorCounters.class);
+ private MBeanServer mbServer = null;
+ private ObjectName mbeanForOFPortDuration = null;
+ private ObjectName mbeanForOFPortReceiveDrop = null;
+ private ObjectName mbeanForOFPortReceiveError = null;
+ private ObjectName mbeanForOFPortPacketSent = null;
+ private ObjectName mbeanForOFPortPacketReceive = null;
+ private ObjectName mbeanForOFPortBytesSent = null;
+ private ObjectName mbeanForOFPortBytesReceive = null;
+ private ObjectName mbeanForEntriesPerOFTable = null;
+ private static final String BEANNAMEFOROFPORTDURATION = "SDNC.PM:type=CounterForOFPortDuration";
+ private static final String BEANNAMEFOROFPORTREVEIVEDROP = "SDNC.PM:type=CounterForOFPortReceiveDrop";
+ private static final String BEANNAMEFOROFPORTREVEIVEERROR = "SDNC.PM:type=CounterForOFPortReceiveError";
+ private static final String BEANNAMEFOROFPORTPACKETSENT = "SDNC.PM:type=CounterForOFPortPacketSent";
+ private static final String BEANNAMEFOROFPORTPACKETRECEIVE = "SDNC.PM:type=CounterForOFPortPacketReceive";
+ private static final String BEANNAMEFOROFPORTBYTESSENT = "SDNC.PM:type=CounterForOFPortBytesSent";
+ private static final String BEANNAMEFOROFPORTBYTESRECEIVE = "SDNC.PM:type=CounterForOFPortBytesReceive";
+ private static final String BEANNAMEFORENTRIESPEROFTABLE = "SDNC.PM:type=CounterForEntriesPerOFTable";
+ private static CounterForOFPortDuration counterForOFPortDurationBean = new CounterForOFPortDuration();
+ private static CounterForOFPortReceiveDrop counterForOFPortReceiveDropBean = new CounterForOFPortReceiveDrop();
+ private static CounterForOFPortReceiveError counterForOFPortReceiveErrorBean = new CounterForOFPortReceiveError();
+ private static CounterForOFPortPacketSent counterForOFPortPacketSent = new CounterForOFPortPacketSent();
+ private static CounterForOFPortPacketReceive counterForOFPortPacketReceive = new CounterForOFPortPacketReceive();
+ private static CounterForOFPortBytesSent counterForOFPortBytesSent = new CounterForOFPortBytesSent();
+ private static CounterForOFPortBytesReceive counterForOFPortBytesReceive = new CounterForOFPortBytesReceive();
+ private static CounterForEntriesPerOFTable counterForEntriesPerOFTable = new CounterForEntriesPerOFTable();
+
+ public PMAgentForNodeConnectorCounters() {
+ // Get the platform MBeanServer
+ mbServer = ManagementFactory.getPlatformMBeanServer();
+ try {
+ mbeanForOFPortDuration = new ObjectName(BEANNAMEFOROFPORTDURATION);
+ mbeanForOFPortReceiveDrop = new ObjectName(BEANNAMEFOROFPORTREVEIVEDROP);
+ mbeanForOFPortReceiveError = new ObjectName(BEANNAMEFOROFPORTREVEIVEERROR);
+ mbeanForOFPortPacketSent = new ObjectName(BEANNAMEFOROFPORTPACKETSENT);
+ mbeanForOFPortPacketReceive = new ObjectName(BEANNAMEFOROFPORTPACKETRECEIVE);
+ mbeanForOFPortBytesSent = new ObjectName(BEANNAMEFOROFPORTBYTESSENT);
+ mbeanForOFPortBytesReceive = new ObjectName(BEANNAMEFOROFPORTBYTESRECEIVE);
+ mbeanForEntriesPerOFTable = new ObjectName(BEANNAMEFORENTRIESPEROFTABLE);
+ } catch (MalformedObjectNameException e) {
+ logger.error("ObjectName instance creation failed with exception {}", e);
+
+ }
+ }
+
+ public void registerMbean() {
+ try {
+ // Uniquely identify the MBeans and register them with the platform MBeanServer
+ if(!mbServer.isRegistered(mbeanForOFPortDuration)) {
+ mbServer.registerMBean(counterForOFPortDurationBean, mbeanForOFPortDuration);
+ logger.info("Registered Mbean {} successfully", mbeanForOFPortDuration);
+ }
+ if(!mbServer.isRegistered(mbeanForOFPortReceiveDrop)) {
+ mbServer.registerMBean(counterForOFPortReceiveDropBean, mbeanForOFPortReceiveDrop);
+ logger.info("Registered Mbean {} successfully", mbeanForOFPortReceiveDrop);
+ }
+ if(!mbServer.isRegistered(mbeanForOFPortReceiveError)) {
+ mbServer.registerMBean(counterForOFPortReceiveErrorBean, mbeanForOFPortReceiveError);
+ logger.info("Registered Mbean {} successfully", mbeanForOFPortReceiveError);
+ }
+ if(!mbServer.isRegistered(mbeanForOFPortPacketSent)) {
+ mbServer.registerMBean(counterForOFPortPacketSent, mbeanForOFPortPacketSent);
+ logger.info("Registered Mbean {} successfully", mbeanForOFPortPacketSent);
+ }
+ if(!mbServer.isRegistered(mbeanForOFPortPacketReceive)) {
+ mbServer.registerMBean(counterForOFPortPacketReceive, mbeanForOFPortPacketReceive);
+ logger.info("Registered Mbean {} successfully", mbeanForOFPortPacketReceive);
+ }
+ if(!mbServer.isRegistered(mbeanForOFPortBytesSent)) {
+ mbServer.registerMBean(counterForOFPortBytesSent, mbeanForOFPortBytesSent);
+ logger.info("Registered Mbean {} successfully", mbeanForOFPortBytesSent);
+ }
+ if(!mbServer.isRegistered(mbeanForOFPortBytesReceive)) {
+ mbServer.registerMBean(counterForOFPortBytesReceive, mbeanForOFPortBytesReceive);
+ logger.info("Registered Mbean {} successfully", mbeanForOFPortBytesReceive);
+ }
+ if(!mbServer.isRegistered(mbeanForEntriesPerOFTable)) {
+ mbServer.registerMBean(counterForEntriesPerOFTable, mbeanForEntriesPerOFTable);
+ logger.info("Registered Mbean {} successfully", mbeanForEntriesPerOFTable);
+ }
+ } catch(Exception e) {
+ logger.error("Registeration failed with exception {}", e);
+ }
+ }
+
+
+ public synchronized void connectToPMAgent(Map<String, String> ofPortDurationCounter, Map<String, String> ofPortReceiveDropCounter,
+ Map<String, String> ofPortReceiveErrorCounter, Map<String, String> ofPortPacketSent, Map<String, String> ofPortPacketReceive,
+ Map<String, String> ofPortBytesSent, Map<String, String> ofPortBytesReceive) {
+ try {
+ mbServer.invoke(mbeanForOFPortDuration, "invokePMManagedObjects", new Object[]{ofPortDurationCounter}, new String[]{Map.class.getName()});
+ mbServer.invoke(mbeanForOFPortReceiveDrop, "invokePMManagedObjects", new Object[]{ofPortReceiveDropCounter}, new String[]{Map.class.getName()});
+ mbServer.invoke(mbeanForOFPortReceiveError, "invokePMManagedObjects", new Object[]{ofPortReceiveErrorCounter}, new String[]{Map.class.getName()});
+ mbServer.invoke(mbeanForOFPortPacketSent, "invokePMManagedObjects", new Object[]{ofPortPacketSent}, new String[]{Map.class.getName()});
+ mbServer.invoke(mbeanForOFPortPacketReceive, "invokePMManagedObjects", new Object[]{ofPortPacketReceive}, new String[]{Map.class.getName()});
+ mbServer.invoke(mbeanForOFPortBytesSent, "invokePMManagedObjects", new Object[]{ofPortBytesSent}, new String[]{Map.class.getName()});
+ mbServer.invoke(mbeanForOFPortBytesReceive, "invokePMManagedObjects", new Object[]{ofPortBytesReceive}, new String[]{Map.class.getName()});
+ } catch (InstanceNotFoundException e ) {
+ logger.error(" InstanceNotFoundException ", e);
+ } catch (MBeanException e) {
+ logger.error(" MBeanException ", e);
+ } catch (ReflectionException e) {
+ logger.error(" ReflectionException ", e);
+ }
+ }
+
+ public synchronized void connectToPMAgentAndInvokeEntriesPerOFTable(Map<String, String> entriesPerOFTable) {
+ try {
+ mbServer.invoke(mbeanForEntriesPerOFTable, "invokePMManagedObjects", new Object[]{entriesPerOFTable}, new String[]{Map.class.getName()});
+ } catch (InstanceNotFoundException e ) {
+ logger.error(" InstanceNotFoundException ", e);
+ } catch (MBeanException e) {
+ logger.error(" MBeanException ", e);
+ } catch (ReflectionException e) {
+ logger.error(" ReflectionException ", e);
+ }
+ }
+}
/*
- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
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.vpnservice.interfacemgr.IfmUtil;
import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils;
import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceMetaUtils;
-import org.opendaylight.vpnservice.interfacemgr.renderer.ovs.utilities.SouthboundUtils;
+import org.opendaylight.vpnservice.interfacemgr.renderer.hwvtep.utilities.SouthboundUtils;
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.InterfaceBuilder;
-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;
-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;
-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.IfL2vlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.AlivenessMonitorService;
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.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.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
private static final Logger LOG = LoggerFactory.getLogger(HwVTEPConfigRemoveHelper.class);
public static List<ListenableFuture<Void>> removeConfiguration(DataBroker dataBroker, Interface interfaceOld,
- ParentRefs parentRefs) {
+ InstanceIdentifier<Node> globalNodeId,
+ InstanceIdentifier<Node> physicalSwitchNodeId) {
List<ListenableFuture<Void>> futures = new ArrayList<ListenableFuture<Void>>();
- LOG.debug("removing hwvtep configuration for {}", interfaceOld.getName());
-
- // TODO delete hwvtep through ovsdb plugin
+ WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
+ LOG.info("removing hwvtep configuration for {}", interfaceOld.getName());
+ if(globalNodeId != null) {
+ IfTunnel ifTunnel = interfaceOld.getAugmentation(IfTunnel.class);
+ //removeTunnelTableEntry(transaction, ifTunnel, physicalSwitchNodeId);
+ removeTerminationEndPoint(transaction, ifTunnel, globalNodeId);
+ InterfaceManagerCommonUtils.deleteStateEntry(interfaceOld.getName(), transaction);
+ InterfaceMetaUtils.removeTunnelToInterfaceMap(physicalSwitchNodeId, transaction, ifTunnel);
+ }
+ futures.add(transaction.submit());
return futures;
}
+
+ private static void removeTerminationEndPoint(WriteTransaction transaction, IfTunnel ifTunnel,
+ InstanceIdentifier<Node> globalNodeId) {
+ LOG.info("removing remote termination end point {}", ifTunnel.getTunnelDestination());
+ TerminationPointKey tpKey = SouthboundUtils.getTerminationPointKey(ifTunnel.getTunnelDestination().
+ getIpv4Address().getValue());
+ InstanceIdentifier<TerminationPoint> tpPath = SouthboundUtils.createInstanceIdentifier
+ (globalNodeId, tpKey);
+ transaction.delete(LogicalDatastoreType.CONFIGURATION, tpPath);
+ }
+
+ private static void removeTunnelTableEntry(WriteTransaction transaction, IfTunnel ifTunnel,
+ InstanceIdentifier<Node> physicalSwitchNodeId) {
+ LOG.info("removing tunnel table entry for {}", ifTunnel.getTunnelDestination());
+ InstanceIdentifier<Tunnels> tunnelsInstanceIdentifier = SouthboundUtils.createTunnelsInstanceIdentifier(physicalSwitchNodeId,
+ ifTunnel.getTunnelSource(), ifTunnel.getTunnelDestination());
+ transaction.delete(LogicalDatastoreType.CONFIGURATION, tunnelsInstanceIdentifier);
+ }
}
\ No newline at end of file
/*
- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
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.vpnservice.interfacemgr.commons.InterfaceMetaUtils;
+import org.opendaylight.vpnservice.interfacemgr.renderer.hwvtep.utilities.SouthboundUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
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.interfacemgr.rev150331.ParentRefs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.EncapsulationTypeVxlanOverIpv4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorAugmentationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfTunnel;
+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.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
public class HwVTEPInterfaceConfigAddHelper {
private static final Logger LOG = LoggerFactory.getLogger(HwVTEPInterfaceConfigAddHelper.class);
- public static List<ListenableFuture<Void>> addConfiguration(DataBroker dataBroker, ParentRefs parentRefs,
- Interface interfaceNew) {
+ public static List<ListenableFuture<Void>> addConfiguration(DataBroker dataBroker, InstanceIdentifier<Node> physicalSwitchNodeId,
+ InstanceIdentifier<Node> globalNodeId,
+ Interface interfaceNew, IfTunnel ifTunnel) {
List<ListenableFuture<Void>> futures = new ArrayList<ListenableFuture<Void>>();
- LOG.debug("adding hwvtep configuration for {}", interfaceNew.getName());
+ LOG.info("adding hwvtep configuration for {}", interfaceNew.getName());
- // TODO create hwvtep through ovsdb plugin
+ // create hwvtep through ovsdb plugin
+ WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
+ InterfaceMetaUtils.createTunnelToInterfaceMap(interfaceNew.getName(), physicalSwitchNodeId, transaction, ifTunnel);
+ if(globalNodeId != null) {
+ addTerminationPoints(transaction, futures, globalNodeId,ifTunnel);
+ SouthboundUtils.addStateEntry(interfaceNew, interfaceNew.getAugmentation(IfTunnel.class), transaction);
+ }else{
+ LOG.debug("specified physical switch is not connected {}", physicalSwitchNodeId);
+ }
+ futures.add(transaction.submit());
return futures;
}
+
+ /*
+ * For each hwvtep configuration, we need to configure Physical LocatorTable of hwvtep schema with
+ * destination IP and tunnel-type. The configuration needs to be done for both local endpoint as well as remote endpoint
+ */
+ public static void addTerminationPoints(WriteTransaction transaction,
+ List<ListenableFuture<Void>> futures,
+ InstanceIdentifier<Node> globalNodeId,
+ IfTunnel ifTunnel) {
+ //InstanceIdentifier<TerminationPoint> localTEP =
+ // createLocalPhysicalLocatorEntryIfNotPresent(futures, dataBroker,transaction, ifTunnel, globalNodeId);
+ createRemotePhysicalLocatorEntry(transaction, futures, globalNodeId, ifTunnel.getTunnelDestination());
+ //InstanceIdentifier<Tunnels> tunnelsInstanceIdentifier = createTunnelTableEntry(transaction, physicalSwitchNodeId, localTEP, remoteTEP);
+ }
+
+ private static InstanceIdentifier<TerminationPoint> createRemotePhysicalLocatorEntry(WriteTransaction transaction, List<ListenableFuture<Void>> futures,
+ InstanceIdentifier<Node> nodeIid, IpAddress destIPAddress){
+ String remoteIp = destIPAddress.getIpv4Address().getValue();
+ LOG.debug("creating remote physical locator entry {}", remoteIp);
+ TerminationPointKey tpKey = SouthboundUtils.getTerminationPointKey(remoteIp);
+ InstanceIdentifier<TerminationPoint> tpPath =
+ SouthboundUtils.createInstanceIdentifier(nodeIid, tpKey);
+ createPhysicalLocatorEntry(transaction, futures, tpPath, tpKey, destIPAddress);
+ return tpPath;
+ }
+
+
+ private static InstanceIdentifier<TerminationPoint> createLocalPhysicalLocatorEntryIfNotPresent(List<ListenableFuture<Void>> futures,
+ DataBroker dataBroker,
+ WriteTransaction transaction,
+ IfTunnel ifTunnel,
+ InstanceIdentifier<Node> nodeIid){
+ String localIp = ifTunnel.getTunnelSource().getIpv4Address().getValue();
+ LOG.debug("creating local physical locator entry {}", localIp);
+ TerminationPointKey tpKey = SouthboundUtils.getTerminationPointKey(localIp);
+ InstanceIdentifier<TerminationPoint> tpPath =
+ SouthboundUtils.createInstanceIdentifier(nodeIid, tpKey);
+ // if local tep is not present, create it
+ TerminationPoint terminationPoint = SouthboundUtils.getTEPFromConfigDS(tpPath, dataBroker);
+ if(terminationPoint == null) {
+ createPhysicalLocatorEntry(transaction, futures, tpPath, tpKey, ifTunnel.getTunnelSource());
+ }
+ return tpPath;
+ }
+
+ /*
+ * This method writes the termination end point details to the topology Config DS
+ */
+ private static void createPhysicalLocatorEntry(WriteTransaction transaction, List<ListenableFuture<Void>> futures,
+ InstanceIdentifier<TerminationPoint> tpPath, TerminationPointKey terminationPointKey,
+ IpAddress destIPAddress){
+ TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
+ HwvtepPhysicalLocatorAugmentationBuilder tpAugmentationBuilder =
+ new HwvtepPhysicalLocatorAugmentationBuilder();
+ tpBuilder.setKey(terminationPointKey);
+ tpBuilder.setTpId(terminationPointKey.getTpId());
+ tpAugmentationBuilder.setEncapsulationType(EncapsulationTypeVxlanOverIpv4.class);
+ SouthboundUtils.setDstIp(tpAugmentationBuilder, destIPAddress);
+ tpBuilder.addAugmentation(HwvtepPhysicalLocatorAugmentation.class, tpAugmentationBuilder.build());
+ LOG.debug("creating physical locator entry for {}", terminationPointKey);
+ transaction.put(LogicalDatastoreType.CONFIGURATION,
+ tpPath, tpBuilder.build(), true);
+ }
}
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.interfacemgr.renderer.hwvtep.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;
+import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils;
+import org.opendaylight.vpnservice.interfacemgr.renderer.hwvtep.utilities.SouthboundUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+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.params.xml.ns.yang.overlay.rev150105.Tunnel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.EncapsulationTypeVxlanOverIpv4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorAugmentationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.TunnelsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.TunnelsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.tunnel.attributes.BfdParams;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.AlivenessMonitorService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfTunnel;
+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.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class HwVTEPInterfaceConfigUpdateHelper {
+ private static final Logger LOG = LoggerFactory.getLogger(HwVTEPInterfaceConfigUpdateHelper.class);
+
+ public static List<ListenableFuture<Void>> updateConfiguration(DataBroker dataBroker, InstanceIdentifier<Node> physicalSwitchNodeId,
+ InstanceIdentifier<Node> globalNodeId,
+ Interface interfaceNew, IfTunnel ifTunnel) {
+ List<ListenableFuture<Void>> futures = new ArrayList<ListenableFuture<Void>>();
+ LOG.info("adding hwvtep configuration for {}", interfaceNew.getName());
+
+ // create hwvtep through ovsdb plugin
+ WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
+ if(globalNodeId != null) {
+ updateBfdMonitoring(dataBroker, physicalSwitchNodeId, ifTunnel);
+
+ }else{
+ LOG.debug("specified physical switch is not connected {}", physicalSwitchNodeId);
+ }
+ futures.add(transaction.submit());
+ return futures;
+ }
+
+ /*
+ * bfd monitoring interval and enable/disbale attributes can be modified
+ */
+ public static List<ListenableFuture<Void>> updateBfdMonitoring(DataBroker dataBroker, InstanceIdentifier<Node> nodeId,
+ IfTunnel ifTunnel) {
+ List<ListenableFuture<Void>> futures = new ArrayList<ListenableFuture<Void>>();
+ WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
+ TunnelsBuilder tBuilder = new TunnelsBuilder();
+ InstanceIdentifier<TerminationPoint> localTEPInstanceIdentifier =
+ SouthboundUtils.createTEPInstanceIdentifier(nodeId, ifTunnel.getTunnelSource());
+ InstanceIdentifier<TerminationPoint> remoteTEPInstanceIdentifier =
+ SouthboundUtils.createTEPInstanceIdentifier(nodeId, ifTunnel.getTunnelDestination());
+ InstanceIdentifier<Tunnels> tunnelsInstanceIdentifier = SouthboundUtils.
+ createTunnelsInstanceIdentifier(nodeId, localTEPInstanceIdentifier, remoteTEPInstanceIdentifier);
+
+ LOG.debug("updating bfd monitoring parameters for the hwvtep {}", tunnelsInstanceIdentifier);
+ tBuilder.setKey(new TunnelsKey(new HwvtepPhysicalLocatorRef(localTEPInstanceIdentifier),
+ new HwvtepPhysicalLocatorRef(remoteTEPInstanceIdentifier)));
+ List <BfdParams> bfdParams = new ArrayList<>();
+ SouthboundUtils.fillBfdParameters(bfdParams, null);
+ tBuilder.setBfdParams(bfdParams);
+ transaction.merge(LogicalDatastoreType.CONFIGURATION, tunnelsInstanceIdentifier,tBuilder.build(), true);
+ futures.add(transaction.submit());
+ return futures;
+ }
+}
+++ /dev/null
-/*
- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.vpnservice.interfacemgr.renderer.hwvtep.statehelpers;
-
-import com.google.common.util.concurrent.ListenableFuture;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-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.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class HwVTEPInterfaceStateAddHelper {
- private static final Logger LOG = LoggerFactory.getLogger(HwVTEPInterfaceStateAddHelper.class);
-
- public static List<ListenableFuture<Void>> addConfiguration(DataBroker dataBroker, ParentRefs parentRefs,
- Interface interfaceNew, IdManagerService idManager) {
- List<ListenableFuture<Void>> futures = new ArrayList<ListenableFuture<Void>>();
- LOG.debug("HwVTEP Interface State Add Helper");
- return futures;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.vpnservice.interfacemgr.renderer.hwvtep.statehelpers;
-
-import com.google.common.util.concurrent.ListenableFuture;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-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.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class HwVTEPInterfaceStateRemoveHelper {
- private static final Logger LOG = LoggerFactory.getLogger(HwVTEPInterfaceStateRemoveHelper.class);
-
- public static List<ListenableFuture<Void>> addConfiguration(DataBroker dataBroker, ParentRefs parentRefs,
- Interface interfaceNew, IdManagerService idManager) {
- List<ListenableFuture<Void>> futures = new ArrayList<ListenableFuture<Void>>();
- LOG.debug("HWvTEP state remove helper");
- return futures;
- }
-}
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.interfacemgr.renderer.hwvtep.statehelpers;
+
+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.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils;
+import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceMetaUtils;
+import org.opendaylight.vpnservice.interfacemgr.renderer.hwvtep.utilities.SouthboundUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.TunnelsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.TunnelsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.tunnel.attributes.BfdParams;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.tunnel.attributes.BfdStatus;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class HwVTEPInterfaceStateUpdateHelper {
+ private static final Logger LOG = LoggerFactory.getLogger(HwVTEPInterfaceStateUpdateHelper.class);
+
+ public static List<ListenableFuture<Void>> updatePhysicalSwitch(DataBroker dataBroker, InstanceIdentifier<Tunnels> tunnelsInstanceIdentifier,
+ Tunnels tunnelsNew, Tunnels tunnelsOld) {
+ List<ListenableFuture<Void>> futures = new ArrayList<ListenableFuture<Void>>();
+ LOG.debug("updating physical switch for tunnels");
+ String interfaceName =
+ InterfaceMetaUtils.getInterfaceForTunnelInstanceIdentifier(tunnelsInstanceIdentifier.toString(), dataBroker);
+ if (interfaceName == null) {
+ return futures;
+ }
+
+ // update opstate of interface if TEP has gone down/up as a result of BFD monitoring
+ WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
+ InterfaceManagerCommonUtils.updateOpState(transaction, interfaceName, getTunnelOpState(tunnelsNew.getBfdStatus()));
+ futures.add(transaction.submit());
+ return futures;
+ }
+
+ private static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus
+ getTunnelOpState(List<BfdStatus> tunnelBfdStatus) {
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus
+ livenessState = org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Down;
+ if (tunnelBfdStatus != null && !tunnelBfdStatus.isEmpty()) {
+ for (BfdStatus bfdState : tunnelBfdStatus) {
+ if (bfdState.getBfdStatusKey().equalsIgnoreCase(SouthboundUtils.BFD_OP_STATE)) {
+ String bfdOpState = bfdState.getBfdStatusValue();
+ if (bfdOpState.equalsIgnoreCase(SouthboundUtils.BFD_STATE_UP)) {
+ livenessState = org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Up;
+ } else {
+ livenessState = org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Down;
+ }
+ break;
+ }
+ }
+ }
+ return livenessState;
+ }
+
+
+ public static List<ListenableFuture<Void>> startBfdMonitoring(DataBroker dataBroker,
+ InstanceIdentifier<Tunnels> tunnelsInstanceIdentifier,
+ Tunnels tunnelsNew) {
+ List<ListenableFuture<Void>> futures = new ArrayList<ListenableFuture<Void>>();
+ /*String interfaceName =
+ InterfaceMetaUtils.getInterfaceForTunnelInstanceIdentifier(tunnelsInstanceIdentifier.toString(), dataBroker);
+ if (interfaceName == null) {
+ LOG.debug("no interface configured for the tunnel {}", tunnelsInstanceIdentifier);
+ return futures;
+ }*/
+
+ LOG.debug("starting bfd monitoring for the hwvtep {}", tunnelsInstanceIdentifier);
+ WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
+ TunnelsBuilder tBuilder = new TunnelsBuilder();
+ tBuilder.setKey(new TunnelsKey(tunnelsNew.getLocalLocatorRef(), tunnelsNew.getRemoteLocatorRef()));
+ tBuilder.setLocalLocatorRef(tunnelsNew.getLocalLocatorRef());
+ tBuilder.setRemoteLocatorRef(tunnelsNew.getLocalLocatorRef());
+ List <BfdParams> bfdParams = new ArrayList<>();
+ SouthboundUtils.fillBfdParameters(bfdParams, null);
+ tBuilder.setBfdParams(bfdParams);
+ transaction.put(LogicalDatastoreType.CONFIGURATION, tunnelsInstanceIdentifier,tBuilder.build(), true);
+ futures.add(transaction.submit());
+ return futures;
+ }
+}
/*
- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
*/
package org.opendaylight.vpnservice.interfacemgr.renderer.hwvtep.utilities;
+import com.google.common.base.Optional;
+
+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.vpnservice.interfacemgr.IfmConstants;
+import org.opendaylight.vpnservice.interfacemgr.IfmUtil;
+import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceMetaUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
+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.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.hwvtep.rev150901.EncapsulationTypeVxlanOverIpv4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorAugmentationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.TunnelsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.TunnelsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.tunnel.attributes.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.monitor.profiles.MonitorProfile;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfTunnel;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
+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.NodeKey;
+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.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.ArrayList;
+import java.util.List;
+
public class SouthboundUtils {
private static final Logger LOG = LoggerFactory.getLogger(SouthboundUtils.class);
- public static final TopologyId HWVTEP_TOPOLOGY_ID = new TopologyId(new Uri("hwvtep:1"));
+ public static final String HWVTEP_TOPOLOGY = "hwvtep:1";
+ public static final TopologyId HWVTEP_TOPOLOGY_ID = new TopologyId(new Uri(HWVTEP_TOPOLOGY));
+ public static final String TEP_PREFIX = "vxlan_over_ipv4:";
+ public static final String BFD_OP_STATE = "state";
+ public static final String BFD_STATE_UP = "up";
+ // BFD parameters
+ static final String BFD_PARAM_ENABLE = "enable";
+ static final String BFD_PARAM_MIN_RX = "min_rx";
+ static final String BFD_PARAM_MIN_TX = "min_tx";
+ static final String BFD_PARAM_DECAY_MIN_RX = "decay_min_rx";
+ static final String BFD_PARAM_FORWARDING_IF_RX = "forwarding_if_rx";
+ static final String BFD_PARAM_CPATH_DOWN = "cpath_down";
+ static final String BFD_PARAM_CHECK_TNL_KEY = "check_tnl_key";
+
+ // BFD Local/Remote Configuration parameters
+ static final String BFD_CONFIG_BFD_DST_MAC = "bfd_dst_mac";
+ static final String BFD_CONFIG_BFD_DST_IP = "bfd_dst_ip";
+
+ // bfd params
+ private static final String BFD_MIN_RX_VAL = "1000";
+ private static final String BFD_MIN_TX_VAL = "100";
+ private static final String BFD_DECAY_MIN_RX_VAL = "200";
+ private static final String BFD_FORWARDING_IF_RX_VAL = "true";
+ private static final String BFD_CPATH_DOWN_VAL = "false";
+ private static final String BFD_CHECK_TNL_KEY_VAL = "false";
+
+ public static InstanceIdentifier<Node> createPhysicalSwitchInstanceIdentifier(String psNodeIdString) {
+ NodeId physicalSwitchNodeId = new NodeId(psNodeIdString);
+ InstanceIdentifier<Node> psNodeId = InstanceIdentifier
+ .create(NetworkTopology.class)
+ .child(Topology.class, new TopologyKey(HWVTEP_TOPOLOGY_ID))
+ .child(Node.class,new NodeKey(physicalSwitchNodeId));
+ return psNodeId;
+ }
+
+ public static InstanceIdentifier<Node> createGlobalNodeInstanceIdentifier(DataBroker dataBroker, String physicalSwitchNodeId) {
+ InstanceIdentifier<Node> psNodeId = InstanceIdentifier
+ .create(NetworkTopology.class)
+ .child(Topology.class, new TopologyKey(HWVTEP_TOPOLOGY_ID))
+ .child(Node.class,new NodeKey(new NodeId(physicalSwitchNodeId)));
+ Optional<Node> physicalSwitchOptional =
+ IfmUtil.read(LogicalDatastoreType.OPERATIONAL, psNodeId, dataBroker);
+ if (!physicalSwitchOptional.isPresent()) {
+ LOG.debug("physical switch is not present for {}", physicalSwitchNodeId);
+ return null;
+ }
+ Node physicalSwitch = physicalSwitchOptional.get();
+ PhysicalSwitchAugmentation physicalSwitchAugmentation = physicalSwitch.getAugmentation(PhysicalSwitchAugmentation.class);
+ return (InstanceIdentifier<Node>) physicalSwitchAugmentation.getManagedBy().getValue();
+ }
+
+ public static InstanceIdentifier<TerminationPoint> createTerminationPointInstanceIdentifier(NodeKey nodekey,
+ String portName){
+ InstanceIdentifier<TerminationPoint> terminationPointPath = InstanceIdentifier
+ .create(NetworkTopology.class)
+ .child(Topology.class, new TopologyKey(HWVTEP_TOPOLOGY_ID))
+ .child(Node.class,nodekey)
+ .child(TerminationPoint.class, new TerminationPointKey(new TpId(portName)));
+
+ LOG.debug("Termination point InstanceIdentifier generated : {}",terminationPointPath);
+ return terminationPointPath;
+ }
+
+ public static InstanceIdentifier<TerminationPoint> createTEPInstanceIdentifier
+ (InstanceIdentifier<Node> nodeIid, IpAddress ipAddress) {
+ TerminationPointKey localTEP = SouthboundUtils.getTerminationPointKey(ipAddress.getIpv4Address().getValue());
+ return createInstanceIdentifier(nodeIid, localTEP);
+ }
+
+ public static InstanceIdentifier<TerminationPoint> createInstanceIdentifier(InstanceIdentifier<Node> nodeIid,
+ TerminationPointKey tpKey) {
+ return nodeIid.child(TerminationPoint.class, tpKey);
+ }
+
+ public static InstanceIdentifier<Tunnels> createTunnelsInstanceIdentifier(InstanceIdentifier<Node> nodeId, IpAddress localIP, IpAddress remoteIp) {
+ InstanceIdentifier<TerminationPoint> localTEPInstanceIdentifier =
+ createTEPInstanceIdentifier(nodeId, localIP);
+ InstanceIdentifier<TerminationPoint> remoteTEPInstanceIdentifier =
+ createTEPInstanceIdentifier(nodeId, remoteIp);
+
+ TunnelsKey tunnelsKey = new TunnelsKey(new HwvtepPhysicalLocatorRef(localTEPInstanceIdentifier),
+ new HwvtepPhysicalLocatorRef(remoteTEPInstanceIdentifier));
+ return InstanceIdentifier.builder(NetworkTopology.class).child(Topology.class, new TopologyKey(HWVTEP_TOPOLOGY_ID))
+ .child(Node.class, new NodeKey(nodeId.firstKeyOf(Node.class))).augmentation(PhysicalSwitchAugmentation.class)
+ .child(Tunnels.class, tunnelsKey).build();
+ }
+
+ public static InstanceIdentifier<Tunnels> createTunnelsInstanceIdentifier(InstanceIdentifier<Node> nodeId,
+ InstanceIdentifier<TerminationPoint> localTEPInstanceIdentifier,
+ InstanceIdentifier<TerminationPoint> remoteTEPInstanceIdentifier) {
+ TunnelsKey tunnelsKey = new TunnelsKey(new HwvtepPhysicalLocatorRef(localTEPInstanceIdentifier),
+ new HwvtepPhysicalLocatorRef(remoteTEPInstanceIdentifier));
+ return InstanceIdentifier.builder(NetworkTopology.class).child(Topology.class, new TopologyKey(HWVTEP_TOPOLOGY_ID))
+ .child(Node.class, new NodeKey(nodeId.firstKeyOf(Node.class))).augmentation(PhysicalSwitchAugmentation.class)
+ .child(Tunnels.class, tunnelsKey).build();
+ }
+
+ public static String getTerminationPointKeyString(String ipAddress) {
+ String tpKeyStr = null;
+ if(ipAddress != null) {
+ tpKeyStr = new StringBuilder(TEP_PREFIX).
+ append(ipAddress).toString();
+ }
+ return tpKeyStr;
+ }
+
+ public static TerminationPointKey getTerminationPointKey(String ipAddress) {
+ TerminationPointKey tpKey = null;
+ String tpKeyStr = getTerminationPointKeyString(ipAddress);
+ if(tpKeyStr != null) {
+ tpKey = new TerminationPointKey(new TpId(tpKeyStr));
+ }
+ return tpKey;
+ }
+
+ public static TerminationPoint getTEPFromConfigDS(InstanceIdentifier<TerminationPoint> tpPath,
+ DataBroker dataBroker) {
+ Optional<TerminationPoint> terminationPointOptional =
+ IfmUtil.read(LogicalDatastoreType.CONFIGURATION, tpPath, dataBroker);
+ if (!terminationPointOptional.isPresent()) {
+ return null;
+ }
+ return terminationPointOptional.get();
+ }
+
+ public static void setDstIp(HwvtepPhysicalLocatorAugmentationBuilder tpAugmentationBuilder, IpAddress ipAddress) {
+ IpAddress ip = new IpAddress(ipAddress);
+ tpAugmentationBuilder.setDstIp(ip);
+ }
+
+ public static void addStateEntry(Interface interfaceInfo, IfTunnel ifTunnel, WriteTransaction transaction) {
+ LOG.debug("adding tep interface state for {}", interfaceInfo.getName());
+ 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.OperStatus.Up;
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.AdminStatus adminStatus =
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.AdminStatus.Up;
+ 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(interfaceInfo.getName());
+ List<String> childLowerLayerIfList = new ArrayList<>();
+ childLowerLayerIfList.add(0, SouthboundUtils.getTerminationPointKeyString(ifTunnel.getTunnelDestination().getIpv4Address().getValue()));
+ InterfaceBuilder ifaceBuilder = new InterfaceBuilder().setAdminStatus(adminStatus)
+ .setOperStatus(operStatus).setLowerLayerIf(childLowerLayerIfList);
+
+
+ if(interfaceInfo != null){
+ ifaceBuilder.setType(interfaceInfo.getType());
+ }
+ ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceInfo.getName()));
+ transaction.put(LogicalDatastoreType.OPERATIONAL, ifStateId,ifaceBuilder.build() , true);
+ }
+
+ public static void fillBfdParameters(List<BfdParams> bfdParams, IfTunnel ifTunnel) {
+ setBfdParamForEnable(bfdParams, ifTunnel != null ? ifTunnel.isMonitorEnabled() :true);
+ bfdParams.add(getBfdParams(BFD_PARAM_MIN_TX, ifTunnel != null ?
+ ifTunnel.getMonitorInterval().toString() : BFD_MIN_TX_VAL));
+ bfdParams.add(getBfdParams(BFD_PARAM_MIN_RX, BFD_MIN_RX_VAL));
+ bfdParams.add(getBfdParams(BFD_PARAM_DECAY_MIN_RX, BFD_DECAY_MIN_RX_VAL));
+ bfdParams.add(getBfdParams(BFD_PARAM_FORWARDING_IF_RX, BFD_FORWARDING_IF_RX_VAL));
+ bfdParams.add(getBfdParams(BFD_PARAM_CPATH_DOWN, BFD_CPATH_DOWN_VAL));
+ bfdParams.add(getBfdParams(BFD_PARAM_CHECK_TNL_KEY, BFD_CHECK_TNL_KEY_VAL));
+ }
+
+ public static void setBfdParamForEnable(List<BfdParams> bfdParams, boolean isEnabled) {
+ bfdParams.add(getBfdParams(BFD_PARAM_ENABLE, Boolean.toString(isEnabled)));
+ }
+
+ public static BfdParams getBfdParams(String key, String value) {
+ return new BfdParamsBuilder().setBfdParamKey(key).setKey(new BfdParamsKey(key))
+ .setBfdParamValue(value).build();
+ }
}
\ No newline at end of file
/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
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()) {
+ if (ifL2vlan == null || (IfL2vlan.L2vlanMode.Trunk != ifL2vlan.getL2vlanMode() && IfL2vlan.L2vlanMode.Transparent != ifL2vlan.getL2vlanMode())) {
return;
}
WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
private static void removeVlanConfiguration(DataBroker dataBroker, ParentRefs parentRefs, Interface interfaceOld, WriteTransaction transaction) {
LOG.debug("removing vlan configuration for {}",interfaceOld.getName());
IfL2vlan ifL2vlan = interfaceOld.getAugmentation(IfL2vlan.class);
- if (ifL2vlan == null || ifL2vlan.getL2vlanMode() != IfL2vlan.L2vlanMode.Trunk) {
+ if (ifL2vlan == null || (IfL2vlan.L2vlanMode.Trunk != ifL2vlan.getL2vlanMode() && IfL2vlan.L2vlanMode.Transparent != ifL2vlan.getL2vlanMode())) {
return;
}
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState =
/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
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.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.mdsalutil.interfaces.IMdsalApiManager;
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.InterfaceBuilder;
-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.alivenessmonitor.rev150629.AlivenessMonitorListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.AlivenessMonitorService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.LivenessState;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.MonitorEvent;
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.ref.info.BridgeRefEntry;
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.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.TunnelTypeVxlan;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Interface interfaceNew, Interface interfaceOld) {
List<ListenableFuture<Void>> futures = new ArrayList<>();
+ // If any of the port attributes are modified, treat it as a delete and recreate scenario
if(portAttributesModified(interfaceOld, interfaceNew)) {
futures.addAll(OvsInterfaceConfigRemoveHelper.removeConfiguration(dataBroker, alivenessMonitorService, interfaceOld, idManager,
mdsalApiManager, interfaceOld.getAugmentation(ParentRefs.class)));
return futures;
}
+ // If there is no operational state entry for the interface, treat it as create
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 futures;
}
- WriteTransaction t = dataBroker.newWriteOnlyTransaction();
- if (interfaceNew.isEnabled() != interfaceOld.isEnabled()) {
- OperStatus operStatus = InterfaceManagerCommonUtils.updateStateEntry(interfaceNew, dataBroker, t, ifState);
-
- 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;
- }
- }
-
- IfL2vlan ifL2vlan = interfaceNew.getAugmentation(IfL2vlan.class);
- if (ifL2vlan == null || ifL2vlan.getL2vlanMode() != IfL2vlan.L2vlanMode.Trunk) {
- futures.add(t.submit());
- return futures;
- }
-
- InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(interfaceNew.getName());
- InterfaceParentEntry interfaceParentEntry =
- InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryKey, dataBroker);
- if (interfaceParentEntry == null || interfaceParentEntry.getInterfaceChildEntry() == null) {
- futures.add(t.submit());
- return futures;
- }
+ WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
+ if(TunnelMonitoringAttributesModified(interfaceOld, interfaceNew)){
+ handleTunnelMonitorUpdates(futures, transaction, alivenessMonitorService, interfaceNew,
+ interfaceOld, dataBroker);
+ return futures;
+ }
- for (InterfaceChildEntry interfaceChildEntry : interfaceParentEntry.getInterfaceChildEntry()) {
- InterfaceManagerCommonUtils.updateOperStatus(interfaceChildEntry.getChildInterface(), operStatus, t);
- }
+ if (interfaceNew.isEnabled() != interfaceOld.isEnabled()) {
+ handleInterfaceAdminStateUpdates(futures, transaction, interfaceNew, dataBroker, ifState);
}
- futures.add(t.submit());
+ futures.add(transaction.submit());
return futures;
}
IfTunnel ifTunnelOld = interfaceOld.getAugmentation(IfTunnel.class);
IfTunnel ifTunnelNew = interfaceNew.getAugmentation(IfTunnel.class);
if (checkAugmentations(ifTunnelOld, ifTunnelNew)) {
- return true;
+ if(!ifTunnelNew.getTunnelDestination().equals(ifTunnelOld.getTunnelDestination()) ||
+ !ifTunnelNew.getTunnelSource().equals(ifTunnelOld.getTunnelSource()) ||
+ !ifTunnelNew.getTunnelGateway().equals(ifTunnelOld.getTunnelGateway())) {
+ return true;
+ }
}
return false;
}
+ private static boolean TunnelMonitoringAttributesModified(Interface interfaceOld, Interface interfaceNew) {
+ IfTunnel ifTunnelOld = interfaceOld.getAugmentation(IfTunnel.class);
+ IfTunnel ifTunnelNew = interfaceNew.getAugmentation(IfTunnel.class);
+ if (checkAugmentations(ifTunnelOld, ifTunnelNew)) {
+ return true;
+ }
+ return false;
+ }
+
+ /*
+ * if the tunnel monitoring attributes have changed, handle it based on the tunnel type.
+ * As of now internal vxlan tunnels use LLDP monitoring and external tunnels use BFD monitoring.
+ */
+ private static void handleTunnelMonitorUpdates(List<ListenableFuture<Void>> futures, WriteTransaction transaction,
+ AlivenessMonitorService alivenessMonitorService,
+ Interface interfaceNew, Interface interfaceOld, DataBroker dataBroker){
+ LOG.debug("tunnel monitoring attributes modified for interface {}", interfaceNew.getName());
+ // update termination point on switch, if switch is connected
+ BridgeRefEntry bridgeRefEntry =
+ InterfaceMetaUtils.getBridgeReferenceForInterface(interfaceNew, dataBroker);
+ if(InterfaceMetaUtils.bridgeExists(bridgeRefEntry, dataBroker)) {
+ SouthboundUtils.updateBfdParamtersForTerminationPoint(bridgeRefEntry.getBridgeReference().getValue(),
+ interfaceNew.getAugmentation(IfTunnel.class),
+ interfaceNew.getName(), transaction);
+ }
+
+ // stop tunnel monitoring if admin state is disabled for an internal vxlan trunk interface
+ if(interfaceOld.isEnabled() && !interfaceNew.isEnabled()) {
+ AlivenessMonitorUtils.stopLLDPMonitoring(alivenessMonitorService, dataBroker, interfaceNew);
+ }else{
+ AlivenessMonitorUtils.handleTunnelMonitorUpdates(alivenessMonitorService, dataBroker, interfaceOld, interfaceNew);
+ }
+ futures.add(transaction.submit());
+ }
+
+ private static void handleInterfaceAdminStateUpdates(List<ListenableFuture<Void>> futures, WriteTransaction transaction,
+ Interface interfaceNew, DataBroker dataBroker,
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState){
+ OperStatus operStatus = InterfaceManagerCommonUtils.updateStateEntry(interfaceNew, dataBroker, transaction, ifState);
+
+ IfL2vlan ifL2vlan = interfaceNew.getAugmentation(IfL2vlan.class);
+ if (ifL2vlan == null || (IfL2vlan.L2vlanMode.Trunk != ifL2vlan.getL2vlanMode() && IfL2vlan.L2vlanMode.Transparent != ifL2vlan.getL2vlanMode())) {
+ futures.add(transaction.submit());
+ return;
+ }
+
+ InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(interfaceNew.getName());
+ InterfaceParentEntry interfaceParentEntry =
+ InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryKey, dataBroker);
+ if (interfaceParentEntry == null || interfaceParentEntry.getInterfaceChildEntry() == null) {
+ futures.add(transaction.submit());
+ return;
+ }
+
+ for (InterfaceChildEntry interfaceChildEntry : interfaceParentEntry.getInterfaceChildEntry()) {
+ InterfaceManagerCommonUtils.updateOperStatus(interfaceChildEntry.getChildInterface(), operStatus, transaction);
+ }
+ }
+
private static<T> boolean checkAugmentations(T oldAug, T newAug) {
if ((oldAug != null && newAug == null) ||
(oldAug == null && newAug != null)) {
/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
if (bridgeNew.getDatapathId() == null) {
- LOG.warn("DataPathId found as null for Bridge Augmentation: {}... retrying...", bridgeNew);
- Optional<OvsdbBridgeAugmentation> bridgeNodeOptional = IfmUtil.read(LogicalDatastoreType.OPERATIONAL, bridgeIid, dataBroker);
- if (bridgeNodeOptional.isPresent()) {
- bridgeNew = bridgeNodeOptional.get();
- }
- if (bridgeNew.getDatapathId() == null) {
- LOG.warn("DataPathId found as null again for Bridge Augmentation: {}. Bailing out.", bridgeNew);
- return futures;
- }
- }
- String bridgeName = bridgeNew.getBridgeName().getValue();
- BigInteger dpnId = IfmUtil.getDpnId(bridgeNew.getDatapathId());
-
- if (dpnId == null) {
- LOG.warn("Got Null DPID for Bridge: {}", bridgeNew);
+ LOG.warn("DataPathId found as null for Bridge Augmentation: {}... returning...", bridgeNew);
return futures;
}
+ BigInteger dpnId = IfmUtil.getDpnId(bridgeNew.getDatapathId());
// create bridge reference entry in interface meta operational DS
InterfaceMetaUtils.createBridgeRefEntry(dpnId, bridgeIid, writeTransaction);
// FIX for OVSDB Bug - manually copying the bridge info from topology operational DS to config DS
SouthboundUtils.addBridge(bridgeIid, bridgeNew, dataBroker, futures);
- BridgeEntryKey bridgeEntryKey = new BridgeEntryKey(dpnId);
- InstanceIdentifier<BridgeEntry> bridgeEntryInstanceIdentifier =
- InterfaceMetaUtils.getBridgeEntryIdentifier(bridgeEntryKey);
- BridgeEntry bridgeEntry =
- InterfaceMetaUtils.getBridgeEntryFromConfigDS(bridgeEntryInstanceIdentifier,
- dataBroker);
+ // handle pre-provisioning of tunnels for the newly connected dpn
+ BridgeEntry bridgeEntry = InterfaceMetaUtils.getBridgeEntryFromConfigDS(dpnId, dataBroker);
if (bridgeEntry == null) {
futures.add(writeTransaction.submit());
return futures;
}
-
- List<BridgeInterfaceEntry> bridgeInterfaceEntries = bridgeEntry.getBridgeInterfaceEntry();
- for (BridgeInterfaceEntry bridgeInterfaceEntry : bridgeInterfaceEntries) {
- String portName = bridgeInterfaceEntry.getInterfaceName();
- InterfaceKey interfaceKey = new InterfaceKey(portName);
- Interface iface = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
- if (iface.getAugmentation(IfTunnel.class) != null) {
- SouthboundUtils.addPortToBridge(bridgeIid, iface, bridgeNew, bridgeName, portName, dataBroker, futures);
- }
- }
+ SouthboundUtils.addAllPortsToBridge(bridgeEntry, dataBroker, bridgeIid, bridgeNew, writeTransaction);
futures.add(writeTransaction.submit());
return futures;
/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
*/
package org.opendaylight.vpnservice.interfacemgr.renderer.ovs.statehelpers;
+import com.google.common.base.Optional;
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;
public static List<ListenableFuture<Void>> removePortFromBridge(InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid,
OvsdbBridgeAugmentation bridgeOld, DataBroker dataBroker) {
List<ListenableFuture<Void>> futures = new ArrayList<>();
- WriteTransaction t = dataBroker.newWriteOnlyTransaction();;
+ WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();;
BigInteger dpnId = IfmUtil.getDpnId(bridgeOld.getDatapathId());
if (dpnId == null) {
LOG.warn("Got Null DPID for Bridge: {}", bridgeOld);
return futures;
}
- BridgeRefEntryKey bridgeRefEntryKey = new BridgeRefEntryKey(dpnId);
- InstanceIdentifier<BridgeRefEntry> bridgeEntryId =
- InterfaceMetaUtils.getBridgeRefEntryIdentifier(bridgeRefEntryKey);
- t.delete(LogicalDatastoreType.OPERATIONAL, bridgeEntryId);
- // FIX for ovsdb bug for delete TEP
- SouthboundUtils.deleteBridge(bridgeIid, dataBroker, futures);
+ //delete bridge reference entry in interface meta operational DS
+ InterfaceMetaUtils.deleteBridgeRefEntry(dpnId, transaction);
- futures.add(t.submit());
+ // Workaround for ovsdb bug for delete TEP..
+ Optional<OvsdbBridgeAugmentation> bridgeNodeOptional =
+ IfmUtil.read(LogicalDatastoreType.OPERATIONAL, bridgeIid, dataBroker);
+ if (!bridgeNodeOptional.isPresent()) {
+ SouthboundUtils.deleteBridge(bridgeIid, dataBroker, futures);
+ }
+
+ futures.add(transaction.submit());
return futures;
}
}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.interfacemgr.renderer.ovs.statehelpers;
+
+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.vpnservice.interfacemgr.IfmUtil;
+import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils;
+import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceMetaUtils;
+import org.opendaylight.vpnservice.interfacemgr.renderer.ovs.utilities.SouthboundUtils;
+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.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfdStatus;
+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;
+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;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+
+public class OvsInterfaceTopologyStateUpdateHelper {
+ private static final Logger LOG = LoggerFactory.getLogger(OvsInterfaceTopologyStateUpdateHelper.class);
+ /*
+ * This code is used to handle only a dpnId change scenario for a particular change,
+ * which is not expected to happen in usual cases.
+ */
+ public static List<ListenableFuture<Void>> updateBridgeRefEntry(InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid,
+ OvsdbBridgeAugmentation bridgeNew,
+ OvsdbBridgeAugmentation bridgeOld,
+ DataBroker dataBroker) {
+ List<ListenableFuture<Void>> futures = new ArrayList<>();
+ WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
+
+ BigInteger dpnIdNew = IfmUtil.getDpnId(bridgeNew.getDatapathId());
+ BigInteger dpnIdOld = IfmUtil.getDpnId(bridgeOld.getDatapathId());
+
+ //delete bridge reference entry for the old dpn in interface meta operational DS
+ InterfaceMetaUtils.deleteBridgeRefEntry(dpnIdOld, writeTransaction);
+
+ // create bridge reference entry in interface meta operational DS
+ InterfaceMetaUtils.createBridgeRefEntry(dpnIdNew, bridgeIid, writeTransaction);
+
+ // handle pre-provisioning of tunnels for the newly connected dpn
+ BridgeEntry bridgeEntry = InterfaceMetaUtils.getBridgeEntryFromConfigDS(dpnIdNew, dataBroker);
+ if (bridgeEntry == null) {
+ futures.add(writeTransaction.submit());
+ return futures;
+ }
+ SouthboundUtils.addAllPortsToBridge(bridgeEntry, dataBroker, bridgeIid, bridgeNew, writeTransaction);
+
+ futures.add(writeTransaction.submit());
+ return futures;
+ }
+
+ public static List<ListenableFuture<Void>> updateTunnelState(DataBroker dataBroker,
+ OvsdbTerminationPointAugmentation terminationPointNew,
+ OvsdbTerminationPointAugmentation terminationPointOld) {
+ List<ListenableFuture<Void>> futures = new ArrayList<ListenableFuture<Void>>();
+
+ // update opstate of interface if TEP has gone down/up as a result of BFD monitoring
+ LOG.debug("updating tunnel state for interface {}", terminationPointNew.getName());
+ WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
+ InterfaceManagerCommonUtils.updateOpState(transaction, terminationPointNew.getName(), getTunnelOpState(terminationPointNew.getInterfaceBfdStatus()));
+ futures.add(transaction.submit());
+ return futures;
+ }
+
+ private static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus
+ getTunnelOpState(List<InterfaceBfdStatus> tunnelBfdStatus) {
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus
+ livenessState = org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Down;
+ if (tunnelBfdStatus != null && !tunnelBfdStatus.isEmpty()) {
+ for (InterfaceBfdStatus bfdState : tunnelBfdStatus) {
+ if (bfdState.getBfdStatusKey().equalsIgnoreCase(SouthboundUtils.BFD_OP_STATE)) {
+ String bfdOpState = bfdState.getBfdStatusValue();
+ if (bfdOpState.equalsIgnoreCase(SouthboundUtils.BFD_STATE_UP)) {
+ livenessState = org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Up;
+ } else {
+ livenessState = org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Down;
+ }
+ break;
+ }
+ }
+ }
+ return livenessState;
+ }
+}
\ No newline at end of file
/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
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.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils;
+import org.opendaylight.vpnservice.mdsalutil.NwConstants;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
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.opendaylight.l2.types.rev130827.VlanId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.*;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.*;
+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.bridge.entry.BridgeInterfaceEntry;
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.NetworkTopology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.vpnservice.interfacemgr.renderer.hwvtep.utilities.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SouthboundUtils {
private static final Logger LOG = LoggerFactory.getLogger(SouthboundUtils.class);
+
+ public static final String BFD_PARAM_ENABLE = "enable";
+ public static final String BFD_PARAM_INTERVAL = "min_tx";
+ // bfd params
+ public static final String BFD_OP_STATE = "state";
+ public static final String BFD_STATE_UP = "up";
+
public static final TopologyId OVSDB_TOPOLOGY_ID = new TopologyId(new Uri("ovsdb:1"));
public static void addPortToBridge(InstanceIdentifier<?> bridgeIid, Interface iface,
futures.add(tx.submit());
}
+ /*
+ * add all tunnels ports corresponding to the bridge to the topology config DS
+ */
+ public static void addAllPortsToBridge(BridgeEntry bridgeEntry, DataBroker dataBroker,
+ InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid,
+ OvsdbBridgeAugmentation bridgeNew,
+ WriteTransaction writeTransaction){
+ String bridgeName = bridgeNew.getBridgeName().getValue();
+ LOG.debug("adding all ports to bridge: {}", bridgeName);
+ List<BridgeInterfaceEntry> bridgeInterfaceEntries = bridgeEntry.getBridgeInterfaceEntry();
+ for (BridgeInterfaceEntry bridgeInterfaceEntry : bridgeInterfaceEntries) {
+ String portName = bridgeInterfaceEntry.getInterfaceName();
+ InterfaceKey interfaceKey = new InterfaceKey(portName);
+ Interface iface = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
+ IfTunnel ifTunnel = iface.getAugmentation(IfTunnel.class);
+ if (ifTunnel != null) {
+ addTunnelPortToBridge(ifTunnel, bridgeIid, iface, bridgeNew, bridgeName, portName, dataBroker, writeTransaction);
+ }
+ }
+ }
+
public static void addBridge(InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid,
OvsdbBridgeAugmentation bridgeAugmentation,
DataBroker dataBroker, List<ListenableFuture<Void>> futures){
futures.add(tx.submit());
}
- private static void addVlanPortToBridge(InstanceIdentifier<?> bridgeIid, IfL2vlan ifL2vlan,
+ private static void addVlanPortToBridge(InstanceIdentifier<?> bridgeIid, IfL2vlan ifL2vlan, IfTunnel ifTunnel,
OvsdbBridgeAugmentation bridgeAugmentation, String bridgeName,
String portName, DataBroker dataBroker, WriteTransaction t) {
if(ifL2vlan.getVlanId() != null) {
- addTerminationPoint(bridgeIid, bridgeAugmentation, bridgeName, portName, ifL2vlan.getVlanId().getValue(), null, null, dataBroker, t);
+ addTerminationPoint(bridgeIid, bridgeAugmentation, bridgeName, portName, ifL2vlan.getVlanId().getValue(), null, null,
+ ifTunnel, t);
}
}
IpAddress remoteIp = ifTunnel.getTunnelDestination();
options.put("remote_ip", remoteIp.getIpv4Address().getValue());
- addTerminationPoint(bridgeIid, bridgeAugmentation, bridgeName, portName, vlanId, type, options, dataBroker, t);
+ addTerminationPoint(bridgeIid, bridgeAugmentation, bridgeName, portName, vlanId, type, options, ifTunnel, t);
}
- private static void addTerminationPoint(InstanceIdentifier<?> bridgeIid, OvsdbBridgeAugmentation bridgeNode,
- String bridgeName, String portName, int vlanId, Class type,
- Map<String, String> options, DataBroker dataBroker, WriteTransaction t) {
+ // Update is allowed only for tunnel monitoring attributes
+ public static void updateBfdParamtersForTerminationPoint(InstanceIdentifier<?> bridgeIid, IfTunnel ifTunnel, String portName,
+ WriteTransaction transaction){
+ if( !ifTunnel.isInternal() && ifTunnel.getTunnelInterfaceType().equals(TunnelTypeVxlan.class) ) {
+ InstanceIdentifier<TerminationPoint> tpIid = createTerminationPointInstanceIdentifier(
+ InstanceIdentifier.keyOf(bridgeIid.firstIdentifierOf(Node.class)), portName);
+ LOG.debug("update bfd parameters for interface {}", tpIid);
+ OvsdbTerminationPointAugmentationBuilder tpAugmentationBuilder = new OvsdbTerminationPointAugmentationBuilder();
+ List<InterfaceBfd> bfdParams = getBfdParams(ifTunnel);
+ tpAugmentationBuilder.setInterfaceBfd(bfdParams);
+
+ TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
+ tpBuilder.setKey(InstanceIdentifier.keyOf(tpIid));
+ tpBuilder.addAugmentation(OvsdbTerminationPointAugmentation.class, tpAugmentationBuilder.build());
+
+ transaction.merge(LogicalDatastoreType.CONFIGURATION, tpIid, tpBuilder.build(), true);
+ }
+ }
+
+ private static void addTerminationPoint(InstanceIdentifier<?> bridgeIid, OvsdbBridgeAugmentation bridgeNode, String bridgeName, String portName, int vlanId, Class type,
+ Map<String, String> options, IfTunnel ifTunnel, WriteTransaction t) {
InstanceIdentifier<TerminationPoint> tpIid = createTerminationPointInstanceIdentifier(
InstanceIdentifier.keyOf(bridgeIid.firstIdentifierOf(Node.class)), portName);
OvsdbTerminationPointAugmentationBuilder tpAugmentationBuilder = new OvsdbTerminationPointAugmentationBuilder();
tpAugmentationBuilder.setVlanTag(new VlanId(vlanId));
}
+
+ if( !ifTunnel.isInternal() && ifTunnel.getTunnelInterfaceType().equals(TunnelTypeVxlan.class) ) {
+ List<InterfaceBfd> bfdParams = getBfdParams(ifTunnel);
+ tpAugmentationBuilder.setInterfaceBfd(bfdParams);
+ }
+
TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
tpBuilder.setKey(InstanceIdentifier.keyOf(tpIid));
tpBuilder.addAugmentation(OvsdbTerminationPointAugmentation.class, tpAugmentationBuilder.build());
t.put(LogicalDatastoreType.CONFIGURATION, tpIid, tpBuilder.build(), true);
+
+ }
+
+ private static List<InterfaceBfd> getBfdParams(IfTunnel ifTunnel) {
+ List<InterfaceBfd> bfdParams = new ArrayList<>();
+ bfdParams.add(getIfBfdObj(BFD_PARAM_ENABLE,
+ Boolean.toString(ifTunnel.isMonitorEnabled())));
+ bfdParams.add(getIfBfdObj(BFD_PARAM_INTERVAL,
+ ifTunnel.getMonitorInterval().toString()));
+ return bfdParams;
+ }
+
+ private static InterfaceBfd getIfBfdObj(String key, String value) {
+ InterfaceBfdBuilder bfdBuilder = new InterfaceBfdBuilder();
+ bfdBuilder.setBfdKey(key).
+ setKey(new InterfaceBfdKey(key)).setBfdValue(value);
+ return bfdBuilder.build();
}
private static InstanceIdentifier<TerminationPoint> createTerminationPointInstanceIdentifier(Node node,
.child(Topology.class, new TopologyKey(OVSDB_TOPOLOGY_ID))
.child(Node.class,new NodeKey(nodeId));
}
-}
\ No newline at end of file
+}
/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import org.opendaylight.vpnservice.interfacemgr.IfmUtil;
import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils;
import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceMetaUtils;
-import org.opendaylight.vpnservice.mdsalutil.*;
+import org.opendaylight.vpnservice.mdsalutil.ActionInfo;
+import org.opendaylight.vpnservice.mdsalutil.ActionType;
+import org.opendaylight.vpnservice.mdsalutil.InstructionInfo;
+import org.opendaylight.vpnservice.mdsalutil.InstructionType;
+import org.opendaylight.vpnservice.mdsalutil.MDSALUtil;
+import org.opendaylight.vpnservice.mdsalutil.MatchFieldType;
+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.iana._if.type.rev140508.L2vlan;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel;
private static final Logger LOG = LoggerFactory.getLogger(InterfaceManagerRpcService.class);
DataBroker dataBroker;
IMdsalApiManager mdsalMgr;
+
+
public InterfaceManagerRpcService(DataBroker dataBroker, IMdsalApiManager mdsalMgr) {
this.dataBroker = dataBroker;
this.mdsalMgr = mdsalMgr;
RpcResultBuilder<GetEgressInstructionsForInterfaceOutput> rpcResultBuilder;
try {
List<InstructionInfo> instructionInfo = new ArrayList<InstructionInfo>();
- List<ActionInfo> actionInfo = IfmUtil.getEgressActionInfosForInterface(input.getIntfName(), 0, dataBroker);
+ List<ActionInfo> actionInfo = IfmUtil.getEgressActionInfosForInterface(input.getIntfName(),
+ input.getTunnelKey(),
+ 0, /* ActionKey starting value */
+ dataBroker);
instructionInfo.add(new InstructionInfo(InstructionType.write_actions, actionInfo));
GetEgressInstructionsForInterfaceOutputBuilder output = new GetEgressInstructionsForInterfaceOutputBuilder().
setInstruction(buildInstructions(instructionInfo));
public Future<RpcResult<GetEgressActionsForInterfaceOutput>> getEgressActionsForInterface(GetEgressActionsForInterfaceInput input) {
RpcResultBuilder<GetEgressActionsForInterfaceOutput> rpcResultBuilder;
try {
- List<Action> actionsList = IfmUtil.getEgressActionsForInterface(input.getIntfName(), dataBroker);
+ LOG.debug("Get Egress Action for interface {} with key {}", input.getIntfName(), input.getTunnelKey());
+ List<Action> actionsList = IfmUtil.getEgressActionsForInterface(input.getIntfName(),
+ input.getTunnelKey(),
+ dataBroker);
GetEgressActionsForInterfaceOutputBuilder output = new GetEgressActionsForInterfaceOutputBuilder().
setAction(actionsList);
rpcResultBuilder = RpcResultBuilder.success();
return Futures.immediateFuture(rpcResultBuilder.build());
}
- @Override
- public Future<RpcResult<GetEgressActionsOutput>> getEgressActions(GetEgressActionsInput input) {
- RpcResultBuilder<GetEgressActionsOutput> rpcResultBuilder;
- try {
- List<Action> actionsList = IfmUtil.getEgressActions(input.getIntfName(), input.getServiceTag(), dataBroker);
- GetEgressActionsOutputBuilder output = new GetEgressActionsOutputBuilder().
- setAction(actionsList);
- rpcResultBuilder = RpcResultBuilder.success();
- rpcResultBuilder.withResult(output.build());
- }catch(Exception e){
- LOG.error("Retrieval of egress actions for the key {} failed due to {}" ,input.getIntfName(), e);
- rpcResultBuilder = RpcResultBuilder.failed();
- }
- return Futures.immediateFuture(rpcResultBuilder.build());
- }
@Override
public Future<RpcResult<GetPortFromInterfaceOutput>> getPortFromInterface(GetPortFromInterfaceInput input) {
return Futures.immediateFuture(rpcResultBuilder.build());
}
- public List<ActionInfo> getEgressActionInfosForInterface(String interfaceName) {
- Interface interfaceInfo = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(new InterfaceKey(interfaceName),
- dataBroker);
- 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);
- 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}));
- }
- }
- return listActionInfo;
- }
-
- public List<Action> getEgressActionsForInterface(String interfaceName) {
- List<ActionInfo> listActionInfo = getEgressActionInfosForInterface(interfaceName);
- List<Action> actionsList = new ArrayList<>();
- for (ActionInfo actionInfo : listActionInfo) {
- actionsList.add(actionInfo.buildAction());
- }
- return actionsList;
- }
-
protected static List<Instruction> buildInstructions(List<InstructionInfo> listInstructionInfo) {
if (listInstructionInfo != null) {
List<Instruction> instructions = new ArrayList<Instruction>();
/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState =
InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceName, dataBroker);
if (ifState == null || ifState.getOperStatus() == OperStatus.Down) {
- LOG.info("Not unbinding Service since operstatus is {} for Interface: {}",
- ifState.getOperStatus(), interfaceName);
+ LOG.info("Not unbinding Service since operstatus is DOWN for Interface: {}", interfaceName);
return futures;
}
List<BoundServices> boundServices = servicesInfo.getBoundServices();
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.interfacemgr.statusanddiag;
+
+import java.lang.management.ManagementFactory;
+
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.MBeanRegistrationException;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class InterfaceStatusMonitor implements InterfaceStatusMonitorMBean{
+
+ private String serviceStatus;
+ private static InterfaceStatusMonitor interfaceStatusMonitor = new InterfaceStatusMonitor();
+ private static final String JMX_INTERFACE_OBJ_NAME = "com.ericsson.sdncp.services.status:type=SvcInterfaceService";
+ private static final Logger log = LoggerFactory.getLogger(InterfaceStatusMonitor.class);
+
+ private InterfaceStatusMonitor () {
+ }
+
+ public void registerMbean() {
+ MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+ try {
+ ObjectName objName = new ObjectName(JMX_INTERFACE_OBJ_NAME);
+ log.debug("MXBean Object-Name framed");
+ mbs.registerMBean(interfaceStatusMonitor, objName);
+ log.info("MXBean registration SUCCESSFUL!!! {}", JMX_INTERFACE_OBJ_NAME);
+ } catch (InstanceAlreadyExistsException iaeEx) {
+ log.error("MXBean registration FAILED with InstanceAlreadyExistsException", iaeEx);
+ } catch (MBeanRegistrationException mbrEx) {
+ log.error("MXBean registration FAILED with MBeanRegistrationException", mbrEx);
+ } catch (NotCompliantMBeanException ncmbEx) {
+ log.error("MXBean registration FAILED with NotCompliantMBeanException", ncmbEx);
+ } catch (MalformedObjectNameException monEx) {
+ log.error("MXBean registration failed with MalformedObjectNameException", monEx);
+ }
+ }
+
+ public static InterfaceStatusMonitor getInstance() {
+ return interfaceStatusMonitor;
+ }
+
+ @Override
+ public String acquireServiceStatus() {
+ return serviceStatus;
+ }
+
+ public void reportStatus (String serviceStatus) {
+ this.serviceStatus = serviceStatus;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.interfacemgr.statusanddiag;
+
+public interface InterfaceStatusMonitorMBean {
+
+ public String acquireServiceStatus();
+
+}
/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
IpAddress remoteIp = new IpAddress(Ipv4Address.getDefaultInstance(remoteIpStr));
IpAddress localIp = new IpAddress(Ipv4Address.getDefaultInstance(localIpStr));
IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(remoteIp).setTunnelGateway(localIp).setTunnelSource(localIp)
- .setTunnelInterfaceType( tunType).build();
+ .setTunnelInterfaceType( tunType).setInternal(true).build();
builder.addAugmentation(IfTunnel.class, tunnel);
return builder.build();
}
LogicalDatastoreType.CONFIGURATION, interfaceInstanceIdentifier);
doReturn(Futures.immediateCheckedFuture(expectedBridgeEntry)).when(mockReadTx).read(
LogicalDatastoreType.CONFIGURATION,bridgeEntryIid);
- doReturn(Futures.immediateCheckedFuture(expectedOvsdbBridgeAugmentation)).when(mockReadTx).read(
- LogicalDatastoreType.OPERATIONAL, bridgeIid);
OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentation = new OvsdbBridgeAugmentationBuilder(bridgeNew);
ovsdbBridgeAugmentation.setDatapathId(DatapathId.getDefaultInstance("00:00:00:00:00:00:00:01"));
@Test
public void testDeleteTopologyStateInterface()
{
+ doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockReadTx).read(
+ LogicalDatastoreType.OPERATIONAL, bridgeIid);
OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentation = new OvsdbBridgeAugmentationBuilder(bridgeOld);
ovsdbBridgeAugmentation.setDatapathId(DatapathId.getDefaultInstance("00:00:00:00:00:00:00:01"));
ovsdbBridgeAugmentation.setBridgeName(OvsdbBridgeName.getDefaultInstance("b"));
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: --><!--
+Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+
+This program and the accompanying materials are made available under the
+terms of the Eclipse Public License v1.0 which accompanies this distribution,
+and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <parent>
+ <groupId>org.opendaylight.vpnservice</groupId>
+ <artifactId>config-parent</artifactId>
+ <version>0.3.0-SNAPSHOT</version>
+ <relativePath>../../commons/config-parent</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.opendaylight.vpnservice</groupId>
+ <artifactId>interfacemgr-shell</artifactId>
+ <version>${vpnservices.version}</version>
+ <packaging>bundle</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.vpnservice</groupId>
+ <artifactId>interfacemgr-api</artifactId>
+ <version>${vpnservices.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.vpnservice</groupId>
+ <artifactId>interfacemgr-impl</artifactId>
+ <version>${vpnservices.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.console</artifactId>
+ <version>${karaf.shell.console.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.interfacemgr.shell;
+
+import org.opendaylight.vpnservice.interfacemgr.globals.InterfaceInfo;
+import org.opendaylight.vpnservice.interfacemgr.globals.InterfaceInfo.InterfaceOpState;
+import org.opendaylight.vpnservice.interfacemgr.globals.VlanInterfaceInfo;
+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.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 java.util.Formatter;
+
+public class IfmCLIUtil {
+ private static final String VLAN_OUTPUT_FORMAT_LINE1 = "%-55s";
+ private static final String VLAN_OUTPUT_FORMAT = "%-24s %-20s %-15s %-24s";
+ private static final String VXLAN_OUTPUT_FORMAT = "%-24s %-24s %-18s %-5s";
+ private static final String VXLAN_OUTPUT_FORMAT_LINE1 = "%-49s %-45s";
+ private static final String UNSET = "N/A";
+
+ public static void showVlanHeaderOutput() {
+ StringBuilder sb = new StringBuilder();
+ Formatter fmt = new Formatter(sb);
+ System.out.println(fmt.format(VLAN_OUTPUT_FORMAT_LINE1, "Name"));
+ sb.setLength(0);
+ System.out.println(fmt.format(VLAN_OUTPUT_FORMAT, "", "Dpn", "PortName",
+ "Vlan-Id"));
+ sb.setLength(0);
+ System.out.println(fmt.format(VLAN_OUTPUT_FORMAT, "Tag", "PortNo",
+ "AdmState", "OpState"));
+ sb.setLength(0);
+ System.out.println(fmt.format(VLAN_OUTPUT_FORMAT, "Description", "", "", ""));
+ sb.setLength(0);
+ System.out.println(fmt.format("--------------------------------------------------------------------------------"));
+ sb.setLength(0);
+ fmt.close();
+ }
+
+ public static void showVlanOutput(InterfaceInfo ifaceInfo, Interface iface) {
+ StringBuilder sb = new StringBuilder();
+ Formatter fmt = new Formatter(sb);
+ IfL2vlan l2vlan = iface.getAugmentation(IfL2vlan.class);
+ int vlanId = l2vlan != null ? l2vlan.getVlanId() != null ? l2vlan.getVlanId().getValue() : 0 : 0;
+ System.out.println(fmt.format(VLAN_OUTPUT_FORMAT_LINE1,
+ iface.getName()));
+ sb.setLength(0);
+ System.out.println(fmt.format(VLAN_OUTPUT_FORMAT,
+ "", (ifaceInfo == null) ? UNSET : ifaceInfo.getDpId(),
+ (ifaceInfo == null) ? UNSET : ifaceInfo.getPortName(), vlanId));
+ sb.setLength(0);
+ System.out.println(fmt.format(VLAN_OUTPUT_FORMAT,
+ (ifaceInfo == null) ? UNSET : ifaceInfo.getInterfaceTag(),
+ (ifaceInfo == null) ? UNSET : ifaceInfo.getPortNo(),
+ (ifaceInfo == null) ? UNSET : ifaceInfo.getAdminState(),
+ (ifaceInfo == null) ? UNSET : ifaceInfo.getOpState()));
+ sb.setLength(0);
+ System.out.println(fmt.format(VLAN_OUTPUT_FORMAT + "\n",
+ iface.getDescription(), "", "", ""));
+ sb.setLength(0);
+ fmt.close();
+ }
+
+ public static void showVxlanHeaderOutput() {
+ StringBuilder sb = new StringBuilder();
+ Formatter fmt = new Formatter(sb);
+ System.out.println(fmt
+ .format(VXLAN_OUTPUT_FORMAT_LINE1, "Name", "Description"));
+ sb.setLength(0);
+ System.out.println(fmt.format(VXLAN_OUTPUT_FORMAT, "Local IP",
+ "Remote IP", "Gateway IP", "AdmState"));
+ sb.setLength(0);
+ System.out.println(fmt.format(VXLAN_OUTPUT_FORMAT, "OpState", "Parent",
+ "Tag", ""));
+ sb.setLength(0);
+ System.out.println(fmt
+ .format("--------------------------------------------------------------------------------"));
+ fmt.close();
+ }
+
+ public static void showVxlanOutput(Interface iface, InterfaceInfo interfaceInfo) {
+ StringBuilder sb = new StringBuilder();
+ Formatter fmt = new Formatter(sb);
+ System.out.println(fmt.format(VXLAN_OUTPUT_FORMAT_LINE1,
+ iface.getName(),
+ iface.getDescription() == null ? UNSET : iface.getDescription()));
+ sb.setLength(0);
+ IfTunnel ifTunnel = iface.getAugmentation(IfTunnel.class);
+ System.out.println(fmt.format(VXLAN_OUTPUT_FORMAT,
+ ifTunnel.getTunnelSource().getIpv4Address().getValue(),
+ ifTunnel.getTunnelDestination().getIpv4Address().getValue(),
+ ifTunnel.getTunnelGateway() == null ? UNSET : ifTunnel.getTunnelGateway().getIpv4Address().getValue(),
+ (interfaceInfo == null) ? UNSET : interfaceInfo.getAdminState()));
+ sb.setLength(0);
+ ParentRefs parentRefs = iface.getAugmentation(ParentRefs.class);
+ System.out.println(fmt.format(VXLAN_OUTPUT_FORMAT + "\n",
+ (interfaceInfo == null) ? UNSET : interfaceInfo.getOpState(),
+ String.format("%s/%s", parentRefs.getDatapathNodeIdentifier(),
+ parentRefs.getParentInterface()),
+ (interfaceInfo == null) ? UNSET : interfaceInfo.getInterfaceTag(), ""));
+ fmt.close();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.interfacemgr.shell;
+
+
+import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.opendaylight.vpnservice.interfacemgr.globals.InterfaceInfo;
+import org.opendaylight.vpnservice.interfacemgr.globals.VlanInterfaceInfo;
+import org.opendaylight.vpnservice.interfacemgr.interfaces.IInterfaceManager;
+import org.opendaylight.vpnservice.interfacemgr.shell.IfmCLIUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+
+@Command(scope = "vlan", name = "show", description = "view the configured vlan ports")
+public class ShowVlan extends OsgiCommandSupport {
+ private static final Logger logger = LoggerFactory.getLogger(ShowVlan.class);
+ private IInterfaceManager interfaceManager;
+
+ public void setInterfaceManager(IInterfaceManager interfaceManager) {
+ this.interfaceManager = interfaceManager;
+ }
+
+ @Override
+ protected Object doExecute() throws Exception {
+ logger.debug("Executing show VLAN command");
+ List<Interface> vlanList = interfaceManager.getVlanInterfaces();
+ if (!vlanList.isEmpty()) {
+ IfmCLIUtil.showVlanHeaderOutput();
+ }
+ for (Interface iface : vlanList) {
+ InterfaceInfo ifaceState = interfaceManager.getInterfaceInfoFromOperationalDataStore(iface.getName());
+ IfmCLIUtil.showVlanOutput(ifaceState, iface);
+ }
+ return null;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.interfacemgr.shell;
+
+
+import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.vpnservice.interfacemgr.globals.InterfaceInfo;
+import org.opendaylight.vpnservice.interfacemgr.interfaces.IInterfaceManager;
+import org.opendaylight.vpnservice.interfacemgr.shell.IfmCLIUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+
+@Command(scope = "vxlan", name = "show", description = "view the configured vxlan ports")
+public class ShowVxlan extends OsgiCommandSupport {
+ private static final Logger logger = LoggerFactory.getLogger(ShowVxlan.class);
+ private IInterfaceManager interfaceManager;
+ private DataBroker dataBroker;
+
+ public void setInterfaceManager(IInterfaceManager interfaceManager) {
+ this.interfaceManager = interfaceManager;
+ }
+
+ public void setDataBroker(DataBroker dataBroker){
+ this.dataBroker = dataBroker;
+ }
+
+ @Override
+ protected Object doExecute() throws Exception {
+ logger.debug("Executing show Vxlan command");
+ List<Interface> vxlanList = interfaceManager.getVxlanInterfaces();
+ if (!vxlanList.isEmpty()) {
+ IfmCLIUtil.showVxlanHeaderOutput();
+ }
+ for (Interface iface : vxlanList) {
+ InterfaceInfo ifaceState = interfaceManager.getInterfaceInfoFromOperationalDataStore(iface.getName());
+ IfmCLIUtil.showVxlanOutput(iface, ifaceState);
+ }
+ return null;
+ }
+}
--- /dev/null
+<!-- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+ <reference id="interfaceManagerRef" interface="org.opendaylight.vpnservice.interfacemgr.interfaces.IInterfaceManager" availability="optional" />
+ <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
+ <command>
+ <action class="org.opendaylight.vpnservice.interfacemgr.shell.ShowVlan">
+ <property name="interfaceManager" ref="interfaceManagerRef" />
+ </action>
+ </command>
+ <command>
+ <action class="org.opendaylight.vpnservice.interfacemgr.shell.ShowVxlan">
+ <property name="interfaceManager" ref="interfaceManagerRef" />
+ </action>
+ </command>
+ </command-bundle>
+</blueprint>
<?xml version="1.0" encoding="UTF-8"?>
<!--
-Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v1.0 which accompanies this distribution,
and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
<modules>
<module>interfacemgr-api</module>
<module>interfacemgr-impl</module>
+ <module>interfacemgr-shell</module>
</modules>
<!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->
<build>