Package org.apache.cloudstack.storage.datastore.db

Examples of org.apache.cloudstack.storage.datastore.db.ImageStoreVO


                Answer answer = _agentMgr.easySend(ssHostId, setupCmd);
                if (answer != null && answer.getResult()) {
                    SecStorageSetupAnswer an = (SecStorageSetupAnswer) answer;
                    if (an.get_dir() != null){
                        // update the parent path in image_store table for this image store
                        ImageStoreVO svo = this._imageStoreDao.findById(ssStore.getId());
                        svo.setParent(an.get_dir());
                        _imageStoreDao.update(ssStore.getId(), svo);
                    }
                    if (s_logger.isDebugEnabled()) {
                        s_logger.debug("Successfully programmed secondary storage " + ssStore.getName() + " in secondary storage VM " + secStorageVm.getInstanceName());
                    }
View Full Code Here


    @Override
    public boolean deleteImageStore(DeleteImageStoreCmd cmd) {
        long storeId = cmd.getId();
        User caller = _accountMgr.getActiveUser(UserContext.current().getCallerUserId());
        // Verify that image store exists
        ImageStoreVO store = _imageStoreDao.findById(storeId);
        if (store == null) {
            throw new InvalidParameterValueException("Image store with id " + storeId + " doesn't exist");
        }
        _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), store.getDataCenterId());

        // Verify that there are no live snapshot, template, volume on the image
        // store to be deleted
        List<SnapshotDataStoreVO> snapshots = _snapshotStoreDao.listByStoreId(storeId, DataStoreRole.Image);
        if (snapshots != null && snapshots.size() > 0) {
View Full Code Here

    @Override
    public boolean deleteSecondaryStagingStore(DeleteSecondaryStagingStoreCmd cmd) {
        long storeId = cmd.getId();
        User caller = _accountMgr.getActiveUser(UserContext.current().getCallerUserId());
        // Verify that cache store exists
        ImageStoreVO store = _imageStoreDao.findById(storeId);
        if (store == null) {
            throw new InvalidParameterValueException("Cache store with id " + storeId + " doesn't exist");
        }
        _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), store.getDataCenterId());

        // Verify that there are no live snapshot, template, volume on the cache
        // store that is currently referenced
        List<SnapshotDataStoreVO> snapshots = _snapshotStoreDao.listActiveOnCache(storeId);
        if (snapshots != null && snapshots.size() > 0) {
View Full Code Here

    ImageStoreDetailsDao imageStoreDetailsDao;
    @Inject
    SnapshotDataStoreDao snapshotStoreDao;

    public ImageStoreVO createImageStore(Map<String, Object> params) {
        ImageStoreVO store = imageStoreDao.findByName((String)params.get("name"));
        if (store != null) {
            return store;
        }
        store = new ImageStoreVO();
        store.setProtocol((String)params.get("protocol"));
        store.setProviderName((String)params.get("providerName"));
        store.setScope((ScopeType)params.get("scope"));
        store.setDataCenterId((Long)params.get("zoneId"));
        String uuid = (String)params.get("uuid");
        if (uuid != null) {
            store.setUuid(uuid);
        } else {
            store.setUuid(UUID.randomUUID().toString());
        }
        store.setName((String)params.get("name"));
        if (store.getName() == null) {
            store.setName(store.getUuid());
        }
        store.setUrl((String)params.get("url"));
        store.setRole((DataStoreRole)params.get("role"));
        store = imageStoreDao.persist(store);
        return store;
    }
View Full Code Here

        store = imageStoreDao.persist(store);
        return store;
    }

    public ImageStoreVO createImageStore(Map<String, Object> params, Map<String, String> details) {
        ImageStoreVO store = imageStoreDao.findByName((String)params.get("name"));
        if (store != null) {
            return store;
        }
        store = new ImageStoreVO();
        store.setProtocol((String)params.get("protocol"));
        store.setProviderName((String)params.get("providerName"));
        store.setScope((ScopeType)params.get("scope"));
        store.setDataCenterId((Long)params.get("zoneId"));
        String uuid = (String)params.get("uuid");
        if (uuid != null) {
            store.setUuid(uuid);
        } else {
            store.setUuid(UUID.randomUUID().toString());
        }
        store.setUrl((String)params.get("url"));
        store.setName((String)params.get("name"));
        if (store.getName() == null) {
            store.setName(store.getUuid());
        }

        store.setRole((DataStoreRole)params.get("role"));

        if ("cifs".equalsIgnoreCase((String) params.get("protocol")) && details != null) {
            String user = details.get("user");
            String password = details.get("password");
            String domain = details.get("domain");
            String updatedPath = (String) params.get("url");

            if (user == null || password == null) {
                String errMsg = "Missing cifs user and password details. Add them as details parameter.";
                throw new InvalidParameterValueException(errMsg);
            } else {
                try {
                    password = DBEncryptionUtil.encrypt(URLEncoder.encode(password, "UTF-8"));
                    details.put("password", password);
                    updatedPath += "?user=" + user + "&password=" + password + "&domain=" + domain;
                } catch (UnsupportedEncodingException e) {
                    throw new CloudRuntimeException("Error while generating the cifs url. " + e.getMessage());
                }
                store.setUrl(updatedPath);
            }
        }

        store = imageStoreDao.persist(store);

        // persist details
        if (details != null) {
            Iterator<String> keyIter = details.keySet().iterator();
            while (keyIter.hasNext()) {
                String key = keyIter.next().toString();
                ImageStoreDetailVO detail = new ImageStoreDetailVO();
                detail.setStoreId(store.getId());
                detail.setName(key);
                String value = details.get(key);
                // encrypt swift key or s3 secret key
                if (key.equals(ApiConstants.KEY) || key.equals(ApiConstants.S3_SECRET_KEY)) {
                    value = DBEncryptionUtil.encrypt(value);
View Full Code Here

        }
        return store;
    }

    public boolean deleteImageStore(long id) {
        ImageStoreVO store = imageStoreDao.findById(id);
        if (store == null) {
            throw new CloudRuntimeException("can't find image store:" + id);
        }

        imageStoreDao.remove(id);
View Full Code Here

     * Convert current NFS secondary storage to Staging store to be ready to migrate to S3 object store.
     * @param store NFS image store.
     * @return true if successful.
     */
    public boolean convertToStagingStore(DataStore store) {
        ImageStoreVO nfsStore = imageStoreDao.findById(store.getId());
        nfsStore.setRole(DataStoreRole.ImageCache);
        imageStoreDao.update(store.getId(), nfsStore);
        // clear snapshot entry on primary store to make next snapshot become full snapshot
        snapshotStoreDao.deleteSnapshotRecordsOnPrimary();
        return true;
    }
View Full Code Here

        cluster.setClusterType(Cluster.ClusterType.CloudManaged);
        cluster.setManagedState(Managed.ManagedState.Managed);
        cluster = clusterDao.persist(cluster);
        clusterId = cluster.getId();

        imageStore = new ImageStoreVO();
        imageStore.setName(UUID.randomUUID().toString());
        imageStore.setDataCenterId(dcId);
        imageStore.setProviderName(DataStoreProvider.NFS_IMAGE);
        imageStore.setRole(DataStoreRole.Image);
        imageStore.setUrl(UUID.randomUUID().toString());
View Full Code Here

            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();

        imageStore = new ImageStoreVO();
        imageStore.setName("test");
        imageStore.setDataCenterId(dcId);
        imageStore.setProviderName(DataStoreProvider.NFS_IMAGE);
        imageStore.setRole(DataStoreRole.Image);
        imageStore.setUrl(this.getSecondaryStorage());
View Full Code Here

            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);

            Calendar cal = Calendar.getInstance();
            cal.setTime(DateUtil.now());
            cal.add(Calendar.DAY_OF_MONTH, -2);
            Date date = cal.getTime();

            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.assertNotNull(cacheReplacementAlgorithm.chooseOneToBeReplaced(store));

        } catch (Exception e) {
            Assert.fail();
        }
View Full Code Here

TOP

Related Classes of org.apache.cloudstack.storage.datastore.db.ImageStoreVO

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.