Repository: cloudstack
Updated Branches:
  refs/heads/4.5 43a9eb40b -> eea716b79


CLOUDSTACK-7593: in 450to451 upgrade path copy vm_details from template for 
vmware

Signed-off-by: Rohit Yadav <[email protected]>


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

Branch: refs/heads/4.5
Commit: 8e1507078052b8068b828d336f8d0358915047e1
Parents: df934c9
Author: Rohit Yadav <[email protected]>
Authored: Mon Apr 13 15:34:27 2015 +0530
Committer: Rohit Yadav <[email protected]>
Committed: Mon Apr 13 15:44:09 2015 +0530

----------------------------------------------------------------------
 .../com/cloud/upgrade/dao/Upgrade450to451.java    | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8e150707/engine/schema/src/com/cloud/upgrade/dao/Upgrade450to451.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade450to451.java 
b/engine/schema/src/com/cloud/upgrade/dao/Upgrade450to451.java
index 89fe5ec..218f4ec 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade450to451.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade450to451.java
@@ -74,6 +74,7 @@ public class Upgrade450to451 implements DbUpgrade {
         encryptKeyInKeyStore(conn);
         encryptIpSecPresharedKeysOfRemoteAccessVpn(conn);
         encryptStoragePoolUserInfo(conn);
+        updateUserVmDetailsWithNicAdapterType(conn);
     }
 
     private void encryptKeyInKeyStore(Connection conn) {
@@ -175,4 +176,21 @@ public class Upgrade450to451 implements DbUpgrade {
         }
         s_logger.debug("Done encrypting storage_pool's user_info column");
     }
+
+    private void updateUserVmDetailsWithNicAdapterType(Connection conn) {
+        PreparedStatement insertPstmt = null;
+        try {
+            insertPstmt = conn.prepareStatement("INSERT INTO 
`cloud`.`user_vm_details`(vm_id,name,value,display) select v.id as vm_id, 
details.name, details.value, details.display from `cloud`.`vm_instance` as v, 
`cloud`.`vm_template_details` as details  where v.removed is null and 
v.vm_template_id=details.template_id and details.name='nicAdapter' and 
details.template_id in (select id from `cloud`.`vm_template` where 
hypervisor_type = 'vmware') and v.id not in (select vm_id from 
`cloud`.`user_vm_details` where name='nicAdapter');");
+            insertPstmt.executeUpdate();
+        } catch (SQLException e) {
+            throw new CloudRuntimeException("Failed to update user_vm_details 
table with nicAdapter entries by copying from vm_template_detail table", e);
+        } finally {
+            try {
+                if (insertPstmt != null)
+                    insertPstmt.close();
+            } catch (SQLException e) {
+            }
+        }
+        s_logger.debug("Done. Updated user_vm_details table with nicAdapter 
entries by copying from vm_template_detail table. This affects only 
VM/templates with hypervisor_type as VMware.");
+    }
 }

Reply via email to