CLOUDSTACK-2303: fix upgrade failed from 2.2.14 to 4.1.0 for systemvm changes

The version of systemvm of 3.* and 4.0.* is systemvm-kvm-3.0.0.(from
http://cloudstack.apache.org/docs/en-US/Apache_CloudStack/4.0.2/pdf/Release_Notes/Apache_CloudStack-4.0.2-Release_Notes-en-US.pdf)
However, on cloudstack 4.1.0, the systemvm version is 4.1.0. (from
http://dissociatedpress.net/uploads/Apache_CloudStack-4.1.0-Release_Notes-en-US.pdf)
so the upgrade processing from 2.2.14 to 4.1.0 will abort at
updateSystemVms in Upgrade2214to30.java.

Signed-off-by: Chip Childers <chipchilders@apache.org>
This commit is contained in:
Wei Zhou 2013-05-02 13:10:28 -04:00 committed by Chip Childers
parent 1206fd6b4e
commit f8504c0960

24
server/src/com/cloud/upgrade/dao/Upgrade2214to30.java Executable file → Normal file
View File

@ -629,8 +629,8 @@ public class Upgrade2214to30 extends Upgrade30xBase implements DbUpgrade {
s_logger.debug("Updating XenSever System Vms");
//XenServer
try {
//Get 3.0.0 xenserer system Vm template Id
pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name = 'systemvm-xenserver-3.0.0' and removed is null");
//Get 3.0.0 or later xenserer system Vm template Id
pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name like 'systemvm-xenserver-%' and removed is null");
rs = pstmt.executeQuery();
if(rs.next()){
long templateId = rs.getLong(1);
@ -648,9 +648,9 @@ public class Upgrade2214to30 extends Upgrade30xBase implements DbUpgrade {
pstmt.close();
} else {
if (xenserver){
throw new CloudRuntimeException("3.0.0 XenServer SystemVm template not found. Cannot upgrade system Vms");
throw new CloudRuntimeException("3.0.0 or later XenServer SystemVm template not found. Cannot upgrade system Vms");
} else {
s_logger.warn("3.0.0 XenServer SystemVm template not found. XenServer hypervisor is not used, so not failing upgrade");
s_logger.warn("3.0.0 or later XenServer SystemVm template not found. XenServer hypervisor is not used, so not failing upgrade");
}
}
} catch (SQLException e) {
@ -660,8 +660,8 @@ public class Upgrade2214to30 extends Upgrade30xBase implements DbUpgrade {
//KVM
s_logger.debug("Updating KVM System Vms");
try {
//Get 3.0.0 KVM system Vm template Id
pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name = 'systemvm-kvm-3.0.0' and removed is null");
//Get 3.0.0 or later KVM system Vm template Id
pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name like 'systemvm-kvm-%' and removed is null");
rs = pstmt.executeQuery();
if(rs.next()){
long templateId = rs.getLong(1);
@ -679,9 +679,9 @@ public class Upgrade2214to30 extends Upgrade30xBase implements DbUpgrade {
pstmt.close();
} else {
if (kvm){
throw new CloudRuntimeException("3.0.0 KVM SystemVm template not found. Cannot upgrade system Vms");
throw new CloudRuntimeException("3.0.0 or later KVM SystemVm template not found. Cannot upgrade system Vms");
} else {
s_logger.warn("3.0.0 KVM SystemVm template not found. KVM hypervisor is not used, so not failing upgrade");
s_logger.warn("3.0.0 or later KVM SystemVm template not found. KVM hypervisor is not used, so not failing upgrade");
}
}
} catch (SQLException e) {
@ -691,8 +691,8 @@ public class Upgrade2214to30 extends Upgrade30xBase implements DbUpgrade {
//VMware
s_logger.debug("Updating VMware System Vms");
try {
//Get 3.0.0 VMware system Vm template Id
pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name = 'systemvm-vmware-3.0.0' and removed is null");
//Get 3.0.0 or later VMware system Vm template Id
pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name like 'systemvm-vmware-%' and removed is null");
rs = pstmt.executeQuery();
if(rs.next()){
long templateId = rs.getLong(1);
@ -710,9 +710,9 @@ public class Upgrade2214to30 extends Upgrade30xBase implements DbUpgrade {
pstmt.close();
} else {
if (VMware){
throw new CloudRuntimeException("3.0.0 VMware SystemVm template not found. Cannot upgrade system Vms");
throw new CloudRuntimeException("3.0.0 or later VMware SystemVm template not found. Cannot upgrade system Vms");
} else {
s_logger.warn("3.0.0 VMware SystemVm template not found. VMware hypervisor is not used, so not failing upgrade");
s_logger.warn("3.0.0 or later VMware SystemVm template not found. VMware hypervisor is not used, so not failing upgrade");
}
}
} catch (SQLException e) {