From: Diti Bhatia Date: Fri, 5 Jul 2013 22:13:03 +0000 (-0700) Subject: Fixed a bug to block the creation of a static host on an ISL port, removed the code... X-Git-Tag: releasepom-0.1.0~288 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=934490635d3a1c4ebd27703d33f382ae7d676a4f;hp=-c Fixed a bug to block the creation of a static host on an ISL port, removed the code to block more than one host per port Change-Id: I600f6d51395b072b3d2bdb90d4fb10ad905fc6c7 Signed-off-by: Diti Bhatia --- 934490635d3a1c4ebd27703d33f382ae7d676a4f diff --git a/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTracker.java b/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTracker.java index 446f51eb04..8468c5b284 100644 --- a/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTracker.java +++ b/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTracker.java @@ -1018,7 +1018,6 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw if (nc == null) { return new Status(StatusCode.BADREQUEST, "Invalid NodeConnector"); } - HostNodeConnector host = null; try { host = new HostNodeConnector(dataLayerAddress, networkAddr, nc, vlan); @@ -1036,6 +1035,14 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw return new Status(StatusCode.CONFLICT, "Existing IP, Use PUT to update"); } host.setStaticHost(true); + /* + * Check if the nc is an ISL port + */ + if (topologyManager != null) { + if (topologyManager.isInternal(nc)) { + return new Status(StatusCode.BADREQUEST, "Cannot add host on ISL port"); + } + } /* * Before adding host, Check if the switch and the port have already * come up diff --git a/opendaylight/northbound/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthbound.java b/opendaylight/northbound/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthbound.java index dbc99d06e4..642c5ccbaa 100644 --- a/opendaylight/northbound/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthbound.java +++ b/opendaylight/northbound/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthbound.java @@ -10,8 +10,8 @@ package org.opendaylight.controller.hosttracker.northbound; import java.net.InetAddress; import java.net.UnknownHostException; -import java.security.Principal; import java.util.List; + import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.DefaultValue; @@ -40,6 +40,7 @@ import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailab import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException; import org.opendaylight.controller.northbound.commons.exception.UnsupportedMediaTypeException; import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils; +import org.opendaylight.controller.sal.authorization.Privilege; import org.opendaylight.controller.sal.core.Node; import org.opendaylight.controller.sal.core.NodeConnector; import org.opendaylight.controller.sal.utils.GlobalConstants; @@ -48,8 +49,6 @@ import org.opendaylight.controller.sal.utils.Status; import org.opendaylight.controller.sal.utils.StatusCode; import org.opendaylight.controller.switchmanager.ISwitchManager; -import org.opendaylight.controller.sal.authorization.Privilege; - /** * Host Tracker Northbound REST APIs.
* This class provides REST APIs to track host location in a network. Host @@ -261,7 +260,7 @@ public class HostTrackerNorthbound { @POST @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @StatusCodes({ - @ResponseCode(code = 201, condition = "Flow Config processed successfully"), + @ResponseCode(code = 201, condition = "Static host created successfully"), @ResponseCode(code = 404, condition = "The Container Name or nodeId or configuration name is not found"), @ResponseCode(code = 406, condition = "Cannot operate on Default Container when other Containers are active"), @ResponseCode(code = 415, condition = "Invalid IP Address passed in networkAddress parameter"), diff --git a/opendaylight/topologymanager/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java b/opendaylight/topologymanager/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java index f9574b993c..ce39fed5fc 100644 --- a/opendaylight/topologymanager/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java +++ b/opendaylight/topologymanager/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java @@ -18,9 +18,9 @@ import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Set; -import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -33,25 +33,22 @@ import org.opendaylight.controller.clustering.services.CacheExistException; import org.opendaylight.controller.clustering.services.IClusterContainerServices; import org.opendaylight.controller.clustering.services.IClusterServices; import org.opendaylight.controller.configuration.IConfigurationContainerAware; -import org.opendaylight.controller.sal.core.ConstructionException; import org.opendaylight.controller.sal.core.Edge; import org.opendaylight.controller.sal.core.Host; import org.opendaylight.controller.sal.core.Node; import org.opendaylight.controller.sal.core.NodeConnector; -import org.opendaylight.controller.sal.core.NodeConnector.NodeConnectorIDType; import org.opendaylight.controller.sal.core.Property; import org.opendaylight.controller.sal.core.TimeStamp; import org.opendaylight.controller.sal.core.UpdateType; -import org.opendaylight.controller.sal.core.Node.NodeIDType; import org.opendaylight.controller.sal.topology.IListenTopoUpdates; import org.opendaylight.controller.sal.topology.ITopologyService; import org.opendaylight.controller.sal.topology.TopoEdgeUpdate; -import org.opendaylight.controller.sal.utils.StatusCode; import org.opendaylight.controller.sal.utils.GlobalConstants; import org.opendaylight.controller.sal.utils.IObjectReader; import org.opendaylight.controller.sal.utils.ObjectReader; import org.opendaylight.controller.sal.utils.ObjectWriter; import org.opendaylight.controller.sal.utils.Status; +import org.opendaylight.controller.sal.utils.StatusCode; import org.opendaylight.controller.topologymanager.ITopologyManager; import org.opendaylight.controller.topologymanager.ITopologyManagerAware; import org.opendaylight.controller.topologymanager.TopologyUserLinkConfig; @@ -429,6 +426,8 @@ CommandProvider { if (this.hostsDB == null) { return null; } + if (this.hostsDB.get(p) == null) + return null; return (this.hostsDB.get(p).getLeft()); }