Search in sources :

Example 6 with VolumeApiResult

use of org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult in project cloudstack by apache.

the class VolumeServiceTest method createVolumeFromTemplate.

@Test(priority = 2)
public void createVolumeFromTemplate() {
    DataStore primaryStore = this.primaryStore;
    TemplateInfo te = createTemplate();
    VolumeVO volume = createVolume(te.getId(), primaryStore.getId());
    VolumeInfo vol = volumeFactory.getVolume(volume.getId(), primaryStore);
    // ve.createVolumeFromTemplate(primaryStore.getId(), new VHD(), te);
    AsyncCallFuture<VolumeApiResult> future = volumeService.createVolumeFromTemplateAsync(vol, primaryStore.getId(), te);
    try {
        future.get();
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ExecutionException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : TemplateInfo(org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo) VolumeVO(com.cloud.storage.VolumeVO) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) VolumeInfo(org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo) VolumeApiResult(org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult) ExecutionException(java.util.concurrent.ExecutionException) Test(org.testng.annotations.Test)

Example 7 with VolumeApiResult

use of org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult in project cloudstack by apache.

the class VolumeTest method testCopyBaseImage.

@Test
public void testCopyBaseImage() {
    DataStore primaryStore = createPrimaryDataStore();
    primaryStoreId = primaryStore.getId();
    primaryStore = this.dataStoreMgr.getPrimaryDataStore(primaryStoreId);
    VolumeVO volume = createVolume(image.getId(), primaryStore.getId());
    VolumeInfo volInfo = this.volFactory.getVolume(volume.getId());
    AsyncCallFuture<VolumeApiResult> future = this.volumeService.createVolumeFromTemplateAsync(volInfo, this.primaryStoreId, this.templateFactory.getTemplate(this.image.getId(), DataStoreRole.Image));
    try {
        VolumeApiResult result = future.get();
        AssertJUnit.assertTrue(result.isSuccess());
        VolumeInfo newVol = result.getVolume();
        boolean res = this.volumeService.destroyVolume(newVol.getId());
        Assert.assertTrue(res);
        VolumeInfo vol = this.volFactory.getVolume(volume.getId());
        future = this.volumeService.expungeVolumeAsync(vol);
        result = future.get();
        Assert.assertTrue(result.isSuccess());
    } catch (InterruptedException e) {
        Assert.fail(e.toString());
    } catch (ExecutionException e) {
        Assert.fail(e.toString());
    } catch (ConcurrentOperationException e) {
        Assert.fail(e.toString());
    }
}
Also used : VolumeVO(com.cloud.storage.VolumeVO) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) VolumeInfo(org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo) VolumeApiResult(org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult) ExecutionException(java.util.concurrent.ExecutionException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) Test(org.testng.annotations.Test)

Example 8 with VolumeApiResult

use of org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult in project cloudstack by apache.

the class VolumeTestVmware method testDeleteDisk.

@Test
public void testDeleteDisk() {
    DataStore primaryStore = createPrimaryDataStore();
    primaryStoreId = primaryStore.getId();
    primaryStore = this.dataStoreMgr.getPrimaryDataStore(primaryStoreId);
    VolumeVO volume = createVolume(null, primaryStore.getId());
    VolumeInfo volInfo = this.volFactory.getVolume(volume.getId());
    AsyncCallFuture<VolumeApiResult> future = this.volumeService.createVolumeAsync(volInfo, primaryStore);
    try {
        VolumeApiResult result = future.get();
        VolumeInfo vol = result.getVolume();
        this.volumeService.destroyVolume(volInfo.getId());
        volInfo = this.volFactory.getVolume(vol.getId());
        this.volumeService.expungeVolumeAsync(volInfo);
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ExecutionException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ConcurrentOperationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : VolumeVO(com.cloud.storage.VolumeVO) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) VolumeInfo(org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo) VolumeApiResult(org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult) ExecutionException(java.util.concurrent.ExecutionException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) Test(org.testng.annotations.Test)

Example 9 with VolumeApiResult

use of org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult in project cloudstack by apache.

the class VolumeTestVmware method testCreateTemplateFromVolume.

@Test
public void testCreateTemplateFromVolume() {
    DataStore primaryStore = createPrimaryDataStore();
    primaryStoreId = primaryStore.getId();
    primaryStore = this.dataStoreMgr.getPrimaryDataStore(primaryStoreId);
    VolumeVO volume = createVolume(null, primaryStore.getId());
    VolumeInfo volInfo = this.volFactory.getVolume(volume.getId());
    AsyncCallFuture<VolumeApiResult> future = this.volumeService.createVolumeAsync(volInfo, primaryStore);
    try {
        VolumeApiResult result = future.get();
        AssertJUnit.assertTrue(result.isSuccess());
        volInfo = result.getVolume();
        VMTemplateVO templateVO = createTemplateInDb();
        TemplateInfo tmpl = this.templateFactory.getTemplate(templateVO.getId(), DataStoreRole.Image);
        DataStore imageStore = this.dataStoreMgr.getImageStore(this.dcId);
        this.imageService.createTemplateFromVolumeAsync(volInfo, tmpl, imageStore);
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ExecutionException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : TemplateInfo(org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo) VolumeVO(com.cloud.storage.VolumeVO) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) VMTemplateVO(com.cloud.storage.VMTemplateVO) VolumeInfo(org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo) VolumeApiResult(org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult) ExecutionException(java.util.concurrent.ExecutionException) Test(org.testng.annotations.Test)

Example 10 with VolumeApiResult

use of org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult in project cloudstack by apache.

the class SnapshotTest method createCopyBaseImage.

public VolumeInfo createCopyBaseImage() throws InterruptedException, ExecutionException {
    DataStore primaryStore = createPrimaryDataStore();
    primaryStoreId = primaryStore.getId();
    primaryStore = this.dataStoreMgr.getPrimaryDataStore(primaryStoreId);
    VolumeVO volume = createVolume(image.getId(), primaryStore.getId());
    VolumeInfo volInfo = this.volFactory.getVolume(volume.getId());
    AsyncCallFuture<VolumeApiResult> future = this.volumeService.createVolumeFromTemplateAsync(volInfo, this.primaryStoreId, this.templateFactory.getTemplate(this.image.getId(), DataStoreRole.Image));
    VolumeApiResult result;
    result = future.get();
    Assert.assertTrue(result.isSuccess());
    return result.getVolume();
}
Also used : VolumeVO(com.cloud.storage.VolumeVO) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) VolumeInfo(org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo) VolumeApiResult(org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult)

Aggregations

VolumeApiResult (org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult)29 ExecutionException (java.util.concurrent.ExecutionException)23 VolumeInfo (org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo)22 DataStore (org.apache.cloudstack.engine.subsystem.api.storage.DataStore)17 VolumeVO (com.cloud.storage.VolumeVO)16 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)14 DB (com.cloud.utils.db.DB)9 Test (org.testng.annotations.Test)8 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)7 StorageUnavailableException (com.cloud.exception.StorageUnavailableException)7 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)6 StoragePoolVO (org.apache.cloudstack.storage.datastore.db.StoragePoolVO)5 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)4 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)4 HostVO (com.cloud.host.HostVO)4 NoTransitionException (com.cloud.utils.fsm.NoTransitionException)4 TemplateInfo (org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo)4 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)3 Host (com.cloud.host.Host)3 SnapshotVO (com.cloud.storage.SnapshotVO)3