cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wid...@apache.org
Subject [53/59] [abbrv] git commit: updated refs/heads/disk-cache to bbae6f8
Date Wed, 25 Sep 2013 10:29:48 GMT
CLOUDSTACK-4405: fix vm migration during the upgrade to 4.2

Signed-off-by: Wei Zhou <w.zhou@leaseweb.com>


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

Branch: refs/heads/disk-cache
Commit: e325fb66ab1fa0796ade6b5d3d70c688b57e5409
Parents: 7b4f846
Author: Edison Su <sudison@gmail.com>
Authored: Thu Aug 29 16:37:45 2013 -0700
Committer: Wei Zhou <w.zhou@leaseweb.com>
Committed: Tue Sep 24 09:53:55 2013 +0200

----------------------------------------------------------------------
 agent/bindir/libvirtqemuhook.in                 | 53 ++++++++++++++++++++
 packaging/centos63/cloud.spec                   |  2 +
 .../kvm/resource/BridgeVifDriver.java           | 21 +++++---
 3 files changed, 68 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e325fb66/agent/bindir/libvirtqemuhook.in
----------------------------------------------------------------------
diff --git a/agent/bindir/libvirtqemuhook.in b/agent/bindir/libvirtqemuhook.in
new file mode 100755
index 0000000..7bf9634
--- /dev/null
+++ b/agent/bindir/libvirtqemuhook.in
@@ -0,0 +1,53 @@
+#!/usr/bin/python
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+import sys
+from xml.dom.minidom import parse
+from cloudutils.configFileOps import configFileOps
+from cloudutils.networkConfig import networkConfig
+def isOldStyleBridge(brName):
+    if brName.find("cloudVirBr") == 0:
+       return True
+    else:
+       return False
+def getGuestNetworkDevice():
+    netlib = networkConfig() 
+    cfo = configFileOps("/etc/cloudstack/agent/agent.properties")
+    guestDev = cfo.getEntry("guest.network.device")
+    enslavedDev = netlib.getEnslavedDev(guestDev, 1)
+    return enslavedDev 
+def handleMigrateBegin():
+    try:
+        domain = parse(sys.stdin)
+        for interface in domain.getElementsByTagName("interface"):
+            source = interface.getElementsByTagName("source")[0]
+            bridge = source.getAttribute("bridge")
+            if not isOldStyleBridge(bridge):
+                continue
+            vlanId = bridge.replace("cloudVirBr","")
+            phyDev = getGuestNetworkDevice()
+            newBrName="br" + phyDev + "-" + vlanId
+            source.setAttribute("bridge", newBrName)
+        print(domain.toxml())
+    except:
+        pass
+if __name__ == '__main__':
+    if len(sys.argv) != 5:
+        sys.exit(0)
+
+    if sys.argv[2] == "migrate" and sys.argv[3] == "begin":
+        handleMigrateBegin() 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e325fb66/packaging/centos63/cloud.spec
----------------------------------------------------------------------
diff --git a/packaging/centos63/cloud.spec b/packaging/centos63/cloud.spec
index 0e4255a..90ebe4b 100644
--- a/packaging/centos63/cloud.spec
+++ b/packaging/centos63/cloud.spec
@@ -288,6 +288,7 @@ install -D agent/target/transformed/environment.properties ${RPM_BUILD_ROOT}%{_s
 install -D agent/target/transformed/log4j-cloud.xml ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/agent/log4j-cloud.xml
 install -D agent/target/transformed/cloud-setup-agent ${RPM_BUILD_ROOT}%{_bindir}/%{name}-setup-agent
 install -D agent/target/transformed/cloudstack-agent-upgrade ${RPM_BUILD_ROOT}%{_bindir}/%{name}-agent-upgrade
+install -D agent/target/transformed/libvirtqemuhook ${RPM_BUILD_ROOT}%{_datadir}/%{name}-agent/lib/libvirtqemuhook
 install -D agent/target/transformed/cloud-ssh ${RPM_BUILD_ROOT}%{_bindir}/%{name}-ssh
 install -D plugins/hypervisors/kvm/target/cloud-plugin-hypervisor-kvm-%{_maventag}.jar ${RPM_BUILD_ROOT}%{_datadir}/%name-agent/lib/cloud-plugin-hypervisor-kvm-%{_maventag}.jar
 cp plugins/hypervisors/kvm/target/dependencies/*  ${RPM_BUILD_ROOT}%{_datadir}/%{name}-agent/lib
@@ -556,6 +557,7 @@ fi
 %config(noreplace) %{_sysconfdir}/%{name}/agent
 %dir %{_localstatedir}/log/%{name}/agent
 %attr(0644,root,root) %{_datadir}/%{name}-agent/lib/*.jar
+%attr(0755,root,root) %{_datadir}/%{name}-agent/lib/libvirtqemuhook
 %dir %{_datadir}/%{name}-agent/plugins
 %{_defaultdocdir}/%{name}-agent-%{version}/LICENSE
 %{_defaultdocdir}/%{name}-agent-%{version}/NOTICE

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e325fb66/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java
index 2f79576..91f5227 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java
@@ -45,6 +45,7 @@ public class BridgeVifDriver extends VifDriverBase {
 
     private static final Object _vnetBridgeMonitor = new Object();
     private String _modifyVlanPath;
+    private String bridgeNameSchema;
 
     @Override
     public void configure(Map<String, Object> params) throws ConfigurationException
{
@@ -59,7 +60,9 @@ public class BridgeVifDriver extends VifDriverBase {
             networkScriptsDir = "scripts/vm/network/vnet";
         }
 
-        String value = (String)params.get("scripts.timeout");
+        bridgeNameSchema = (String) params.get("network.bridge.name.schema");
+
+        String value = (String) params.get("scripts.timeout");
         _timeout = NumbersUtil.parseInt(value, 30 * 60) * 1000;
 
         _modifyVlanPath = Script.findScript(networkScriptsDir, "modifyvlan.sh");
@@ -142,13 +145,15 @@ public class BridgeVifDriver extends VifDriverBase {
     }
 
     private String setVnetBrName(String pifName, String vnetId) {
-        String brName = "br" + pifName + "-" + vnetId;
-        String oldStyleBrName = "cloudVirBr" + vnetId;
-
-        String cmdout = Script.runSimpleBashScript("brctl show | grep " + oldStyleBrName);
-        if (cmdout != null && cmdout.contains(oldStyleBrName)) {
-            s_logger.info("Using old style bridge name for vlan " + vnetId + " because existing
bridge " + oldStyleBrName + " was found");
-            brName = oldStyleBrName;
+        String brName = null;
+        if (bridgeNameSchema != null) {
+            if (bridgeNameSchema.equalsIgnoreCase("3.0")) {
+                brName = "cloudVirBr" + vnetId;
+            } else if (bridgeNameSchema.equalsIgnoreCase("4.0")) {
+                brName = "br" + pifName + "-"+ vnetId;
+            }
+        } else {
+            brName = "br" + pifName + "-"+ vnetId;
         }
 
         return brName;


Mime
View raw message