Search in sources :

Example 26 with MockVolumeVO

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);
}
Also used : MockSecStorageVO(com.cloud.simulator.MockSecStorageVO) DownloadAnswer(com.cloud.agent.api.storage.DownloadAnswer) PrimaryStorageDownloadAnswer(com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer) MockVolumeVO(com.cloud.simulator.MockVolumeVO)

Example 27 with MockVolumeVO

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());
}
Also used : PrimaryStorageDownloadAnswer(com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer) MockStoragePoolVO(com.cloud.simulator.MockStoragePoolVO) MockVolumeVO(com.cloud.simulator.MockVolumeVO)

Example 28 with MockVolumeVO

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);
}
Also used : DownloadAnswer(com.cloud.agent.api.storage.DownloadAnswer) Answer(com.cloud.agent.api.Answer) BackupSnapshotAnswer(com.cloud.agent.api.BackupSnapshotAnswer) ListTemplateAnswer(com.cloud.agent.api.storage.ListTemplateAnswer) ManageSnapshotAnswer(com.cloud.agent.api.ManageSnapshotAnswer) CreatePrivateTemplateAnswer(com.cloud.agent.api.storage.CreatePrivateTemplateAnswer) AttachVolumeAnswer(com.cloud.agent.api.AttachVolumeAnswer) ModifyStoragePoolAnswer(com.cloud.agent.api.ModifyStoragePoolAnswer) PrimaryStorageDownloadAnswer(com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer) CopyVolumeAnswer(com.cloud.agent.api.storage.CopyVolumeAnswer) CreateAnswer(com.cloud.agent.api.storage.CreateAnswer) GetStorageStatsAnswer(com.cloud.agent.api.GetStorageStatsAnswer) CreateVolumeFromSnapshotAnswer(com.cloud.agent.api.CreateVolumeFromSnapshotAnswer) SecStorageSetupAnswer(com.cloud.agent.api.SecStorageSetupAnswer) MockVolumeVO(com.cloud.simulator.MockVolumeVO)

Example 29 with MockVolumeVO

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);
}
Also used : BackupSnapshotAnswer(com.cloud.agent.api.BackupSnapshotAnswer) MockVolumeVO(com.cloud.simulator.MockVolumeVO) MockSecStorageVO(com.cloud.simulator.MockSecStorageVO)

Example 30 with MockVolumeVO

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);
}
Also used : CreateAnswer(com.cloud.agent.api.storage.CreateAnswer) VolumeTO(com.cloud.agent.api.to.VolumeTO) MockStoragePoolVO(com.cloud.simulator.MockStoragePoolVO) MockVolumeVO(com.cloud.simulator.MockVolumeVO) StorageFilerTO(com.cloud.agent.api.to.StorageFilerTO) DiskProfile(com.cloud.vm.DiskProfile)

Aggregations

MockVolumeVO (com.cloud.simulator.MockVolumeVO)37 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)19 PrimaryStorageDownloadAnswer (com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer)18 TransactionLegacy (com.cloud.utils.db.TransactionLegacy)18 URISyntaxException (java.net.URISyntaxException)18 MockSecStorageVO (com.cloud.simulator.MockSecStorageVO)17 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)17 ConfigurationException (javax.naming.ConfigurationException)17 CreatePrivateTemplateAnswer (com.cloud.agent.api.storage.CreatePrivateTemplateAnswer)16 DownloadAnswer (com.cloud.agent.api.storage.DownloadAnswer)16 BackupSnapshotAnswer (com.cloud.agent.api.BackupSnapshotAnswer)14 CreateVolumeFromSnapshotAnswer (com.cloud.agent.api.CreateVolumeFromSnapshotAnswer)14 ManageSnapshotAnswer (com.cloud.agent.api.ManageSnapshotAnswer)14 CopyVolumeAnswer (com.cloud.agent.api.storage.CopyVolumeAnswer)14 CreateAnswer (com.cloud.agent.api.storage.CreateAnswer)14 Answer (com.cloud.agent.api.Answer)12 GetStorageStatsAnswer (com.cloud.agent.api.GetStorageStatsAnswer)12 ModifyStoragePoolAnswer (com.cloud.agent.api.ModifyStoragePoolAnswer)12 SecStorageSetupAnswer (com.cloud.agent.api.SecStorageSetupAnswer)12 ListTemplateAnswer (com.cloud.agent.api.storage.ListTemplateAnswer)12