Skip to content

Commit a8cc285

Browse files
committed
bug 8934: set correct guest_type for default Xen Centos template. DB upgrade script is also updated.
status 8934: resolved fixed
1 parent 1932652 commit a8cc285

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

‎server/src/com/cloud/upgrade/dao/Upgrade222to224.java‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public File[] getPrepareScripts() {
5757
@Override
5858
public void performDataMigration(Connection conn) {
5959
updateClusterIdInOpHostCapacity(conn);
60+
updateGuestOsType(conn);
6061
}
6162

6263
@Override
@@ -68,6 +69,26 @@ public File[] getCleanupScripts() {
6869

6970
return new File[] {new File(file)};
7071
}
72+
73+
private void updateGuestOsType(Connection conn) {
74+
try {
75+
PreparedStatement pstmt = conn.prepareStatement("SELECT id FROM `cloud`.`guest_os` WHERE `display_name`='CentOS 5.3 (64-bit)'");
76+
ResultSet rs = pstmt.executeQuery();
77+
Long osId = null;
78+
if (rs.next()) {
79+
osId = rs.getLong(1);
80+
}
81+
82+
if (osId != null) {
83+
pstmt = conn.prepareStatement("UPDATE `cloud`.`vm_template` SET `guest_os_id`=? WHERE id=2");
84+
pstmt.setLong(1, osId);
85+
pstmt.executeUpdate();
86+
}
87+
88+
}catch (SQLException e) {
89+
throw new CloudRuntimeException("Unable to update the guest os type for default template as a part of 222 to 224 upgrade", e);
90+
}
91+
}
7192

7293
private void updateClusterIdInOpHostCapacity(Connection conn){
7394
PreparedStatement pstmt = null;
@@ -122,6 +143,5 @@ private void updateClusterIdInOpHostCapacity(Connection conn){
122143
}
123144

124145
}
125-
126146
}
127147
}

‎setup/db/schema-222to224.sql‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ ALTER TABLE `cloud`.`storage_pool` MODIFY `host_address` char(40) NOT NULL;
4040
ALTER TABLE `cloud`.`networks` DROP FOREIGN KEY `fk_networks__related`;
4141
ALTER TABLE `cloud`.`networks` ADD CONSTRAINT `fk_networks__related` FOREIGN KEY(`related`) REFERENCES `networks`(`id`) ON DELETE CASCADE;
4242

43+

‎setup/db/templates.sql‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
INSERT INTO `cloud`.`vm_template` (id, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type)
22
VALUES (1, 'routing-1', 'SystemVM Template (XenServer)', 0, now(), 'SYSTEM', 0, 64, 1, 'http://download.cloud.com/releases/2.2.0/systemvm.vhd.bz2', 'c33dfaf0937b35c25ef6a0fdd98f24d3', 0, 'SystemVM Template (XenServer)', 'VHD', 15, 0, 1, 'XenServer');
33
INSERT INTO `cloud`.`vm_template` (id, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable)
4-
VALUES (2, 'centos53-x86_64', 'CentOS 5.3(64-bit) no GUI (XenServer)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloud.com/templates/builtin/f59f18fb-ae94-4f97-afd2-f84755767aca.vhd.bz2', 'b63d854a9560c013142567bbae8d98cf', 0, 'CentOS 5.3(64-bit) no GUI (XenServer)', 'VHD', 11, 1, 1, 'XenServer', 1);
4+
VALUES (2, 'centos53-x86_64', 'CentOS 5.3(64-bit) no GUI (XenServer)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloud.com/templates/builtin/f59f18fb-ae94-4f97-afd2-f84755767aca.vhd.bz2', 'b63d854a9560c013142567bbae8d98cf', 0, 'CentOS 5.3(64-bit) no GUI (XenServer)', 'VHD', 12, 1, 1, 'XenServer', 1);
55

66
INSERT INTO `cloud`.`vm_template` (id, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type)
77
VALUES (3, 'routing-3', 'SystemVM Template (KVM)', 0, now(), 'SYSTEM', 0, 64, 1, 'http://download.cloud.com/releases/2.2.0/systemvm.qcow2.bz2', 'ec463e677054f280f152fcc264255d2f', 0, 'SystemVM Template (KVM)', 'QCOW2', 15, 0, 1, 'KVM');

0 commit comments

Comments
 (0)