From 8025297a9d760ee5add270ad673d4adc5b41d79f Mon Sep 17 00:00:00 2001 From: Suraj Ranjan Date: Thu, 31 Mar 2016 15:16:43 +0530 Subject: [PATCH] HwVTEP support for interfacemanager Change-Id: Id1cc53124beb9995a401ecb6b4a0a8e2e12b8be6 Signed-off-by: Suraj Ranjan --- .../vpnservice/elan/utils/ElanUtils.java | 23 +- features/pom.xml | 5 + features/src/main/features/features.xml | 1 + .../interfacemgr/globals/InterfaceInfo.java | 3 +- .../globals/InterfaceServiceUtil.java | 14 +- .../interfaces/IInterfaceManager.java | 14 +- .../src/main/yang/odl-interface-meta.yang | 13 + .../src/main/yang/odl-interface-rpc.yang | 23 +- .../src/main/yang/odl-interface.yang | 6 +- .../vpnservice/interfacemgr/IfmConstants.java | 3 - .../vpnservice/interfacemgr/IfmUtil.java | 134 +++++--- .../interfacemgr/InterfacemgrProvider.java | 170 +++++++++-- .../commons/AlivenessMonitorUtils.java | 134 ++++---- .../commons/InterfaceManagerCommonUtils.java | 62 +++- .../commons/InterfaceMetaUtils.java | 107 ++++++- .../listeners/HwVTEPConfigListener.java | 90 ++++-- .../listeners/HwVTEPTunnelsStateListener.java | 116 +++++++ .../listeners/InterfaceConfigListener.java | 17 +- .../InterfaceTopologyStateListener.java | 41 ++- .../TerminationPointStateListener.java | 100 ++++++ .../CounterForEntriesPerOFTable.java | 34 +++ .../CounterForEntriesPerOFTableMBean.java | 23 ++ .../CounterForOFPortBytesReceive.java | 34 +++ .../CounterForOFPortBytesReceiveMBean.java | 23 ++ .../pmcounters/CounterForOFPortBytesSent.java | 34 +++ .../CounterForOFPortBytesSentMBean.java | 23 ++ .../pmcounters/CounterForOFPortDuration.java | 34 +++ .../CounterForOFPortDurationMBean.java | 23 ++ .../CounterForOFPortPacketReceive.java | 34 +++ .../CounterForOFPortPacketReceiveMBean.java | 23 ++ .../CounterForOFPortPacketSent.java | 34 +++ .../CounterForOFPortPacketSentMBean.java | 23 ++ .../CounterForOFPortReceiveDrop.java | 35 +++ .../CounterForOFPortReceiveDropMBean.java | 23 ++ .../CounterForOFPortReceiveError.java | 35 +++ .../CounterForOFPortReceiveErrorMBean.java | 23 ++ .../pmcounters/NodeConnectorStatsImpl.java | 289 ++++++++++++++++++ .../PMAgentForNodeConnectorCounters.java | 142 +++++++++ .../HwVTEPConfigRemoveHelper.java | 61 ++-- .../HwVTEPInterfaceConfigAddHelper.java | 98 +++++- .../HwVTEPInterfaceConfigUpdateHelper.java | 86 ++++++ .../HwVTEPInterfaceStateAddHelper.java | 30 -- .../HwVTEPInterfaceStateRemoveHelper.java | 30 -- .../HwVTEPInterfaceStateUpdateHelper.java | 94 ++++++ .../hwvtep/utilities/SouthboundUtils.java | 213 ++++++++++++- .../OvsInterfaceConfigAddHelper.java | 4 +- .../OvsInterfaceConfigRemoveHelper.java | 4 +- .../OvsInterfaceConfigUpdateHelper.java | 125 +++++--- .../OvsInterfaceTopologyStateAddHelper.java | 38 +-- ...OvsInterfaceTopologyStateRemoveHelper.java | 22 +- ...OvsInterfaceTopologyStateUpdateHelper.java | 100 ++++++ .../ovs/utilities/SouthboundUtils.java | 92 +++++- .../InterfaceManagerRpcService.java | 80 ++--- .../FlowBasedServicesConfigUnbindHelper.java | 5 +- .../statusanddiag/InterfaceStatusMonitor.java | 62 ++++ .../InterfaceStatusMonitorMBean.java | 14 + .../test/InterfaceManagerTestUtil.java | 4 +- .../test/TopologyStateInterfaceTest.java | 4 +- interfacemgr/interfacemgr-shell/pom.xml | 41 +++ .../interfacemgr/shell/IfmCLIUtil.java | 108 +++++++ .../interfacemgr/shell/ShowVlan.java | 45 +++ .../interfacemgr/shell/ShowVxlan.java | 50 +++ .../OSGI-INF/blueprint/blueprint.xml | 22 ++ interfacemgr/pom.xml | 3 +- 64 files changed, 2917 insertions(+), 483 deletions(-) create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/listeners/HwVTEPTunnelsStateListener.java create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/listeners/TerminationPointStateListener.java create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForEntriesPerOFTable.java create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForEntriesPerOFTableMBean.java create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortBytesReceive.java create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortBytesReceiveMBean.java create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortBytesSent.java create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortBytesSentMBean.java create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortDuration.java create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortDurationMBean.java create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortPacketReceive.java create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortPacketReceiveMBean.java create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortPacketSent.java create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortPacketSentMBean.java create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortReceiveDrop.java create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortReceiveDropMBean.java create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortReceiveError.java create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortReceiveErrorMBean.java create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/NodeConnectorStatsImpl.java create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/PMAgentForNodeConnectorCounters.java create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/confighelpers/HwVTEPInterfaceConfigUpdateHelper.java delete mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/statehelpers/HwVTEPInterfaceStateAddHelper.java delete mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/statehelpers/HwVTEPInterfaceStateRemoveHelper.java create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/statehelpers/HwVTEPInterfaceStateUpdateHelper.java create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/statehelpers/OvsInterfaceTopologyStateUpdateHelper.java create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/statusanddiag/InterfaceStatusMonitor.java create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/statusanddiag/InterfaceStatusMonitorMBean.java create mode 100644 interfacemgr/interfacemgr-shell/pom.xml create mode 100644 interfacemgr/interfacemgr-shell/src/main/java/org/opendaylight/vpnservice/interfacemgr/shell/IfmCLIUtil.java create mode 100644 interfacemgr/interfacemgr-shell/src/main/java/org/opendaylight/vpnservice/interfacemgr/shell/ShowVlan.java create mode 100644 interfacemgr/interfacemgr-shell/src/main/java/org/opendaylight/vpnservice/interfacemgr/shell/ShowVxlan.java create mode 100644 interfacemgr/interfacemgr-shell/src/main/resources/OSGI-INF/blueprint/blueprint.xml diff --git a/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/vpnservice/elan/utils/ElanUtils.java b/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/vpnservice/elan/utils/ElanUtils.java index e51320f3..201eef26 100644 --- a/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/vpnservice/elan/utils/ElanUtils.java +++ b/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/vpnservice/elan/utils/ElanUtils.java @@ -1,5 +1,5 @@ /* - * 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, @@ -72,9 +72,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150 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; @@ -784,12 +781,18 @@ public class ElanUtils { return actions; } if (tunnelInterfaceName != null && !tunnelInterfaceName.isEmpty()) { - GetEgressActionsInput getEgressActionsForInterfaceInput = new GetEgressActionsInputBuilder().setServiceTag(Long.valueOf(serviceTag)).setIntfName(tunnelInterfaceName).build(); - Future> egressActionsOutputFuture = interfaceManagerRpcService.getEgressActions(getEgressActionsForInterfaceInput); - try { - GetEgressActionsOutput egressActionsOutput = egressActionsOutputFuture.get().getResult(); - List outputAction = egressActionsOutput.getAction(); - return outputAction; + try{ + GetEgressActionsForInterfaceInput getEgressActionInput = + new GetEgressActionsForInterfaceInputBuilder().setIntfName(tunnelInterfaceName).setTunnelKey(null).build(); + Future> result = + interfaceManagerRpcService.getEgressActionsForInterface(getEgressActionInput); + RpcResult 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; diff --git a/features/pom.xml b/features/pom.xml index c21897e9..96b6db0f 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -195,6 +195,11 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL interfacemgr-api ${interfacemgr.version} + + ${project.groupId} + interfacemgr-shell + ${interfacemgr.version} + ${project.groupId} elanmanager-impl diff --git a/features/src/main/features/features.xml b/features/src/main/features/features.xml index dfd0ca06..47e83889 100644 --- a/features/src/main/features/features.xml +++ b/features/src/main/features/features.xml @@ -60,6 +60,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html mvn:org.opendaylight.vpnservice/mdsalutil-impl/{{VERSION}} mvn:org.opendaylight.vpnservice/interfacemgr-api/{{VERSION}} mvn:org.opendaylight.vpnservice/interfacemgr-impl/{{VERSION}} + mvn:org.opendaylight.vpnservice/interfacemgr-shell/{{VERSION}} mvn:org.opendaylight.vpnservice/vpnmanager-impl/{{VERSION}} mvn:org.opendaylight.vpnservice/fibmanager-impl/{{VERSION}} mvn:org.opendaylight.vpnservice/fibmanager-shell/{{VERSION}} diff --git a/interfacemgr/interfacemgr-api/src/main/java/org/opendaylight/vpnservice/interfacemgr/globals/InterfaceInfo.java b/interfacemgr/interfacemgr-api/src/main/java/org/opendaylight/vpnservice/interfacemgr/globals/InterfaceInfo.java index 0118fbf8..dff008ae 100644 --- a/interfacemgr/interfacemgr-api/src/main/java/org/opendaylight/vpnservice/interfacemgr/globals/InterfaceInfo.java +++ b/interfacemgr/interfacemgr-api/src/main/java/org/opendaylight/vpnservice/interfacemgr/globals/InterfaceInfo.java @@ -1,5 +1,5 @@ /* - * 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, @@ -22,6 +22,7 @@ public class InterfaceInfo implements Serializable { VXLAN_TRUNK_INTERFACE, GRE_TRUNK_INTERFACE, VXLAN_VNI_INTERFACE, + MPLS_OVER_GRE, LOGICAL_GROUP_INTERFACE, UNKNOWN_INTERFACE; } diff --git a/interfacemgr/interfacemgr-api/src/main/java/org/opendaylight/vpnservice/interfacemgr/globals/InterfaceServiceUtil.java b/interfacemgr/interfacemgr-api/src/main/java/org/opendaylight/vpnservice/interfacemgr/globals/InterfaceServiceUtil.java index 36f18989..db154b07 100644 --- a/interfacemgr/interfacemgr-api/src/main/java/org/opendaylight/vpnservice/interfacemgr/globals/InterfaceServiceUtil.java +++ b/interfacemgr/interfacemgr-api/src/main/java/org/opendaylight/vpnservice/interfacemgr/globals/InterfaceServiceUtil.java @@ -1,5 +1,5 @@ /* - * 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, @@ -34,6 +34,10 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; 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; @@ -46,6 +50,14 @@ public class InterfaceServiceUtil { return new ServicesInfoBuilder().setBoundServices(boundService).setKey(new ServicesInfoKey(serviceName)).build(); } + public static BoundServices getBoundServices(String serviceName, short servicePriority, int flowPriority, + BigInteger cookie, List 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 boundService = new ArrayList(); diff --git a/interfacemgr/interfacemgr-api/src/main/java/org/opendaylight/vpnservice/interfacemgr/interfaces/IInterfaceManager.java b/interfacemgr/interfacemgr-api/src/main/java/org/opendaylight/vpnservice/interfacemgr/interfaces/IInterfaceManager.java index c79b1d25..a1592937 100644 --- a/interfacemgr/interfacemgr-api/src/main/java/org/opendaylight/vpnservice/interfacemgr/interfaces/IInterfaceManager.java +++ b/interfacemgr/interfacemgr-api/src/main/java/org/opendaylight/vpnservice/interfacemgr/interfaces/IInterfaceManager.java @@ -1,5 +1,5 @@ /* - * 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, @@ -11,9 +11,13 @@ package org.opendaylight.vpnservice.interfacemgr.interfaces; 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 { @@ -38,4 +42,12 @@ 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 getVlanInterfaces(); + List getVxlanInterfaces(); } \ No newline at end of file diff --git a/interfacemgr/interfacemgr-api/src/main/yang/odl-interface-meta.yang b/interfacemgr/interfacemgr-api/src/main/yang/odl-interface-meta.yang index 8654cc8f..2f7f8335 100644 --- a/interfacemgr/interfacemgr-api/src/main/yang/odl-interface-meta.yang +++ b/interfacemgr/interfacemgr-api/src/main/yang/odl-interface-meta.yang @@ -100,4 +100,17 @@ module odl-interface-meta { } } } + + 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 diff --git a/interfacemgr/interfacemgr-api/src/main/yang/odl-interface-rpc.yang b/interfacemgr/interfacemgr-api/src/main/yang/odl-interface-rpc.yang index 281caff8..a6f3874d 100644 --- a/interfacemgr/interfacemgr-api/src/main/yang/odl-interface-rpc.yang +++ b/interfacemgr/interfacemgr-api/src/main/yang/odl-interface-rpc.yang @@ -66,21 +66,13 @@ module odl-interface-rpc { 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 { @@ -93,6 +85,13 @@ module odl-interface-rpc { 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 { diff --git a/interfacemgr/interfacemgr-api/src/main/yang/odl-interface.yang b/interfacemgr/interfacemgr-api/src/main/yang/odl-interface.yang index 43646e40..9b6add1d 100644 --- a/interfacemgr/interfacemgr-api/src/main/yang/odl-interface.yang +++ b/interfacemgr/interfacemgr-api/src/main/yang/odl-interface.yang @@ -103,13 +103,11 @@ module odl-interface { 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"; } } } diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/IfmConstants.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/IfmConstants.java index 9a315e02..c809ce94 100644 --- a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/IfmConstants.java +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/IfmConstants.java @@ -25,9 +25,6 @@ public class IfmConstants { 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); diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/IfmUtil.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/IfmUtil.java index 0cd1a718..7538939b 100644 --- a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/IfmUtil.java +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/IfmUtil.java @@ -26,17 +26,22 @@ import org.opendaylight.vpnservice.mdsalutil.ActionInfo; 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; @@ -47,9 +52,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150 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; @@ -62,6 +66,9 @@ import org.slf4j.LoggerFactory; public class IfmUtil { private static final Logger LOG = LoggerFactory.getLogger(IfmUtil.class); private static final int INVALID_ID = 0; + + + public static String getDpnFromNodeConnectorId(NodeConnectorId portId) { /* * NodeConnectorId is of form 'openflow:dpnid:portnum' @@ -182,10 +189,8 @@ public class IfmUtil { return result; } - public static List getEgressActions(String interfaceName, long serviceTag, DataBroker dataBroker) { - List listActionInfo = new ArrayList<>(); - List interfaceActionList = IfmUtil.getEgressActionInfosForInterface(interfaceName, serviceTag, dataBroker); - listActionInfo.addAll(interfaceActionList); + public static List getEgressActionsForInterface(String interfaceName, Long tunnelKey, DataBroker dataBroker) { + List listActionInfo = getEgressActionInfosForInterface(interfaceName, tunnelKey, 0, dataBroker); List actionsList = new ArrayList<>(); for (ActionInfo actionInfo : listActionInfo) { actionsList.add(actionInfo.buildAction()); @@ -193,55 +198,74 @@ public class IfmUtil { return actionsList; } - public static List getEgressActionsForInterface(String interfaceName, DataBroker dataBroker) { - List listActionInfo = getEgressActionInfosForInterface(interfaceName, 0, dataBroker); - List actionsList = new ArrayList<>(); - for (ActionInfo actionInfo : listActionInfo) { - actionsList.add(actionInfo.buildAction()); - } - return actionsList; + public static List getEgressActionInfosForInterface(String interfaceName, + int actionKeyStart, + DataBroker dataBroker) { + return getEgressActionInfosForInterface(interfaceName, null, actionKeyStart, dataBroker); } - public static List 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 getEgressActionInfosForInterface(String interfaceName, + Long tunnelKey, + int actionKeyStart, + DataBroker dataBroker) { + List result = new ArrayList(); Interface interfaceInfo = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(new InterfaceKey(interfaceName), dataBroker); - List listActionInfo = new ArrayList(); - 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 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 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 listActionInfo = new ArrayList(); - 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(":"))); @@ -316,6 +340,20 @@ public class IfmUtil { return FlowBasedServicesUtils.getNodeConnectorIdFromInterface(iface, dataBroker); } + public static String getPortName(DataBroker dataBroker, NodeConnectorId ncId){ + InstanceIdentifier ncIdentifier = + InstanceIdentifier.builder(Nodes.class) + .child(Node.class, new NodeKey(getNodeIdFromNodeConnectorId(ncId))) + .child(NodeConnector.class, new NodeConnectorKey(ncId)).build(); + Optional 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 ofportIds = ifState.getLowerLayerIf(); @@ -338,6 +376,8 @@ public class IfmUtil { 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 diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/InterfacemgrProvider.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/InterfacemgrProvider.java index 6f110536..4cc72503 100644 --- a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/InterfacemgrProvider.java +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/InterfacemgrProvider.java @@ -7,13 +7,11 @@ */ 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; @@ -23,42 +21,63 @@ import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUt 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; @@ -67,17 +86,22 @@ public class InterfacemgrProvider implements BindingAwareProvider, AutoCloseable 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 rpcRegistration; + private NodeConnectorStatsImpl nodeConnectorStatsManager; public void setRpcProviderRegistry(RpcProviderRegistry rpcProviderRegistry) { this.rpcProviderRegistry = rpcProviderRegistry; + interfaceStatusMonitor.registerMbean(); } public void setMdsalManager(IMdsalApiManager mdsalManager) { @@ -91,6 +115,7 @@ public class InterfacemgrProvider implements BindingAwareProvider, AutoCloseable @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); @@ -110,6 +135,12 @@ public class InterfacemgrProvider implements BindingAwareProvider, AutoCloseable 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); @@ -118,21 +149,33 @@ public class InterfacemgrProvider implements BindingAwareProvider, AutoCloseable 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> result = idManager.createIdPool(createPool); try { @@ -192,13 +235,17 @@ public class InterfacemgrProvider implements BindingAwareProvider, AutoCloseable 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); @@ -267,6 +314,65 @@ public class InterfacemgrProvider implements BindingAwareProvider, AutoCloseable 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 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 boundServicesInstanceIdentifier = InstanceIdentifier.builder(ServiceBindings.class).child(ServicesInfo.class, new ServicesInfoKey(interfaceName)) + .child(BoundServices.class, new BoundServicesKey(serviceInfo.getServicePriority())).build(); + // List services = (List)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 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(); @@ -309,4 +415,28 @@ public class InterfacemgrProvider implements BindingAwareProvider, AutoCloseable public BigInteger getDpnForInterface(Interface intrf) { return getDpnForInterface(intrf.getName()); } + + @Override + public List getVlanInterfaces() { + List vlanList = new ArrayList(); + InstanceIdentifier interfacesInstanceIdentifier = InstanceIdentifier.builder(Interfaces.class).build(); + Optional interfacesOptional = IfmUtil.read(LogicalDatastoreType.CONFIGURATION, interfacesInstanceIdentifier, dataBroker); + if (!interfacesOptional.isPresent()) { + return vlanList; + } + Interfaces interfaces = interfacesOptional.get(); + List interfacesList = interfaces.getInterface(); + for (Interface iface : interfacesList) { + if (IfmUtil.getInterfaceType(iface) == InterfaceInfo.InterfaceType.VLAN_INTERFACE) { + vlanList.add(iface); + } + } + return vlanList; + } + + @Override + public List getVxlanInterfaces() { + return InterfaceManagerCommonUtils.getAllTunnelInterfaces(dataBroker, + InterfaceInfo.InterfaceType.VXLAN_TRUNK_INTERFACE); + } } \ No newline at end of file diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/commons/AlivenessMonitorUtils.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/commons/AlivenessMonitorUtils.java index abc3b2c8..98c1a6ff 100644 --- a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/commons/AlivenessMonitorUtils.java +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/commons/AlivenessMonitorUtils.java @@ -1,5 +1,5 @@ /* - * 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, @@ -9,38 +9,20 @@ package org.opendaylight.vpnservice.interfacemgr.commons; 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; @@ -59,22 +41,22 @@ import java.util.concurrent.Future; 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> result = alivenessMonitorService.monitorStart(lldpMonitorInput); RpcResult rpcResult = result.get(); @@ -96,7 +78,7 @@ public class AlivenessMonitorUtils { 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 monitorIds = getMonitorIdForInterface(dataBroker, trunkInterface.getName()); @@ -153,50 +135,32 @@ public class AlivenessMonitorUtils { endpoint.type.InterfaceBuilder().setInterfaceIp(ipAddress).setInterfaceName(interfaceName).build(); } - protected void handleTunnelMonitorEnabledUpdates(AlivenessMonitorService alivenessMonitorService, DataBroker dataBroker, - List 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 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 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 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); - } } @@ -253,11 +217,9 @@ public class AlivenessMonitorUtils { 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> result = alivenessMonitor.monitorProfileCreate(input); + Future> result = alivenessMonitor.monitorProfileCreate(monitorProfileCreateInput); RpcResult rpcResult = result.get(); if(rpcResult.isSuccessful()) { return rpcResult.getResult().getProfileId(); @@ -269,4 +231,26 @@ public class AlivenessMonitorUtils { } 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 diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/commons/InterfaceManagerCommonUtils.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/commons/InterfaceManagerCommonUtils.java index aa350d6c..bb9d5d14 100644 --- a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/commons/InterfaceManagerCommonUtils.java +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/commons/InterfaceManagerCommonUtils.java @@ -1,5 +1,5 @@ /* - * 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, @@ -17,6 +17,7 @@ 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.globals.InterfaceInfo; import org.opendaylight.vpnservice.interfacemgr.servicebindings.flowbased.utilities.FlowBasedServicesUtils; import org.opendaylight.vpnservice.mdsalutil.FlowEntity; import org.opendaylight.vpnservice.mdsalutil.InstructionInfo; @@ -27,6 +28,7 @@ import org.opendaylight.vpnservice.mdsalutil.MatchInfo; 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; @@ -80,6 +82,23 @@ public class InterfaceManagerCommonUtils { return interfaceInstanceIdentifierBuilder.build(); } + public static List getAllTunnelInterfaces(DataBroker dataBroker, InterfaceInfo.InterfaceType interfaceType) { + List vxlanList = new ArrayList(); + InstanceIdentifier interfacesInstanceIdentifier = InstanceIdentifier.builder(Interfaces.class).build(); + Optional interfacesOptional = IfmUtil.read(LogicalDatastoreType.CONFIGURATION, interfacesInstanceIdentifier, dataBroker); + if (!interfacesOptional.isPresent()) { + return vxlanList; + } + Interfaces interfaces = interfacesOptional.get(); + List 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 interfaceId = getInterfaceIdentifier(interfaceKey); Optional interfaceOptional = IfmUtil.read(LogicalDatastoreType.CONFIGURATION, interfaceId, dataBroker); @@ -112,10 +131,10 @@ public class InterfaceManagerCommonUtils { 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})); } @@ -314,4 +333,39 @@ public class InterfaceManagerCommonUtils { return true; } + public static void deleteInterfaceChildEntry(WriteTransaction transaction, DataBroker dataBroker, String parentInterface, String childInterface){ + InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(parentInterface); + InstanceIdentifier interfaceParentEntryIid = + InterfaceMetaUtils.getInterfaceParentEntryIdentifier(interfaceParentEntryKey); + InterfaceParentEntry interfaceParentEntry = + InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryIid, dataBroker); + + if(interfaceParentEntry == null){ + return; + } + + List interfaceChildEntries = interfaceParentEntry.getInterfaceChildEntry(); + if (interfaceChildEntries.size() <= 1) { + transaction.delete(LogicalDatastoreType.CONFIGURATION, interfaceParentEntryIid); + } else { + InterfaceChildEntryKey interfaceChildEntryKey = new InterfaceChildEntryKey(childInterface); + InstanceIdentifier 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 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 diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/commons/InterfaceMetaUtils.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/commons/InterfaceMetaUtils.java index 797e5597..b768b406 100644 --- a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/commons/InterfaceMetaUtils.java +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/commons/InterfaceMetaUtils.java @@ -1,5 +1,5 @@ /* - * 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, @@ -8,22 +8,17 @@ 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; @@ -39,14 +34,17 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.met 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); @@ -67,12 +65,44 @@ public class InterfaceMetaUtils { 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 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 bridgeIid = + (InstanceIdentifier) bridgeRefEntry.getBridgeReference().getValue(); + Optional bridgeNodeOptional = + IfmUtil.read(LogicalDatastoreType.OPERATIONAL, bridgeIid, dataBroker); + if (bridgeNodeOptional.isPresent()) { + return true; + } + } + return false; + } public static InstanceIdentifier getBridgeEntryIdentifier(BridgeEntryKey bridgeEntryKey) { InstanceIdentifier.InstanceIdentifierBuilder 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 bridgeEntryInstanceIdentifier = + InterfaceMetaUtils.getBridgeEntryIdentifier(bridgeEntryKey); + return getBridgeEntryFromConfigDS(bridgeEntryInstanceIdentifier, + dataBroker); + } + public static BridgeEntry getBridgeEntryFromConfigDS(InstanceIdentifier bridgeEntryInstanceIdentifier, DataBroker dataBroker) { Optional bridgeEntryOptional = @@ -186,6 +216,8 @@ public class InterfaceMetaUtils { 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 bridgeEntryId = InterfaceMetaUtils.getBridgeRefEntryIdentifier(bridgeRefEntryKey); @@ -194,4 +226,55 @@ public class InterfaceMetaUtils { .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 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 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 nodeId, + WriteTransaction transaction, + IfTunnel ifTunnel){ + InstanceIdentifier 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 nodeId, + WriteTransaction transaction, + IfTunnel ifTunnel){ + InstanceIdentifier 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 id = InstanceIdentifier.builder(TunnelInstanceInterfaceMap.class). + child(TunnelInstanceInterface.class, new TunnelInstanceInterfaceKey(tunnelInstanceId)).build(); + Optional tunnelInstanceInterfaceOptional = IfmUtil.read(LogicalDatastoreType.OPERATIONAL, id, dataBroker); + if(tunnelInstanceInterfaceOptional.isPresent()){ + return tunnelInstanceInterfaceOptional.get().getInterfaceName(); + } + return null; + } + } \ No newline at end of file diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/listeners/HwVTEPConfigListener.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/listeners/HwVTEPConfigListener.java index 4cb1e224..3109e199 100644 --- a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/listeners/HwVTEPConfigListener.java +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/listeners/HwVTEPConfigListener.java @@ -13,13 +13,17 @@ import org.opendaylight.vpnservice.datastoreutils.AsyncDataTreeChangeListenerBas 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; @@ -47,11 +51,13 @@ public class HwVTEPConfigListener extends AsyncDataTreeChangeListenerBase 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 @@ -70,12 +91,14 @@ public class HwVTEPConfigListener extends AsyncDataTreeChangeListenerBase>> { InstanceIdentifier key; Interface interfaceNew; - IfL2vlan ifL2vlan; - ParentRefs parentRefs; + InstanceIdentifier physicalSwitchNodeId; + InstanceIdentifier globalNodeId; + IfTunnel ifTunnel; public RendererConfigAddWorker(InstanceIdentifier key, Interface interfaceNew, - ParentRefs parentRefs) { + InstanceIdentifier physicalSwitchNodeId, InstanceIdentifier globalNodeId, IfTunnel ifTunnel) { + this.key = key; + this.interfaceNew = interfaceNew; + this.physicalSwitchNodeId = physicalSwitchNodeId; + this.globalNodeId = globalNodeId; + this.ifTunnel = ifTunnel; + } + + @Override + public List> call() throws Exception { + return HwVTEPInterfaceConfigAddHelper.addConfiguration(dataBroker, + physicalSwitchNodeId, globalNodeId, interfaceNew, ifTunnel); + } + } + + private class RendererConfigUpdateWorker implements Callable>> { + InstanceIdentifier key; + Interface interfaceNew; + InstanceIdentifier globalNodeId; + InstanceIdentifier physicalSwitchNodeId; + IfTunnel ifTunnel; + + public RendererConfigUpdateWorker(InstanceIdentifier key, Interface interfaceNew, + InstanceIdentifier physicalSwitchNodeId, InstanceIdentifier 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> call() throws Exception { - return HwVTEPInterfaceConfigAddHelper.addConfiguration(dataBroker, parentRefs, interfaceNew); + return HwVTEPInterfaceConfigUpdateHelper.updateConfiguration(dataBroker, + physicalSwitchNodeId, globalNodeId, interfaceNew, ifTunnel); } } private class RendererConfigRemoveWorker implements Callable>> { InstanceIdentifier key; Interface interfaceOld; - ParentRefs parentRefs; + InstanceIdentifier physicalSwitchNodeId; + InstanceIdentifier globalNodeId; public RendererConfigRemoveWorker(InstanceIdentifier key, Interface interfaceOld, - ParentRefs parentRefs) { + InstanceIdentifier physicalSwitchNodeId, InstanceIdentifier globalNodeId) { this.key = key; this.interfaceOld = interfaceOld; - this.parentRefs = parentRefs; + this.physicalSwitchNodeId = physicalSwitchNodeId; + this.globalNodeId = globalNodeId; } @Override public List> call() throws Exception { - return HwVTEPConfigRemoveHelper.removeConfiguration(dataBroker, interfaceOld, parentRefs); + return HwVTEPConfigRemoveHelper.removeConfiguration(dataBroker, + interfaceOld, globalNodeId, physicalSwitchNodeId); } } } \ No newline at end of file diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/listeners/HwVTEPTunnelsStateListener.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/listeners/HwVTEPTunnelsStateListener.java new file mode 100644 index 00000000..99f6a802 --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/listeners/HwVTEPTunnelsStateListener.java @@ -0,0 +1,116 @@ +/* + * 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 { + 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 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 identifier, Tunnels tunnelOld) { + LOG.info("Received Remove DataChange Notification for identifier: {}, physicalSwitchAugmentation: {}", + identifier, tunnelOld); + } + + @Override + protected void update(InstanceIdentifier 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 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>> { + InstanceIdentifier instanceIdentifier; + Tunnels tunnelsNew; + Tunnels tunnelsOld; + + public RendererStateUpdateWorker(InstanceIdentifier instanceIdentifier, + Tunnels tunnelsNew, Tunnels tunnelsOld) { + this.instanceIdentifier = instanceIdentifier; + this.tunnelsNew = tunnelsNew; + this.tunnelsOld = tunnelsOld; + } + + @Override + public List> 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>> { + InstanceIdentifier instanceIdentifier; + Tunnels tunnelsNew; + + public RendererStateAddWorker(InstanceIdentifier instanceIdentifier, + Tunnels tunnelsNew) { + this.instanceIdentifier = instanceIdentifier; + this.tunnelsNew = tunnelsNew; + } + + @Override + public List> 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 diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/listeners/InterfaceConfigListener.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/listeners/InterfaceConfigListener.java index dec2f154..7e764aa0 100644 --- a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/listeners/InterfaceConfigListener.java +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/listeners/InterfaceConfigListener.java @@ -1,5 +1,5 @@ /* - * 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, @@ -39,6 +39,7 @@ public class InterfaceConfigListener extends AsyncDataTreeChangeListenerBase 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 @@ -84,12 +90,13 @@ public class InterfaceConfigListener extends AsyncDataTreeChangeListenerBase>> { diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/listeners/InterfaceTopologyStateListener.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/listeners/InterfaceTopologyStateListener.java index db2ebcd7..1ff38f51 100644 --- a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/listeners/InterfaceTopologyStateListener.java +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/listeners/InterfaceTopologyStateListener.java @@ -1,5 +1,5 @@ /* - * 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, @@ -15,6 +15,7 @@ import org.opendaylight.vpnservice.datastoreutils.AsyncDataChangeListenerBase; 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; @@ -48,7 +49,7 @@ public class InterfaceTopologyStateListener extends AsyncDataChangeListenerBase< @Override protected AsyncDataBroker.DataChangeScope getDataChangeScope() { - return AsyncDataBroker.DataChangeScope.BASE; + return AsyncDataBroker.DataChangeScope.ONE; } @Override @@ -57,14 +58,23 @@ public class InterfaceTopologyStateListener extends AsyncDataChangeListenerBase< 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 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 @@ -115,4 +125,25 @@ public class InterfaceTopologyStateListener extends AsyncDataChangeListenerBase< bridgeNew, dataBroker); } } + private class RendererStateUpdateWorker implements Callable>> { + InstanceIdentifier instanceIdentifier; + OvsdbBridgeAugmentation bridgeNew; + OvsdbBridgeAugmentation bridgeOld; + + + public RendererStateUpdateWorker(InstanceIdentifier instanceIdentifier, + OvsdbBridgeAugmentation bridgeNew, OvsdbBridgeAugmentation bridgeOld) { + this.instanceIdentifier = instanceIdentifier; + this.bridgeNew = bridgeNew; + this.bridgeOld = bridgeOld; + } + + @Override + public List> 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 diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/listeners/TerminationPointStateListener.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/listeners/TerminationPointStateListener.java new file mode 100644 index 00000000..9d9debcd --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/listeners/TerminationPointStateListener.java @@ -0,0 +1,100 @@ +/* + * 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 { + 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 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 identifier, + OvsdbTerminationPointAugmentation tpOld) { + } + + @Override + protected void update(InstanceIdentifier 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 identifier, + OvsdbTerminationPointAugmentation tpNew) { + + } + + private class RendererStateUpdateWorker implements Callable>> { + InstanceIdentifier instanceIdentifier; + OvsdbTerminationPointAugmentation terminationPointNew; + OvsdbTerminationPointAugmentation terminationPointOld; + + + public RendererStateUpdateWorker(InstanceIdentifier instanceIdentifier, + OvsdbTerminationPointAugmentation tpNew, OvsdbTerminationPointAugmentation tpOld) { + this.instanceIdentifier = instanceIdentifier; + this.terminationPointNew = tpNew; + this.terminationPointOld = tpOld; + } + + @Override + public List> 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 diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForEntriesPerOFTable.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForEntriesPerOFTable.java new file mode 100644 index 00000000..1641d402 --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForEntriesPerOFTable.java @@ -0,0 +1,34 @@ +/* + * 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 counterCache = new HashMap(); + public static Map counterMap = new HashMap(); + public void invokePMManagedObjects(Map map) { + setCounterDetails(map); + } + + public Map getCounterDetails() { + return counterCache; + } + + public synchronized void setCounterDetails(Map map) { + counterCache = map; + } + + public Map retrieveCounterMap(){ + counterMap = (HashMap) counterCache; + return counterMap; + } + +} diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForEntriesPerOFTableMBean.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForEntriesPerOFTableMBean.java new file mode 100644 index 00000000..0afa8c1a --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForEntriesPerOFTableMBean.java @@ -0,0 +1,23 @@ +/* + * 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 map); + public Map getCounterDetails(); + //----------- + // attributes + //----------- + public void invokePMManagedObjects(Map map); + public Map retrieveCounterMap(); +} diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortBytesReceive.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortBytesReceive.java new file mode 100644 index 00000000..c06d7dee --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortBytesReceive.java @@ -0,0 +1,34 @@ +/* + * 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 counterCache = new HashMap(); + public static Map counterMap = new HashMap(); + public void invokePMManagedObjects(Map map) { + setCounterDetails(map); + } + + public Map getCounterDetails() { + return counterCache; + } + + public synchronized void setCounterDetails(Map map) { + counterCache = map; + } + + public Map retrieveCounterMap(){ + counterMap = (HashMap) counterCache; + return counterMap; + } + +} diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortBytesReceiveMBean.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortBytesReceiveMBean.java new file mode 100644 index 00000000..2546b9b2 --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortBytesReceiveMBean.java @@ -0,0 +1,23 @@ +/* + * 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 map); + public Map getCounterDetails(); + //----------- + // attributes + //----------- + public void invokePMManagedObjects(Map map); + public Map retrieveCounterMap(); +} diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortBytesSent.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortBytesSent.java new file mode 100644 index 00000000..cd92d529 --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortBytesSent.java @@ -0,0 +1,34 @@ +/* + * 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 counterCache = new HashMap(); + public static Map counterMap = new HashMap(); + public void invokePMManagedObjects(Map map) { + setCounterDetails(map); + } + + public Map getCounterDetails() { + return counterCache; + } + + public synchronized void setCounterDetails(Map map) { + counterCache = map; + } + + public Map retrieveCounterMap(){ + counterMap = (HashMap) counterCache; + return counterMap; + } + +} \ No newline at end of file diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortBytesSentMBean.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortBytesSentMBean.java new file mode 100644 index 00000000..e32f066b --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortBytesSentMBean.java @@ -0,0 +1,23 @@ +/* + * 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 map); + public Map getCounterDetails(); + //----------- + // attributes + //----------- + public void invokePMManagedObjects(Map map); + public Map retrieveCounterMap(); +} diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortDuration.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortDuration.java new file mode 100644 index 00000000..6aa59271 --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortDuration.java @@ -0,0 +1,34 @@ +/* + * 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 counterCache = new HashMap(); + public static Map counterMap = new HashMap(); + public void invokePMManagedObjects(Map map) { + setCounterDetails(map); + } + + public Map getCounterDetails() { + return counterCache; + } + + public synchronized void setCounterDetails(Map map) { + counterCache = map; + } + + public Map retrieveCounterMap(){ + counterMap = (HashMap) counterCache; + return counterMap; + } + +} \ No newline at end of file diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortDurationMBean.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortDurationMBean.java new file mode 100644 index 00000000..071a5aec --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortDurationMBean.java @@ -0,0 +1,23 @@ +/* + * 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 map); + public Map getCounterDetails(); + //----------- + // attributes + //----------- + public void invokePMManagedObjects(Map map); + public Map retrieveCounterMap(); +} diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortPacketReceive.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortPacketReceive.java new file mode 100644 index 00000000..02954fdb --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortPacketReceive.java @@ -0,0 +1,34 @@ +/* + * 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 counterCache = new HashMap(); + public static Map counterMap = new HashMap(); + public void invokePMManagedObjects(Map map) { + setCounterDetails(map); + } + + public Map getCounterDetails() { + return counterCache; + } + + public synchronized void setCounterDetails(Map map) { + counterCache = map; + } + + public Map retrieveCounterMap(){ + counterMap = (HashMap) counterCache; + return counterMap; + } + +} diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortPacketReceiveMBean.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortPacketReceiveMBean.java new file mode 100644 index 00000000..22d7380d --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortPacketReceiveMBean.java @@ -0,0 +1,23 @@ +/* + * 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 map); + public Map getCounterDetails(); + //----------- + // attributes + //----------- + public void invokePMManagedObjects(Map map); + public Map retrieveCounterMap(); +} diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortPacketSent.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortPacketSent.java new file mode 100644 index 00000000..79973039 --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortPacketSent.java @@ -0,0 +1,34 @@ +/* + * 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 counterCache = new HashMap(); + public static Map counterMap = new HashMap(); + public void invokePMManagedObjects(Map map) { + setCounterDetails(map); + } + + public Map getCounterDetails() { + return counterCache; + } + + public synchronized void setCounterDetails(Map map) { + counterCache = map; + } + + public Map retrieveCounterMap(){ + counterMap = (HashMap) counterCache; + return counterMap; + } + +} diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortPacketSentMBean.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortPacketSentMBean.java new file mode 100644 index 00000000..9610324c --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortPacketSentMBean.java @@ -0,0 +1,23 @@ +/* + * 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 map); + public Map getCounterDetails(); + //----------- + // attributes + //----------- + public void invokePMManagedObjects(Map map); + public Map retrieveCounterMap(); +} \ No newline at end of file diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortReceiveDrop.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortReceiveDrop.java new file mode 100644 index 00000000..4380082d --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortReceiveDrop.java @@ -0,0 +1,35 @@ +/* + * 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 counterCache = new HashMap(); + public static Map counterMap = new HashMap(); + public void invokePMManagedObjects(Map map) { + setCounterDetails(map); + } + + public Map getCounterDetails() { + return counterCache; + } + + public synchronized void setCounterDetails(Map map) { + counterCache = map; + } + + public Map retrieveCounterMap(){ + counterMap = (HashMap) counterCache; + return counterMap; + } + +} + diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortReceiveDropMBean.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortReceiveDropMBean.java new file mode 100644 index 00000000..bfc979bc --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortReceiveDropMBean.java @@ -0,0 +1,23 @@ +/* + * 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 map); + public Map getCounterDetails(); + //----------- + // attributes + //----------- + public void invokePMManagedObjects(Map map); + public Map retrieveCounterMap(); +} diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortReceiveError.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortReceiveError.java new file mode 100644 index 00000000..d8662aa8 --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortReceiveError.java @@ -0,0 +1,35 @@ +/* + * 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 counterCache = new HashMap(); + public static Map counterMap = new HashMap(); + public void invokePMManagedObjects(Map map) { + setCounterDetails(map); + } + + public Map getCounterDetails() { + return counterCache; + } + + public synchronized void setCounterDetails(Map map) { + counterCache = map; + } + + public Map retrieveCounterMap(){ + counterMap = (HashMap) counterCache; + return counterMap; + } + +} + diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortReceiveErrorMBean.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortReceiveErrorMBean.java new file mode 100644 index 00000000..9ed7a705 --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/CounterForOFPortReceiveErrorMBean.java @@ -0,0 +1,23 @@ +/* + * 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 map); + public Map getCounterDetails(); + //----------- + // attributes + //----------- + public void invokePMManagedObjects(Map map); + public Map retrieveCounterMap(); +} diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/NodeConnectorStatsImpl.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/NodeConnectorStatsImpl.java new file mode 100644 index 00000000..226af182 --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/NodeConnectorStatsImpl.java @@ -0,0 +1,289 @@ +/* + * 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{ + + 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 nodes = new ArrayList<>(); + Map> nodeAndNcIdOFPortDurationMap = new ConcurrentHashMap>(); + Map> nodeAndNcIdOFPortReceiveDropMap = new ConcurrentHashMap>(); + Map> nodeAndNcIdOFPortReceiveError = new ConcurrentHashMap>(); + Map> nodeAndNcIdPacketSentMap = new ConcurrentHashMap>(); + Map> nodeAndNcIdPacketReceiveMap = new ConcurrentHashMap>(); + Map> nodeAndNcIdBytesSentMap = new ConcurrentHashMap>(); + Map> nodeAndNcIdBytesReceiveMap = new ConcurrentHashMap>(); + Map> nodeAndEntriesPerOFTableMap = new ConcurrentHashMap>(); + 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 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 ncIdOFPortDurationMap = new HashMap(); + Map ncIdOFPortReceiveDropMap = new HashMap(); + Map ncIdOFPortReceiveError = new HashMap(); + Map ncIdPacketSentMap = new HashMap(); + Map ncIdPacketReceiveMap = new HashMap(); + Map ncIdBytesSentMap = new HashMap(); + Map ncIdBytesReceiveMap = new HashMap(); + List 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 combineAllNodesStats(Map> allNodesStats) { + Map allNcsStatsMap = new HashMap(); + for (Map.Entry> entry : allNodesStats.entrySet()) { + Map ncStatsMap = entry.getValue(); + for (Map.Entry 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 entriesPerOFTableMap = new HashMap(); + List 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 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 identifier, Node original, + Node update) { + // TODO Auto-generated method stub + } + + @Override + protected void add(InstanceIdentifier 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(); + } + } +} diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/PMAgentForNodeConnectorCounters.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/PMAgentForNodeConnectorCounters.java new file mode 100644 index 00000000..acea10e2 --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/pmcounters/PMAgentForNodeConnectorCounters.java @@ -0,0 +1,142 @@ +/* + * 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 ofPortDurationCounter, Map ofPortReceiveDropCounter, + Map ofPortReceiveErrorCounter, Map ofPortPacketSent, Map ofPortPacketReceive, + Map ofPortBytesSent, Map 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 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); + } + } +} diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/confighelpers/HwVTEPConfigRemoveHelper.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/confighelpers/HwVTEPConfigRemoveHelper.java index a5fa68af..c1f1d660 100644 --- a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/confighelpers/HwVTEPConfigRemoveHelper.java +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/confighelpers/HwVTEPConfigRemoveHelper.java @@ -1,5 +1,5 @@ /* - * 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, @@ -11,37 +11,20 @@ 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.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; @@ -49,11 +32,37 @@ public class HwVTEPConfigRemoveHelper { private static final Logger LOG = LoggerFactory.getLogger(HwVTEPConfigRemoveHelper.class); public static List> removeConfiguration(DataBroker dataBroker, Interface interfaceOld, - ParentRefs parentRefs) { + InstanceIdentifier globalNodeId, + InstanceIdentifier physicalSwitchNodeId) { List> futures = new ArrayList>(); - 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 globalNodeId) { + LOG.info("removing remote termination end point {}", ifTunnel.getTunnelDestination()); + TerminationPointKey tpKey = SouthboundUtils.getTerminationPointKey(ifTunnel.getTunnelDestination(). + getIpv4Address().getValue()); + InstanceIdentifier tpPath = SouthboundUtils.createInstanceIdentifier + (globalNodeId, tpKey); + transaction.delete(LogicalDatastoreType.CONFIGURATION, tpPath); + } + + private static void removeTunnelTableEntry(WriteTransaction transaction, IfTunnel ifTunnel, + InstanceIdentifier physicalSwitchNodeId) { + LOG.info("removing tunnel table entry for {}", ifTunnel.getTunnelDestination()); + InstanceIdentifier tunnelsInstanceIdentifier = SouthboundUtils.createTunnelsInstanceIdentifier(physicalSwitchNodeId, + ifTunnel.getTunnelSource(), ifTunnel.getTunnelDestination()); + transaction.delete(LogicalDatastoreType.CONFIGURATION, tunnelsInstanceIdentifier); + } } \ No newline at end of file diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/confighelpers/HwVTEPInterfaceConfigAddHelper.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/confighelpers/HwVTEPInterfaceConfigAddHelper.java index a069302a..202b6b59 100644 --- a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/confighelpers/HwVTEPInterfaceConfigAddHelper.java +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/confighelpers/HwVTEPInterfaceConfigAddHelper.java @@ -1,5 +1,5 @@ /* - * 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, @@ -10,24 +10,108 @@ 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.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> addConfiguration(DataBroker dataBroker, ParentRefs parentRefs, - Interface interfaceNew) { + public static List> addConfiguration(DataBroker dataBroker, InstanceIdentifier physicalSwitchNodeId, + InstanceIdentifier globalNodeId, + Interface interfaceNew, IfTunnel ifTunnel) { List> futures = new ArrayList>(); - 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> futures, + InstanceIdentifier globalNodeId, + IfTunnel ifTunnel) { + //InstanceIdentifier localTEP = + // createLocalPhysicalLocatorEntryIfNotPresent(futures, dataBroker,transaction, ifTunnel, globalNodeId); + createRemotePhysicalLocatorEntry(transaction, futures, globalNodeId, ifTunnel.getTunnelDestination()); + //InstanceIdentifier tunnelsInstanceIdentifier = createTunnelTableEntry(transaction, physicalSwitchNodeId, localTEP, remoteTEP); + } + + private static InstanceIdentifier createRemotePhysicalLocatorEntry(WriteTransaction transaction, List> futures, + InstanceIdentifier nodeIid, IpAddress destIPAddress){ + String remoteIp = destIPAddress.getIpv4Address().getValue(); + LOG.debug("creating remote physical locator entry {}", remoteIp); + TerminationPointKey tpKey = SouthboundUtils.getTerminationPointKey(remoteIp); + InstanceIdentifier tpPath = + SouthboundUtils.createInstanceIdentifier(nodeIid, tpKey); + createPhysicalLocatorEntry(transaction, futures, tpPath, tpKey, destIPAddress); + return tpPath; + } + + + private static InstanceIdentifier createLocalPhysicalLocatorEntryIfNotPresent(List> futures, + DataBroker dataBroker, + WriteTransaction transaction, + IfTunnel ifTunnel, + InstanceIdentifier nodeIid){ + String localIp = ifTunnel.getTunnelSource().getIpv4Address().getValue(); + LOG.debug("creating local physical locator entry {}", localIp); + TerminationPointKey tpKey = SouthboundUtils.getTerminationPointKey(localIp); + InstanceIdentifier 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> futures, + InstanceIdentifier 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); + } } diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/confighelpers/HwVTEPInterfaceConfigUpdateHelper.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/confighelpers/HwVTEPInterfaceConfigUpdateHelper.java new file mode 100644 index 00000000..a91fcce9 --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/confighelpers/HwVTEPInterfaceConfigUpdateHelper.java @@ -0,0 +1,86 @@ +/* + * 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> updateConfiguration(DataBroker dataBroker, InstanceIdentifier physicalSwitchNodeId, + InstanceIdentifier globalNodeId, + Interface interfaceNew, IfTunnel ifTunnel) { + List> futures = new ArrayList>(); + 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> updateBfdMonitoring(DataBroker dataBroker, InstanceIdentifier nodeId, + IfTunnel ifTunnel) { + List> futures = new ArrayList>(); + WriteTransaction transaction = dataBroker.newWriteOnlyTransaction(); + TunnelsBuilder tBuilder = new TunnelsBuilder(); + InstanceIdentifier localTEPInstanceIdentifier = + SouthboundUtils.createTEPInstanceIdentifier(nodeId, ifTunnel.getTunnelSource()); + InstanceIdentifier remoteTEPInstanceIdentifier = + SouthboundUtils.createTEPInstanceIdentifier(nodeId, ifTunnel.getTunnelDestination()); + InstanceIdentifier 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 = new ArrayList<>(); + SouthboundUtils.fillBfdParameters(bfdParams, null); + tBuilder.setBfdParams(bfdParams); + transaction.merge(LogicalDatastoreType.CONFIGURATION, tunnelsInstanceIdentifier,tBuilder.build(), true); + futures.add(transaction.submit()); + return futures; + } +} diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/statehelpers/HwVTEPInterfaceStateAddHelper.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/statehelpers/HwVTEPInterfaceStateAddHelper.java deleted file mode 100644 index 3b4eca6b..00000000 --- a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/statehelpers/HwVTEPInterfaceStateAddHelper.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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> addConfiguration(DataBroker dataBroker, ParentRefs parentRefs, - Interface interfaceNew, IdManagerService idManager) { - List> futures = new ArrayList>(); - LOG.debug("HwVTEP Interface State Add Helper"); - return futures; - } -} diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/statehelpers/HwVTEPInterfaceStateRemoveHelper.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/statehelpers/HwVTEPInterfaceStateRemoveHelper.java deleted file mode 100644 index d087e7b6..00000000 --- a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/statehelpers/HwVTEPInterfaceStateRemoveHelper.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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> addConfiguration(DataBroker dataBroker, ParentRefs parentRefs, - Interface interfaceNew, IdManagerService idManager) { - List> futures = new ArrayList>(); - LOG.debug("HWvTEP state remove helper"); - return futures; - } -} diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/statehelpers/HwVTEPInterfaceStateUpdateHelper.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/statehelpers/HwVTEPInterfaceStateUpdateHelper.java new file mode 100644 index 00000000..f796f1e3 --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/statehelpers/HwVTEPInterfaceStateUpdateHelper.java @@ -0,0 +1,94 @@ +/* + * 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> updatePhysicalSwitch(DataBroker dataBroker, InstanceIdentifier tunnelsInstanceIdentifier, + Tunnels tunnelsNew, Tunnels tunnelsOld) { + List> futures = new ArrayList>(); + 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 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> startBfdMonitoring(DataBroker dataBroker, + InstanceIdentifier tunnelsInstanceIdentifier, + Tunnels tunnelsNew) { + List> futures = new ArrayList>(); + /*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 = new ArrayList<>(); + SouthboundUtils.fillBfdParameters(bfdParams, null); + tBuilder.setBfdParams(bfdParams); + transaction.put(LogicalDatastoreType.CONFIGURATION, tunnelsInstanceIdentifier,tBuilder.build(), true); + futures.add(transaction.submit()); + return futures; + } +} diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/utilities/SouthboundUtils.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/utilities/SouthboundUtils.java index fd72995b..c3b4d3eb 100644 --- a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/utilities/SouthboundUtils.java +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/utilities/SouthboundUtils.java @@ -1,5 +1,5 @@ /* - * 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, @@ -7,12 +7,221 @@ */ 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 createPhysicalSwitchInstanceIdentifier(String psNodeIdString) { + NodeId physicalSwitchNodeId = new NodeId(psNodeIdString); + InstanceIdentifier psNodeId = InstanceIdentifier + .create(NetworkTopology.class) + .child(Topology.class, new TopologyKey(HWVTEP_TOPOLOGY_ID)) + .child(Node.class,new NodeKey(physicalSwitchNodeId)); + return psNodeId; + } + + public static InstanceIdentifier createGlobalNodeInstanceIdentifier(DataBroker dataBroker, String physicalSwitchNodeId) { + InstanceIdentifier psNodeId = InstanceIdentifier + .create(NetworkTopology.class) + .child(Topology.class, new TopologyKey(HWVTEP_TOPOLOGY_ID)) + .child(Node.class,new NodeKey(new NodeId(physicalSwitchNodeId))); + Optional 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) physicalSwitchAugmentation.getManagedBy().getValue(); + } + + public static InstanceIdentifier createTerminationPointInstanceIdentifier(NodeKey nodekey, + String portName){ + InstanceIdentifier 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 createTEPInstanceIdentifier + (InstanceIdentifier nodeIid, IpAddress ipAddress) { + TerminationPointKey localTEP = SouthboundUtils.getTerminationPointKey(ipAddress.getIpv4Address().getValue()); + return createInstanceIdentifier(nodeIid, localTEP); + } + + public static InstanceIdentifier createInstanceIdentifier(InstanceIdentifier nodeIid, + TerminationPointKey tpKey) { + return nodeIid.child(TerminationPoint.class, tpKey); + } + + public static InstanceIdentifier createTunnelsInstanceIdentifier(InstanceIdentifier nodeId, IpAddress localIP, IpAddress remoteIp) { + InstanceIdentifier localTEPInstanceIdentifier = + createTEPInstanceIdentifier(nodeId, localIP); + InstanceIdentifier 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 createTunnelsInstanceIdentifier(InstanceIdentifier nodeId, + InstanceIdentifier localTEPInstanceIdentifier, + InstanceIdentifier 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 tpPath, + DataBroker dataBroker) { + Optional 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 ifStateId = + IfmUtil.buildStateInterfaceId(interfaceInfo.getName()); + List 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, 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, 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 diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/confighelpers/OvsInterfaceConfigAddHelper.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/confighelpers/OvsInterfaceConfigAddHelper.java index fecf3cf7..6e5d6bd0 100644 --- a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/confighelpers/OvsInterfaceConfigAddHelper.java +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/confighelpers/OvsInterfaceConfigAddHelper.java @@ -1,5 +1,5 @@ /* - * 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, @@ -66,7 +66,7 @@ public class OvsInterfaceConfigAddHelper { private static void addVlanConfiguration(Interface interfaceNew, ParentRefs parentRefs, DataBroker dataBroker, IdManagerService idManager, List> 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(); diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/confighelpers/OvsInterfaceConfigRemoveHelper.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/confighelpers/OvsInterfaceConfigRemoveHelper.java index 1f1cc9cf..97187870 100644 --- a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/confighelpers/OvsInterfaceConfigRemoveHelper.java +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/confighelpers/OvsInterfaceConfigRemoveHelper.java @@ -1,5 +1,5 @@ /* - * 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, @@ -78,7 +78,7 @@ public class OvsInterfaceConfigRemoveHelper { 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 = diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/confighelpers/OvsInterfaceConfigUpdateHelper.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/confighelpers/OvsInterfaceConfigUpdateHelper.java index 73e38309..05b21139 100644 --- a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/confighelpers/OvsInterfaceConfigUpdateHelper.java +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/confighelpers/OvsInterfaceConfigUpdateHelper.java @@ -1,5 +1,5 @@ /* - * 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, @@ -10,34 +10,22 @@ package org.opendaylight.vpnservice.interfacemgr.renderer.ovs.confighelpers; import com.google.common.util.concurrent.ListenableFuture; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -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; @@ -52,6 +40,7 @@ public class OvsInterfaceConfigUpdateHelper{ Interface interfaceNew, Interface interfaceOld) { List> 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))); @@ -60,6 +49,7 @@ public class OvsInterfaceConfigUpdateHelper{ 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) { @@ -68,40 +58,18 @@ public class OvsInterfaceConfigUpdateHelper{ 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; } @@ -121,12 +89,75 @@ public class OvsInterfaceConfigUpdateHelper{ 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> 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> 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 boolean checkAugmentations(T oldAug, T newAug) { if ((oldAug != null && newAug == null) || (oldAug == null && newAug != null)) { diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/statehelpers/OvsInterfaceTopologyStateAddHelper.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/statehelpers/OvsInterfaceTopologyStateAddHelper.java index ae9dccf3..95f9e91f 100644 --- a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/statehelpers/OvsInterfaceTopologyStateAddHelper.java +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/statehelpers/OvsInterfaceTopologyStateAddHelper.java @@ -1,5 +1,5 @@ /* - * 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, @@ -44,23 +44,10 @@ public class OvsInterfaceTopologyStateAddHelper { WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction(); if (bridgeNew.getDatapathId() == null) { - LOG.warn("DataPathId found as null for Bridge Augmentation: {}... retrying...", bridgeNew); - Optional 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); @@ -68,26 +55,13 @@ public class OvsInterfaceTopologyStateAddHelper { // 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 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 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; diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/statehelpers/OvsInterfaceTopologyStateRemoveHelper.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/statehelpers/OvsInterfaceTopologyStateRemoveHelper.java index dd4f25db..c607bff9 100644 --- a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/statehelpers/OvsInterfaceTopologyStateRemoveHelper.java +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/statehelpers/OvsInterfaceTopologyStateRemoveHelper.java @@ -1,5 +1,5 @@ /* - * 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, @@ -7,6 +7,7 @@ */ 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; @@ -31,22 +32,25 @@ public class OvsInterfaceTopologyStateRemoveHelper { public static List> removePortFromBridge(InstanceIdentifier bridgeIid, OvsdbBridgeAugmentation bridgeOld, DataBroker dataBroker) { List> 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 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 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 diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/statehelpers/OvsInterfaceTopologyStateUpdateHelper.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/statehelpers/OvsInterfaceTopologyStateUpdateHelper.java new file mode 100644 index 00000000..3ce9aece --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/statehelpers/OvsInterfaceTopologyStateUpdateHelper.java @@ -0,0 +1,100 @@ +/* + * 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> updateBridgeRefEntry(InstanceIdentifier bridgeIid, + OvsdbBridgeAugmentation bridgeNew, + OvsdbBridgeAugmentation bridgeOld, + DataBroker dataBroker) { + List> 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> updateTunnelState(DataBroker dataBroker, + OvsdbTerminationPointAugmentation terminationPointNew, + OvsdbTerminationPointAugmentation terminationPointOld) { + List> futures = new ArrayList>(); + + // 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 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 diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/utilities/SouthboundUtils.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/utilities/SouthboundUtils.java index 12100561..9fbd1b7d 100644 --- a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/utilities/SouthboundUtils.java +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/utilities/SouthboundUtils.java @@ -1,5 +1,5 @@ /* - * 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, @@ -12,12 +12,17 @@ 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.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; @@ -32,6 +37,7 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology. 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; @@ -41,6 +47,13 @@ import java.util.Map; 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, @@ -54,6 +67,27 @@ public class SouthboundUtils { 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 bridgeIid, + OvsdbBridgeAugmentation bridgeNew, + WriteTransaction writeTransaction){ + String bridgeName = bridgeNew.getBridgeName().getValue(); + LOG.debug("adding all ports to bridge: {}", bridgeName); + List 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 bridgeIid, OvsdbBridgeAugmentation bridgeAugmentation, DataBroker dataBroker, List> futures){ @@ -74,11 +108,12 @@ public class SouthboundUtils { 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); } } @@ -115,12 +150,30 @@ public class SouthboundUtils { 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 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 tpIid = createTerminationPointInstanceIdentifier( + InstanceIdentifier.keyOf(bridgeIid.firstIdentifierOf(Node.class)), portName); + LOG.debug("update bfd parameters for interface {}", tpIid); + OvsdbTerminationPointAugmentationBuilder tpAugmentationBuilder = new OvsdbTerminationPointAugmentationBuilder(); + List 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 options, IfTunnel ifTunnel, WriteTransaction t) { InstanceIdentifier tpIid = createTerminationPointInstanceIdentifier( InstanceIdentifier.keyOf(bridgeIid.firstIdentifierOf(Node.class)), portName); OvsdbTerminationPointAugmentationBuilder tpAugmentationBuilder = new OvsdbTerminationPointAugmentationBuilder(); @@ -148,11 +201,34 @@ public class SouthboundUtils { tpAugmentationBuilder.setVlanTag(new VlanId(vlanId)); } + + if( !ifTunnel.isInternal() && ifTunnel.getTunnelInterfaceType().equals(TunnelTypeVxlan.class) ) { + List 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 getBfdParams(IfTunnel ifTunnel) { + List 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 createTerminationPointInstanceIdentifier(Node node, @@ -185,4 +261,4 @@ public class SouthboundUtils { .child(Topology.class, new TopologyKey(OVSDB_TOPOLOGY_ID)) .child(Node.class,new NodeKey(nodeId)); } -} \ No newline at end of file +} diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/rpcservice/InterfaceManagerRpcService.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/rpcservice/InterfaceManagerRpcService.java index a4ce8b8c..53523c7b 100644 --- a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/rpcservice/InterfaceManagerRpcService.java +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/rpcservice/InterfaceManagerRpcService.java @@ -1,5 +1,5 @@ /* - * 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, @@ -20,7 +20,14 @@ import org.opendaylight.vpnservice.interfacemgr.IfmConstants; import org.opendaylight.vpnservice.interfacemgr.IfmUtil; import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils; import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceMetaUtils; -import org.opendaylight.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; @@ -60,6 +67,8 @@ public class InterfaceManagerRpcService implements OdlInterfaceRpcService { 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; @@ -205,7 +214,10 @@ public class InterfaceManagerRpcService implements OdlInterfaceRpcService { RpcResultBuilder rpcResultBuilder; try { List instructionInfo = new ArrayList(); - List actionInfo = IfmUtil.getEgressActionInfosForInterface(input.getIntfName(), 0, dataBroker); + List 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)); @@ -265,7 +277,10 @@ public class InterfaceManagerRpcService implements OdlInterfaceRpcService { public Future> getEgressActionsForInterface(GetEgressActionsForInterfaceInput input) { RpcResultBuilder rpcResultBuilder; try { - List actionsList = IfmUtil.getEgressActionsForInterface(input.getIntfName(), dataBroker); + LOG.debug("Get Egress Action for interface {} with key {}", input.getIntfName(), input.getTunnelKey()); + List actionsList = IfmUtil.getEgressActionsForInterface(input.getIntfName(), + input.getTunnelKey(), + dataBroker); GetEgressActionsForInterfaceOutputBuilder output = new GetEgressActionsForInterfaceOutputBuilder(). setAction(actionsList); rpcResultBuilder = RpcResultBuilder.success(); @@ -277,21 +292,6 @@ public class InterfaceManagerRpcService implements OdlInterfaceRpcService { return Futures.immediateFuture(rpcResultBuilder.build()); } - @Override - public Future> getEgressActions(GetEgressActionsInput input) { - RpcResultBuilder rpcResultBuilder; - try { - List 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> getPortFromInterface(GetPortFromInterfaceInput input) { @@ -358,48 +358,6 @@ public class InterfaceManagerRpcService implements OdlInterfaceRpcService { return Futures.immediateFuture(rpcResultBuilder.build()); } - public List getEgressActionInfosForInterface(String interfaceName) { - Interface interfaceInfo = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(new InterfaceKey(interfaceName), - dataBroker); - List listActionInfo = new ArrayList(); - 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 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 getEgressActionsForInterface(String interfaceName) { - List listActionInfo = getEgressActionInfosForInterface(interfaceName); - List actionsList = new ArrayList<>(); - for (ActionInfo actionInfo : listActionInfo) { - actionsList.add(actionInfo.buildAction()); - } - return actionsList; - } - protected static List buildInstructions(List listInstructionInfo) { if (listInstructionInfo != null) { List instructions = new ArrayList(); diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/servicebindings/flowbased/confighelpers/FlowBasedServicesConfigUnbindHelper.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/servicebindings/flowbased/confighelpers/FlowBasedServicesConfigUnbindHelper.java index 25b93c24..4fb67c69 100644 --- a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/servicebindings/flowbased/confighelpers/FlowBasedServicesConfigUnbindHelper.java +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/servicebindings/flowbased/confighelpers/FlowBasedServicesConfigUnbindHelper.java @@ -1,5 +1,5 @@ /* - * 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, @@ -56,8 +56,7 @@ public class FlowBasedServicesConfigUnbindHelper { 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 = servicesInfo.getBoundServices(); diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/statusanddiag/InterfaceStatusMonitor.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/statusanddiag/InterfaceStatusMonitor.java new file mode 100644 index 00000000..b1bd9428 --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/statusanddiag/InterfaceStatusMonitor.java @@ -0,0 +1,62 @@ +/* + * 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; + } +} diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/statusanddiag/InterfaceStatusMonitorMBean.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/statusanddiag/InterfaceStatusMonitorMBean.java new file mode 100644 index 00000000..947b30dc --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/statusanddiag/InterfaceStatusMonitorMBean.java @@ -0,0 +1,14 @@ +/* + * 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(); + +} diff --git a/interfacemgr/interfacemgr-impl/src/test/java/org/opendaylight/vpnservice/interfacemgr/test/InterfaceManagerTestUtil.java b/interfacemgr/interfacemgr-impl/src/test/java/org/opendaylight/vpnservice/interfacemgr/test/InterfaceManagerTestUtil.java index 47827d8f..9b1e0feb 100644 --- a/interfacemgr/interfacemgr-impl/src/test/java/org/opendaylight/vpnservice/interfacemgr/test/InterfaceManagerTestUtil.java +++ b/interfacemgr/interfacemgr-impl/src/test/java/org/opendaylight/vpnservice/interfacemgr/test/InterfaceManagerTestUtil.java @@ -1,5 +1,5 @@ /* - * 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, @@ -169,7 +169,7 @@ public class InterfaceManagerTestUtil { 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(); } diff --git a/interfacemgr/interfacemgr-impl/src/test/java/org/opendaylight/vpnservice/interfacemgr/test/TopologyStateInterfaceTest.java b/interfacemgr/interfacemgr-impl/src/test/java/org/opendaylight/vpnservice/interfacemgr/test/TopologyStateInterfaceTest.java index 914e8cf1..36649f99 100644 --- a/interfacemgr/interfacemgr-impl/src/test/java/org/opendaylight/vpnservice/interfacemgr/test/TopologyStateInterfaceTest.java +++ b/interfacemgr/interfacemgr-impl/src/test/java/org/opendaylight/vpnservice/interfacemgr/test/TopologyStateInterfaceTest.java @@ -128,8 +128,6 @@ public class TopologyStateInterfaceTest { 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")); @@ -152,6 +150,8 @@ public class TopologyStateInterfaceTest { @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")); diff --git a/interfacemgr/interfacemgr-shell/pom.xml b/interfacemgr/interfacemgr-shell/pom.xml new file mode 100644 index 00000000..d982b773 --- /dev/null +++ b/interfacemgr/interfacemgr-shell/pom.xml @@ -0,0 +1,41 @@ + + + + + + org.opendaylight.vpnservice + config-parent + 0.3.0-SNAPSHOT + ../../commons/config-parent + + + 4.0.0 + org.opendaylight.vpnservice + interfacemgr-shell + ${vpnservices.version} + bundle + + + org.opendaylight.vpnservice + interfacemgr-api + ${vpnservices.version} + + + org.opendaylight.vpnservice + interfacemgr-impl + ${vpnservices.version} + + + org.apache.karaf.shell + org.apache.karaf.shell.console + ${karaf.shell.console.version} + + + + diff --git a/interfacemgr/interfacemgr-shell/src/main/java/org/opendaylight/vpnservice/interfacemgr/shell/IfmCLIUtil.java b/interfacemgr/interfacemgr-shell/src/main/java/org/opendaylight/vpnservice/interfacemgr/shell/IfmCLIUtil.java new file mode 100644 index 00000000..d90f57e3 --- /dev/null +++ b/interfacemgr/interfacemgr-shell/src/main/java/org/opendaylight/vpnservice/interfacemgr/shell/IfmCLIUtil.java @@ -0,0 +1,108 @@ +/* + * 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(); + } +} diff --git a/interfacemgr/interfacemgr-shell/src/main/java/org/opendaylight/vpnservice/interfacemgr/shell/ShowVlan.java b/interfacemgr/interfacemgr-shell/src/main/java/org/opendaylight/vpnservice/interfacemgr/shell/ShowVlan.java new file mode 100644 index 00000000..788ec4bc --- /dev/null +++ b/interfacemgr/interfacemgr-shell/src/main/java/org/opendaylight/vpnservice/interfacemgr/shell/ShowVlan.java @@ -0,0 +1,45 @@ +/* + * 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 vlanList = interfaceManager.getVlanInterfaces(); + if (!vlanList.isEmpty()) { + IfmCLIUtil.showVlanHeaderOutput(); + } + for (Interface iface : vlanList) { + InterfaceInfo ifaceState = interfaceManager.getInterfaceInfoFromOperationalDataStore(iface.getName()); + IfmCLIUtil.showVlanOutput(ifaceState, iface); + } + return null; + } +} diff --git a/interfacemgr/interfacemgr-shell/src/main/java/org/opendaylight/vpnservice/interfacemgr/shell/ShowVxlan.java b/interfacemgr/interfacemgr-shell/src/main/java/org/opendaylight/vpnservice/interfacemgr/shell/ShowVxlan.java new file mode 100644 index 00000000..e6a490e0 --- /dev/null +++ b/interfacemgr/interfacemgr-shell/src/main/java/org/opendaylight/vpnservice/interfacemgr/shell/ShowVxlan.java @@ -0,0 +1,50 @@ +/* + * 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 vxlanList = interfaceManager.getVxlanInterfaces(); + if (!vxlanList.isEmpty()) { + IfmCLIUtil.showVxlanHeaderOutput(); + } + for (Interface iface : vxlanList) { + InterfaceInfo ifaceState = interfaceManager.getInterfaceInfoFromOperationalDataStore(iface.getName()); + IfmCLIUtil.showVxlanOutput(iface, ifaceState); + } + return null; + } +} diff --git a/interfacemgr/interfacemgr-shell/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/interfacemgr/interfacemgr-shell/src/main/resources/OSGI-INF/blueprint/blueprint.xml new file mode 100644 index 00000000..5c07298f --- /dev/null +++ b/interfacemgr/interfacemgr-shell/src/main/resources/OSGI-INF/blueprint/blueprint.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + diff --git a/interfacemgr/pom.xml b/interfacemgr/pom.xml index df21dfb3..9c97adb9 100644 --- a/interfacemgr/pom.xml +++ b/interfacemgr/pom.xml @@ -1,6 +1,6 @@ -- 2.36.6