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

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit 8e1507078052b8068b828d336f8d0358915047e1)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2015-04-13 15:34:27 +05:30
parent a07497b373
commit a70947f9b1

View File

@ -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.");
}
}