set correct secondary storage host id in snapshot table

This commit is contained in:
anthony 2011-06-28 14:07:48 -07:00
parent c7d17d2e3c
commit 1e7399dd19
2 changed files with 3 additions and 7 deletions

View File

@ -110,7 +110,7 @@ public class SnapshotVO implements Snapshot {
public SnapshotVO() { }
public SnapshotVO(long dcId, long accountId, long domainId, Long volumeId, Long diskOfferingId, String path, String name, short snapshotType, String typeDescription, long size, HypervisorType hypervisorType, Long secHostId) {
public SnapshotVO(long dcId, long accountId, long domainId, Long volumeId, Long diskOfferingId, String path, String name, short snapshotType, String typeDescription, long size, HypervisorType hypervisorType ) {
this.dataCenterId = dcId;
this.accountId = accountId;
this.domainId = domainId;
@ -125,7 +125,6 @@ public class SnapshotVO implements Snapshot {
this.prevSnapshotId = 0;
this.hypervisorType = hypervisorType;
this.version = "2.2";
this.secHostId = secHostId;
}

View File

@ -581,6 +581,7 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
snapshot.setSwiftId(1L);
snapshot.setSwiftName(backedUpSnapshotUuid);
} else {
snapshot.setSecHostId(secHost.getId());
snapshot.setBackupSnapshotId(backedUpSnapshotUuid);
}
if (answer.isFull()) {
@ -1279,12 +1280,8 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
// user
Type snapshotType = getSnapshotType(policyId);
HypervisorType hypervisorType = this._volsDao.getHypervisorType(volumeId);
HostVO ssHost = _hostDao.findSecondaryStorageHost(volume.getDataCenterId());
if( ssHost == null ) {
throw new CloudRuntimeException("There is no secondary storage in this zone :" + volume.getDataCenterId());
}
SnapshotVO snapshotVO = new SnapshotVO(volume.getDataCenterId(), volume.getAccountId(), volume.getDomainId(), volume.getId(), volume.getDiskOfferingId(), null, snapshotName,
(short) snapshotType.ordinal(), snapshotType.name(), volume.getSize(), hypervisorType, ssHost.getId());
(short) snapshotType.ordinal(), snapshotType.name(), volume.getSize(), hypervisorType);
SnapshotVO snapshot = _snapshotDao.persist(snapshotVO);
if (snapshot != null) {