From: Martin Sunal Date: Wed, 27 Aug 2014 14:47:36 +0000 (+0200) Subject: Removed implementation of RPC get-node-ip-address X-Git-Tag: release/helium~70 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=0fae30104464c435b8f9da8e19db47db3670f45b;p=openflowplugin.git Removed implementation of RPC get-node-ip-address implementation of RPC get-node-ip-address from flow-node-inventory is removed. This RPC is not needed anymore. IP address is stored in datastore. Signed-off-by: Martin Sunal --- diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/ModelDrivenSwitch.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/ModelDrivenSwitch.java index 2a06cd88cd..06350308b4 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/ModelDrivenSwitch.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/ModelDrivenSwitch.java @@ -9,7 +9,6 @@ package org.opendaylight.openflowplugin.openflow.md; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowNodeInventoryService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService; @@ -44,7 +43,6 @@ public interface ModelDrivenSwitch extends // OpendaylightPortStatisticsService, // OpendaylightFlowTableStatisticsService, // OpendaylightQueueStatisticsService, // - FlowNodeInventoryService, Identifiable> { /** diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/AbstractModelDrivenSwitch.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/AbstractModelDrivenSwitch.java index 5dada33e68..e3db0982a1 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/AbstractModelDrivenSwitch.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/AbstractModelDrivenSwitch.java @@ -11,7 +11,6 @@ import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderCo import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; import org.opendaylight.openflowplugin.openflow.md.ModelDrivenSwitch; import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowNodeInventoryService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService; @@ -61,8 +60,6 @@ public abstract class AbstractModelDrivenSwitch implements ModelDrivenSwitch { private RoutedRpcRegistration queueStatisticsRegistration; - private RoutedRpcRegistration flowNodeInventoryRegistration; - protected final SessionContext sessionContext; protected AbstractModelDrivenSwitch(InstanceIdentifier identifier,SessionContext conductor) { @@ -128,10 +125,6 @@ public abstract class AbstractModelDrivenSwitch implements ModelDrivenSwitch { queueStatisticsRegistration.registerPath(NodeContext.class, getIdentifier()); builder.add(queueStatisticsRegistration); - flowNodeInventoryRegistration = ctx.addRoutedRpcImplementation(FlowNodeInventoryService.class, this); - flowNodeInventoryRegistration.registerPath(NodeContext.class, getIdentifier()); - builder.add(flowNodeInventoryRegistration); - return builder.toInstance(); } diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/ModelDrivenSwitchImpl.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/ModelDrivenSwitchImpl.java index 8c7e0633f8..10247a54c6 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/ModelDrivenSwitchImpl.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/ModelDrivenSwitchImpl.java @@ -7,10 +7,6 @@ */ package org.opendaylight.openflowplugin.openflow.md.core.sal; -import java.net.Inet4Address; -import java.net.Inet6Address; -import java.net.InetAddress; -import java.net.InetSocketAddress; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; @@ -21,12 +17,6 @@ import org.opendaylight.openflowplugin.openflow.md.core.session.IMessageDispatch import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil; import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext; import org.opendaylight.openflowplugin.openflow.md.core.session.SwitchConnectionCookieOFImpl; -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.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.GetNodeIpAddressInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.GetNodeIpAddressOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.GetNodeIpAddressOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput; @@ -94,7 +84,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.Upd import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutput; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; import com.google.common.util.concurrent.Futures; @@ -531,36 +520,4 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch { ListenableFuture> result = task.submit(); return result; } - - @Override - public Future> getNodeIpAddress(GetNodeIpAddressInput input) { - if (!sessionContext.isValid()) { - return Futures.immediateFuture(RpcResultBuilder - . failed() - .withError(org.opendaylight.yangtools.yang.common.RpcError.ErrorType.TRANSPORT, - "Session is not valid.").build()); - } - InetSocketAddress remoteAddress = sessionContext.getPrimaryConductor().getConnectionAdapter() - .getRemoteAddress(); - if (remoteAddress == null) { - return Futures.immediateFuture(RpcResultBuilder - . failed() - .withError(org.opendaylight.yangtools.yang.common.RpcError.ErrorType.TRANSPORT, - "No connection with switch.").build()); - } - IpAddress ipAddress = resolveIpAddress(remoteAddress.getAddress()); - GetNodeIpAddressOutput result = new GetNodeIpAddressOutputBuilder().setIpAddress(ipAddress).build(); - return Futures.immediateFuture(RpcResultBuilder. success(result).build()); - } - - private static IpAddress resolveIpAddress(InetAddress address) { - String hostAddress = address.getHostAddress(); - if (address instanceof Inet4Address) { - return new IpAddress(new Ipv4Address(hostAddress)); - } - if (address instanceof Inet6Address) { - return new IpAddress(new Ipv6Address(hostAddress)); - } - throw new IllegalArgumentException("Unsupported IP address type!"); - } } diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/SalRegistrationManager.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/SalRegistrationManager.java index 27cc0bdb74..a426e283ad 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/SalRegistrationManager.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/SalRegistrationManager.java @@ -8,7 +8,12 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal; import java.math.BigInteger; +import java.net.Inet4Address; +import java.net.Inet6Address; +import java.net.InetAddress; +import java.net.InetSocketAddress; import java.util.Collection; +import java.util.concurrent.Future; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; import org.opendaylight.controller.sal.binding.api.NotificationProviderService; @@ -20,11 +25,15 @@ import org.opendaylight.openflowplugin.openflow.md.core.session.SessionListener; import org.opendaylight.openflowplugin.openflow.md.core.session.SessionManager; import org.opendaylight.openflowplugin.openflow.md.core.session.SwitchSessionKeyOF; import org.opendaylight.openflowplugin.openflow.md.lldp.LLDPSpeaker; +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.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdated; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdatedBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.GetNodeIpAddressInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.GetNodeIpAddressInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.GetNodeIpAddressOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.GetNodeIpAddressOutputBuilder; 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.NodeRemoved; @@ -40,6 +49,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -125,29 +135,36 @@ public class SalRegistrationManager implements SessionListener, AutoCloseable { builder.setId(sw.getNodeId()); builder.setNodeRef(nodeRef); FlowCapableNodeUpdatedBuilder builder2 = new FlowCapableNodeUpdatedBuilder(); - setIpAddressToBuilder(builder2, sw, nodeRef); + builder2.setIpAddress(getIpAddressOf(sw)); builder2.setSwitchFeatures(swFeaturesUtil.buildSwitchFeatures(features)); builder.addAugmentation(FlowCapableNodeUpdated.class, builder2.build()); return builder.build(); } - private void setIpAddressToBuilder(FlowCapableNodeUpdatedBuilder builder, ModelDrivenSwitch sw, NodeRef nodeRef) { - GetNodeIpAddressInput rpcInputGetIpAddress = new GetNodeIpAddressInputBuilder().setNode(nodeRef).build(); - RpcResult rpcResultGetIpAddress = Futures.getUnchecked(sw - .getNodeIpAddress(rpcInputGetIpAddress)); - if (rpcResultGetIpAddress.isSuccessful()) { - builder.setIpAddress(rpcResultGetIpAddress.getResult().getIpAddress()); - } else { - printRpcErrors(rpcResultGetIpAddress.getErrors()); + private IpAddress getIpAddressOf(ModelDrivenSwitch sw) { + SessionContext sessionContext = sw.getSessionContext(); + if (!sessionContext.isValid()) { + LOG.warn("IP address of the node {} cannot be obtained. Session is not valid.", sw.getNodeId()); + return null; } + InetSocketAddress remoteAddress = sessionContext.getPrimaryConductor().getConnectionAdapter() + .getRemoteAddress(); + if (remoteAddress == null) { + LOG.warn("IP address of the node {} cannot be obtained. No connection with switch.", sw.getNodeId()); + return null; + } + return resolveIpAddress(remoteAddress.getAddress()); } - private static void printRpcErrors(Collection rpcErrors) { - if (rpcErrors != null) { - for (RpcError error : rpcErrors) { - LOG.warn("{}", error); - } + private static IpAddress resolveIpAddress(InetAddress address) { + String hostAddress = address.getHostAddress(); + if (address instanceof Inet4Address) { + return new IpAddress(new Ipv4Address(hostAddress)); + } + if (address instanceof Inet6Address) { + return new IpAddress(new Ipv6Address(hostAddress)); } + throw new IllegalArgumentException("Unsupported IP address type!"); } private NodeRemoved nodeRemoved(NodeRef nodeRef) {