From 0969ba8063710e183bc5410d4715a83a1dc10178 Mon Sep 17 00:00:00 2001 From: Murali Reddy Date: Fri, 12 Aug 2011 17:30:01 +0530 Subject: [PATCH] bug 10923: changes for snapshot command to carry primary storage pool path --- .../com/cloud/agent/api/BackupSnapshotCommand.java | 11 ++++++++++- .../com/cloud/agent/api/ManageSnapshotCommand.java | 13 +++++++++++-- .../cloud/storage/snapshot/SnapshotManagerImpl.java | 6 ++++-- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/api/src/com/cloud/agent/api/BackupSnapshotCommand.java b/api/src/com/cloud/agent/api/BackupSnapshotCommand.java index b00da5aed64..afff7368c70 100644 --- a/api/src/com/cloud/agent/api/BackupSnapshotCommand.java +++ b/api/src/com/cloud/agent/api/BackupSnapshotCommand.java @@ -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; + } } \ No newline at end of file diff --git a/api/src/com/cloud/agent/api/ManageSnapshotCommand.java b/api/src/com/cloud/agent/api/ManageSnapshotCommand.java index efcb37d2ab2..0693509e6a7 100644 --- a/api/src/com/cloud/agent/api/ManageSnapshotCommand.java +++ b/api/src/com/cloud/agent/api/ManageSnapshotCommand.java @@ -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; diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java index adb5692dfc3..9767c0a0b04 100755 --- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java +++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java @@ -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 ) {