use of org.apache.cloudstack.engine.subsystem.api.storage.DataStore 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();
}
}
use of org.apache.cloudstack.engine.subsystem.api.storage.DataStore in project cloudstack by apache.
the class SnapshotDataFactoryImpl method listSnapshotOnCache.
@Override
public List<SnapshotInfo> listSnapshotOnCache(long snapshotId) {
List<SnapshotDataStoreVO> cacheSnapshots = snapshotStoreDao.listOnCache(snapshotId);
List<SnapshotInfo> snapObjs = new ArrayList<SnapshotInfo>();
for (SnapshotDataStoreVO cacheSnap : cacheSnapshots) {
long storeId = cacheSnap.getDataStoreId();
DataStore store = storeMgr.getDataStore(storeId, DataStoreRole.ImageCache);
SnapshotInfo tmplObj = getSnapshot(snapshotId, store);
snapObjs.add(tmplObj);
}
return snapObjs;
}
use of org.apache.cloudstack.engine.subsystem.api.storage.DataStore 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();
}
}
use of org.apache.cloudstack.engine.subsystem.api.storage.DataStore in project cloudstack by apache.
the class VolumeServiceTest method createTemplate.
private TemplateInfo createTemplate() {
try {
DataStore store = createImageStore();
VMTemplateVO image = createImageData();
TemplateInfo template = imageDataFactory.getTemplate(image.getId(), store);
// AsyncCallFuture<TemplateApiResult> future =
// imageService.createTemplateAsync(template, store);
// future.get();
template = imageDataFactory.getTemplate(image.getId(), store);
/*
* imageProviderMgr.configure("image Provider", new HashMap<String,
* Object>()); VMTemplateVO image = createImageData();
* ImageDataStoreProvider defaultProvider =
* imageProviderMgr.getProvider("DefaultProvider");
* ImageDataStoreLifeCycle lifeCycle =
* defaultProvider.getLifeCycle(); ImageDataStore store =
* lifeCycle.registerDataStore("defaultHttpStore", new
* HashMap<String, String>());
* imageService.registerTemplate(image.getId(),
* store.getImageDataStoreId()); TemplateEntity te =
* imageService.getTemplateEntity(image.getId()); return te;
*/
return template;
} catch (Exception e) {
Assert.fail("failed", e);
return null;
}
}
use of org.apache.cloudstack.engine.subsystem.api.storage.DataStore in project cloudstack by apache.
the class VolumeServiceTest method createPrimaryDataStore.
public DataStore createPrimaryDataStore() {
try {
DataStoreProvider provider = dataStoreProviderMgr.getDataStoreProvider("sample primary data store provider");
Map<String, Object> params = new HashMap<String, Object>();
URI uri = new URI(this.getPrimaryStorageUrl());
params.put("url", this.getPrimaryStorageUrl());
params.put("server", uri.getHost());
params.put("path", uri.getPath());
params.put("protocol", Storage.StoragePoolType.NetworkFilesystem);
params.put("dcId", dcId.toString());
params.put("hypervisorType", HypervisorType.None);
params.put("clusterId", clusterId.toString());
params.put("name", this.primaryName);
params.put("port", "1");
params.put("roles", DataStoreRole.Primary.toString());
params.put("uuid", UUID.nameUUIDFromBytes(this.getPrimaryStorageUrl().getBytes()).toString());
params.put("providerName", String.valueOf(provider.getName()));
DataStoreLifeCycle lifeCycle = provider.getDataStoreLifeCycle();
DataStore store = lifeCycle.initialize(params);
ClusterScope scope = new ClusterScope(clusterId, podId, dcId);
lifeCycle.attachCluster(store, scope);
/*
* PrimaryDataStoreProvider provider =
* primaryDataStoreProviderMgr.getDataStoreProvider
* ("sample primary data store provider");
* primaryDataStoreProviderMgr.configure("primary data store mgr",
* new HashMap<String, Object>());
*
* List<PrimaryDataStoreVO> ds =
* primaryStoreDao.findPoolByName(this.primaryName); if (ds.size()
* >= 1) { PrimaryDataStoreVO store = ds.get(0); if
* (store.getRemoved() == null) { return
* provider.getDataStore(store.getId()); } }
*
*
* Map<String, String> params = new HashMap<String, String>();
* params.put("url", this.getPrimaryStorageUrl());
* params.put("dcId", dcId.toString()); params.put("clusterId",
* clusterId.toString()); params.put("name", this.primaryName);
* PrimaryDataStoreInfo primaryDataStoreInfo =
* provider.registerDataStore(params); PrimaryDataStoreLifeCycle lc
* = primaryDataStoreInfo.getLifeCycle(); ClusterScope scope = new
* ClusterScope(clusterId, podId, dcId); lc.attachCluster(scope);
* return primaryDataStoreInfo;
*/
return store;
} catch (Exception e) {
return null;
}
}
Aggregations