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

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


        driverMaps = new HashMap<String, ImageStoreDriver>();
    }

    @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;
    }
View Full Code Here


        return true;
    }

    @Override
    public ImageStoreEntity getImageStore(String uuid) {
        ImageStoreVO dataStore = dataStoreDao.findByUuid(uuid);
        return getImageStore(dataStore.getId());
    }
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

        }

        if (name == null) {
            name = url;
        }
        ImageStoreVO imageStore = _imageStoreDao.findByName(name);
        if (imageStore != null) {
            throw new InvalidParameterValueException("The image store with name " + name + " already exists, try creating with another name");
        }

        // check if scope is supported by store provider
View Full Code Here

    @Override
    public boolean deleteImageStore(DeleteImageStoreCmd cmd) {
        final long storeId = cmd.getId();
        // 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(CallContext.current().getCallingAccount(), 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) {
        final long storeId = cmd.getId();
        // 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(CallContext.current().getCallingAccount(), 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

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.