mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 11:52:28 +01:00
engine/schema: new 4.11.1 systemvmtemplate
This moves db upgrade paths and checks around a new systemvmtemplate for 4.11.1. The new systemvmtemplate compared to 4.11.0 template is slightly smaller and has meltdown/spectre fixes among few other security fixes from Debian and changes to cloud-early-config. Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
85ad4639b0
commit
05857c717d
@ -22,15 +22,11 @@ import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.utils.PropertiesUtil;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@ -68,7 +64,6 @@ public class Upgrade41000to41100 implements DbUpgrade {
|
||||
public void performDataMigration(Connection conn) {
|
||||
checkAndEnableDynamicRoles(conn);
|
||||
validateUserDataInBase64(conn);
|
||||
updateSystemVmTemplates(conn);
|
||||
}
|
||||
|
||||
private void checkAndEnableDynamicRoles(final Connection conn) {
|
||||
@ -126,176 +121,6 @@ public class Upgrade41000to41100 implements DbUpgrade {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private void updateSystemVmTemplates(final Connection conn) {
|
||||
LOG.debug("Updating System Vm template IDs");
|
||||
// Get all hypervisors in use
|
||||
final Set<Hypervisor.HypervisorType> hypervisorsListInUse = new HashSet<Hypervisor.HypervisorType>();
|
||||
try (PreparedStatement pstmt = conn.prepareStatement("select distinct(hypervisor_type) from `cloud`.`cluster` where removed is null"); ResultSet rs = pstmt.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
switch (Hypervisor.HypervisorType.getType(rs.getString(1))) {
|
||||
case XenServer:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.XenServer);
|
||||
break;
|
||||
case KVM:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.KVM);
|
||||
break;
|
||||
case VMware:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.VMware);
|
||||
break;
|
||||
case Hyperv:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.Hyperv);
|
||||
break;
|
||||
case LXC:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.LXC);
|
||||
break;
|
||||
case Ovm3:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.Ovm3);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
LOG.error("updateSystemVmTemplates: Exception caught while getting hypervisor types from clusters: " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while getting hypervisor types from clusters", e);
|
||||
}
|
||||
|
||||
final Map<Hypervisor.HypervisorType, String> NewTemplateNameList = new HashMap<Hypervisor.HypervisorType, String>() {
|
||||
{
|
||||
put(Hypervisor.HypervisorType.KVM, "systemvm-kvm-4.11");
|
||||
put(Hypervisor.HypervisorType.VMware, "systemvm-vmware-4.11");
|
||||
put(Hypervisor.HypervisorType.XenServer, "systemvm-xenserver-4.11");
|
||||
put(Hypervisor.HypervisorType.Hyperv, "systemvm-hyperv-4.11");
|
||||
put(Hypervisor.HypervisorType.LXC, "systemvm-lxc-4.11");
|
||||
put(Hypervisor.HypervisorType.Ovm3, "systemvm-ovm3-4.11");
|
||||
}
|
||||
};
|
||||
|
||||
final Map<Hypervisor.HypervisorType, String> routerTemplateConfigurationNames = new HashMap<Hypervisor.HypervisorType, String>() {
|
||||
{
|
||||
put(Hypervisor.HypervisorType.KVM, "router.template.kvm");
|
||||
put(Hypervisor.HypervisorType.VMware, "router.template.vmware");
|
||||
put(Hypervisor.HypervisorType.XenServer, "router.template.xenserver");
|
||||
put(Hypervisor.HypervisorType.Hyperv, "router.template.hyperv");
|
||||
put(Hypervisor.HypervisorType.LXC, "router.template.lxc");
|
||||
put(Hypervisor.HypervisorType.Ovm3, "router.template.ovm3");
|
||||
}
|
||||
};
|
||||
|
||||
final Map<Hypervisor.HypervisorType, String> newTemplateUrl = new HashMap<Hypervisor.HypervisorType, String>() {
|
||||
{
|
||||
put(Hypervisor.HypervisorType.KVM, "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.0-kvm.qcow2.bz2");
|
||||
put(Hypervisor.HypervisorType.VMware, "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.0-vmware.ova");
|
||||
put(Hypervisor.HypervisorType.XenServer, "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.0-xen.vhd.bz2");
|
||||
put(Hypervisor.HypervisorType.Hyperv, "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.0-hyperv.vhd.zip");
|
||||
put(Hypervisor.HypervisorType.LXC, "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.0-kvm.qcow2.bz2");
|
||||
put(Hypervisor.HypervisorType.Ovm3, "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.0-ovm.raw.bz2");
|
||||
}
|
||||
};
|
||||
|
||||
final Map<Hypervisor.HypervisorType, String> newTemplateChecksum = new HashMap<Hypervisor.HypervisorType, String>() {
|
||||
{
|
||||
put(Hypervisor.HypervisorType.KVM, "2d8d1e4eacc976814b97f02849481433");
|
||||
put(Hypervisor.HypervisorType.XenServer, "a5ecf7ed485e2da5ec1993069aa60553");
|
||||
put(Hypervisor.HypervisorType.VMware, "84dab5d1e8267b5dc85eb4eaa21a1efe");
|
||||
put(Hypervisor.HypervisorType.Hyperv, "d592ab6a2271303fe75b6a27f8e6bd53");
|
||||
put(Hypervisor.HypervisorType.LXC, "2d8d1e4eacc976814b97f02849481433");
|
||||
put(Hypervisor.HypervisorType.Ovm3, "60fe2227b89a8980ee09f89dc7b19582");
|
||||
}
|
||||
};
|
||||
|
||||
for (final Map.Entry<Hypervisor.HypervisorType, String> hypervisorAndTemplateName : NewTemplateNameList.entrySet()) {
|
||||
LOG.debug("Updating " + hypervisorAndTemplateName.getKey() + " System Vms");
|
||||
try (PreparedStatement pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name = ? and removed is null order by id desc limit 1")) {
|
||||
// Get 4.11.0 systemvm template id for corresponding hypervisor
|
||||
long templateId = -1;
|
||||
pstmt.setString(1, hypervisorAndTemplateName.getValue());
|
||||
try (ResultSet rs = pstmt.executeQuery()) {
|
||||
if (rs.next()) {
|
||||
templateId = rs.getLong(1);
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
LOG.error("updateSystemVmTemplates: Exception caught while getting ids of templates: " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates: Exception caught while getting ids of templates", e);
|
||||
}
|
||||
|
||||
// change template type to SYSTEM
|
||||
if (templateId != -1) {
|
||||
try (PreparedStatement templ_type_pstmt = conn.prepareStatement("update `cloud`.`vm_template` set type='SYSTEM' where id = ?");) {
|
||||
templ_type_pstmt.setLong(1, templateId);
|
||||
templ_type_pstmt.executeUpdate();
|
||||
} catch (final SQLException e) {
|
||||
LOG.error("updateSystemVmTemplates:Exception while updating template with id " + templateId + " to be marked as 'system': " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while updating template with id " + templateId + " to be marked as 'system'", e);
|
||||
}
|
||||
// update template ID of system Vms
|
||||
try (PreparedStatement update_templ_id_pstmt = conn
|
||||
.prepareStatement("update `cloud`.`vm_instance` set vm_template_id = ? where type <> 'User' and hypervisor_type = ?");) {
|
||||
update_templ_id_pstmt.setLong(1, templateId);
|
||||
update_templ_id_pstmt.setString(2, hypervisorAndTemplateName.getKey().toString());
|
||||
update_templ_id_pstmt.executeUpdate();
|
||||
} catch (final Exception e) {
|
||||
LOG.error("updateSystemVmTemplates:Exception while setting template for " + hypervisorAndTemplateName.getKey().toString() + " to " + templateId
|
||||
+ ": " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while setting template for " + hypervisorAndTemplateName.getKey().toString() + " to "
|
||||
+ templateId, e);
|
||||
}
|
||||
|
||||
// Change value of global configuration parameter
|
||||
// router.template.* for the corresponding hypervisor
|
||||
try (PreparedStatement update_pstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` SET value = ? WHERE name = ?");) {
|
||||
update_pstmt.setString(1, hypervisorAndTemplateName.getValue());
|
||||
update_pstmt.setString(2, routerTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()));
|
||||
update_pstmt.executeUpdate();
|
||||
} catch (final SQLException e) {
|
||||
LOG.error("updateSystemVmTemplates:Exception while setting " + routerTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()) + " to "
|
||||
+ hypervisorAndTemplateName.getValue() + ": " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while setting "
|
||||
+ routerTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()) + " to " + hypervisorAndTemplateName.getValue(), e);
|
||||
}
|
||||
|
||||
// Change value of global configuration parameter
|
||||
// minreq.sysvmtemplate.version for the ACS version
|
||||
try (PreparedStatement update_pstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` SET value = ? WHERE name = ?");) {
|
||||
update_pstmt.setString(1, "4.11.0");
|
||||
update_pstmt.setString(2, "minreq.sysvmtemplate.version");
|
||||
update_pstmt.executeUpdate();
|
||||
} catch (final SQLException e) {
|
||||
LOG.error("updateSystemVmTemplates:Exception while setting 'minreq.sysvmtemplate.version' to 4.11.0: " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while setting 'minreq.sysvmtemplate.version' to 4.11.0", e);
|
||||
}
|
||||
} else {
|
||||
if (hypervisorsListInUse.contains(hypervisorAndTemplateName.getKey())) {
|
||||
throw new CloudRuntimeException(getUpgradedVersion() + hypervisorAndTemplateName.getKey() + " SystemVm template not found. Cannot upgrade system Vms");
|
||||
} else {
|
||||
LOG.warn(getUpgradedVersion() + hypervisorAndTemplateName.getKey() + " SystemVm template not found. " + hypervisorAndTemplateName.getKey()
|
||||
+ " hypervisor is not used, so not failing upgrade");
|
||||
// Update the latest template URLs for corresponding
|
||||
// hypervisor
|
||||
try (PreparedStatement update_templ_url_pstmt = conn
|
||||
.prepareStatement("UPDATE `cloud`.`vm_template` SET url = ? , checksum = ? WHERE hypervisor_type = ? AND type = 'SYSTEM' AND removed is null order by id desc limit 1");) {
|
||||
update_templ_url_pstmt.setString(1, newTemplateUrl.get(hypervisorAndTemplateName.getKey()));
|
||||
update_templ_url_pstmt.setString(2, newTemplateChecksum.get(hypervisorAndTemplateName.getKey()));
|
||||
update_templ_url_pstmt.setString(3, hypervisorAndTemplateName.getKey().toString());
|
||||
update_templ_url_pstmt.executeUpdate();
|
||||
} catch (final SQLException e) {
|
||||
LOG.error("updateSystemVmTemplates:Exception while updating 'url' and 'checksum' for hypervisor type "
|
||||
+ hypervisorAndTemplateName.getKey().toString() + ": " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while updating 'url' and 'checksum' for hypervisor type "
|
||||
+ hypervisorAndTemplateName.getKey().toString(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
LOG.error("updateSystemVmTemplates:Exception while getting ids of templates: " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while getting ids of templates", e);
|
||||
}
|
||||
}
|
||||
LOG.debug("Updating System Vm Template IDs Complete");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public InputStream[] getCleanupScripts() {
|
||||
final String scriptFile = "META-INF/db/schema-41000to41100-cleanup.sql";
|
||||
|
||||
@ -19,12 +19,24 @@
|
||||
|
||||
package com.cloud.upgrade.dao;
|
||||
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
public class Upgrade41100to41110 implements DbUpgrade {
|
||||
final static Logger LOG = Logger.getLogger(Upgrade41000to41100.class);
|
||||
|
||||
@Override
|
||||
public String[] getUpgradableVersionRange() {
|
||||
return new String[]{"4.11.0.0", "4.11.1.0"};
|
||||
@ -53,7 +65,175 @@ public class Upgrade41100to41110 implements DbUpgrade {
|
||||
|
||||
@Override
|
||||
public void performDataMigration(Connection conn) {
|
||||
updateSystemVmTemplates(conn);
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private void updateSystemVmTemplates(final Connection conn) {
|
||||
LOG.debug("Updating System Vm template IDs");
|
||||
final Set<Hypervisor.HypervisorType> hypervisorsListInUse = new HashSet<Hypervisor.HypervisorType>();
|
||||
try (PreparedStatement pstmt = conn.prepareStatement("select distinct(hypervisor_type) from `cloud`.`cluster` where removed is null"); ResultSet rs = pstmt.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
switch (Hypervisor.HypervisorType.getType(rs.getString(1))) {
|
||||
case XenServer:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.XenServer);
|
||||
break;
|
||||
case KVM:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.KVM);
|
||||
break;
|
||||
case VMware:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.VMware);
|
||||
break;
|
||||
case Hyperv:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.Hyperv);
|
||||
break;
|
||||
case LXC:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.LXC);
|
||||
break;
|
||||
case Ovm3:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.Ovm3);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
LOG.error("updateSystemVmTemplates: Exception caught while getting hypervisor types from clusters: " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while getting hypervisor types from clusters", e);
|
||||
}
|
||||
|
||||
final Map<Hypervisor.HypervisorType, String> NewTemplateNameList = new HashMap<Hypervisor.HypervisorType, String>() {
|
||||
{
|
||||
put(Hypervisor.HypervisorType.KVM, "systemvm-kvm-4.11.1");
|
||||
put(Hypervisor.HypervisorType.VMware, "systemvm-vmware-4.11.1");
|
||||
put(Hypervisor.HypervisorType.XenServer, "systemvm-xenserver-4.11.1");
|
||||
put(Hypervisor.HypervisorType.Hyperv, "systemvm-hyperv-4.11.1");
|
||||
put(Hypervisor.HypervisorType.LXC, "systemvm-lxc-4.11.1");
|
||||
put(Hypervisor.HypervisorType.Ovm3, "systemvm-ovm3-4.11.1");
|
||||
}
|
||||
};
|
||||
|
||||
final Map<Hypervisor.HypervisorType, String> routerTemplateConfigurationNames = new HashMap<Hypervisor.HypervisorType, String>() {
|
||||
{
|
||||
put(Hypervisor.HypervisorType.KVM, "router.template.kvm");
|
||||
put(Hypervisor.HypervisorType.VMware, "router.template.vmware");
|
||||
put(Hypervisor.HypervisorType.XenServer, "router.template.xenserver");
|
||||
put(Hypervisor.HypervisorType.Hyperv, "router.template.hyperv");
|
||||
put(Hypervisor.HypervisorType.LXC, "router.template.lxc");
|
||||
put(Hypervisor.HypervisorType.Ovm3, "router.template.ovm3");
|
||||
}
|
||||
};
|
||||
|
||||
final Map<Hypervisor.HypervisorType, String> newTemplateUrl = new HashMap<Hypervisor.HypervisorType, String>() {
|
||||
{
|
||||
put(Hypervisor.HypervisorType.KVM, "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.1-kvm.qcow2.bz2");
|
||||
put(Hypervisor.HypervisorType.VMware, "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.1-vmware.ova");
|
||||
put(Hypervisor.HypervisorType.XenServer, "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.1-xen.vhd.bz2");
|
||||
put(Hypervisor.HypervisorType.Hyperv, "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.1-hyperv.vhd.zip");
|
||||
put(Hypervisor.HypervisorType.LXC, "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.1-kvm.qcow2.bz2");
|
||||
put(Hypervisor.HypervisorType.Ovm3, "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.1-ovm.raw.bz2");
|
||||
}
|
||||
};
|
||||
|
||||
final Map<Hypervisor.HypervisorType, String> newTemplateChecksum = new HashMap<Hypervisor.HypervisorType, String>() {
|
||||
{
|
||||
put(Hypervisor.HypervisorType.KVM, "6019c2ed1a13669dcf334fe380c776b0");
|
||||
put(Hypervisor.HypervisorType.XenServer, "f2245e912c856ab610d91f88c362a1f9");
|
||||
put(Hypervisor.HypervisorType.VMware, "1dbcd051fcfcd0fd568ff6eb5294988a");
|
||||
put(Hypervisor.HypervisorType.Hyperv, "e68ec90f0dc06821d94a2ee0e88fa646");
|
||||
put(Hypervisor.HypervisorType.LXC, "6019c2ed1a13669dcf334fe380c776b0");
|
||||
put(Hypervisor.HypervisorType.Ovm3, "cd2ac8dcdaf6c05d75e29cb39ee9a10f");
|
||||
}
|
||||
};
|
||||
|
||||
for (final Map.Entry<Hypervisor.HypervisorType, String> hypervisorAndTemplateName : NewTemplateNameList.entrySet()) {
|
||||
LOG.debug("Updating " + hypervisorAndTemplateName.getKey() + " System Vms");
|
||||
try (PreparedStatement pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name = ? and removed is null order by id desc limit 1")) {
|
||||
// Get 4.11.0 systemvm template id for corresponding hypervisor
|
||||
long templateId = -1;
|
||||
pstmt.setString(1, hypervisorAndTemplateName.getValue());
|
||||
try (ResultSet rs = pstmt.executeQuery()) {
|
||||
if (rs.next()) {
|
||||
templateId = rs.getLong(1);
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
LOG.error("updateSystemVmTemplates: Exception caught while getting ids of templates: " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates: Exception caught while getting ids of templates", e);
|
||||
}
|
||||
|
||||
// change template type to SYSTEM
|
||||
if (templateId != -1) {
|
||||
try (PreparedStatement templ_type_pstmt = conn.prepareStatement("update `cloud`.`vm_template` set type='SYSTEM' where id = ?");) {
|
||||
templ_type_pstmt.setLong(1, templateId);
|
||||
templ_type_pstmt.executeUpdate();
|
||||
} catch (final SQLException e) {
|
||||
LOG.error("updateSystemVmTemplates:Exception while updating template with id " + templateId + " to be marked as 'system': " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while updating template with id " + templateId + " to be marked as 'system'", e);
|
||||
}
|
||||
// update template ID of system Vms
|
||||
try (PreparedStatement update_templ_id_pstmt = conn
|
||||
.prepareStatement("update `cloud`.`vm_instance` set vm_template_id = ? where type <> 'User' and hypervisor_type = ?");) {
|
||||
update_templ_id_pstmt.setLong(1, templateId);
|
||||
update_templ_id_pstmt.setString(2, hypervisorAndTemplateName.getKey().toString());
|
||||
update_templ_id_pstmt.executeUpdate();
|
||||
} catch (final Exception e) {
|
||||
LOG.error("updateSystemVmTemplates:Exception while setting template for " + hypervisorAndTemplateName.getKey().toString() + " to " + templateId
|
||||
+ ": " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while setting template for " + hypervisorAndTemplateName.getKey().toString() + " to "
|
||||
+ templateId, e);
|
||||
}
|
||||
|
||||
// Change value of global configuration parameter
|
||||
// router.template.* for the corresponding hypervisor
|
||||
try (PreparedStatement update_pstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` SET value = ? WHERE name = ?");) {
|
||||
update_pstmt.setString(1, hypervisorAndTemplateName.getValue());
|
||||
update_pstmt.setString(2, routerTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()));
|
||||
update_pstmt.executeUpdate();
|
||||
} catch (final SQLException e) {
|
||||
LOG.error("updateSystemVmTemplates:Exception while setting " + routerTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()) + " to "
|
||||
+ hypervisorAndTemplateName.getValue() + ": " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while setting "
|
||||
+ routerTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()) + " to " + hypervisorAndTemplateName.getValue(), e);
|
||||
}
|
||||
|
||||
// Change value of global configuration parameter
|
||||
// minreq.sysvmtemplate.version for the ACS version
|
||||
try (PreparedStatement update_pstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` SET value = ? WHERE name = ?");) {
|
||||
update_pstmt.setString(1, "4.11.1");
|
||||
update_pstmt.setString(2, "minreq.sysvmtemplate.version");
|
||||
update_pstmt.executeUpdate();
|
||||
} catch (final SQLException e) {
|
||||
LOG.error("updateSystemVmTemplates:Exception while setting 'minreq.sysvmtemplate.version' to 4.11.1: " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while setting 'minreq.sysvmtemplate.version' to 4.11.1", e);
|
||||
}
|
||||
} else {
|
||||
if (hypervisorsListInUse.contains(hypervisorAndTemplateName.getKey())) {
|
||||
throw new CloudRuntimeException(getUpgradedVersion() + hypervisorAndTemplateName.getKey() + " SystemVm template not found. Cannot upgrade system Vms");
|
||||
} else {
|
||||
LOG.warn(getUpgradedVersion() + hypervisorAndTemplateName.getKey() + " SystemVm template not found. " + hypervisorAndTemplateName.getKey()
|
||||
+ " hypervisor is not used, so not failing upgrade");
|
||||
// Update the latest template URLs for corresponding
|
||||
// hypervisor
|
||||
try (PreparedStatement update_templ_url_pstmt = conn
|
||||
.prepareStatement("UPDATE `cloud`.`vm_template` SET url = ? , checksum = ? WHERE hypervisor_type = ? AND type = 'SYSTEM' AND removed is null order by id desc limit 1");) {
|
||||
update_templ_url_pstmt.setString(1, newTemplateUrl.get(hypervisorAndTemplateName.getKey()));
|
||||
update_templ_url_pstmt.setString(2, newTemplateChecksum.get(hypervisorAndTemplateName.getKey()));
|
||||
update_templ_url_pstmt.setString(3, hypervisorAndTemplateName.getKey().toString());
|
||||
update_templ_url_pstmt.executeUpdate();
|
||||
} catch (final SQLException e) {
|
||||
LOG.error("updateSystemVmTemplates:Exception while updating 'url' and 'checksum' for hypervisor type "
|
||||
+ hypervisorAndTemplateName.getKey().toString() + ": " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while updating 'url' and 'checksum' for hypervisor type "
|
||||
+ hypervisorAndTemplateName.getKey().toString(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
LOG.error("updateSystemVmTemplates:Exception while getting ids of templates: " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while getting ids of templates", e);
|
||||
}
|
||||
}
|
||||
LOG.debug("Updating System Vm Template IDs Complete");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user