Package com.cloud.agent.api.to

Examples of com.cloud.agent.api.to.S3TO


                s_logger.debug(details);
                return new Answer(cmd, false, details);
            }
            return new Answer(cmd, true, null);
        } else if (dstore instanceof S3TO) {
            final S3TO s3 = (S3TO) dstore;
            final String path = cmd.getDirectory();
            final String bucket = s3.getBucketName();
            try {
                S3Utils.deleteDirectory(s3, bucket, path);
                return new Answer(cmd, true, String.format("Deleted snapshot %1%s from bucket %2$s.", path, bucket));
            } catch (Exception e) {
                final String errorMessage = String.format(
View Full Code Here


                s_logger.warn(details);
                return new Answer(cmd, false, details);
            }
            return new Answer(cmd, true, null);
        } else if (dstore instanceof S3TO) {
            final S3TO s3 = (S3TO) dstore;
            final String path = obj.getPath();
            final String bucket = s3.getBucketName();
            try {
                S3Utils.deleteObject(s3, bucket, path);
                return new Answer(cmd, true, String.format("Deleted snapshot %1%s from bucket %2$s.", path, bucket));
            } catch (Exception e) {
                final String errorMessage = String.format(
View Full Code Here

        } else if (store instanceof SwiftTO) {
            SwiftTO swift = (SwiftTO) store;
            Map<String, TemplateProp> templateInfos = swiftListTemplate(swift);
            return new ListTemplateAnswer(swift.toString(), templateInfos);
        } else if (store instanceof S3TO) {
            S3TO s3 = (S3TO) store;
            Map<String, TemplateProp> templateInfos = s3ListTemplate(s3);
            return new ListTemplateAnswer(s3.getBucketName(), templateInfos);
        } else {
            return new Answer(cmd, false, "Unsupported image data store: " + store);
        }
    }
View Full Code Here

            NfsTO nfs = (NfsTO) store;
            String root = getRootDir(cmd.getSecUrl());
            Map<Long, TemplateProp> templateInfos = _dlMgr.gatherVolumeInfo(root);
            return new ListVolumeAnswer(cmd.getSecUrl(), templateInfos);
        } else if (store instanceof S3TO) {
            S3TO s3 = (S3TO) store;
            Map<Long, TemplateProp> templateInfos = s3ListVolume(s3);
            return new ListVolumeAnswer(s3.getBucketName(), templateInfos);
        } else {
            return new Answer(cmd, false, "Unsupported image data store: " + store);
        }

    }
View Full Code Here

                s_logger.debug(details);
                return new Answer(cmd, false, details);
            }
            return new Answer(cmd, true, null);
        } else if (dstore instanceof S3TO) {
            final S3TO s3 = (S3TO) dstore;
            final String path = obj.getPath();
            final String bucket = s3.getBucketName();
            try {
                S3Utils.deleteDirectory(s3, bucket, path);
                return new Answer(cmd, true, String.format("Deleted template %1$s from bucket %2$s.", path, bucket));
            } catch (Exception e) {
                final String errorMessage = String.format(
View Full Code Here

                s_logger.debug(details);
                return new Answer(cmd, false, details);
            }
            return new Answer(cmd, true, null);
        } else if (dstore instanceof S3TO) {
            final S3TO s3 = (S3TO) dstore;
            final String path = obj.getPath();
            final String bucket = s3.getBucketName();
            try {
                S3Utils.deleteDirectory(s3, bucket, path);
                return new Answer(cmd, true, String.format("Deleted volume %1%s from bucket %2$s.", path, bucket));
            } catch (Exception e) {
                final String errorMessage = String.format(
View Full Code Here

    @Override
    public void run() {

        try {

            final S3TO s3 = s3Mgr.getS3TO();

            if (s3 == null) {
                LOGGER.warn("S3 sync skipped because no S3 instance is configured.");
                return;
            }
View Full Code Here

    }

    private Answer execute(
            final DownloadTemplateFromS3ToSecondaryStorageCommand cmd) {

        final S3TO s3 = cmd.getS3();
        final String storagePath = cmd.getStoragePath();
        final Long accountId = cmd.getAccountId();
        final Long templateId = cmd.getTemplateId();

        try {

            final File downloadDirectory = _storage
                    .getFile(determineStorageTemplatePath(storagePath,
                            accountId, templateId));
            downloadDirectory.mkdirs();

            if (!downloadDirectory.exists()) {
                final String errMsg = format(
                        "Unable to create directory "
                                + "download directory %1$s for download of template id "
                                + "%2$s from S3.", downloadDirectory.getName(),
                                templateId);
                s_logger.error(errMsg);
                return new Answer(cmd, false, errMsg);
            }

            getDirectory(s3, s3.getBucketName(),
                    determineS3TemplateDirectory(accountId, templateId),
                    downloadDirectory, new FileNamingStrategy() {
                @Override
                public String determineFileName(final String key) {
                    return substringAfterLast(key, S3Utils.SEPARATOR);
View Full Code Here

        }
    }

    private Answer execute(UploadTemplateToS3FromSecondaryStorageCommand cmd) {

        final S3TO s3 = cmd.getS3();
        final Long accountId = cmd.getAccountId();
        final Long templateId = cmd.getTemplateId();

        try {

            final String templatePath = determineStorageTemplatePath(
                    cmd.getStoragePath(), accountId, templateId);

            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Found template id " + templateId
                        + " account id " + accountId + " from directory "
                        + templatePath + " to upload to S3.");
            }

            if (!_storage.isDirectory(templatePath)) {
                final String errMsg = format("S3 Sync Failure: Directory %1$s"
                        + "for template id %2$s does not exist.", templatePath,
                        templateId);
                s_logger.error(errMsg);
                return new Answer(cmd, false, errMsg);
            }

            if (!_storage.isFile(templatePath + "/template.properties")) {
                final String errMsg = format("S3 Sync Failure: Template id "
                        + "%1$s does not exist on the file system.",
                        templatePath);
                s_logger.error(errMsg);
                return new Answer(cmd, false, errMsg);
            }

            if (s_logger.isDebugEnabled()) {
                s_logger.debug(format(
                        "Pushing template id %1$s from %2$s to S3...",
                        templateId, templatePath));
            }

            final String bucket = s3.getBucketName();
            putDirectory(s3, bucket, _storage.getFile(templatePath),
                    new FilenameFilter() {
                @Override
                public boolean accept(final File directory,
                        final String fileName) {
View Full Code Here

    }

    private Answer execute(final DeleteTemplateFromS3Command cmd) {

        final S3TO s3 = cmd.getS3();
        final Long accountId = cmd.getAccountId();
        final Long templateId = cmd.getTemplateId();

        if (accountId == null || (accountId != null && accountId <= 0)) {
            final String errorMessage = "No account id specified for S3 template deletion.";
            s_logger.error(errorMessage);
            return new Answer(cmd, false, errorMessage);
        }

        if (templateId == null || (templateId != null && templateId <= 0)) {
            final String errorMessage = "No template id specified for S3 template deletion.";
            s_logger.error(errorMessage);
            return new Answer(cmd, false, errorMessage);
        }

        if (s3 == null) {
            final String errorMessge = "No S3 client options provided";
            s_logger.error(errorMessge);
            return new Answer(cmd, false, errorMessge);
        }

        final String bucket = s3.getBucketName();
        try {
            deleteDirectory(s3, bucket,
                    determineS3TemplateDirectory(templateId, accountId));
            return new Answer(cmd, true, String.format(
                    "Deleted template %1%s from bucket %2$s.", templateId,
View Full Code Here

TOP

Related Classes of com.cloud.agent.api.to.S3TO

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.