use of com.cloud.simulator.MockVolumeVO in project CloudStack-archive by CloudStack-extras.
the class MockStorageManagerImpl method Download.
@Override
public DownloadAnswer Download(DownloadCommand cmd) {
MockSecStorageVO ssvo = _mockSecStorageDao.findByUrl(cmd.getSecUrl());
if (ssvo == null) {
return new DownloadAnswer("can't find secondary storage", VMTemplateStorageResourceAssoc.Status.DOWNLOAD_ERROR);
}
MockVolumeVO volume = new MockVolumeVO();
volume.setPoolId(ssvo.getId());
volume.setName(cmd.getName());
volume.setPath(ssvo.getMountPoint() + cmd.getName());
volume.setSize(0);
volume.setType(MockVolumeType.TEMPLATE);
volume.setStatus(Status.DOWNLOAD_IN_PROGRESS);
volume = _mockVolumeDao.persist(volume);
return new DownloadAnswer(String.valueOf(volume.getId()), 0, "Downloading", Status.DOWNLOAD_IN_PROGRESS, cmd.getName(), cmd.getName(), volume.getSize(), volume.getSize(), null);
}
use of com.cloud.simulator.MockVolumeVO in project CloudStack-archive by CloudStack-extras.
the class MockStorageManagerImpl method primaryStorageDownload.
@Override
public PrimaryStorageDownloadAnswer primaryStorageDownload(PrimaryStorageDownloadCommand cmd) {
MockVolumeVO template = findVolumeFromSecondary(cmd.getUrl(), cmd.getSecondaryStorageUrl(), MockVolumeType.TEMPLATE);
if (template == null) {
return new PrimaryStorageDownloadAnswer("Can't find primary storage");
}
MockStoragePoolVO primaryStorage = _mockStoragePoolDao.findByUuid(cmd.getPoolUuid());
if (primaryStorage == null) {
return new PrimaryStorageDownloadAnswer("Can't find primary storage");
}
String volumeName = UUID.randomUUID().toString();
MockVolumeVO newVolume = new MockVolumeVO();
newVolume.setName(volumeName);
newVolume.setPath(primaryStorage.getMountPoint() + volumeName);
newVolume.setPoolId(primaryStorage.getId());
newVolume.setSize(template.getSize());
newVolume.setType(MockVolumeType.VOLUME);
_mockVolumeDao.persist(newVolume);
return new PrimaryStorageDownloadAnswer(newVolume.getPath(), newVolume.getSize());
}
use of com.cloud.simulator.MockVolumeVO in project CloudStack-archive by CloudStack-extras.
the class MockStorageManagerImpl method DeleteSnapshotBackup.
@Override
public Answer DeleteSnapshotBackup(DeleteSnapshotBackupCommand cmd) {
MockVolumeVO backSnapshot = _mockVolumeDao.findByName(cmd.getSnapshotUuid());
if (backSnapshot == null) {
return new Answer(cmd, false, "can't find the backupsnapshot: " + cmd.getSnapshotUuid());
}
_mockVolumeDao.remove(backSnapshot.getId());
return new Answer(cmd);
}
use of com.cloud.simulator.MockVolumeVO in project CloudStack-archive by CloudStack-extras.
the class MockStorageManagerImpl method BackupSnapshot.
@Override
public BackupSnapshotAnswer BackupSnapshot(BackupSnapshotCommand cmd, SimulatorInfo info) {
//emulate xenserver backupsnapshot, if the base volume is deleted, then backupsnapshot failed
MockVolumeVO volume = _mockVolumeDao.findByStoragePathAndType(cmd.getVolumePath());
if (volume == null) {
return new BackupSnapshotAnswer(cmd, false, "Can't find base volume: " + cmd.getVolumePath(), null, true);
}
String snapshotPath = cmd.getSnapshotUuid();
MockVolumeVO snapshot = _mockVolumeDao.findByStoragePathAndType(snapshotPath);
if (snapshot == null) {
return new BackupSnapshotAnswer(cmd, false, "can't find snapshot" + snapshotPath, null, true);
}
String secStorageUrl = cmd.getSecondaryStorageUrl();
MockSecStorageVO secStorage = _mockSecStorageDao.findByUrl(secStorageUrl);
if (secStorage == null) {
return new BackupSnapshotAnswer(cmd, false, "can't find sec storage" + snapshotPath, null, true);
}
MockVolumeVO newsnapshot = new MockVolumeVO();
String name = UUID.randomUUID().toString();
newsnapshot.setName(name);
newsnapshot.setPath(secStorage.getMountPoint() + name);
newsnapshot.setPoolId(secStorage.getId());
newsnapshot.setSize(snapshot.getSize());
newsnapshot.setStatus(Status.DOWNLOADED);
newsnapshot.setType(MockVolumeType.SNAPSHOT);
newsnapshot = _mockVolumeDao.persist(newsnapshot);
return new BackupSnapshotAnswer(cmd, true, null, newsnapshot.getName(), true);
}
use of com.cloud.simulator.MockVolumeVO in project CloudStack-archive by CloudStack-extras.
the class MockStorageManagerImpl method createVolume.
@Override
public CreateAnswer createVolume(CreateCommand cmd) {
StorageFilerTO sf = cmd.getPool();
DiskProfile dskch = cmd.getDiskCharacteristics();
MockStoragePoolVO storagePool = _mockStoragePoolDao.findByUuid(sf.getUuid());
if (storagePool == null) {
return new CreateAnswer(cmd, "Failed to find storage pool: " + sf.getUuid());
}
String volumeName = UUID.randomUUID().toString();
MockVolumeVO volume = new MockVolumeVO();
volume.setPoolId(storagePool.getId());
volume.setName(volumeName);
volume.setPath(storagePool.getMountPoint() + volumeName);
volume.setSize(dskch.getSize());
volume.setType(MockVolumeType.VOLUME);
volume = _mockVolumeDao.persist(volume);
VolumeTO volumeTo = new VolumeTO(cmd.getVolumeId(), dskch.getType(), sf.getType(), sf.getUuid(), volume.getName(), storagePool.getMountPoint(), volume.getPath(), volume.getSize(), null);
return new CreateAnswer(cmd, volumeTo);
}
Aggregations