Merge "sal-remote yang"
authorEd Warnicke <eaw@cisco.com>
Thu, 23 Jan 2014 23:42:08 +0000 (23:42 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 23 Jan 2014 23:42:08 +0000 (23:42 +0000)
opendaylight/clustering/services_implementation/src/main/java/org/opendaylight/controller/clustering/services_implementation/internal/ClusterManager.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DataPacketMuxDemux.java
opendaylight/web/devices/src/main/resources/js/page.js

index 83db4144007963a94e503a33345b1e641eadc2a0..e34eb329330d2e1b30ee72aac6950f2084894777 100644 (file)
@@ -13,6 +13,8 @@ import java.net.InetAddress;
 import java.net.NetworkInterface;
 import java.net.SocketException;
 import java.net.UnknownHostException;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.EnumSet;
 import java.util.Enumeration;
@@ -95,9 +97,20 @@ public class ClusterManager implements IClusterServices {
         InetAddress gossipRouterAddress = null;
         String supernodes_list = System.getProperty("supernodes",
                 loopbackAddress);
-        StringBuilder sanitized_supernodes_list = new StringBuilder();
+        /*
+         * Check the environment for the "container" variable, if this is set
+         * and is equal to "lxc", then ODL is running inside an lxc
+         * container, and address resolution of supernodes will be modified
+         * accordingly.
+         */
+        boolean inContainer = "lxc".equals(System.getenv("container"));
+        StringBuffer sanitized_supernodes_list = new StringBuffer();
         List<InetAddress> myAddresses = new ArrayList<InetAddress>();
 
+        if (inContainer) {
+            logger.trace("DOCKER: Resolving supernode host names using docker container semantics");
+        }
+
         StringTokenizer supernodes = new StringTokenizer(supernodes_list, ":");
         if (supernodes.hasMoreTokens()) {
             // Populate the list of my addresses
@@ -131,6 +144,34 @@ public class ClusterManager implements IClusterServices {
             }
             host = host_port.nextToken();
             InetAddress hostAddr;
+            /*
+             * If we are in a container and the hostname begins with a '+', this is
+             * an indication that we should resolve this host name in the context
+             * of a docker container.
+             *
+             * Specifically this means:
+             * '+self'   : self reference and the host will be mapped to the value of
+             *             HOSTNAME in the environment
+             * '+<name>' : references another container by its name. The docker established
+             *             environment variables will be used to resolve the host to an
+             *             IP address.
+             */
+            if (inContainer && host != null && host.charAt(0) == '+') {
+                if ("+self".equals(host)) {
+                    host = System.getenv("HOSTNAME");
+                } else {
+                    String link = System.getenv(host.substring(1).toUpperCase() + "_PORT");
+                    if (link != null) {
+                        try {
+                            host = new URI(link).getHost();
+                        } catch (URISyntaxException e) {
+                            logger.error("DOCKER: Unable to translate container reference ({}) to host IP Address, will attempt using normal host name",
+                                host.substring(1));
+                        }
+                    }
+                }
+            }
+
             try {
                 hostAddr = InetAddress.getByName(host);
             } catch (UnknownHostException ue) {
index a1fcd1ab23b7c5a8836d5ad1200533b5a08a03ec..5c2af6d8b430471d25f68a68c25e8915c9d02e97 100644 (file)
@@ -313,9 +313,13 @@ public class DataPacketMuxDemux implements IContainerListener,
         // build packet out
         OFPacketOut po = new OFPacketOut()
                 .setBufferId(OFPacketOut.BUFFER_ID_NONE)
-                .setInPort(OFPort.OFPP_NONE)
                 .setActions(Collections.singletonList((OFAction) action))
                 .setActionsLength((short) OFActionOutput.MINIMUM_LENGTH);
+        if(outPkt.getIncomingNodeConnector() != null) {
+            po.setInPort((Short)outPkt.getIncomingNodeConnector().getID());
+        } else {
+            po.setInPort(OFPort.OFPP_NONE);
+        }
 
         po.setLengthU(OFPacketOut.MINIMUM_LENGTH + po.getActionsLength()
                 + data.length);
index 855dc90aa9023208b41168c384806db16d86dae5..935354e304b204fb31ba1947424ef7912c3c6c02 100644 (file)
@@ -127,6 +127,7 @@ one.f.switchmanager.nodesLearnt = {
     }
   },
   modal : {
+    registry : { callback:undefined },
     initialize: {
       updateNode: function(evt) {
         one.f.switchmanager.nodesLearnt.ajax.main(one.f.switchmanager.rootUrl + "/tiers", function(tiers) {
@@ -151,7 +152,13 @@ one.f.switchmanager.nodesLearnt = {
 
           // inject body (nodePorts)
           one.lib.modal.inject.body($modal, $body);
-          $modal.modal();
+
+          $modal.modal().on("shown",function() {
+              var callback = one.f.switchmanager.nodesLearnt.modal.registry.callback;
+              if( callback !== undefined && $.isFunction(callback)) {
+                 callback();
+              }
+          });
         });
       },
       popout: function() {