Updated Branches:
  refs/heads/4.2-forward 0b9b36cbc -> 07d79c7ad

CLOUDSTACK-4539: [VMWARE] vmware.create.full.clone is set to true in upgraded 
setup;default nature of vms are full clone
Reviwed-by: Kelven Yang <[email protected]>
Description:

    Change the criterion for overriding/preserving the vmware.create.full.clone
    flag. The earlier criterion was simply the version numbers, but that is not
    a good business logic basis for the change. With this fix, if past version
    deployments have any deployments (data centers), this flag will be set to
    false. Else, it will be set to true.


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

Branch: refs/heads/4.2-forward
Commit: 07d79c7ad660375cfb0e88794048993c4e349cf0
Parents: 0b9b36c
Author: Vijayendra Bhamidipati <[email protected]>
Authored: Thu Aug 29 09:02:22 2013 -0700
Committer: Vijayendra Bhamidipati <[email protected]>
Committed: Thu Aug 29 09:21:23 2013 -0700

----------------------------------------------------------------------
 .../com/cloud/upgrade/dao/Upgrade410to420.java  | 48 ++++++++++++++++++++
 setup/db/db/schema-410to420.sql                 |  7 ---
 2 files changed, 48 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07d79c7a/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 773ad62..839ab86 100755
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
@@ -113,6 +113,54 @@ public class Upgrade410to420 implements DbUpgrade {
         migrateDatafromIsoIdInVolumesTable(conn);
         setRAWformatForRBDVolumes(conn);
         migrateVolumeOnSecondaryStorage(conn);
+        createFullCloneFlag(conn);
+    }
+
+    private void createFullCloneFlag(Connection conn) {
+        ResultSet rs = null;
+        PreparedStatement delete = null;
+        PreparedStatement query = null;
+        PreparedStatement update = null;
+        int numRows = 0;
+        try {
+            delete = conn.prepareStatement("delete from 
`cloud`.`configuration` where name='vmware.create.full.clone';");
+            delete.executeUpdate();
+            query = conn.prepareStatement("select count(*) from 
`cloud`.`data_center`");
+            rs = query.executeQuery();
+            if (rs.next()) {
+                numRows = rs.getInt(1);
+            }
+            if (numRows > 0) {
+                update = conn.prepareStatement("insert into 
`cloud`.`configuration` (`category`, `instance`, `component`, `name`, `value`, 
`description`) VALUES ('Advanced', 'DEFAULT', 'UserVmManager', 
'vmware.create.full.clone' , 'false', 'If set to true, creates VMs as full 
clones on ESX hypervisor');");
+            } else {
+                update = conn.prepareStatement("insert into 
`cloud`.`configuration` (`category`, `instance`, `component`, `name`, `value`, 
`description`) VALUES ('Advanced', 'DEFAULT', 'UserVmManager', 
'vmware.create.full.clone' , 'true', 'If set to true, creates VMs as full 
clones on ESX hypervisor');");
+            }
+            update.executeUpdate();
+        } catch (SQLException e) {
+            throw new CloudRuntimeException("Failed to set global flag 
vmware.create.full.clone: ", e);
+        } finally {
+            if (update != null) {
+                try {
+                    update.close();
+                } catch (SQLException e) {
+
+                }
+            }
+            if (query != null) {
+                try {
+                    query.close();
+                } catch (SQLException e) {
+
+                }
+            }
+            if (delete != null) {
+                try {
+                    delete.close();
+                } catch (SQLException e) {
+
+                }
+            }
+        }
     }
 
     private void migrateVolumeOnSecondaryStorage(Connection conn) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07d79c7a/setup/db/db/schema-410to420.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql
index 6eb7534..6e9fe72 100644
--- a/setup/db/db/schema-410to420.sql
+++ b/setup/db/db/schema-410to420.sql
@@ -403,13 +403,6 @@ CREATE TABLE `cloud`.`user_vm_clone_setting` (
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 
-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,
   `name` varchar(255) NOT NULL,

Reply via email to