Merge "Added support to generate interfaces from Choices and Cases."
authorAlessandro Boch <aboch@cisco.com>
Tue, 2 Jul 2013 19:58:09 +0000 (19:58 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 2 Jul 2013 19:58:09 +0000 (19:58 +0000)
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Latency.java
opendaylight/samples/simpleforwarding/pom.xml
opendaylight/samples/simpleforwarding/src/main/java/org/opendaylight/controller/samples/simpleforwarding/HostNodePair.java [moved from opendaylight/samples/simpleforwarding/src/main/java/org/opendaylight/controller/samples/simpleforwarding/internal/HostNodePair.java with 97% similarity]
opendaylight/samples/simpleforwarding/src/main/java/org/opendaylight/controller/samples/simpleforwarding/internal/SimpleForwardingImpl.java
opendaylight/samples/simpleforwarding/src/test/java/org/opendaylight/controller/samples/simpleforwarding/internal/HostSwitchTest.java
opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SpanConfig.java
opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SubnetConfig.java
opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SwitchConfig.java
opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImpl.java
opendaylight/web/root/src/main/resources/WEB-INF/jsp/main.jsp
opendaylight/web/root/src/main/resources/css/one.less

index 61e3872669b67f6a01f955bf2d15780635e0c84a..818002a21e042f87da32f5e14573e1b502ffc328 100644 (file)
@@ -9,6 +9,7 @@
 
 package org.opendaylight.controller.sal.core;
 
+import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
 /**
@@ -21,7 +22,9 @@ import javax.xml.bind.annotation.XmlRootElement;
 @XmlRootElement
 public class Latency extends Property {
     private static final long serialVersionUID = 1L;
-    private long latency;
+
+    @XmlElement
+    private long latencyValue;
 
     public static final long LATENCYUNK = 0;
     public static final long LATENCY1ns = (long) Math.pow(10, 3);
@@ -40,37 +43,37 @@ public class Latency extends Property {
      */
     private Latency() {
         super(LatencyPropName);
-        this.latency = LATENCYUNK;
+        this.latencyValue = LATENCYUNK;
     }
 
     public Latency(long latency) {
         super(LatencyPropName);
-        this.latency = latency;
+        this.latencyValue = latency;
     }
 
     public Latency(int latency) {
         super(LatencyPropName);
-        this.latency = (long) latency;
+        this.latencyValue = (long) latency;
     }
 
     public Latency(short latency) {
         super(LatencyPropName);
-        this.latency = (long) latency;
+        this.latencyValue = (long) latency;
     }
 
     public Latency clone() {
-        return new Latency(this.latency);
+        return new Latency(this.latencyValue);
     }
 
     public long getValue() {
-        return this.latency;
+        return this.latencyValue;
     }
 
     @Override
     public int hashCode() {
         final int prime = 31;
         int result = super.hashCode();
-        result = prime * result + (int) (latency ^ (latency >>> 32));
+        result = prime * result + (int) (latencyValue ^ (latencyValue >>> 32));
         return result;
     }
 
@@ -83,7 +86,7 @@ public class Latency extends Property {
         if (getClass() != obj.getClass())
             return false;
         Latency other = (Latency) obj;
-        if (latency != other.latency)
+        if (latencyValue != other.latencyValue)
             return false;
         return true;
     }
@@ -93,16 +96,16 @@ public class Latency extends Property {
         StringBuffer sb = new StringBuffer();
 
         sb.append("Latency[");
-        if (this.latency == 0) {
+        if (this.latencyValue == 0) {
             sb.append("UnKnown");
-        } else if (this.latency < LATENCY1ns) {
-            sb.append(this.latency + "psec");
-        } else if (this.latency < LATENCY1us) {
-            sb.append(Long.toString(this.latency / LATENCY1ns) + "nsec");
-        } else if (this.latency < LATENCY1ms) {
-            sb.append(Long.toString(this.latency / LATENCY1us) + "usec");
-        } else if (this.latency < LATENCY1s) {
-            sb.append(Long.toString(this.latency / LATENCY1ms) + "msec");
+        } else if (this.latencyValue < LATENCY1ns) {
+            sb.append(this.latencyValue + "psec");
+        } else if (this.latencyValue < LATENCY1us) {
+            sb.append(Long.toString(this.latencyValue / LATENCY1ns) + "nsec");
+        } else if (this.latencyValue < LATENCY1ms) {
+            sb.append(Long.toString(this.latencyValue / LATENCY1us) + "usec");
+        } else if (this.latencyValue < LATENCY1s) {
+            sb.append(Long.toString(this.latencyValue / LATENCY1ms) + "msec");
         }
 
         sb.append("]");
index fd288c71276e3669ea30adffb12c5f89248aa9a5..14e440df029f1bb71b901a647d12c2cf548b617e 100644 (file)
@@ -40,6 +40,9 @@
               org.slf4j,
               org.apache.felix.dm
             </Import-Package>
+            <Export-Package>
+              org.opendaylight.controller.sample.simpleforwarding
+            </Export-Package>
             <Bundle-Activator>
               org.opendaylight.controller.samples.simpleforwarding.internal.Activator
             </Bundle-Activator>
index 11056478dbf1742ec48e5cc6bbf9ec3bf01ad56a..7f4c98a6483969fabfd14f6bc54219873ae00cd8 100644 (file)
@@ -50,12 +50,15 @@ import org.opendaylight.controller.sal.routing.IRouting;
 import org.opendaylight.controller.sal.utils.EtherTypes;
 import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
 import org.opendaylight.controller.sal.utils.Status;
+import org.opendaylight.controller.samples.simpleforwarding.HostNodePair;
 import org.opendaylight.controller.switchmanager.IInventoryListener;
 import org.opendaylight.controller.switchmanager.ISwitchManager;
 import org.opendaylight.controller.topologymanager.ITopologyManager;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+
+
 public class SimpleForwardingImpl implements IfNewHostNotify,
         IListenRoutingUpdates, IInventoryListener {
     private static Logger log = LoggerFactory
index afa4c42d36095072371dafc09c171fd9b6ebb587..7897c398909a48a02cd0221279cf51d054bbaa6c 100644 (file)
@@ -18,7 +18,8 @@ import org.junit.Assert;
 import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector;
 import org.opendaylight.controller.sal.core.ConstructionException;
 import org.opendaylight.controller.sal.utils.NodeCreator;
-import org.opendaylight.controller.samples.simpleforwarding.internal.HostNodePair;
+import org.opendaylight.controller.samples.simpleforwarding.HostNodePair;
+
 
 public class HostSwitchTest {
     @Test
index 80ed20981961b56e21d397575ea09c2712190cdd..83cb8b1cc9786f42757e1f609dedf724943c0f19 100644 (file)
@@ -150,4 +150,9 @@ public class SpanConfig implements Serializable {
     public boolean matchNode(String nodeId) {
         return this.nodeId.equals(nodeId);
     }
+
+    @Override
+    public String toString() {
+        return ("Span Config [nodeId=" + nodeId + " spanPort=" + spanPort + "]");
+    }
 }
index 87dd99da7f80736c76fc2e31765e84d46667fd35..895f117321a6c61645742e425bcf0ad2d0af6cbd 100644 (file)
@@ -231,6 +231,7 @@ public class SubnetConfig implements Serializable {
         nodePorts.remove(sp);
     }
 
+    @Override
     public String toString() {
         return ("Subnet Config [Description=" + name + " Subnet=" + subnet
                 + " NodeConnectors=" + nodePorts + "]");
index 253096edc34116ed4cc9474624f9711f90efa13a..61b2f0a3a8edf0a00a7a783d088b4751e379859a 100644 (file)
@@ -97,4 +97,10 @@ public class SwitchConfig implements Serializable {
             return false;
         return true;
     }
+
+    @Override
+    public String toString() {
+        return ("Switch Config [Node=" + nodeId + " Description=" + description +
+                " Tier=" + tier + " Mode=" + mode + "]");
+    }
 }
index ab3149610309b08f314b9cee1ca85a6998063a5c..d32f98650b8b549ce8235fd3c14d22c55205ac56 100644 (file)
@@ -52,14 +52,14 @@ import org.opendaylight.controller.sal.core.Tier;
 import org.opendaylight.controller.sal.core.UpdateType;
 import org.opendaylight.controller.sal.inventory.IInventoryService;
 import org.opendaylight.controller.sal.inventory.IListenInventoryUpdates;
-import org.opendaylight.controller.sal.utils.HexEncode;
-import org.opendaylight.controller.sal.utils.StatusCode;
 import org.opendaylight.controller.sal.utils.GlobalConstants;
+import org.opendaylight.controller.sal.utils.HexEncode;
 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.ServiceHelper;
 import org.opendaylight.controller.sal.utils.Status;
+import org.opendaylight.controller.sal.utils.StatusCode;
 import org.opendaylight.controller.switchmanager.IInventoryListener;
 import org.opendaylight.controller.switchmanager.ISpanAware;
 import org.opendaylight.controller.switchmanager.ISwitchManager;
@@ -174,7 +174,7 @@ CommandProvider {
 
     public void startUp() {
         // Initialize configuration file names
-        subnetFileName = ROOT + "subnets" + this.getContainerName() + ".conf";
+        subnetFileName = ROOT + "subnets_" + this.getContainerName() + ".conf";
         spanFileName = ROOT + "spanPorts_" + this.getContainerName() + ".conf";
         switchConfigFileName = ROOT + "switchConfig_" + this.getContainerName()
                 + ".conf";
@@ -201,7 +201,6 @@ CommandProvider {
     }
 
     public void shutDown() {
-        destroyCaches(this.getContainerName());
     }
 
     @SuppressWarnings("deprecation")
@@ -499,11 +498,13 @@ CommandProvider {
         }
 
         conf.addNodeConnectors(switchPorts);
+        subnetsConfigList.put(name, conf);
 
         // Update Database
         Subnet sub = subnets.get(conf.getIPnum());
         Set<NodeConnector> sp = conf.getNodeConnectors(switchPorts);
         sub.addNodeConnectors(sp);
+        subnets.put(conf.getIPnum(), sub);
         return new Status(StatusCode.SUCCESS, null);
     }
 
@@ -515,11 +516,13 @@ CommandProvider {
             return new Status(StatusCode.NOTFOUND, "Subnet does not exist");
         }
         conf.removeNodeConnectors(switchPorts);
+        subnetsConfigList.put(name, conf);
 
         // Update Database
         Subnet sub = subnets.get(conf.getIPnum());
         Set<NodeConnector> sp = conf.getNodeConnectors(switchPorts);
         sub.deleteNodeConnectors(sp);
+        subnets.put(conf.getIPnum(), sub);
         return new Status(StatusCode.SUCCESS, null);
     }
 
@@ -554,7 +557,7 @@ CommandProvider {
     @SuppressWarnings("unchecked")
     private void loadSubnetConfiguration() {
         ObjectReader objReader = new ObjectReader();
-        ConcurrentMap<Integer, SubnetConfig> confList = (ConcurrentMap<Integer, SubnetConfig>) objReader
+        ConcurrentMap<String, SubnetConfig> confList = (ConcurrentMap<String, SubnetConfig>) objReader
                 .read(this, subnetFileName);
 
         if (confList == null) {
@@ -598,6 +601,11 @@ CommandProvider {
 
     @Override
     public void updateSwitchConfig(SwitchConfig cfgObject) {
+        // update default container only
+        if (!isDefaultContainer) {
+            return;
+        }
+
         boolean modeChange = false;
 
         SwitchConfig sc = nodeConfigList.get(cfgObject.getNodeId());
@@ -607,28 +615,25 @@ CommandProvider {
 
         nodeConfigList.put(cfgObject.getNodeId(), cfgObject);
         try {
-            // update default container only
-            if (isDefaultContainer) {
-                String nodeId = cfgObject.getNodeId();
-                Node node = Node.fromString(nodeId);
-                Map<String, Property> propMap;
-                if (nodeProps.get(node) != null) {
-                    propMap = nodeProps.get(node);
-                } else {
-                    propMap = new HashMap<String, Property>();
-                }
-                Property desc = new Description(cfgObject.getNodeDescription());
-                propMap.put(desc.getName(), desc);
-                Property tier = new Tier(Integer.parseInt(cfgObject.getTier()));
-                propMap.put(tier.getName(), tier);
-                addNodeProps(node, propMap);
+            String nodeId = cfgObject.getNodeId();
+            Node node = Node.fromString(nodeId);
+            Map<String, Property> propMap;
+            if (nodeProps.get(node) != null) {
+                propMap = nodeProps.get(node);
+            } else {
+                propMap = new HashMap<String, Property>();
+            }
+            Property desc = new Description(cfgObject.getNodeDescription());
+            propMap.put(desc.getName(), desc);
+            Property tier = new Tier(Integer.parseInt(cfgObject.getTier()));
+            propMap.put(tier.getName(), tier);
+            addNodeProps(node, propMap);
 
-                log.info("Set Node {}'s Mode to {}", nodeId,
-                        cfgObject.getMode());
+            log.info("Set Node {}'s Mode to {}", nodeId,
+                    cfgObject.getMode());
 
-                if (modeChange) {
-                    notifyModeChange(node, cfgObject.isProactive());
-                }
+            if (modeChange) {
+                notifyModeChange(node, cfgObject.isProactive());
             }
         } catch (Exception e) {
             log.debug("updateSwitchConfig: {}", e.getMessage());
@@ -1333,17 +1338,26 @@ CommandProvider {
             return;
         }
 
-        nodeProps = this.inventoryService.getNodeProps();
-        Set<Node> nodeSet = nodeProps.keySet();
-        if (nodeSet != null) {
-            for (Node node : nodeSet) {
-                log.debug("getInventories: {} added for container {}",
-                        new Object[] { node, containerName });
-                addNode(node, null);
+        Map<Node, Map<String, Property>> nodeProp = this.inventoryService.getNodeProps();
+        for(Map.Entry<Node, Map<String, Property>> entry : nodeProp.entrySet()) {
+            Node node = entry.getKey();
+            log.debug("getInventories: {} added for container {}",
+                    new Object[] { node, containerName });
+            Map<String, Property> propMap = entry.getValue();
+            Set<Property> props = new HashSet<Property>();
+            for(Property property : propMap.values()) {
+                props.add(property);
             }
+            addNode(node, props);
         }
 
-        nodeConnectorProps = inventoryService.getNodeConnectorProps();
+        Map<NodeConnector, Map<String, Property>> nodeConnectorProp = this.inventoryService.getNodeConnectorProps();
+        for(Map.Entry<NodeConnector, Map<String, Property>> entry : nodeConnectorProp.entrySet()) {
+            Map<String, Property> propMap = entry.getValue();
+            for(Property property : propMap.values()) {
+                addNodeConnectorProp(entry.getKey(), property);
+            }
+        }
     }
 
     private void clearInventories() {
index 863b0a64a04b6e2f32abfaf50bc78adf7965236b..a532560bcde4b3166cf42c7f7bc8e62fc83ef068 100644 (file)
   <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal"
     aria-hidden="true">&times;</button>
+   <button type="button" class="help" aria-hidden="true"
+    >?</button>
    <h3></h3>
   </div>
   <div class="modal-body"></div>
index cb6fbc54fce32f897c65c05512a785be7f018351..b5ab76f323a557278bdb4dd5fe70d7a040678f0b 100644 (file)
 .table-cursor tr:hover {
        cursor: pointer;
 }
+
+// hide
+.modal {
+       .help {
+               display: none;
+       }
+}
\ No newline at end of file