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 <chipchild...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/f8504c09 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f8504c09 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f8504c09 Branch: refs/heads/internallb Commit: f8504c096054d638fb5ed1e21e55243653c4649a Parents: 1206fd6 Author: Wei Zhou <w.z...@leaseweb.com> Authored: Thu May 2 13:10:28 2013 -0400 Committer: Chip Childers <chipchild...@apache.org> Committed: Thu May 2 13:12:18 2013 -0400 ---------------------------------------------------------------------- .../src/com/cloud/upgrade/dao/Upgrade2214to30.java | 24 +++++++------- 1 files changed, 12 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f8504c09/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java b/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java old mode 100755 new mode 100644 index c0f827e..817231f --- a/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java +++ b/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java @@ -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) {