From 8e1507078052b8068b828d336f8d0358915047e1 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Mon, 13 Apr 2015 15:34:27 +0530 Subject: [PATCH] CLOUDSTACK-7593: in 450to451 upgrade path copy vm_details from template for vmware Signed-off-by: Rohit Yadav --- .../com/cloud/upgrade/dao/Upgrade450to451.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade450to451.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade450to451.java index 89fe5eca389..218f4ec60b0 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."); + } }