Search in sources :

Example 11 with TemplateApiResult

use of org.apache.cloudstack.engine.subsystem.api.storage.TemplateService.TemplateApiResult in project cloudstack by apache.

the class S3TemplateTest method registerTemplate.

@Test(priority = 1)
public void registerTemplate() {
    TemplateInfo template = templateFactory.getTemplate(templateId, DataStoreRole.Image);
    DataStore store = dataStoreMgr.getImageStore(dcId);
    AsyncCallFuture<TemplateApiResult> future = new AsyncCallFuture<TemplateApiResult>();
    templateSvr.createTemplateAsync(template, store, future);
    try {
        TemplateApiResult result = future.get();
        assertTrue(result.isSuccess(), "failed to register template: " + result.getResult());
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        assertTrue(false, e.getMessage());
    } catch (ExecutionException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        assertTrue(false, e.getMessage());
    }
}
Also used : AsyncCallFuture(org.apache.cloudstack.framework.async.AsyncCallFuture) TemplateInfo(org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) ExecutionException(java.util.concurrent.ExecutionException) TemplateApiResult(org.apache.cloudstack.engine.subsystem.api.storage.TemplateService.TemplateApiResult) Test(org.testng.annotations.Test)

Example 12 with TemplateApiResult

use of org.apache.cloudstack.engine.subsystem.api.storage.TemplateService.TemplateApiResult in project cloudstack by apache.

the class TemplateTest method deleteTemplate.

// @Test
public void deleteTemplate() {
    TemplateInfo template = templateFactory.getTemplate(templateId, DataStoreRole.Image);
    DataStore store = dataStoreMgr.getImageStore(dcId);
    AsyncCallFuture<TemplateApiResult> future = new AsyncCallFuture<TemplateApiResult>();
    templateSvr.deleteTemplateAsync(template);
    try {
        TemplateApiResult result = future.get();
        assertTrue(result.isSuccess(), "failed to delete template: " + result.getResult());
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        assertTrue(false, e.getMessage());
    } catch (ExecutionException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        assertTrue(false, e.getMessage());
    }
}
Also used : AsyncCallFuture(org.apache.cloudstack.framework.async.AsyncCallFuture) TemplateInfo(org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) ExecutionException(java.util.concurrent.ExecutionException) TemplateApiResult(org.apache.cloudstack.engine.subsystem.api.storage.TemplateService.TemplateApiResult)

Example 13 with TemplateApiResult

use of org.apache.cloudstack.engine.subsystem.api.storage.TemplateService.TemplateApiResult in project cloudstack by apache.

the class TemplateTest method registerTemplate.

@Test
public void registerTemplate() {
    TemplateInfo template = templateFactory.getTemplate(templateId, DataStoreRole.Image);
    DataStore store = dataStoreMgr.getImageStore(dcId);
    AsyncCallFuture<TemplateApiResult> future = new AsyncCallFuture<TemplateApiResult>();
    templateSvr.createTemplateAsync(template, store, future);
    try {
        TemplateApiResult result = future.get();
        assertTrue(result.isSuccess(), "failed to register template: " + result.getResult());
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        assertTrue(false, e.getMessage());
    } catch (ExecutionException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        assertTrue(false, e.getMessage());
    }
}
Also used : AsyncCallFuture(org.apache.cloudstack.framework.async.AsyncCallFuture) TemplateInfo(org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) ExecutionException(java.util.concurrent.ExecutionException) TemplateApiResult(org.apache.cloudstack.engine.subsystem.api.storage.TemplateService.TemplateApiResult) Test(org.testng.annotations.Test)

Example 14 with TemplateApiResult

use of org.apache.cloudstack.engine.subsystem.api.storage.TemplateService.TemplateApiResult in project cloudstack by apache.

the class VolumeTest method testCreateTemplateFromVolume.

@Test
public void testCreateTemplateFromVolume() throws InterruptedException, ExecutionException {
    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);
    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);
    AsyncCallFuture<TemplateApiResult> templateResult = this.imageService.createTemplateFromVolumeAsync(volInfo, tmpl, imageStore);
    TemplateApiResult templateApiResult = templateResult.get();
    Assert.assertTrue(templateApiResult.isSuccess());
}
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) TemplateApiResult(org.apache.cloudstack.engine.subsystem.api.storage.TemplateService.TemplateApiResult) Test(org.testng.annotations.Test)

Aggregations

TemplateApiResult (org.apache.cloudstack.engine.subsystem.api.storage.TemplateService.TemplateApiResult)14 DataStore (org.apache.cloudstack.engine.subsystem.api.storage.DataStore)13 TemplateInfo (org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo)13 ExecutionException (java.util.concurrent.ExecutionException)9 VMTemplateVO (com.cloud.storage.VMTemplateVO)8 TemplateDataStoreVO (org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO)7 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)6 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)5 DB (com.cloud.utils.db.DB)5 StorageUnavailableException (com.cloud.exception.StorageUnavailableException)4 PrimaryDataStore (org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore)4 VolumeInfo (org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo)4 Test (org.testng.annotations.Test)4 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)3 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)3 URISyntaxException (java.net.URISyntaxException)3 ZoneScope (org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope)3 AsyncCallFuture (org.apache.cloudstack.framework.async.AsyncCallFuture)3 SnapshotVO (com.cloud.storage.SnapshotVO)2 VMTemplateStoragePoolVO (com.cloud.storage.VMTemplateStoragePoolVO)2