bug 10923: changes for snapshot command to carry primary storage pool path

This commit is contained in:
Murali Reddy 2011-08-12 17:30:01 +05:30
parent 5ef0c96e70
commit cc60989a68
3 changed files with 25 additions and 5 deletions

View File

@ -17,7 +17,9 @@
*/
package com.cloud.agent.api;
import com.cloud.agent.api.to.StorageFilerTO;
import com.cloud.agent.api.to.SwiftTO;
import com.cloud.storage.StoragePool;
/**
* When a snapshot of a VDI is taken, it creates two new files,
@ -33,7 +35,8 @@ public class BackupSnapshotCommand extends SnapshotCommand {
private String vmName;
private Long snapshotId;
private SwiftTO swift;
StorageFilerTO pool;
protected BackupSnapshotCommand() {
}
@ -55,6 +58,7 @@ public class BackupSnapshotCommand extends SnapshotCommand {
Long volumeId,
Long snapshotId,
String volumePath,
StoragePool pool,
String snapshotUuid,
String snapshotName,
String prevSnapshotUuid,
@ -68,6 +72,7 @@ public class BackupSnapshotCommand extends SnapshotCommand {
this.prevBackupUuid = prevBackupUuid;
this.isVolumeInactive = isVolumeInactive;
this.vmName = vmName;
this.pool = new StorageFilerTO(pool);
setVolumePath(volumePath);
}
@ -98,4 +103,8 @@ public class BackupSnapshotCommand extends SnapshotCommand {
public Long getSnapshotId() {
return snapshotId;
}
public StorageFilerTO getPool() {
return pool;
}
}

View File

@ -17,6 +17,9 @@
*/
package com.cloud.agent.api;
import com.cloud.agent.api.to.StorageFilerTO;
import com.cloud.storage.StoragePool;
public class ManageSnapshotCommand extends Command {
@ -29,7 +32,8 @@ public class ManageSnapshotCommand extends Command {
// Information about the volume that the snapshot is based on
private String _volumePath = null;
StorageFilerTO _pool;
// Information about the snapshot
private String _snapshotPath = null;
private String _snapshotName = null;
@ -38,9 +42,10 @@ public class ManageSnapshotCommand extends Command {
public ManageSnapshotCommand() {}
public ManageSnapshotCommand(long snapshotId, String volumePath, String preSnapshotPath ,String snapshotName, String vmName) {
public ManageSnapshotCommand(long snapshotId, String volumePath, StoragePool pool, String preSnapshotPath ,String snapshotName, String vmName) {
_commandSwitch = ManageSnapshotCommand.CREATE_SNAPSHOT;
_volumePath = volumePath;
_pool = new StorageFilerTO(pool);
_snapshotPath = preSnapshotPath;
_snapshotName = snapshotName;
_snapshotId = snapshotId;
@ -65,6 +70,10 @@ public class ManageSnapshotCommand extends Command {
public String getVolumePath() {
return _volumePath;
}
public StorageFilerTO getPool() {
return _pool;
}
public String getSnapshotPath() {
return _snapshotPath;

View File

@ -265,7 +265,8 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
preSnapshotPath = preSnapshotVO.getPath();
}
}
ManageSnapshotCommand cmd = new ManageSnapshotCommand(snapshotId, volume.getPath(), preSnapshotPath, snapshot.getName(), vmName);
StoragePoolVO srcPool = _storagePoolDao.findById(volume.getPoolId());
ManageSnapshotCommand cmd = new ManageSnapshotCommand(snapshotId, volume.getPath(), srcPool, preSnapshotPath, snapshot.getName(), vmName);
ManageSnapshotAnswer answer = (ManageSnapshotAnswer) sendToPool(volume, cmd);
// Update the snapshot in the database
@ -557,7 +558,8 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
}
boolean isVolumeInactive = _storageMgr.volumeInactive(volume);
String vmName = _storageMgr.getVmNameOnVolume(volume);
BackupSnapshotCommand backupSnapshotCommand = new BackupSnapshotCommand(primaryStoragePoolNameLabel, secondaryStoragePoolUrl, dcId, accountId, volumeId, snapshot.getId(), volume.getPath(), snapshotUuid,
StoragePoolVO srcPool = _storagePoolDao.findById(volume.getPoolId());
BackupSnapshotCommand backupSnapshotCommand = new BackupSnapshotCommand(primaryStoragePoolNameLabel, secondaryStoragePoolUrl, dcId, accountId, volumeId, snapshot.getId(), volume.getPath(), srcPool, snapshotUuid,
snapshot.getName(), prevSnapshotUuid, prevBackupUuid, isVolumeInactive, vmName);
if ( swift != null ) {