cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anim...@apache.org
Subject [07/21] git commit: updated refs/heads/4.2 to 51707d8
Date Tue, 03 Sep 2013 23:41:36 GMT
CLOUDSTACK-4405: fix vm migration during the upgrade to 4.2
(cherry picked from commit 3cca6502a1b48556ca7bb103ed226d44557dc399)

Signed-off-by: animesh <animesh@apache.org>


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

Branch: refs/heads/4.2
Commit: 1b684ac23137c598a9cd605e7c43c8c667228125
Parents: 679aae7
Author: Edison Su <sudison@gmail.com>
Authored: Thu Aug 29 16:37:45 2013 -0700
Committer: animesh <animesh@apache.org>
Committed: Tue Sep 3 16:17:38 2013 -0700

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


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1b684ac2/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/1b684ac2/packaging/centos63/cloud.spec
----------------------------------------------------------------------
diff --git a/packaging/centos63/cloud.spec b/packaging/centos63/cloud.spec
index 01685e3..2b814f8 100644
--- a/packaging/centos63/cloud.spec
+++ b/packaging/centos63/cloud.spec
@@ -287,6 +287,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
@@ -555,6 +556,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/1b684ac2/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 195cf40..e3779a7 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
{
@@ -60,6 +61,8 @@ public class BridgeVifDriver extends VifDriverBase {
             networkScriptsDir = "scripts/vm/network/vnet";
         }
 
+        bridgeNameSchema = (String) params.get("network.bridge.name.schema");
+
         String value = (String) params.get("scripts.timeout");
         _timeout = NumbersUtil.parseInt(value, 30 * 60) * 1000;
 
@@ -144,13 +147,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