use of org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult 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());
}
use of org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult in project cloudstack by apache.
the class VolumeTest method testCreateDataDisk.
@Test
public void testCreateDataDisk() 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();
Assert.assertTrue(result.isSuccess());
}
use of org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult in project cloudstack by apache.
the class VolumeServiceTest method createAndDeleteDataDisk.
// @Test(priority=3)
public void createAndDeleteDataDisk() {
DataStore primaryStore = this.primaryStore;
VolumeVO volume = createVolume(null, primaryStore.getId());
VolumeInfo vol = volumeFactory.getVolume(volume.getId(), primaryStore);
AsyncCallFuture<VolumeApiResult> future = volumeService.createVolumeAsync(vol, primaryStore);
try {
future.get();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// delete the volume
vol = volumeFactory.getVolume(volume.getId(), primaryStore);
future = volumeService.expungeVolumeAsync(vol);
try {
future.get();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult in project cloudstack by apache.
the class VolumeServiceTest method createDataDisk.
// @Test(priority=3)
public void createDataDisk() {
DataStore primaryStore = this.primaryStore;
VolumeVO volume = createVolume(null, primaryStore.getId());
VolumeInfo vol = volumeFactory.getVolume(volume.getId(), primaryStore);
AsyncCallFuture<VolumeApiResult> future = volumeService.createVolumeAsync(vol, primaryStore);
try {
future.get();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult in project cloudstack by apache.
the class VolumeTestVmware 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();
this.volumeService.destroyVolume(newVol.getId());
VolumeInfo vol = this.volFactory.getVolume(volume.getId());
this.volumeService.expungeVolumeAsync(vol);
} 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();
}
}
Aggregations