Package com.cloud.storage.Storage

Examples of com.cloud.storage.Storage.ImageFormat


        DataStore store = volume.getDataStore();
        VolumeInfo volInfo = (VolumeInfo)volume;
        RegisterVolumePayload payload = (RegisterVolumePayload)volInfo.getpayload();
        String url = payload.getUrl();
        String checkSum = payload.getChecksum();
        ImageFormat format = ImageFormat.valueOf(payload.getFormat());

        volumeHost = _volumeStoreDao.findByStoreVolume(store.getId(), volume.getId());
        if (volumeHost == null) {
            volumeHost = new VolumeDataStoreVO(store.getId(), volume.getId(), new Date(), 0, Status.NOT_DOWNLOADED,
                    null, null, "jobid0000", null, url, checkSum);
View Full Code Here


        if (sortKey != null) {
            template.setSortKey(sortKey);
        }

        ImageFormat imageFormat = null;
        if (format != null) {
            try {
                imageFormat = ImageFormat.valueOf(format.toUpperCase());
            } catch (IllegalArgumentException e) {
                throw new InvalidParameterValueException("Image format: " + format + " is incorrect. Supported formats are "
View Full Code Here

        if (url.toLowerCase().contains("file://")) {
            throw new InvalidParameterValueException(
                    "File:// type urls are currently unsupported");
        }

        ImageFormat imgfmt = ImageFormat.valueOf(format.toUpperCase());
        if (imgfmt == null) {
            throw new IllegalArgumentException("Image format is incorrect "
                    + format + ". Supported formats are "
                    + EnumUtils.listValues(ImageFormat.values()));
        }
View Full Code Here

            return copySnapshotToTemplateFromNfsToNfsXenserver(cmd, srcData, srcDataStore, destData, destDataStore);
        } else if (srcData.getHypervisorType() == HypervisorType.KVM) {
            File srcFile = getFile(srcData.getPath(), srcDataStore.getUrl());
            File destFile = getFile(destData.getPath(), destDataStore.getUrl());
            VolumeObjectTO volumeObjectTO = srcData.getVolume();
            ImageFormat srcFormat = null;
            //TODO: the image format should be stored in snapshot table, instead of getting from volume
            if (volumeObjectTO != null) {
                srcFormat = volumeObjectTO.getFormat();
            } else {
                srcFormat = ImageFormat.QCOW2;
            }

            // get snapshot file name
            String templateName = srcFile.getName();
            // add kvm file extension for copied template name   
            String fileName = templateName + "." + srcFormat.getFileExtension();
            String destFileFullPath = destFile.getAbsolutePath() + File.separator + fileName;
            s_logger.debug("copy snapshot " + srcFile.getAbsolutePath() + " to template " + destFileFullPath);
            Script.runSimpleBashScript("cp " + srcFile.getAbsolutePath() + " " + destFileFullPath);
            try {
                // generate template.properties file
View Full Code Here

                    }
                }
            }

            long srcSize = srcFile.length();
            ImageFormat format = this.getTemplateFormat(srcFile.getName());
            String key = destData.getPath() + S3Utils.SEPARATOR + srcFile.getName();
            if (!s3.getSingleUpload(srcSize)){
                mputFile(s3, srcFile, bucket, key);
            } else{
                putFile(s3, srcFile, bucket, key);
View Full Code Here

        DataStore store = volume.getDataStore();
        VolumeInfo volInfo = (VolumeInfo)volume;
        RegisterVolumePayload payload = (RegisterVolumePayload)volInfo.getpayload();
        String url = payload.getUrl();
        String checkSum = payload.getChecksum();
        ImageFormat format = ImageFormat.valueOf(payload.getFormat());

        volumeHost = _volumeStoreDao.findByStoreVolume(store.getId(), volume.getId());
        if (volumeHost == null) {
            volumeHost = new VolumeDataStoreVO(store.getId(), volume.getId(), new Date(), 0, Status.NOT_DOWNLOADED,
                    null, null, "jobid0000", null, url, checkSum);
View Full Code Here

            return null;
        }
    }

    private boolean isSupportedImageFormatForCluster(VolumeInfo volume, HypervisorType rootDiskHyperType) {
        ImageFormat volumeFormat = volume.getFormat();
        if (rootDiskHyperType == HypervisorType.Hyperv) {
            if (volumeFormat.equals(ImageFormat.VHDX) || volumeFormat.equals(ImageFormat.VHD)) {
                return true;
            } else {
                return false;
            }
        } else {
View Full Code Here

        } else if (srcData.getHypervisorType() == HypervisorType.KVM) {
            File srcFile = getFile(srcData.getPath(), srcDataStore.getUrl());
            File destFile = getFile(destData.getPath(), destDataStore.getUrl());

            VolumeObjectTO volumeObjectTO = srcData.getVolume();
            ImageFormat srcFormat = null;
            //TODO: the image format should be stored in snapshot table, instead of getting from volume
            if (volumeObjectTO != null) {
                srcFormat = volumeObjectTO.getFormat();
            } else {
                srcFormat = ImageFormat.QCOW2;
            }

            // get snapshot file name
            String templateName = srcFile.getName();
            // add kvm file extension for copied template name
            String fileName = templateName + "." + srcFormat.getFileExtension();
            String destFileFullPath = destFile.getAbsolutePath() + File.separator + fileName;
            s_logger.debug("copy snapshot " + srcFile.getAbsolutePath() + " to template " + destFileFullPath);
            Script.runSimpleBashScript("cp " + srcFile.getAbsolutePath() + " " + destFileFullPath);
            try {
                // generate template.properties file
                String metaFileName = destFile.getAbsolutePath() + File.separator + "template.properties";
                _storage.create(destFile.getAbsolutePath(), "template.properties");
                File metaFile = new File(metaFileName);
                FileWriter writer = new FileWriter(metaFile);
                BufferedWriter bufferWriter = new BufferedWriter(writer);
                // KVM didn't change template unique name, just used the template name passed from orchestration layer, so no need
                // to send template name back.
                bufferWriter.write("uniquename=" + destData.getName());
                bufferWriter.write("\n");
                bufferWriter.write("filename=" + fileName);
                bufferWriter.write("\n");
                long size = _storage.getSize(destFileFullPath);
                bufferWriter.write("size=" + size);
                bufferWriter.close();
                writer.close();

                /**
                 * Snapshots might be in either QCOW2 or RAW image format
                 *
                 * For example RBD snapshots are in RAW format
                 */
                Processor processor = null;
                if (srcFormat == ImageFormat.QCOW2) {
                    processor = new QCOW2Processor();
                } else if (srcFormat == ImageFormat.RAW) {
                    processor = new RawImageProcessor();
                } else {
                    throw new ConfigurationException("Unknown image format " + srcFormat.toString());
                }

                Map<String, Object> params = new HashMap<String, Object>();
                params.put(StorageLayer.InstanceConfigKey, _storage);

View Full Code Here

                    }
                }
            }

            long srcSize = srcFile.length();
            ImageFormat format = getTemplateFormat(srcFile.getName());
            String key = destData.getPath() + S3Utils.SEPARATOR + srcFile.getName();
            if (!s3.getSingleUpload(srcSize)) {
                mputFile(s3, srcFile, bucket, key);
            } else {
                putFile(s3, srcFile, bucket, key);
View Full Code Here

                long id = rs.getLong(1);
                String uniqueName = rs.getString(2);
                String name = rs.getString(3);
                boolean isPublic = rs.getBoolean(4);
                String value = rs.getString(5);
                ImageFormat format = ImageFormat.valueOf(value);
                String tmpltType = rs.getString(6);
                boolean requiresHVM = rs.getBoolean(7);
                int bits = rs.getInt(8);
                String url = rs.getString(9);
                String createdTS = rs.getString(10);
View Full Code Here

TOP

Related Classes of com.cloud.storage.Storage.ImageFormat

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.