You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by an...@apache.org on 2013/09/04 01:11:30 UTC

[01/12] git commit: updated refs/heads/4.2 to f09afea

Updated Branches:
  refs/heads/4.2 3c58f9bb9 -> f09afea06


CLOUDSTACK-4434: EN: Ubuntu: Direct input "- _ ", "? /", "keyboard /" ,"keyboard -" keys are not working well for the US keyboard.
Reviewed-by: Fang Wang <fa...@citrix.com>

Signed-off-by: Vijayendra Bhamidipati <vi...@citrix.com>
(cherry picked from commit f2874d0f228680b0dcd3299bb070215a2648a4a8)

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


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

Branch: refs/heads/4.2
Commit: 0fc996c20f74d935833e1a2df48f4477dd9babfc
Parents: 3c58f9b
Author: Sanjay Tripathi <sa...@citrix.com>
Authored: Wed Aug 28 14:22:21 2013 +0530
Committer: animesh <an...@apache.org>
Committed: Tue Sep 3 15:56:45 2013 -0700

----------------------------------------------------------------------
 services/console-proxy/server/js/ajaxviewer.js | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0fc996c2/services/console-proxy/server/js/ajaxviewer.js
----------------------------------------------------------------------
diff --git a/services/console-proxy/server/js/ajaxviewer.js b/services/console-proxy/server/js/ajaxviewer.js
index d3f3aa9..9643204 100644
--- a/services/console-proxy/server/js/ajaxviewer.js
+++ b/services/console-proxy/server/js/ajaxviewer.js
@@ -140,9 +140,13 @@ KeyboardMapper.prototype = {
 			this.jsX11KeysymMap[AjaxViewer.JS_KEY_SELECT_KEY] 		= AjaxViewer.X11_KEY_SELECT_KEY;
 			this.jsX11KeysymMap[AjaxViewer.JS_KEY_DECIMAL_POINT] 	= AjaxViewer.X11_KEY_DECIMAL_POINT;
 			this.jsKeyPressX11KeysymMap[45] 				= [{type: AjaxViewer.KEY_DOWN, code: AjaxViewer.X11_KEY_SUBSTRACT, modifiers: 0, shift: true },
-			                                				   {type: AjaxViewer.KEY_DOWN, code: AjaxViewer.X11_KEY_SUBSTRACT, modifiers: 0, shift: false }];
+															   {type: AjaxViewer.KEY_UP, code: AjaxViewer.X11_KEY_SUBSTRACT, modifiers: 0, shift: true },
+															   {type: AjaxViewer.KEY_DOWN, code: AjaxViewer.X11_KEY_SUBSTRACT, modifiers: 0, shift: false },
+															   {type: AjaxViewer.KEY_UP, code: AjaxViewer.X11_KEY_SUBSTRACT, modifiers: 0, shift: false }];
 			this.jsKeyPressX11KeysymMap[47] 				= [{type: AjaxViewer.KEY_DOWN, code: 0x2f, modifiers: 0, shift: true },
-			                                				   {type: AjaxViewer.KEY_DOWN, code: 0x2f, modifiers: 0, shift: false }];
+															   {type: AjaxViewer.KEY_UP, code: 0x2f, modifiers: 0, shift: true },
+															   {type: AjaxViewer.KEY_DOWN, code: 0x2f, modifiers: 0, shift: false },
+															   {type: AjaxViewer.KEY_UP, code: 0x2f, modifiers: 0, shift: false }];
 		}
 	},
 	RawkeyboardInputHandler : function(eventType, code, modifiers, guestos, browser, browserVersion) {


[02/12] git commit: updated refs/heads/4.2 to f09afea

Posted by an...@apache.org.
CLOUDSTACK-4405: add a tool: cloudstack-agent-upgrade to upgrade bridge name on kvm host
(cherry picked from commit 0ef6084d2c838a78eda29d258b1af98df96451b3)

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


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

Branch: refs/heads/4.2
Commit: ad3794df9106886e454ba278e91cf14ce86afb1c
Parents: 0fc996c
Author: Edison Su <su...@gmail.com>
Authored: Wed Aug 28 15:45:18 2013 -0700
Committer: animesh <an...@apache.org>
Committed: Tue Sep 3 15:57:08 2013 -0700

----------------------------------------------------------------------
 agent/bindir/cloudstack-agent-upgrade.in | 50 +++++++++++++++++++++++++++
 packaging/centos63/cloud.spec            |  2 ++
 python/lib/cloudutils/networkConfig.py   |  5 +++
 3 files changed, 57 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ad3794df/agent/bindir/cloudstack-agent-upgrade.in
----------------------------------------------------------------------
diff --git a/agent/bindir/cloudstack-agent-upgrade.in b/agent/bindir/cloudstack-agent-upgrade.in
new file mode 100644
index 0000000..4972d39
--- /dev/null
+++ b/agent/bindir/cloudstack-agent-upgrade.in
@@ -0,0 +1,50 @@
+#!/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.
+from cloudutils.networkConfig import networkConfig
+from cloudutils.utilities import bash
+def isOldStyleBridge(brName):
+    if brName.find("cloudVirBr") == 0:
+       return True
+    else:
+       return False
+def upgradeBridgeName(brName, enslavedDev):
+    print("upgrade bridge: %s, %s"%(brName, enslavedDev))
+    vlanId = brName.replace("cloudVirBr", "")
+    print("find vlan Id: %s"%vlanId)
+    phyDev = enslavedDev.split(".")[0]
+    print("find physical device %s"%phyDev)
+    newBrName = "br" + phyDev + "-" + vlanId
+    print("new bridge name %s"%newBrName)
+    bash("ip link set %s down"%brName) 
+    bash("ip link set %s name %s"%(brName, newBrName))
+    bash("ip link set %s up" %newBrName)
+if __name__ == '__main__':
+   netlib = networkConfig() 
+   bridges = netlib.listNetworks()
+   bridges = filter(isOldStyleBridge, bridges)
+   for br in bridges:
+       enslavedDev = netlib.getEnslavedDev(br, 1)
+       if enslavedDev is not None:
+           upgradeBridgeName(br, enslavedDev)
+   
+   bridges = netlib.listNetworks()
+   bridges = filter(isOldStyleBridge, bridges)
+   if len(bridges) > 0:
+       print("Warning: upgrade is not finished, still some bridges have the old style name:" + str(bridges))
+   else:
+       print("Upgrade succeed")

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ad3794df/packaging/centos63/cloud.spec
----------------------------------------------------------------------
diff --git a/packaging/centos63/cloud.spec b/packaging/centos63/cloud.spec
index 1ae43ba..01685e3 100644
--- a/packaging/centos63/cloud.spec
+++ b/packaging/centos63/cloud.spec
@@ -286,6 +286,7 @@ install -D agent/target/transformed/agent.properties ${RPM_BUILD_ROOT}%{_sysconf
 install -D agent/target/transformed/environment.properties ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/agent/environment.properties
 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/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
@@ -547,6 +548,7 @@ fi
 
 %files agent
 %attr(0755,root,root) %{_bindir}/%{name}-setup-agent
+%attr(0755,root,root) %{_bindir}/%{name}-agent-upgrade
 %attr(0755,root,root) %{_bindir}/%{name}-ssh
 %attr(0755,root,root) %{_sysconfdir}/init.d/%{name}-agent
 %attr(0755,root,root) %{_datadir}/%{name}-common/scripts/network/cisco

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ad3794df/python/lib/cloudutils/networkConfig.py
----------------------------------------------------------------------
diff --git a/python/lib/cloudutils/networkConfig.py b/python/lib/cloudutils/networkConfig.py
index 405a3be..41ef9d9 100644
--- a/python/lib/cloudutils/networkConfig.py
+++ b/python/lib/cloudutils/networkConfig.py
@@ -35,6 +35,11 @@ class networkConfig:
             self.method = None 
      
     @staticmethod
+    def listNetworks():
+        devs = os.listdir("/sys/class/net/") 
+        devs = filter(networkConfig.isBridge, devs) 
+        return devs
+    @staticmethod
     def getDefaultNetwork():
         cmd = bash("route -n|awk \'/^0.0.0.0/ {print $2,$8}\'") 
         if not cmd.isSuccess():


[08/12] git commit: updated refs/heads/4.2 to f09afea

Posted by an...@apache.org.
CLOUDSTACK-4538 Should update the vmware clusters with the global overporvisioning factors after upgrade to 4.2.
Signed off by : Nitin Mehta <ni...@citrix.com>
(cherry picked from commit 4a7d7324d0f71888365c0b8f235b30909c9cbceb)

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


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

Branch: refs/heads/4.2
Commit: fc77090f8ace62912d11184ce6df9ff1ee05c86d
Parents: 34ee6f9
Author: bharat kumar <bh...@citrix.com>
Authored: Thu Aug 29 12:24:45 2013 +0530
Committer: animesh <an...@apache.org>
Committed: Tue Sep 3 15:59:58 2013 -0700

----------------------------------------------------------------------
 .../com/cloud/upgrade/dao/Upgrade410to420.java  | 66 +++++++++++++++-----
 1 file changed, 51 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fc77090f/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
index 5db6420..a2c6b4e 100755
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
@@ -845,31 +845,67 @@ public class Upgrade410to420 implements DbUpgrade {
         PreparedStatement pstmt = null;
         PreparedStatement pstmt1 = null;
         PreparedStatement pstmt2 =null;
-        ResultSet rs = null;
-
+        PreparedStatement pstmt3 = null;
+        ResultSet rs1 = null;
+        ResultSet rscpu_global = null;
+        ResultSet rsmem_global = null;
         try {
-            pstmt = conn.prepareStatement("select id from `cloud`.`cluster`");
-            pstmt1=conn.prepareStatement("INSERT INTO `cloud`.`cluster_details` (cluster_id, name, value)  VALUES(?, 'cpuOvercommitRatio', '1')");
-            pstmt2=conn.prepareStatement("INSERT INTO `cloud`.`cluster_details` (cluster_id, name, value)  VALUES(?, 'memoryOvercommitRatio', '1')");
-            rs = pstmt.executeQuery();
-            while (rs.next()) {
-                long id = rs.getLong(1);
-                //update cluster_details table with the default overcommit ratios.
-                pstmt1.setLong(1,id);
-                pstmt1.execute();
-                pstmt2.setLong(1,id);
-                pstmt2.execute();
+            pstmt = conn.prepareStatement("select id, hypervisor_type from `cloud`.`cluster`");
+            pstmt1=conn.prepareStatement("INSERT INTO `cloud`.`cluster_details` (cluster_id, name, value)  VALUES(?, 'cpuOvercommitRatio', ?)");
+            pstmt2=conn.prepareStatement("INSERT INTO `cloud`.`cluster_details` (cluster_id, name, value)  VALUES(?, 'memoryOvercommitRatio', ?)");
+            pstmt3=conn.prepareStatement("select value from `cloud`.`configuration` where name=?");
+            pstmt3.setString(1,"cpu.overprovisioning.factor");
+            rscpu_global = pstmt3.executeQuery();
+            rscpu_global.next();
+            String global_cpu_overprovisioning_factor=rscpu_global.getString(1);
+            pstmt3.setString(1,"mem.overprovisioning.factor");
+            rsmem_global = pstmt3.executeQuery();
+            rsmem_global.next();
+            String global_mem_overprovisioning_factor = rsmem_global.getString(1);
+            rs1 = pstmt.executeQuery();
+
+            while (rs1.next()) {
+                long id = rs1.getLong(1);
+                String hypervisor_type = rs1.getString(2);
+                if (hypervisor_type.equalsIgnoreCase(HypervisorType.VMware.toString())) {
+                    pstmt1.setLong(1,id);
+                    pstmt1.setString(2,global_cpu_overprovisioning_factor);
+                    pstmt1.execute();
+                    pstmt2.setLong(1,id);
+                    pstmt2.setString(2,global_mem_overprovisioning_factor);
+                    pstmt2.execute();
+                }else {
+                    //update cluster_details table with the default overcommit ratios.
+                    pstmt1.setLong(1,id);
+                    pstmt1.setString(2,"1");
+                    pstmt1.execute();
+                    pstmt2.setLong(1,id);
+                    pstmt2.setString(2,"1");
+                    pstmt2.execute();
+                }
             }
         } catch (SQLException e) {
             throw new CloudRuntimeException("Unable to update cluster_details with default overcommit ratios.", e);
         } finally {
             try {
-                if (rs != null) {
-                    rs.close();
+                if (rs1 != null) {
+                    rs1.close();
+                }
+                if (rsmem_global != null) {
+                    rsmem_global.close();
+                }
+                if (rscpu_global != null) {
+                    rsmem_global.close();
                 }
                 if (pstmt != null) {
                     pstmt.close();
                 }
+                if (pstmt2 != null) {
+                    pstmt2.close();
+                }
+                if (pstmt3 != null) {
+                    pstmt3.close();
+                }
             } catch (SQLException e) {
             }
         }


[05/12] git commit: updated refs/heads/4.2 to f09afea

Posted by an...@apache.org.
CLOUDSTACK-4539: [VMWARE] vmware.create.full.clone is set to true in upgraded setup;default nature of vms are full clone

Description:

    Do not overwrite value of vmware.create.full.clone flag in the
    cloud db if it already exists. This will preserve the configured
    clone creation behaviour across upgrades.
(cherry picked from commit a30a33c14d38a30840be19619c9aff65ed14cf2f)

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


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

Branch: refs/heads/4.2
Commit: 42e66aa4e6e1a33b63ed65176e4cf38363485922
Parents: 72a3cbb
Author: Vijayendra Bhamidipati <vi...@citrix.com>
Authored: Wed Aug 28 10:58:02 2013 -0700
Committer: animesh <an...@apache.org>
Committed: Tue Sep 3 15:58:43 2013 -0700

----------------------------------------------------------------------
 setup/db/db/schema-410to420.sql | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/42e66aa4/setup/db/db/schema-410to420.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql
index 4d68838..723791d 100644
--- a/setup/db/db/schema-410to420.sql
+++ b/setup/db/db/schema-410to420.sql
@@ -403,7 +403,12 @@ CREATE TABLE `cloud`.`user_vm_clone_setting` (
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 
-INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'UserVmManager', 'vmware.create.full.clone' , 'true', 'If set to true, creates VMs as full clones on ESX hypervisor');
+INSERT INTO `cloud`.`configuration` (category, instance, component, name, value, description)
+    SELECT tmp.category, tmp.instance, tmp.component, tmp.name, tmp.value, tmp.description FROM
+    (SELECT 'Advanced' category, 'DEFAULT' instance, 'UserVmManager' component, 'vmware.create.full.clone' name, 'true' value, 'If set to true, creates VMs as full clones on ESX hypervisor' description) tmp
+    WHERE NOT EXISTS (SELECT 1 FROM `cloud`.`configuration` WHERE name = 'vmware.create.full.clone');
+
+
 
 CREATE TABLE `cloud`.`affinity_group` (
   `id` bigint unsigned NOT NULL auto_increment,


[06/12] git commit: updated refs/heads/4.2 to f09afea

Posted by an...@apache.org.
CLOUDSTACK-4519: reimplementdestroy-volume to take consideration of on-disk snapshot
(cherry picked from commit a316ffa27f84c261cace31982aaaa9c3aaf52e6a)

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


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

Branch: refs/heads/4.2
Commit: 2b12088eabb683a6de9b411dce93a3d909923b38
Parents: 42e66aa
Author: Kelven Yang <ke...@gmail.com>
Authored: Wed Aug 28 17:50:44 2013 -0700
Committer: animesh <an...@apache.org>
Committed: Tue Sep 3 15:59:04 2013 -0700

----------------------------------------------------------------------
 .../com/cloud/hypervisor/guru/VMwareGuru.java   |  8 ----
 .../resource/VmwareStorageLayoutHelper.java     | 42 ++++++++++++++--
 .../resource/VmwareStorageProcessor.java        | 33 +++++++------
 .../hypervisor/vmware/mo/VirtualMachineMO.java  | 50 +++++++++++++++++---
 4 files changed, 102 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2b12088e/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java
index 7c70c6a..c8e82ab 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java
@@ -426,14 +426,6 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru {
     }
 
     @Override
-    public List<Command> finalizeExpunge(VirtualMachine vm) {
-        UnregisterVMCommand unregisterVMCommand = new UnregisterVMCommand(vm.getInstanceName());
-        List<Command> commands = new ArrayList<Command>();
-        commands.add(unregisterVMCommand);
-        return commands;
-    }
-
-    @Override
     public List<Command> finalizeExpungeNics(VirtualMachine vm, List<NicProfile> nics) {
         List<Command> commands = new ArrayList<Command>();
         List<NicVO> nicVOs = _nicDao.listByVmId(vm.getId());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2b12088e/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageLayoutHelper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageLayoutHelper.java b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageLayoutHelper.java
index d60abad..20544df 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageLayoutHelper.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageLayoutHelper.java
@@ -16,6 +16,8 @@
 // under the License.
 package com.cloud.storage.resource;
 
+import java.util.List;
+
 import org.apache.log4j.Logger;
 
 import com.cloud.hypervisor.vmware.mo.DatacenterMO;
@@ -166,6 +168,40 @@ public class VmwareStorageLayoutHelper {
 		s_logger.info("Fixup folder-synchronization. move " + fileDsFullPath + " -> " + targetPath);
     	ds.moveDatastoreFile(fileDsFullPath, dcMo.getMor(), ds.getMor(), targetPath, dcMo.getMor(), true);
     }
+    
+    public static void moveVolumeToRootFolder(DatacenterMO dcMo, List<String> detachedDisks) throws Exception {
+    	if(detachedDisks.size() > 0) {
+    		for(String fileFullDsPath : detachedDisks) {
+    			DatastoreFile file = new DatastoreFile(fileFullDsPath);
+    			
+    			s_logger.info("Check if we need to move " + fileFullDsPath + " to its root location");
+    			DatastoreMO dsMo = new DatastoreMO(dcMo.getContext(), dcMo.findDatastore(file.getDatastoreName()));
+    			if(dsMo.getMor() != null) {
+    				DatastoreFile targetFile = new DatastoreFile(file.getDatastoreName(), file.getFileName());
+    				if(!targetFile.getPath().equalsIgnoreCase(file.getPath())) {
+    					s_logger.info("Move " + file.getPath() + " -> " + targetFile.getPath());
+    					dsMo.moveDatastoreFile(file.getPath(), dcMo.getMor(), dsMo.getMor(), targetFile.getPath(), dcMo.getMor(), true);
+
+    					String pairSrcFilePath = file.getCompanionPath(file.getFileBaseName() + "-flat.vmdk");
+        				String pairTargetFilePath = targetFile.getCompanionPath(file.getFileBaseName() + "-flat.vmdk");
+        				if(dsMo.fileExists(pairSrcFilePath)) {
+	        				s_logger.info("Move " + pairSrcFilePath + " -> " + pairTargetFilePath);
+	    					dsMo.moveDatastoreFile(pairSrcFilePath, dcMo.getMor(), dsMo.getMor(), pairTargetFilePath, dcMo.getMor(), true);
+        				}
+        				
+    					pairSrcFilePath = file.getCompanionPath(file.getFileBaseName() + "-delta.vmdk");
+        				pairTargetFilePath = targetFile.getCompanionPath(file.getFileBaseName() + "-delta.vmdk");
+        				if(dsMo.fileExists(pairSrcFilePath)) {
+	        				s_logger.info("Move " + pairSrcFilePath + " -> " + pairTargetFilePath);
+	    					dsMo.moveDatastoreFile(pairSrcFilePath, dcMo.getMor(), dsMo.getMor(), pairTargetFilePath, dcMo.getMor(), true);
+        				}
+    				}
+    			} else {
+    				s_logger.warn("Datastore for " + fileFullDsPath + " no longer exists, we have to skip");
+    			}
+    		}
+    	}
+    }
      
     public static String getTemplateOnSecStorageFilePath(String secStorageMountPoint, String templateRelativeFolderPath,
     	String templateName, String fileExtension) {
@@ -227,7 +263,7 @@ public class VmwareStorageLayoutHelper {
 		if(!dsMo.fileExists(fileFullPath))
 			fileFullPath = dsMo.searchFileInSubFolders(fileName, false);
 		if(fileFullPath != null) {
-			dsMo.deleteFile(fileFullPath, dcMo.getMor(), false);
+			dsMo.deleteFile(fileFullPath, dcMo.getMor(), true);
 		} else {
 			s_logger.warn("Unable to locate VMDK file: " + fileName);
 		}
@@ -237,7 +273,7 @@ public class VmwareStorageLayoutHelper {
 		if(!dsMo.fileExists(fileFullPath))
 			fileFullPath = dsMo.searchFileInSubFolders(fileName, false);
 		if(fileFullPath != null) {
-			dsMo.deleteFile(fileFullPath, dcMo.getMor(), false);
+			dsMo.deleteFile(fileFullPath, dcMo.getMor(), true);
 		} else {
 			s_logger.warn("Unable to locate VMDK file: " + fileName);
 		}
@@ -247,7 +283,7 @@ public class VmwareStorageLayoutHelper {
 		if(!dsMo.fileExists(fileFullPath))
 			fileFullPath = dsMo.searchFileInSubFolders(fileName, false);
 		if(fileFullPath != null) {
-			dsMo.deleteFile(fileFullPath, dcMo.getMor(), false);
+			dsMo.deleteFile(fileFullPath, dcMo.getMor(), true);
 		} else {
 			s_logger.warn("Unable to locate VMDK file: " + fileName);
 		}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2b12088e/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
index 4a0b192..20c26fb 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
@@ -63,6 +63,7 @@ import com.cloud.hypervisor.vmware.mo.DatastoreMO;
 import com.cloud.hypervisor.vmware.mo.HostMO;
 import com.cloud.hypervisor.vmware.mo.HypervisorHostHelper;
 import com.cloud.hypervisor.vmware.mo.NetworkDetails;
+import com.cloud.hypervisor.vmware.mo.VirtualMachineDiskInfo;
 import com.cloud.hypervisor.vmware.mo.VirtualMachineMO;
 import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost;
 import com.cloud.hypervisor.vmware.resource.VmwareResource;
@@ -1323,7 +1324,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
                     } else {
                         try{
                             vmMo.unmountToolsInstaller();
-                        }catch(Throwable e){
+                        } catch(Throwable e){
                             vmMo.detachIso(null);
                         }
                     }
@@ -1462,18 +1463,6 @@ public class VmwareStorageProcessor implements StorageProcessor {
             s_logger.info("Executing resource DestroyCommand: " + _gson.toJson(cmd));
         }
 
-        /*
-         * DestroyCommand content example
-         *
-         * {"volume": {"id":5,"name":"Volume1", "mountPoint":"/export/home/kelven/vmware-test/primary",
-         * "path":"6bb8762f-c34c-453c-8e03-26cc246ceec4", "size":0,"type":"DATADISK","resourceType":
-         * "STORAGE_POOL","storagePoolType":"NetworkFilesystem", "poolId":0,"deviceId":0 } }
-         *
-         * {"volume": {"id":1, "name":"i-2-1-KY-ROOT", "mountPoint":"/export/home/kelven/vmware-test/primary",
-         * "path":"i-2-1-KY-ROOT","size":0,"type":"ROOT", "resourceType":"STORAGE_POOL", "storagePoolType":"NetworkFilesystem",
-         * "poolId":0,"deviceId":0 } }
-         */
-
         try {
             VmwareContext context = hostService.getServiceContext(null);
             VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, null);
@@ -1494,6 +1483,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
             ClusterMO clusterMo = new ClusterMO(context, morCluster);
 
             if (vol.getVolumeType() == Volume.Type.ROOT) {
+            	
                 String vmName = vol.getVmName();
                 if (vmName != null) {
                     VirtualMachineMO vmMo = clusterMo.findVmOnHyperHost(vmName);
@@ -1502,6 +1492,14 @@ public class VmwareStorageProcessor implements StorageProcessor {
                             s_logger.info("Destroy root volume and VM itself. vmName " + vmName);
                         }
 
+                        // Remove all snapshots to consolidate disks for removal
+                        vmMo.removeAllSnapshots();
+                        
+                        VirtualMachineDiskInfo diskInfo = null;
+                        if(vol.getChainInfo() != null)
+                        	diskInfo = _gson.fromJson(vol.getChainInfo(), VirtualMachineDiskInfo.class);
+                        
+                        
                         HostMO hostMo = vmMo.getRunningHost();
                         List<NetworkDetails> networks = vmMo.getNetworksWithDetails();
 
@@ -1509,7 +1507,12 @@ public class VmwareStorageProcessor implements StorageProcessor {
                         if (resource.getVmState(vmMo) != State.Stopped) {
                             vmMo.safePowerOff(_shutdown_waitMs);
                         }
-                        vmMo.tearDownDevices(new Class<?>[] { VirtualDisk.class, VirtualEthernetCard.class });
+                        
+                        List<String> detachedDisks = vmMo.detachAllDisksExcept(vol.getPath(), diskInfo != null ? diskInfo.getDiskDeviceBusName() : null);
+                        VmwareStorageLayoutHelper.moveVolumeToRootFolder(new DatacenterMO(context, morDc), detachedDisks);
+
+                        // let vmMo.destroy to delete volume for us
+                        // vmMo.tearDownDevices(new Class<?>[] { VirtualDisk.class, VirtualEthernetCard.class });
                         vmMo.destroy();
 
                         for (NetworkDetails netDetails : networks) {
@@ -1521,11 +1524,13 @@ public class VmwareStorageProcessor implements StorageProcessor {
                         }
                     }
 
+/*                    
                     if (s_logger.isInfoEnabled()) {
                         s_logger.info("Destroy volume by original name: " + vol.getPath() + ".vmdk");
                     }
 
                     VmwareStorageLayoutHelper.deleteVolumeVmdkFiles(dsMo, vol.getPath(), new DatacenterMO(context, morDc));
+*/
                     return new Answer(cmd, true, "Success");
                 }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2b12088e/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
index 71ab609..7dd947c 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
@@ -991,13 +991,11 @@ public class VirtualMachineMO extends BaseMO {
 		VirtualDevice newDisk = VmwareHelper.prepareDiskDevice(this, getScsiDeviceControllerKey(),
 			vmdkDatastorePathChain, morDs, -1, 1);
 	    VirtualMachineConfigSpec reConfigSpec = new VirtualMachineConfigSpec();
-	    //VirtualDeviceConfigSpec[] deviceConfigSpecArray = new VirtualDeviceConfigSpec[1];
 	    VirtualDeviceConfigSpec deviceConfigSpec = new VirtualDeviceConfigSpec();
 
 	    deviceConfigSpec.setDevice(newDisk);
 	    deviceConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.ADD);
 
-	    //deviceConfigSpecArray[0] = deviceConfigSpec;
 	    reConfigSpec.getDeviceChange().add(deviceConfigSpec);
 
 	    ManagedObjectReference morTask = _context.getService().reconfigVMTask(_mor, reConfigSpec);
@@ -1024,13 +1022,11 @@ public class VirtualMachineMO extends BaseMO {
 		VirtualDevice newDisk = VmwareHelper.prepareDiskDevice(this, controllerKey,
 			vmdkDatastorePathChain, -1, 1);
 	    VirtualMachineConfigSpec reConfigSpec = new VirtualMachineConfigSpec();
-	    //VirtualDeviceConfigSpec[] deviceConfigSpecArray = new VirtualDeviceConfigSpec[1];
 	    VirtualDeviceConfigSpec deviceConfigSpec = new VirtualDeviceConfigSpec();
 
 	    deviceConfigSpec.setDevice(newDisk);
 	    deviceConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.ADD);
 
-	    //deviceConfigSpecArray[0] = deviceConfigSpec;
 	    reConfigSpec.getDeviceChange().add(deviceConfigSpec);
 
 	    ManagedObjectReference morTask = _context.getService().reconfigVMTask(_mor, reConfigSpec);
@@ -1067,7 +1063,6 @@ public class VirtualMachineMO extends BaseMO {
 		List<Pair<String, ManagedObjectReference>> chain = getDiskDatastorePathChain(deviceInfo.first(), true);
 
 	    VirtualMachineConfigSpec reConfigSpec = new VirtualMachineConfigSpec();
-	    //VirtualDeviceConfigSpec[] deviceConfigSpecArray = new VirtualDeviceConfigSpec[1];
 	    VirtualDeviceConfigSpec deviceConfigSpec = new VirtualDeviceConfigSpec();
 
 	    deviceConfigSpec.setDevice(deviceInfo.first());
@@ -1076,7 +1071,6 @@ public class VirtualMachineMO extends BaseMO {
         }
 	    deviceConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.REMOVE);
 
-	    //deviceConfigSpecArray[0] = deviceConfigSpec;
 	    reConfigSpec.getDeviceChange().add(deviceConfigSpec);
 
 	    ManagedObjectReference morTask = _context.getService().reconfigVMTask(_mor, reConfigSpec);
@@ -1964,6 +1958,50 @@ public class VirtualMachineMO extends BaseMO {
 		throw new Exception("Unable to find device controller");
 	}
 	
+	public List<String> detachAllDisksExcept(String vmdkBaseName, String deviceBusName) throws Exception {
+		List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
+
+	    VirtualMachineConfigSpec reConfigSpec = new VirtualMachineConfigSpec();
+	    List<String> detachedDiskFiles = new ArrayList<String>();
+	    
+	    for(VirtualDevice device : devices) {
+	    	if(device instanceof VirtualDisk) {
+			    VirtualDeviceConfigSpec deviceConfigSpec = new VirtualDeviceConfigSpec();
+		
+				VirtualDiskFlatVer2BackingInfo diskBackingInfo = (VirtualDiskFlatVer2BackingInfo)device.getBacking();
+	
+				DatastoreFile dsBackingFile = new DatastoreFile(diskBackingInfo.getFileName());
+				String backingBaseName = dsBackingFile.getFileBaseName();
+				String deviceNumbering = getDeviceBusName(devices, device);
+				if(backingBaseName.equalsIgnoreCase(vmdkBaseName) || (deviceBusName != null && deviceBusName.equals(deviceNumbering))) {
+					continue;
+				} else {
+					s_logger.info("Detach " + diskBackingInfo.getFileName() + " from " + getName());
+					
+					detachedDiskFiles.add(diskBackingInfo.getFileName());
+					
+				    deviceConfigSpec.setDevice(device);
+				    deviceConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.REMOVE);
+			
+				    reConfigSpec.getDeviceChange().add(deviceConfigSpec);
+				}
+	    	}
+	    }
+	    
+	    if(detachedDiskFiles.size() > 0) {
+		    ManagedObjectReference morTask = _context.getService().reconfigVMTask(_mor, reConfigSpec);
+			boolean result = _context.getVimClient().waitForTask(morTask);
+			if(result) {
+				_context.waitForTaskProgressDone(morTask);
+			} else {
+				s_logger.warn("Unable to reconfigure the VM to detach disks");
+				throw new Exception("Unable to reconfigure the VM to detach disks");
+			}
+	    }
+	    	
+	    return detachedDiskFiles; 
+	}
+	
 	public VirtualDisk[] getAllDiskDevice() throws Exception {
 		List<VirtualDisk> deviceList = new ArrayList<VirtualDisk>();
 		List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");


[04/12] git commit: updated refs/heads/4.2 to f09afea

Posted by an...@apache.org.
CLOUDSTACK-4528 [Vmware] new mapping vmware datacenter cloudstack zone - Virtual Router host migration across cluster FAIL

Change:
- Also add a check in migrateSystemVM API to check that source and destination host are in the same cluster
(cherry picked from commit b24e9a6dd5281b2163ce088e6f5b1fa730c33f7d)

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


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

Branch: refs/heads/4.2
Commit: 72a3cbb82e5d6fa620bbcf110416b295ff99a635
Parents: cd592f5
Author: Prachi Damle <pr...@cloud.com>
Authored: Wed Aug 28 15:54:30 2013 -0700
Committer: animesh <an...@apache.org>
Committed: Tue Sep 3 15:57:52 2013 -0700

----------------------------------------------------------------------
 server/src/com/cloud/vm/UserVmManagerImpl.java | 12 ++++++++++++
 1 file changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/72a3cbb8/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index ce77630..251c203 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -3950,6 +3950,18 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
                             + destinationHost.getResourceState());
         }
 
+        if (vm.getType() != VirtualMachine.Type.User) {
+            // for System VMs check that the destination host is within the same
+            // cluster
+            HostVO srcHost = _hostDao.findById(srcHostId);
+            if (srcHost != null && srcHost.getClusterId() != null && destinationHost.getClusterId() != null) {
+                if (srcHost.getClusterId().longValue() != destinationHost.getClusterId().longValue()) {
+                    throw new InvalidParameterValueException(
+                            "Cannot migrate the VM, destination host is not in the same cluster as current host of the VM");
+                }
+            }
+        }
+
         checkHostsDedication(vm, srcHostId, destinationHost.getId());
 
          // call to core process


[03/12] git commit: updated refs/heads/4.2 to f09afea

Posted by an...@apache.org.
CLOUDSTACK-4528: [Vmware] new mapping vmware datacenter cloudstack zone - Virtual Router host migration across cluster FAIL

Changes:
- listHosts within same cluster for migration of system and router VMs
(cherry picked from commit 52f4683099e03e16916dfdf741f2d5544491aaad)

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


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

Branch: refs/heads/4.2
Commit: cd592f5c23717d44517bd9f2461e31e1d4b2cdc7
Parents: ad3794d
Author: Prachi Damle <pr...@cloud.com>
Authored: Wed Aug 28 14:06:07 2013 -0700
Committer: animesh <an...@apache.org>
Committed: Tue Sep 3 15:57:31 2013 -0700

----------------------------------------------------------------------
 server/src/com/cloud/server/ManagementServerImpl.java | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd592f5c/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index b20bf48..3341c05 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -1090,10 +1090,13 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
 
         // Check if the vm can be migrated with storage.
         boolean canMigrateWithStorage = false;
-        HypervisorCapabilitiesVO capabilities = _hypervisorCapabilitiesDao.findByHypervisorTypeAndVersion(
-                srcHost.getHypervisorType(), srcHost.getHypervisorVersion());
-        if (capabilities != null) {
-            canMigrateWithStorage = capabilities.isStorageMotionSupported();
+
+        if (vm.getType() == VirtualMachine.Type.User) {
+            HypervisorCapabilitiesVO capabilities = _hypervisorCapabilitiesDao.findByHypervisorTypeAndVersion(
+                    srcHost.getHypervisorType(), srcHost.getHypervisorVersion());
+            if (capabilities != null) {
+                canMigrateWithStorage = capabilities.isStorageMotionSupported();
+            }
         }
 
         // Check if the vm is using any disks on local storage.


[09/12] git commit: updated refs/heads/4.2 to f09afea

Posted by an...@apache.org.
CLOUDSTACK-4499: Wait until hosts are up before adding storage pools

This works around the delay caused in adding Xen 6.1/6.2 hosts where
host takes two attempts to transition to Up state. We will wait for one
minute per cluster before attempting to add storage pool in the cluster.

Signed-off-by: Prasanna Santhanam <ts...@apache.org>
(cherry picked from commit 22ee499c3571b2a6b6921abb36c679128893c415)
(cherry picked from commit dc071e963e3df9e504f951a28117f567558bb496)

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


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

Branch: refs/heads/4.2
Commit: 204f85b0515b9e053c488008e46e430cd9bcac53
Parents: fc77090
Author: Prasanna Santhanam <ts...@apache.org>
Authored: Thu Aug 29 12:33:26 2013 +0530
Committer: animesh <an...@apache.org>
Committed: Tue Sep 3 16:00:37 2013 -0700

----------------------------------------------------------------------
 tools/marvin/marvin/deployDataCenter.py | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/204f85b0/tools/marvin/marvin/deployDataCenter.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/deployDataCenter.py b/tools/marvin/marvin/deployDataCenter.py
index 5352029..4c34a50 100644
--- a/tools/marvin/marvin/deployDataCenter.py
+++ b/tools/marvin/marvin/deployDataCenter.py
@@ -22,6 +22,7 @@ import cloudstackTestClient
 import logging
 from cloudstackAPI import *
 from os import path
+from time import sleep
 from optparse import OptionParser
 
 
@@ -87,9 +88,28 @@ specify a valid config file" % cfgFile)
             if cluster.hypervisor.lower() != "vmware":
                 self.addHosts(cluster.hosts, zoneId, podId, clusterId,
                               cluster.hypervisor)
+            self.wait_for_host(zoneId, clusterId)
             self.createPrimaryStorages(cluster.primaryStorages, zoneId, podId,
                                        clusterId)
 
+    def wait_for_host(self, zoneId, clusterId):
+        """
+        Wait for the hosts in the zoneid, clusterid to be up
+
+        2 retries with 30s delay
+        """
+        retry, timeout = 2, 30
+        cmd = listHosts.listHostsCmd()
+        cmd.clusterid, cmd.zoneid = clusterId, zoneId
+        hosts = self.apiClient.listHosts(cmd)
+        while retry != 0:
+            for host in hosts:
+                if host.state != 'Up':
+                    break
+            sleep(timeout)
+            retry = retry - 1
+
+
     def createPrimaryStorages(self, primaryStorages, zoneId, podId, clusterId):
         if primaryStorages is None:
             return


[11/12] git commit: updated refs/heads/4.2 to f09afea

Posted by an...@apache.org.
CLOUDSTACK-4538: set default value of cpu.overprovisioning.factor and mem.overprovisioning.factor to 1

On a fresh environment, some values in cloud.configuration table are persisted in com.cloud.server.ConfigurationServerImpl.persistDefaultValues()
A default value need to be set before com.cloud.upgrade.DatabaseUpgradeChecker
(cherry picked from commit 1a67750cb66cf74175e2776ba3f3ba76fde0d1bb)
(cherry picked from commit 61ebfad4493d4f3fe4ced948985e69202080654b)

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


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

Branch: refs/heads/4.2
Commit: 30c5388253db121f5557231523c23a80e72ac3b7
Parents: c0471e6
Author: Wei Zhou <w....@leaseweb.com>
Authored: Thu Aug 29 12:41:18 2013 +0200
Committer: animesh <an...@apache.org>
Committed: Tue Sep 3 16:02:20 2013 -0700

----------------------------------------------------------------------
 .../schema/src/com/cloud/upgrade/dao/Upgrade410to420.java | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30c53882/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
index f0b459a..2e58ddd 100755
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
@@ -856,12 +856,14 @@ public class Upgrade410to420 implements DbUpgrade {
             pstmt3=conn.prepareStatement("select value from `cloud`.`configuration` where name=?");
             pstmt3.setString(1,"cpu.overprovisioning.factor");
             rscpu_global = pstmt3.executeQuery();
-            rscpu_global.next();
-            String global_cpu_overprovisioning_factor=rscpu_global.getString(1);
+            String global_cpu_overprovisioning_factor = "1";
+            if (rscpu_global.next())
+                global_cpu_overprovisioning_factor = rscpu_global.getString(1);
             pstmt3.setString(1,"mem.overprovisioning.factor");
             rsmem_global = pstmt3.executeQuery();
-            rsmem_global.next();
-            String global_mem_overprovisioning_factor = rsmem_global.getString(1);
+            String global_mem_overprovisioning_factor = "1";
+            if (rsmem_global.next())
+                global_mem_overprovisioning_factor = rsmem_global.getString(1);
             rs1 = pstmt.executeQuery();
 
             while (rs1.next()) {


[12/12] git commit: updated refs/heads/4.2 to f09afea

Posted by an...@apache.org.
CLOUDSTACK-4435 [VMWARE]System VM's are failed to start with Nexus enabled Zone

Since introducing pool of session contexts we no more have a dedicated context for each VMware hypervisor host.
Hence vsm credentials stored in session context cannot be retrieved always correctly. Fix is to register the vsm credentials after fetching context and the context gets recycled after use.

Signed-off-by: Sateesh Chodapuneedi <sa...@apache.org>
(cherry picked from commit eaea8f8c5f21257f036d4c13ba1ec50c69664a52)

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


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

Branch: refs/heads/4.2
Commit: f09afea067389fc42e99645ff90e5b081813c171
Parents: 30c5388
Author: Sateesh Chodapuneedi <sa...@apache.org>
Authored: Thu Aug 29 14:52:20 2013 +0530
Committer: animesh <an...@apache.org>
Committed: Tue Sep 3 16:02:42 2013 -0700

----------------------------------------------------------------------
 .../hypervisor/vmware/resource/VmwareResource.java   | 15 +++++----------
 .../hypervisor/vmware/mo/HypervisorHostHelper.java   |  7 ++++++-
 2 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f09afea0/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index 7ff4918..16b829a 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -46,7 +46,6 @@ import java.util.concurrent.TimeUnit;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
-import com.cloud.configuration.Config;
 import org.apache.cloudstack.storage.command.DeleteCommand;
 import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
 import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
@@ -202,6 +201,7 @@ import com.cloud.agent.api.to.StaticNatRuleTO;
 import com.cloud.agent.api.to.StorageFilerTO;
 import com.cloud.agent.api.to.VirtualMachineTO;
 import com.cloud.agent.api.to.VolumeTO;
+import com.cloud.configuration.Config;
 import com.cloud.dc.DataCenter.NetworkType;
 import com.cloud.dc.Vlan;
 import com.cloud.exception.InternalErrorException;
@@ -219,7 +219,6 @@ import com.cloud.hypervisor.vmware.mo.DatastoreMO;
 import com.cloud.hypervisor.vmware.mo.DiskControllerType;
 import com.cloud.hypervisor.vmware.mo.FeatureKeyConstants;
 import com.cloud.hypervisor.vmware.mo.HostDatastoreSystemMO;
-import com.cloud.hypervisor.vmware.mo.HostFirewallSystemMO;
 import com.cloud.hypervisor.vmware.mo.HostMO;
 import com.cloud.hypervisor.vmware.mo.HostStorageSystemMO;
 import com.cloud.hypervisor.vmware.mo.HypervisorHostHelper;
@@ -362,6 +361,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
     protected String _privateNetworkVSwitchName;
     protected VmwareTrafficLabel _guestTrafficInfo = new VmwareTrafficLabel(TrafficType.Guest);
     protected VmwareTrafficLabel _publicTrafficInfo = new VmwareTrafficLabel(TrafficType.Public);
+    protected Map<String, String> _vsmCredentials = null;
     protected int _portsPerDvPortGroup;
     protected boolean _fullCloneFlag = false;
     protected boolean _instanceNameFlag = false;
@@ -1956,7 +1956,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
         	}
         } else {
             networkInfo = HypervisorHostHelper.prepareNetwork(_publicTrafficInfo.getVirtualSwitchName(), "cloud.public",
-                    vmMo.getRunningHost(), vlanId, null, null, null, _ops_timeout, vSwitchType, _portsPerDvPortGroup, null, false, BroadcastDomainType.Vlan);
+                    vmMo.getRunningHost(), vlanId, null, null, null, _ops_timeout, vSwitchType, _portsPerDvPortGroup, null, false, BroadcastDomainType.Vlan, _vsmCredentials);
         }
 
         int nicIndex = allocPublicNicIndex(vmMo);
@@ -3525,7 +3525,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
             }
             networkInfo = HypervisorHostHelper.prepareNetwork(switchName.first(), namePrefix, hostMo, vlanId, svlanId,
                     nicTo.getNetworkRateMbps(), nicTo.getNetworkRateMulticastMbps(), _ops_timeout, switchType,
-                    _portsPerDvPortGroup, nicTo.getGateway(), configureVServiceInNexus, nicTo.getBroadcastType());
+                    _portsPerDvPortGroup, nicTo.getGateway(), configureVServiceInNexus, nicTo.getBroadcastType(), _vsmCredentials);
         }
 
         return networkInfo;
@@ -6660,14 +6660,9 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
 	            VmwareHypervisorHost hostMo = this.getHyperHost(context);
 	            _hostName = hostMo.getHyperHostName();
 	
-	            Map<String, String> vsmCredentials;
 	            if (_guestTrafficInfo.getVirtualSwitchType() == VirtualSwitchType.NexusDistributedVirtualSwitch ||
 	                    _publicTrafficInfo.getVirtualSwitchType() == VirtualSwitchType.NexusDistributedVirtualSwitch) {
-	                vsmCredentials = mgr.getNexusVSMCredentialsByClusterId(Long.parseLong(_cluster));
-	                if (vsmCredentials != null) {
-	                    s_logger.info("Stocking credentials while configuring resource.");
-	                    context.registerStockObject("vsmcredentials", vsmCredentials);
-	                }
+	                _vsmCredentials = mgr.getNexusVSMCredentialsByClusterId(Long.parseLong(_cluster));
 	                _privateNetworkVSwitchName = mgr.getPrivateVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware);
 	            }
 	

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f09afea0/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
index 43c59fc..014a9f8 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
@@ -444,7 +444,8 @@ public class HypervisorHostHelper {
 
     public static Pair<ManagedObjectReference, String> prepareNetwork(String physicalNetwork, String namePrefix,
             HostMO hostMo, String vlanId, String secondaryvlanId, Integer networkRateMbps, Integer networkRateMulticastMbps, long timeOutMs,
-            VirtualSwitchType vSwitchType, int numPorts, String gateway, boolean configureVServiceInNexus, BroadcastDomainType broadcastDomainType) throws Exception {
+            VirtualSwitchType vSwitchType, int numPorts, String gateway, boolean configureVServiceInNexus, BroadcastDomainType broadcastDomainType,
+            Map<String, String> vsmCredentials) throws Exception {
         ManagedObjectReference morNetwork = null;
         VmwareContext context = hostMo.getContext();
         ManagedObjectReference dcMor = hostMo.getHyperHostDatacenter();
@@ -577,6 +578,10 @@ public class HypervisorHostHelper {
             // TODO(sateesh): Optionally let user specify the burst coefficient
             long burstSize = 5 * averageBandwidth / 8;
 
+            if (vsmCredentials != null) {
+                s_logger.info("Stocking credentials of Nexus VSM");
+                context.registerStockObject("vsmcredentials", vsmCredentials);
+            }
             if (!dataCenterMo.hasDvPortGroup(networkName)) {
                 s_logger.info("Port profile " + networkName + " not found.");
                 createPortProfile(context, physicalNetwork, networkName, vid, networkRateMbps, peakBandwidth, burstSize, gateway, configureVServiceInNexus);


[10/12] git commit: updated refs/heads/4.2 to f09afea

Posted by an...@apache.org.
CLOUDSTACK-4538: fix small typo
(cherry picked from commit 68b668ae8f126e339de971c99e4c29c7f86b3d6e)

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


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

Branch: refs/heads/4.2
Commit: c0471e64fe6645a7b27dab994aa96730acffd242
Parents: 204f85b
Author: Wei Zhou <w....@leaseweb.com>
Authored: Thu Aug 29 11:32:34 2013 +0200
Committer: animesh <an...@apache.org>
Committed: Tue Sep 3 16:01:58 2013 -0700

----------------------------------------------------------------------
 engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c0471e64/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
index a2c6b4e..f0b459a 100755
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
@@ -895,7 +895,7 @@ public class Upgrade410to420 implements DbUpgrade {
                     rsmem_global.close();
                 }
                 if (rscpu_global != null) {
-                    rsmem_global.close();
+                    rscpu_global.close();
                 }
                 if (pstmt != null) {
                     pstmt.close();


[07/12] git commit: updated refs/heads/4.2 to f09afea

Posted by an...@apache.org.
CLOUDSTACK-4458: Volume attach/detach command needs to sent to hypervisor resource even when target VM is in Stopped state
(cherry picked from commit 995e193be2a1aad8ffe0eeb03357e23fb5c63769)

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


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

Branch: refs/heads/4.2
Commit: 34ee6f90bb5f69b619116d2c61a3f61fbdbca536
Parents: 2b12088
Author: Kelven Yang <ke...@gmail.com>
Authored: Wed Aug 28 18:37:45 2013 -0700
Committer: animesh <an...@apache.org>
Committed: Tue Sep 3 15:59:25 2013 -0700

----------------------------------------------------------------------
 .../storage/snapshot/SnapshotServiceImpl.java           |  1 -
 .../src/com/cloud/hypervisor/guru/VMwareGuru.java       |  2 +-
 .../cloud/storage/resource/VmwareStorageProcessor.java  |  2 +-
 server/src/com/cloud/storage/VolumeManagerImpl.java     | 12 +++++++++++-
 .../cloud/hypervisor/vmware/mo/VirtualMachineMO.java    |  3 +--
 5 files changed, 14 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/34ee6f90/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java
index e53bf9c..00d9631 100644
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java
@@ -247,7 +247,6 @@ public class SnapshotServiceImpl implements SnapshotService {
         AsyncCallFuture<SnapshotResult> future = new AsyncCallFuture<SnapshotResult>();
         SnapshotResult result = new SnapshotResult(snapshot, null);
         try {
-
             snapObj.processEvent(Snapshot.Event.BackupToSecondary);
 
             DataStore imageStore = this.findSnapshotImageStore(snapshot);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/34ee6f90/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java
index c8e82ab..73cc8e3 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java
@@ -351,7 +351,7 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru {
                 }
             }
         }
-
+        
         if(!needDelegation) {
             return new Pair<Boolean, Long>(Boolean.FALSE, new Long(hostId));
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/34ee6f90/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
index 20c26fb..14fca3a 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
@@ -969,7 +969,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
                     throw new Exception("unable to prepare snapshot backup directory");
                 }
             }
-        }
+        }	
 
         VirtualMachineMO clonedVm = null;
         try {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/34ee6f90/server/src/com/cloud/storage/VolumeManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeManagerImpl.java b/server/src/com/cloud/storage/VolumeManagerImpl.java
index 35fe72a..85a19ca 100644
--- a/server/src/com/cloud/storage/VolumeManagerImpl.java
+++ b/server/src/com/cloud/storage/VolumeManagerImpl.java
@@ -2026,6 +2026,16 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
         String errorMsg = "Failed to detach volume: " + volume.getName()
                 + " from VM: " + vm.getHostName();
         boolean sendCommand = (vm.getState() == State.Running);
+        Long hostId = vm.getHostId();
+        if (hostId == null) {
+            hostId = vm.getLastHostId();
+            HostVO host = _hostDao.findById(hostId);
+            if (host != null
+                    && host.getHypervisorType() == HypervisorType.VMware) {
+                sendCommand = true;
+            }
+        }
+        
         Answer answer = null;
 
         if (sendCommand) {
@@ -2044,7 +2054,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
             cmd.set_iScsiName(volume.get_iScsiName());
 
             try {
-                answer = _agentMgr.send(vm.getHostId(), cmd);
+                answer = _agentMgr.send(hostId, cmd);
             } catch (Exception e) {
                 throw new CloudRuntimeException(errorMsg + " due to: "
                         + e.getMessage());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/34ee6f90/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
index 7dd947c..6007bf0 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
@@ -1055,8 +1055,7 @@ public class VirtualMachineMO extends BaseMO {
 		// VirtualDisk, we only perform prefix matching
 		Pair<VirtualDisk, String> deviceInfo = getDiskDevice(vmdkDatastorePath, false);
 		if(deviceInfo == null) {
-			if(s_logger.isTraceEnabled())
-				s_logger.trace("vCenter API trace - detachDisk() done (failed)");
+			s_logger.warn("vCenter API trace - detachDisk() done (failed)");
 			throw new Exception("No such disk device: " + vmdkDatastorePath);
 		}