You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mu...@apache.org on 2014/06/17 14:25:37 UTC

git commit: updated refs/heads/master to 70a114c

Repository: cloudstack
Updated Branches:
  refs/heads/master 591148c46 -> 70a114c3a


CLOUDSTACK-6925: [OVS] get rid custom logic to create bridges on hosts
in the XenServer pool for GRE tunnel networks

Fix uses XenServer recommended way
Network.other_config:assume_network_is_shared=true
which ensures bridge is created automatically on hosts in the pool for
GRE tunnel networks. Fix also gets rid of  error prone custom logic that ensures
bridge is created by plugging a VIF into the dom0 and connected to
GRE tunnel network.

Conflicts:
	plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/70a114c3
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/70a114c3
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/70a114c3

Branch: refs/heads/master
Commit: 70a114c3a8754f1845c128f3c3a2d1fd961dc779
Parents: 591148c
Author: Murali Reddy <mu...@gmail.com>
Authored: Tue Jun 17 17:31:40 2014 +0530
Committer: Murali Reddy <mu...@gmail.com>
Committed: Tue Jun 17 17:54:12 2014 +0530

----------------------------------------------------------------------
 .../xenserver/resource/CitrixResourceBase.java  | 82 +-------------------
 1 file changed, 4 insertions(+), 78 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/70a114c3/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
index 9979802..af76760 100644
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
@@ -893,76 +893,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
         throw new CloudRuntimeException("Unsupported network type: " + type);
     }
 
-    /**
-     * This is a tricky to create network in xenserver.
-     * if you create a network then create bridge by brctl or openvswitch yourself,
-     * then you will get an expection that is "REQUIRED_NETWROK" when you start a
-     * vm with this network. The soultion is, create a vif of dom0 and plug it in
-     * network, xenserver will create the bridge on behalf of you. But we can not keep the dom0 vif for the entire
-     * existence of network, as we will seen reach max VIF (8) that can be conencted to a domain. So as soon as we have
-     * one more VIF for any of the VM, delete dom0 VIF so that we can scale beyond 8 networks on a host.
-     * @throws XmlRpcException
-     * @throws XenAPIException
-     */
-    private void enableXenServerNetwork(Connection conn, Network nw, String vifNameLabel, String networkDesc) throws XenAPIException, XmlRpcException {
-        /* Make sure there is a physical bridge on this network */
-        VIF dom0vif = null;
-        Pair<VM, VM.Record> vm = getControlDomain(conn);
-        VM dom0 = vm.first();
-        // Create a VIF unless there's not already another VIF
-        Set<VIF> dom0Vifs = dom0.getVIFs(conn);
-        for (VIF vif : dom0Vifs) {
-            vif.getRecord(conn);
-            if (vif.getNetwork(conn).getUuid(conn).equals(nw.getUuid(conn))) {
-                dom0vif = vif;
-                s_logger.debug("A VIF for dom0 has already been found - No need to create one");
-            }
-        }
-
-        int domuVifCount=0;
-        Set<VIF> domUVifs = nw.getVIFs(conn);
-        Host host = Host.getByUuid(conn, _host.uuid);
-        for (VIF vif : domUVifs) {
-            vif.getRecord(conn);
-            if (vif.getVM(conn).getResidentOn(conn).equals(host)) {
-                domuVifCount++;
-            }
-        }
-
-        if (dom0vif == null && domuVifCount == 0) {
-            s_logger.debug("Create a vif on dom0 for " + networkDesc);
-            VIF.Record vifr = new VIF.Record();
-            vifr.VM = dom0;
-            vifr.device = getLowestAvailableVIFDeviceNum(conn, dom0);
-            if (vifr.device == null) {
-                s_logger.debug("Failed to create " + networkDesc + ", no vif available");
-                return;
-            }
-            Map<String, String> config = new HashMap<String, String>();
-            config.put("nameLabel", vifNameLabel);
-            vifr.otherConfig = config;
-            vifr.MAC = "FE:FF:FF:FF:FF:FF";
-            vifr.network = nw;
-
-            vifr.lockingMode = Types.VifLockingMode.NETWORK_DEFAULT;
-            dom0vif = VIF.create(conn, vifr);
-            synchronized (_tmpDom0Vif) {
-                _tmpDom0Vif.add(dom0vif);
-            }
-            try {
-                dom0vif.plug(conn);
-            } catch (Exception e) {
-                // though an exception is thrown here, VIF actually gets plugged-in to dom0, so just ignore the exception
-            }
-            dom0vif.unplug(conn);
-        }
-
-        if (dom0vif != null && domuVifCount > 1) {
-            // now that there is at least one more VIF (other than dom0 vif) destroy dom0 VIF
-            dom0vif.destroy(conn);
-        }
-    }
-
     private synchronized Network setupvSwitchNetwork(Connection conn) {
         try {
             if (_host.vswitchNetwork == null) {
@@ -978,8 +908,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
                 } else {
                     vswitchNw = networks.iterator().next();
                 }
-                if (!is_xcp())
-                    enableXenServerNetwork(conn, vswitchNw, "vswitch", "vswitch network");
                 _host.vswitchNetwork = vswitchNw;
             }
             return _host.vswitchNetwork;
@@ -1003,21 +931,20 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
             Network.Record rec = new Network.Record();
             Set<Network> networks = Network.getByNameLabel(conn, nwName);
 
-
             if (networks.size() == 0) {
                 rec.nameDescription = "tunnel network id# " + nwName;
                 rec.nameLabel = nwName;
                 //Initialize the ovs-host-setup to avoid error when doing get-param in plugin
                 Map<String, String> otherConfig = new HashMap<String, String>();
                 otherConfig.put("ovs-host-setup", "");
+                // Mark 'internal network' as shared so bridge gets automatically created on each host in the cluster
+                // when VM with vif connected to this internal network is started
+                otherConfig.put("assume_network_is_shared", "true");
                 rec.otherConfig = otherConfig;
                 nw = Network.create(conn, rec);
-                // Plug dom0 vif only when creating network
-                enableXenServerNetwork(conn, nw, nwName, "tunnel network for account " + nwName);
                 s_logger.debug("### XenServer network for tunnels created:" + nwName);
             } else {
                 nw = networks.iterator().next();
-                enableXenServerNetwork(conn, nw, nwName, "tunnel network for account " + nwName);
                 s_logger.debug("XenServer network for tunnels found:" + nwName);
             }
             return nw;
@@ -1048,9 +975,8 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
                     }
                 }
             }
+
             if (!configured) {
-                // Plug dom0 vif only if not done before for network and host
-                enableXenServerNetwork(conn, nw, nwName, "tunnel network for account " + bridgeName);
                 String result;
                 if (bridgeName.startsWith("OVS-DR-VPC-Bridge")) {
                     result = callHostPlugin(conn, "ovstunnel", "setup_ovs_bridge_for_distributed_routing", "bridge", bridge,