Package org.apache.cloudstack.engine.subsystem.api.storage

Examples of org.apache.cloudstack.engine.subsystem.api.storage.DataStore


         * 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);
View Full Code Here


            pool.setPoolType(StoragePoolType.NetworkFilesystem);
            pool.setPodId(podId);
            pool.setScope(ScopeType.CLUSTER);
            pool.setStorageProviderName(DataStoreProvider.DEFAULT_PRIMARY);
            pool = this.primaryStoreDao.persist(pool);
            DataStore store = this.dataStoreMgr.getPrimaryDataStore(pool.getId());
            return store;
        } catch (Exception e) {
            return null;
        }
    }
View Full Code Here

        volume = volumeDao.persist(volume);
        return volume;
    }

    public VolumeInfo createCopyBaseImage() throws InterruptedException, ExecutionException {
        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));

        VolumeApiResult result;
View Full Code Here

        Mockito.when(epSelector.select(Matchers.any(DataObject.class), Matchers.any(DataObject.class))).thenReturn(ep);

        try {
            VMTemplateVO templateVO = createTemplateInDb();
            TemplateInfo tmpl = this.templateFactory.getTemplate(templateVO.getId(), DataStoreRole.Image);
            DataStore imageStore = this.dataStoreMgr.getImageStore(this.dcId);
            AsyncCallFuture<TemplateApiResult> templateFuture = this.imageService.createTemplateFromSnapshotAsync(snapshot, tmpl, imageStore);
            TemplateApiResult apiResult = templateFuture.get();
            Assert.assertTrue(apiResult.isSuccess());
        } finally {
            Mockito.when(epSelector.select(Matchers.any(DataObject.class), Matchers.any(DataObject.class))).thenReturn(remoteEp);
View Full Code Here

        pool.setPoolType(Storage.StoragePoolType.NetworkFilesystem);
        pool.setPodId(podId);
        pool.setScope(scope);
        pool.setStorageProviderName(DataStoreProvider.DEFAULT_PRIMARY);
        pool = primaryDataStoreDao.persist(pool);
        DataStore store = dataStoreManager.getPrimaryDataStore(pool.getId());
        return store;
    }
View Full Code Here

    @Test
    public void testMixZonePrimaryStorages() {
        Long srcStoreId = null;
        Long destStoreId = imageStore.getId();
        DataStore store = createPrimaryDataStore(ScopeType.ZONE);
        srcStoreId = store.getId();
        HostVO host = createHost(Hypervisor.HypervisorType.VMware);
        addStorageToHost(store, host);

        store = createPrimaryDataStore(ScopeType.ZONE);
        host = createHost(Hypervisor.HypervisorType.VMware);
        addStorageToHost(store, host);

        Long xenStoreId = null;
        store = createPrimaryDataStore(ScopeType.CLUSTER);
        xenStoreId = store.getId();
        host = createHost(Hypervisor.HypervisorType.XenServer);
        addStorageToHost(store, host);

        store = createPrimaryDataStore(ScopeType.CLUSTER);
        host = createHost(Hypervisor.HypervisorType.XenServer);
        addStorageToHost(store, host);

        ZoneScope srcScope = new ZoneScope(dcId);

        DataStore srcStore = mock(DataStore.class);
        DataStore destStore = mock(DataStore.class);

        when(srcStore.getScope()).thenReturn(srcScope);
        when(srcStore.getRole()).thenReturn(DataStoreRole.Primary);
        when(srcStore.getId()).thenReturn(srcStoreId);
        when(destStore.getScope()).thenReturn(srcScope);
        when(destStore.getRole()).thenReturn(DataStoreRole.Image);
        when(destStore.getId()).thenReturn(destStoreId);



        DataObject srcObj = mock(DataObject.class);
        DataObject destObj = mock(DataObject.class);
        when(srcObj.getDataStore()).thenReturn(srcStore);
        when(destObj.getDataStore()).thenReturn(destStore);
        EndPoint ep = endPointSelector.select(srcObj, destObj);

        Assert.assertTrue(ep != null);
        Long hostId = ep.getId();
        HostVO newHost = hostDao.findById(hostId);
        Assert.assertTrue(newHost.getHypervisorType() == Hypervisor.HypervisorType.VMware);

        when(srcStore.getRole()).thenReturn(DataStoreRole.Image);
        when(srcStore.getId()).thenReturn(destStoreId);
        when(destStore.getId()).thenReturn(srcStoreId);
        when(destStore.getRole()).thenReturn(DataStoreRole.Primary);
        ep = endPointSelector.select(srcObj, destObj);

        Assert.assertTrue(ep != null);
        hostId = ep.getId();
        newHost = hostDao.findById(hostId);
View Full Code Here

        }
    }

    protected DataObject cacheSnapshotChain(SnapshotInfo snapshot) {
        DataObject leafData = null;
        DataStore store = cacheMgr.getCacheStorage(snapshot.getDataStore().getScope());
        while (snapshot != null) {
            DataObject cacheData = cacheMgr.createCacheObject(snapshot, store);
            if (leafData == null) {
                leafData = cacheData;
            }
View Full Code Here

    protected Answer copyVolumeFromSnapshot(DataObject snapObj, DataObject volObj) {
        SnapshotInfo snapshot = (SnapshotInfo) snapObj;
        StoragePool pool = (StoragePool) volObj.getDataStore();

        String basicErrMsg = "Failed to create volume from " + snapshot.getName() + " on pool " + pool;
        DataStore store = snapObj.getDataStore();
        DataStoreTO storTO = store.getTO();
        DataObject srcData = snapObj;
        try {
            if (!(storTO instanceof NfsTO)) {
                srcData = cacheSnapshotChain(snapshot);
            }
View Full Code Here

    protected Answer copyVolumeBetweenPools(DataObject srcData, DataObject destData) {
        String value = configDao.getValue(Config.CopyVolumeWait.key());
        int _copyvolumewait = NumbersUtil.parseInt(value, Integer.parseInt(Config.CopyVolumeWait.getDefaultValue()));

        Scope destScope = getZoneScope(destData.getDataStore().getScope());
        DataStore cacheStore = cacheMgr.getCacheStorage(destScope);
        if (cacheStore == null) {
            // need to find a nfs image store, assuming that can't copy volume
            // directly to s3
            ImageStoreEntity imageStore = (ImageStoreEntity) this.dataStoreMgr.getImageStore(destScope.getScopeId());
            if (!imageStore.getProtocol().equalsIgnoreCase("nfs")) {
View Full Code Here

    @Override
    public String getSecondaryStorageStoreUrl(long dcId) {

        String secUrl = null;
        DataStore secStore = _dataStoreMgr.getImageStore(dcId);
        if (secStore != null) {
            secUrl = secStore.getUri();
        }

        if (secUrl == null) {
            // we are using non-NFS image store, then use cache storage instead
            s_logger.info("Secondary storage is not NFS, we need to use staging storage");
            DataStore cacheStore = _dataStoreMgr.getImageCacheStore(dcId);
            if (cacheStore != null) {
                secUrl = cacheStore.getUri();
            } else {
                s_logger.warn("No staging storage is found when non-NFS secondary storage is used");
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.cloudstack.engine.subsystem.api.storage.DataStore

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.