Fixed a bug to block the creation of a static host on an ISL port, removed the code... 69/569/4
authorDiti Bhatia <dibhatia@cisco.com>
Fri, 5 Jul 2013 22:13:03 +0000 (15:13 -0700)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 11 Jul 2013 23:58:12 +0000 (23:58 +0000)
Change-Id: I600f6d51395b072b3d2bdb90d4fb10ad905fc6c7
Signed-off-by: Diti Bhatia <dibhatia@cisco.com>
opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTracker.java
opendaylight/northbound/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthbound.java
opendaylight/topologymanager/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java

index 446f51e..8468c5b 100644 (file)
@@ -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
index dbc99d0..642c5cc 100644 (file)
@@ -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.<br>
  * 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"),
index f9574b9..ce39fed 100644 (file)
@@ -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());
     }