mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-732 Add disk snapshot for KVM 6.3, add the flag in CS.
Signed-off-by: Edison Su <sudison@gmail.com> Conflicts: engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
This commit is contained in:
parent
823c72552e
commit
cd6853cc1a
@ -90,6 +90,7 @@ public class Upgrade410to420 implements DbUpgrade {
|
||||
correctExternalNetworkDevicesSetup(conn);
|
||||
removeFirewallServiceFromSharedNetworkOfferingWithSGService(conn);
|
||||
fix22xKVMSnapshots(conn);
|
||||
setKVMSnapshotFlag(conn);
|
||||
addIndexForAlert(conn);
|
||||
fixBaremetalForeignKeys(conn);
|
||||
// storage refactor related migration
|
||||
@ -297,9 +298,46 @@ public class Upgrade410to420 implements DbUpgrade {
|
||||
*/
|
||||
}
|
||||
|
||||
private void updatePrimaryStore(Connection conn) {
|
||||
PreparedStatement sql = null;
|
||||
PreparedStatement sql2 = null;
|
||||
//KVM snapshot flag: only turn on if Customers is using snapshot;
|
||||
private void setKVMSnapshotFlag(Connection conn) {
|
||||
s_logger.debug("Verify and set the KVM snapshot flag if snapshot was used. ");
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
int numRows = 0;
|
||||
pstmt = conn.prepareStatement("select count(*) from `cloud`.`snapshots` where hypervisor_type = 'KVM'");
|
||||
rs = pstmt.executeQuery();
|
||||
if(rs.next()){
|
||||
numRows = rs.getInt(1);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
if (numRows > 0){
|
||||
//Add the configuration flag
|
||||
pstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` SET value = ? WHERE name = 'KVM.snapshot.enabled'");
|
||||
pstmt.setString(1, "true");
|
||||
pstmt.executeUpdate();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("Failed to read the snapshot table for KVM upgrade. ", e);
|
||||
} finally {
|
||||
try {
|
||||
if (rs != null) {
|
||||
rs.close();
|
||||
}
|
||||
|
||||
if (pstmt != null) {
|
||||
pstmt.close();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
}
|
||||
s_logger.debug("Done set KVM snapshot flag. ");
|
||||
}
|
||||
|
||||
private void updatePrimaryStore(Connection conn) {
|
||||
PreparedStatement sql = null;
|
||||
PreparedStatement sql2 = null;
|
||||
try {
|
||||
sql = conn.prepareStatement("update storage_pool set storage_provider_name = ? , scope = ? where pool_type = 'Filesystem' or pool_type = 'LVM'");
|
||||
sql.setString(1, DataStoreProvider.DEFAULT_PRIMARY);
|
||||
|
||||
@ -145,6 +145,7 @@ public enum Config {
|
||||
SnapshotPollInterval("Snapshots", SnapshotManager.class, Integer.class, "snapshot.poll.interval", "300", "The time interval in seconds when the management server polls for snapshots to be scheduled.", null),
|
||||
SnapshotDeltaMax("Snapshots", SnapshotManager.class, Integer.class, "snapshot.delta.max", "16", "max delta snapshots between two full snapshots.", null),
|
||||
BackupSnapshotAferTakingSnapshot("Snapshots", SnapshotManager.class, Boolean.class, "snapshot.backup.rightafter", "true", "backup snapshot right after snapshot is taken", null),
|
||||
KVMSnapshotEnabled("Snapshots", SnapshotManager.class, Boolean.class, "KVM.snapshot.enabled", "false", "whether snapshot is enabled for KVM hosts", null),
|
||||
|
||||
// Advanced
|
||||
JobExpireMinutes("Advanced", ManagementServer.class, String.class, "job.expire.minutes", "1440", "Time (in minutes) for async-jobs to be kept in system", null),
|
||||
|
||||
@ -910,6 +910,12 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
||||
if (host.getHypervisorType() != HypervisorType.KVM) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//Turn off snapshot by default for KVM, unless it is set in the global flag
|
||||
boolean snapshotEnabled = Boolean.parseBoolean(_configDao.getValue("KVM.snapshot.enabled"));
|
||||
if (!snapshotEnabled) {
|
||||
return false;
|
||||
}
|
||||
// Determine host capabilities
|
||||
String caps = host.getCapabilities();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user