use of org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo in project cloudstack by apache.
the class S3TemplateTest method copyTemplateToCache.
@Test(priority = 2)
public void copyTemplateToCache() {
TemplateInfo template = templateFactory.getTemplate(templateId, DataStoreRole.Image);
DataObject cacheObj = this.cacheMgr.createCacheObject(template, new ZoneScope(dcId));
assertNotNull(cacheObj, "failed to create cache object");
}
use of org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo 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.TemplateInfo in project cloudstack by apache.
the class VolumeTestVmware method setUp.
@Test(priority = -1)
public void setUp() {
ComponentContext.initComponentsLifeCycle();
host = hostDao.findByGuid(this.getHostGuid());
if (host != null) {
dcId = host.getDataCenterId();
clusterId = host.getClusterId();
podId = host.getPodId();
imageStore = this.imageStoreDao.findByName(imageStoreName);
} else {
// create data center
DataCenterVO dc = new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24", null, null, NetworkType.Basic, null, null, true, true, null, null);
dc = dcDao.persist(dc);
dcId = dc.getId();
// create pod
HostPodVO pod = new HostPodVO(UUID.randomUUID().toString(), dc.getId(), this.getHostGateway(), this.getHostCidr(), 8, "test");
pod = podDao.persist(pod);
podId = pod.getId();
// create xen cluster
ClusterVO cluster = new ClusterVO(dc.getId(), pod.getId(), "devcloud cluster");
cluster.setHypervisorType(HypervisorType.VMware.toString());
cluster.setClusterType(ClusterType.ExternalManaged);
cluster.setManagedState(ManagedState.Managed);
cluster = clusterDao.persist(cluster);
clusterId = cluster.getId();
// setup vcenter
ClusterDetailsVO clusterDetailVO = new ClusterDetailsVO(cluster.getId(), "url", null);
this.clusterDetailsDao.persist(clusterDetailVO);
clusterDetailVO = new ClusterDetailsVO(cluster.getId(), "username", null);
this.clusterDetailsDao.persist(clusterDetailVO);
clusterDetailVO = new ClusterDetailsVO(cluster.getId(), "password", null);
this.clusterDetailsDao.persist(clusterDetailVO);
// create xen host
host = new HostVO(this.getHostGuid());
host.setName("devcloud vmware host");
host.setType(Host.Type.Routing);
host.setPrivateIpAddress(this.getHostIp());
host.setDataCenterId(dc.getId());
host.setVersion("6.0.1");
host.setAvailable(true);
host.setSetup(true);
host.setPodId(podId);
host.setLastPinged(0);
host.setResourceState(ResourceState.Enabled);
host.setHypervisorType(HypervisorType.VMware);
host.setClusterId(cluster.getId());
host = hostDao.persist(host);
imageStore = new ImageStoreVO();
imageStore.setName(imageStoreName);
imageStore.setDataCenterId(dcId);
imageStore.setProviderName("CloudStack ImageStore Provider");
imageStore.setRole(DataStoreRole.Image);
imageStore.setUrl(this.getSecondaryStorage());
imageStore.setUuid(UUID.randomUUID().toString());
imageStore.setProtocol("nfs");
imageStore = imageStoreDao.persist(imageStore);
}
image = new VMTemplateVO();
image.setTemplateType(TemplateType.USER);
image.setUrl(this.getTemplateUrl());
image.setUniqueName(UUID.randomUUID().toString());
image.setName(UUID.randomUUID().toString());
image.setPublicTemplate(true);
image.setFeatured(true);
image.setRequiresHvm(true);
image.setBits(64);
image.setFormat(Storage.ImageFormat.VHD);
image.setEnablePassword(true);
image.setEnableSshKey(true);
image.setGuestOSId(1);
image.setBootable(true);
image.setPrepopulate(true);
image.setCrossZones(true);
image.setExtractable(true);
image = imageDataDao.persist(image);
/*
* TemplateDataStoreVO templateStore = new TemplateDataStoreVO();
*
* templateStore.setDataStoreId(imageStore.getId());
* templateStore.setDownloadPercent(100);
* templateStore.setDownloadState(Status.DOWNLOADED);
* templateStore.setDownloadUrl(imageStore.getUrl());
* templateStore.setInstallPath(this.getImageInstallPath());
* templateStore.setTemplateId(image.getId());
* templateStoreDao.persist(templateStore);
*/
DataStore store = this.dataStoreMgr.getDataStore(imageStore.getId(), DataStoreRole.Image);
TemplateInfo template = templateFactory.getTemplate(image.getId(), DataStoreRole.Image);
DataObject templateOnStore = store.create(template);
TemplateObjectTO to = new TemplateObjectTO();
to.setPath(this.getImageInstallPath());
CopyCmdAnswer answer = new CopyCmdAnswer(to);
templateOnStore.processEvent(Event.CreateOnlyRequested);
templateOnStore.processEvent(Event.OperationSuccessed, answer);
}
use of org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo 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());
}
}
use of org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo 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());
}
}
Aggregations