Search in sources :

Example 6 with ImageStoreVO

use of org.apache.cloudstack.storage.datastore.db.ImageStoreVO in project cloudstack by apache.

the class StorageCacheReplacementAlgorithmLRUTest method testSelectObjectFailed.

@Test
public void testSelectObjectFailed() {
    cacheReplacementAlgorithm.setUnusedTimeInterval(1);
    try {
        VMTemplateVO template = new VMTemplateVO();
        template.setTemplateType(Storage.TemplateType.USER);
        template.setUrl(UUID.randomUUID().toString());
        template.setUniqueName(UUID.randomUUID().toString());
        template.setName(UUID.randomUUID().toString());
        template.setPublicTemplate(true);
        template.setFeatured(true);
        template.setRequiresHvm(true);
        template.setBits(64);
        template.setFormat(Storage.ImageFormat.VHD);
        template.setEnablePassword(true);
        template.setEnableSshKey(true);
        template.setGuestOSId(1);
        template.setBootable(true);
        template.setPrepopulate(true);
        template.setCrossZones(true);
        template.setExtractable(true);
        template = templateDao.persist(template);
        VMTemplateVO template2 = new VMTemplateVO();
        template2.setTemplateType(Storage.TemplateType.USER);
        template2.setUrl(UUID.randomUUID().toString());
        template2.setUniqueName(UUID.randomUUID().toString());
        template2.setName(UUID.randomUUID().toString());
        template2.setPublicTemplate(true);
        template2.setFeatured(true);
        template2.setRequiresHvm(true);
        template2.setBits(64);
        template2.setFormat(Storage.ImageFormat.VHD);
        template2.setEnablePassword(true);
        template2.setEnableSshKey(true);
        template2.setGuestOSId(1);
        template2.setBootable(true);
        template2.setPrepopulate(true);
        template2.setCrossZones(true);
        template2.setExtractable(true);
        template2 = templateDao.persist(template2);
        ImageStoreVO imageStoreVO = new ImageStoreVO();
        imageStoreVO.setRole(DataStoreRole.ImageCache);
        imageStoreVO.setName(UUID.randomUUID().toString());
        imageStoreVO.setProviderName(DataStoreProvider.NFS_IMAGE);
        imageStoreVO.setProtocol("nfs");
        imageStoreVO.setUrl(UUID.randomUUID().toString());
        imageStoreVO = imageStoreDao.persist(imageStoreVO);
        Date date = DateUtil.now();
        TemplateDataStoreVO templateStoreVO1 = new TemplateDataStoreVO();
        templateStoreVO1.setLastUpdated(date);
        templateStoreVO1.setDataStoreRole(DataStoreRole.ImageCache);
        templateStoreVO1.setDataStoreId(imageStoreVO.getId());
        templateStoreVO1.setState(ObjectInDataStoreStateMachine.State.Ready);
        templateStoreVO1.setCopy(true);
        templateStoreVO1.setTemplateId(template.getId());
        templateDataStoreDao.persist(templateStoreVO1);
        TemplateDataStoreVO templateStoreVO2 = new TemplateDataStoreVO();
        templateStoreVO2.setLastUpdated(date);
        templateStoreVO2.setDataStoreRole(DataStoreRole.ImageCache);
        templateStoreVO2.setDataStoreId(imageStoreVO.getId());
        templateStoreVO2.setState(ObjectInDataStoreStateMachine.State.Ready);
        templateStoreVO2.setCopy(true);
        templateStoreVO2.setTemplateId(template2.getId());
        templateDataStoreDao.persist(templateStoreVO2);
        DataStore store = dataStoreManager.getDataStore(imageStoreVO.getId(), DataStoreRole.ImageCache);
        Assert.assertNull(cacheReplacementAlgorithm.chooseOneToBeReplaced(store));
    } catch (Exception e) {
        Assert.fail();
    }
}
Also used : DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) VMTemplateVO(com.cloud.storage.VMTemplateVO) ImageStoreVO(org.apache.cloudstack.storage.datastore.db.ImageStoreVO) TemplateDataStoreVO(org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO) Date(java.util.Date) Test(org.junit.Test)

Example 7 with ImageStoreVO

use of org.apache.cloudstack.storage.datastore.db.ImageStoreVO in project cloudstack by apache.

the class SnapshotTest 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 xenserver cluster
        ClusterVO cluster = new ClusterVO(dc.getId(), pod.getId(), "devcloud cluster");
        cluster.setHypervisorType(this.getHypervisor().toString());
        cluster.setClusterType(ClusterType.CloudManaged);
        cluster.setManagedState(ManagedState.Managed);
        cluster = clusterDao.persist(cluster);
        clusterId = cluster.getId();
        // create xenserver host
        host = new HostVO(this.getHostGuid());
        host.setName("devcloud xenserver 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(this.getHypervisor());
        host.setClusterId(cluster.getId());
        host = hostDao.persist(host);
        imageStore = new ImageStoreVO();
        imageStore.setName(imageStoreName);
        imageStore.setDataCenterId(dcId);
        imageStore.setProviderName(DataStoreProvider.NFS_IMAGE);
        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());
    to.setFormat(ImageFormat.VHD);
    to.setSize(1000L);
    CopyCmdAnswer answer = new CopyCmdAnswer(to);
    templateOnStore.processEvent(Event.CreateOnlyRequested);
    templateOnStore.processEvent(Event.OperationSuccessed, answer);
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) TemplateInfo(org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo) ClusterVO(com.cloud.dc.ClusterVO) DataObject(org.apache.cloudstack.engine.subsystem.api.storage.DataObject) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) VMTemplateVO(com.cloud.storage.VMTemplateVO) ImageStoreVO(org.apache.cloudstack.storage.datastore.db.ImageStoreVO) TemplateObjectTO(org.apache.cloudstack.storage.to.TemplateObjectTO) HostPodVO(com.cloud.dc.HostPodVO) HostVO(com.cloud.host.HostVO) CopyCmdAnswer(org.apache.cloudstack.storage.command.CopyCmdAnswer) Test(org.testng.annotations.Test)

Example 8 with ImageStoreVO

use of org.apache.cloudstack.storage.datastore.db.ImageStoreVO in project cloudstack by apache.

the class ImageStoreProviderManagerImpl method getImageStore.

@Override
public ImageStoreEntity getImageStore(long dataStoreId) {
    ImageStoreVO dataStore = dataStoreDao.findById(dataStoreId);
    String providerName = dataStore.getProviderName();
    ImageStoreProvider provider = (ImageStoreProvider) providerManager.getDataStoreProvider(providerName);
    ImageStoreEntity imgStore = ImageStoreImpl.getDataStore(dataStore, driverMaps.get(provider.getName()), provider);
    return imgStore;
}
Also used : ImageStoreProvider(org.apache.cloudstack.engine.subsystem.api.storage.ImageStoreProvider) ImageStoreEntity(org.apache.cloudstack.storage.image.datastore.ImageStoreEntity) ImageStoreVO(org.apache.cloudstack.storage.datastore.db.ImageStoreVO)

Example 9 with ImageStoreVO

use of org.apache.cloudstack.storage.datastore.db.ImageStoreVO in project cloudstack by apache.

the class ImageStoreProviderManagerImpl method listImageCacheStores.

@Override
public List<DataStore> listImageCacheStores() {
    List<ImageStoreVO> stores = dataStoreDao.listImageCacheStores();
    List<DataStore> imageStores = new ArrayList<DataStore>();
    for (ImageStoreVO store : stores) {
        imageStores.add(getImageStore(store.getId()));
    }
    return imageStores;
}
Also used : DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) ArrayList(java.util.ArrayList) ImageStoreVO(org.apache.cloudstack.storage.datastore.db.ImageStoreVO)

Example 10 with ImageStoreVO

use of org.apache.cloudstack.storage.datastore.db.ImageStoreVO in project cloudstack by apache.

the class ImageStoreProviderManagerImpl method listImageCacheStores.

@Override
public List<DataStore> listImageCacheStores(Scope scope) {
    if (scope.getScopeType() != ScopeType.ZONE) {
        s_logger.debug("only support zone wide image cache stores");
        return null;
    }
    List<ImageStoreVO> stores = dataStoreDao.findImageCacheByScope(new ZoneScope(scope.getScopeId()));
    List<DataStore> imageStores = new ArrayList<DataStore>();
    for (ImageStoreVO store : stores) {
        imageStores.add(getImageStore(store.getId()));
    }
    return imageStores;
}
Also used : ZoneScope(org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) ArrayList(java.util.ArrayList) ImageStoreVO(org.apache.cloudstack.storage.datastore.db.ImageStoreVO)

Aggregations

ImageStoreVO (org.apache.cloudstack.storage.datastore.db.ImageStoreVO)38 DataStore (org.apache.cloudstack.engine.subsystem.api.storage.DataStore)14 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)12 Account (com.cloud.user.Account)10 DataCenterVO (com.cloud.dc.DataCenterVO)9 HashMap (java.util.HashMap)9 VMTemplateVO (com.cloud.storage.VMTemplateVO)8 ArrayList (java.util.ArrayList)8 ClusterVO (com.cloud.dc.ClusterVO)6 HostPodVO (com.cloud.dc.HostPodVO)5 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)5 Map (java.util.Map)5 HostVO (com.cloud.host.HostVO)4 DataStoreRole (com.cloud.storage.DataStoreRole)4 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)3 HypervisorType (com.cloud.hypervisor.Hypervisor.HypervisorType)3 URISyntaxException (java.net.URISyntaxException)3 DataStoreProvider (org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider)3 Test (org.testng.annotations.Test)3 ClusterDetailsVO (com.cloud.dc.ClusterDetailsVO)2