Skip to content

Commit 07d79c7

Browse files
author
Vijayendra Bhamidipati
committed
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 <kelven.yang@citrix.com> 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.
1 parent 0b9b36c commit 07d79c7

2 files changed

Lines changed: 48 additions & 7 deletions

File tree

‎engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,54 @@ public void performDataMigration(Connection conn) {
113113
migrateDatafromIsoIdInVolumesTable(conn);
114114
setRAWformatForRBDVolumes(conn);
115115
migrateVolumeOnSecondaryStorage(conn);
116+
createFullCloneFlag(conn);
117+
}
118+
119+
private void createFullCloneFlag(Connection conn) {
120+
ResultSet rs = null;
121+
PreparedStatement delete = null;
122+
PreparedStatement query = null;
123+
PreparedStatement update = null;
124+
int numRows = 0;
125+
try {
126+
delete = conn.prepareStatement("delete from `cloud`.`configuration` where name='vmware.create.full.clone';");
127+
delete.executeUpdate();
128+
query = conn.prepareStatement("select count(*) from `cloud`.`data_center`");
129+
rs = query.executeQuery();
130+
if (rs.next()) {
131+
numRows = rs.getInt(1);
132+
}
133+
if (numRows > 0) {
134+
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');");
135+
} else {
136+
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');");
137+
}
138+
update.executeUpdate();
139+
} catch (SQLException e) {
140+
throw new CloudRuntimeException("Failed to set global flag vmware.create.full.clone: ", e);
141+
} finally {
142+
if (update != null) {
143+
try {
144+
update.close();
145+
} catch (SQLException e) {
146+
147+
}
148+
}
149+
if (query != null) {
150+
try {
151+
query.close();
152+
} catch (SQLException e) {
153+
154+
}
155+
}
156+
if (delete != null) {
157+
try {
158+
delete.close();
159+
} catch (SQLException e) {
160+
161+
}
162+
}
163+
}
116164
}
117165

118166
private void migrateVolumeOnSecondaryStorage(Connection conn) {

‎setup/db/db/schema-410to420.sql‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -403,13 +403,6 @@ CREATE TABLE `cloud`.`user_vm_clone_setting` (
403403
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
404404

405405

406-
INSERT INTO `cloud`.`configuration` (category, instance, component, name, value, description)
407-
SELECT tmp.category, tmp.instance, tmp.component, tmp.name, tmp.value, tmp.description FROM
408-
(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
409-
WHERE NOT EXISTS (SELECT 1 FROM `cloud`.`configuration` WHERE name = 'vmware.create.full.clone');
410-
411-
412-
413406
CREATE TABLE `cloud`.`affinity_group` (
414407
`id` bigint unsigned NOT NULL auto_increment,
415408
`name` varchar(255) NOT NULL,

0 commit comments

Comments
 (0)