CS-16042: 3.0.x to 3.0.5 Upgrade: VMWare : Upgrade Procedure for using the new Burbank System Template in place of Acton System Template Required

Description:

    Modifying reference to system VM template for vmware for the
    2.2.14 to 3.0 upgrade path so that it picks up the burbank
    template if upgrading from 2.2.14 to 3.0.5 or beyond, and
    the acton template if upgrading from 2.2.14 to 3.0.[0-4].
This commit is contained in:
Vijayendra Bhamidipati 2012-08-17 15:59:35 -07:00
parent 91bd6d96d9
commit 0cf0523afe
2 changed files with 32 additions and 1 deletions

View File

@ -46,6 +46,11 @@ public class Version {
String[] tokens = version.split("[.]");
return tokens[0] + "." + tokens[1]+ "." + tokens[2];
}
public static String trimToPatchNormalized(String version) {
String[] tokens = version.split("[.]");
return tokens[0] + tokens[1] + tokens[2];
}
public static void main(String[] args) {
System.out.println("Result is " + compare(args[0], args[1]));

View File

@ -27,6 +27,7 @@ import java.util.UUID;
import org.apache.log4j.Logger;
import com.cloud.maint.Version;
import com.cloud.offering.NetworkOffering;
import com.cloud.utils.crypt.DBEncryptionUtil;
import com.cloud.utils.crypt.EncryptionSecretKeyChecker;
@ -666,7 +667,32 @@ public class Upgrade2214to30 extends Upgrade30xBase implements DbUpgrade {
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");
// First get the current version of the Mgmt server from the db.
String curDbVersion = "";
String trimmedCurrentVersion = "";
pstmt = conn.prepareStatement("select version from `cloud`.`version`");
try {
rs = pstmt.executeQuery();
if(rs.next()) {
curDbVersion = rs.getString(1);
rs.close();
pstmt.close();
} else
throw new CloudRuntimeException("Couldn't retrieve current version from db");
} catch (SQLException e) {
throw new CloudRuntimeException("Encountered sql exception : Couldn't retrieve current version from db");
}
if (curDbVersion != null) {
trimmedCurrentVersion = Version.trimToPatchNormalized(curDbVersion);
}
// If the current version is >= 3.0.5, use the new burbank template.
if (Long.valueOf(trimmedCurrentVersion).longValue() >= 305 ) {
s_logger.info("Using 3.0.5 vmware system vm template");
pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name = 'systemvm-vmware-3.0.5' and removed is null");
} else {
s_logger.info("Using 3.0.0 vmware system vm template");
pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name = 'systemvm-vmware-3.0.0' and removed is null");
}
rs = pstmt.executeQuery();
if(rs.next()){
long templateId = rs.getLong(1);