bug 8934: set correct guest_type for default Xen Centos template. DB upgrade script is also updated.

status 8934: resolved fixed
This commit is contained in:
alena 2011-03-25 15:53:18 -07:00
parent 1932652125
commit a8cc285ca9
3 changed files with 23 additions and 2 deletions

View File

@ -57,6 +57,7 @@ public class Upgrade222to224 implements DbUpgrade {
@Override
public void performDataMigration(Connection conn) {
updateClusterIdInOpHostCapacity(conn);
updateGuestOsType(conn);
}
@Override
@ -68,6 +69,26 @@ public class Upgrade222to224 implements DbUpgrade {
return new File[] {new File(file)};
}
private void updateGuestOsType(Connection conn) {
try {
PreparedStatement pstmt = conn.prepareStatement("SELECT id FROM `cloud`.`guest_os` WHERE `display_name`='CentOS 5.3 (64-bit)'");
ResultSet rs = pstmt.executeQuery();
Long osId = null;
if (rs.next()) {
osId = rs.getLong(1);
}
if (osId != null) {
pstmt = conn.prepareStatement("UPDATE `cloud`.`vm_template` SET `guest_os_id`=? WHERE id=2");
pstmt.setLong(1, osId);
pstmt.executeUpdate();
}
}catch (SQLException e) {
throw new CloudRuntimeException("Unable to update the guest os type for default template as a part of 222 to 224 upgrade", e);
}
}
private void updateClusterIdInOpHostCapacity(Connection conn){
PreparedStatement pstmt = null;
@ -122,6 +143,5 @@ public class Upgrade222to224 implements DbUpgrade {
}
}
}
}

View File

@ -40,3 +40,4 @@ ALTER TABLE `cloud`.`storage_pool` MODIFY `host_address` char(40) NOT NULL;
ALTER TABLE `cloud`.`networks` DROP FOREIGN KEY `fk_networks__related`;
ALTER TABLE `cloud`.`networks` ADD CONSTRAINT `fk_networks__related` FOREIGN KEY(`related`) REFERENCES `networks`(`id`) ON DELETE CASCADE;

View File

@ -1,7 +1,7 @@
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)
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');
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)
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);
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);
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)
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');