Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 39D7410B2E for ; Wed, 4 Sep 2013 19:57:33 +0000 (UTC) Received: (qmail 10910 invoked by uid 500); 4 Sep 2013 19:57:32 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 10817 invoked by uid 500); 4 Sep 2013 19:57:29 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 10808 invoked by uid 99); 4 Sep 2013 19:57:28 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Sep 2013 19:57:28 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 672909005FB; Wed, 4 Sep 2013 19:57:28 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: vijayendrabvs@apache.org To: commits@cloudstack.apache.org Message-Id: <51b7745135a14409819311d0cc92942d@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: updated refs/heads/master to 57dc52b Date: Wed, 4 Sep 2013 19:57:28 +0000 (UTC) Updated Branches: refs/heads/master f31c31815 -> 57dc52bb6 CLOUDSTACK-4539: [VMWARE] vmware.create.full.clone is set to true in upgraded setup;default nature of vms are full clone Description: Set the criterion for overriding/preserving the vmware.create.full.clone flag so that if past version deployments have any deployments (data centers), this flag will be set to false. Else, it will be set to true. The earlier criterion to set this flag was based on the CS version numbers, but that is not a good business logic to serve as a basis to set the flag. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/57dc52bb Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/57dc52bb Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/57dc52bb Branch: refs/heads/master Commit: 57dc52bb6f04c6e6c92a90282d9c88c5db741c23 Parents: f31c318 Author: Vijayendra Bhamidipati Authored: Thu Aug 29 09:02:22 2013 -0700 Committer: Vijayendra Bhamidipati Committed: Wed Sep 4 05:58:25 2013 -0700 ---------------------------------------------------------------------- .../com/cloud/upgrade/dao/Upgrade410to420.java | 67 ++++++++++++++++++++ setup/db/db/schema-410to420.sql | 4 -- 2 files changed, 67 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/57dc52bb/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 c24ac11..2afca0b 100755 --- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java +++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java @@ -113,6 +113,73 @@ public class Upgrade410to420 implements DbUpgrade { encryptSite2SitePSK(conn); 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) { + PreparedStatement sql = null; + try { + sql = conn.prepareStatement("update `cloud`.`volumes` set state='Uploaded' where state='UploadOp'"); + sql.executeUpdate(); + } catch (SQLException e) { + throw new CloudRuntimeException("Failed to upgrade volume state: ", e); + } finally { + if (sql != null) { + try { + sql.close(); + } catch (SQLException e) { + + } + } + } } private void persistVswitchConfiguration(Connection conn) { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/57dc52bb/setup/db/db/schema-410to420.sql ---------------------------------------------------------------------- diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql index b459832..097adc8 100644 --- a/setup/db/db/schema-410to420.sql +++ b/setup/db/db/schema-410to420.sql @@ -397,10 +397,6 @@ CREATE TABLE `cloud`.`user_vm_clone_setting` ( PRIMARY KEY (`vm_id`) ) 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,