Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import javax.inject.Inject;

import com.cloud.upgrade.dao.Upgrade41900to41910;
import com.cloud.utils.FileUtil;
import org.apache.cloudstack.utils.CloudStackVersion;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -85,7 +86,6 @@
import com.cloud.upgrade.dao.Upgrade41720to41800;
import com.cloud.upgrade.dao.Upgrade41800to41810;
import com.cloud.upgrade.dao.Upgrade41810to41900;
import com.cloud.upgrade.dao.Upgrade41900to41910;
import com.cloud.upgrade.dao.Upgrade420to421;
import com.cloud.upgrade.dao.Upgrade421to430;
import com.cloud.upgrade.dao.Upgrade430to440;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@
// under the License.
package com.cloud.upgrade.dao;

import com.cloud.upgrade.SystemVmTemplateRegistration;
import com.cloud.utils.exception.CloudRuntimeException;
import org.apache.log4j.Logger;

import java.io.InputStream;
import java.sql.Connection;

public class Upgrade41900to41910 implements DbUpgrade {
public class Upgrade41900to41910 implements DbUpgrade, DbUpgradeSystemVmTemplate {
final static Logger LOG = Logger.getLogger(Upgrade41900to41910.class);
private SystemVmTemplateRegistration systemVmTemplateRegistration;

@Override
public String[] getUpgradableVersionRange() {
return new String[] {"4.19.0.0", "4.19.1.0"};
return new String[]{"4.19.0.0", "4.19.1.0"};
}

@Override
Expand All @@ -46,11 +50,12 @@ public InputStream[] getPrepareScripts() {
throw new CloudRuntimeException("Unable to find " + scriptFile);
}

return new InputStream[] {script};
return new InputStream[]{script};
}

@Override
public void performDataMigration(Connection conn) {
addIndexes(conn);
}

@Override
Expand All @@ -61,6 +66,25 @@ public InputStream[] getCleanupScripts() {
throw new CloudRuntimeException("Unable to find " + scriptFile);
}

return new InputStream[] {script};
return new InputStream[]{script};
}

private void addIndexes(Connection conn) {
DbUpgradeUtils.addIndexIfNeeded(conn, "vm_stats", "vm_id", "timestamp");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
DbUpgradeUtils.addIndexIfNeeded(conn, "vm_stats", "vm_id", "timestamp");
DbUpgradeUtils.addIndexIfNeeded(conn, "vm_stats", "vm_id");

}

@Override
public void updateSystemVmTemplates(Connection conn) {
LOG.debug("Updating System Vm template IDs");
initSystemVmTemplateRegistration();
try {
systemVmTemplateRegistration.updateSystemVmTemplates(conn);
} catch (Exception e) {
throw new CloudRuntimeException("Failed to find / register SystemVM template(s)");
}
}

private void initSystemVmTemplateRegistration() {
systemVmTemplateRegistration = new SystemVmTemplateRegistration("");
Comment thread
yadvr marked this conversation as resolved.
}
}