Examples of VMTemplateS3VO


Examples of com.cloud.storage.VMTemplateS3VO

            final String errorMessage = "Delete Template Failed: No S3 configuration defined.";
            LOGGER.error(errorMessage);
            throw new CloudRuntimeException(errorMessage);
        }

        final VMTemplateS3VO vmTemplateS3VO = vmTemplateS3Dao
                .findOneByS3Template(s3.getId(), templateId);
        if (vmTemplateS3VO == null) {
            final String errorMessage = format(
                    "Delete Template Failed: Unable to find Template %1$s in S3.",
                    templateId);
            LOGGER.error(errorMessage);
            throw new CloudRuntimeException(errorMessage);
        }

        try {

            executeWithNoWaitLock(determineLockId(accountId, templateId),
                    new Callable<Void>() {

                @Override
                public Void call() throws Exception {

                    final Answer answer = agentManager.sendToSSVM(null,
                            new DeleteTemplateFromS3Command(s3,
                                    accountId, templateId));
                    if (answer == null || !answer.getResult()) {
                        final String errorMessage = format(
                                "Delete Template Failed: Unable to delete template id %1$s from S3 due to following error: %2$s",
                                templateId,
                                ((answer == null) ? "answer is null"
                                        : answer.getDetails()));
                        LOGGER.error(errorMessage);
                        throw new CloudRuntimeException(errorMessage);
                    }

                    vmTemplateS3Dao.remove(vmTemplateS3VO.getId());
                    LOGGER.debug(format(
                            "Deleted template %1$s from S3.",
                            templateId));

                    return null;
View Full Code Here

Examples of com.cloud.storage.VMTemplateS3VO

                            templateId);
            LOGGER.error(errorMessage);
            return errorMessage;
        }

        final VMTemplateS3VO templateS3VO = findByTemplateId(templateId);
        if (templateS3VO == null) {
            final String errorMessage = format(
                    "Failed to download template id %1$s from S3 because it does not exist in S3.",
                    templateId);
            LOGGER.error(errorMessage);
            return errorMessage;
        }

        final S3TO s3 = getS3TO(templateS3VO.getS3Id());
        if (s3 == null) {
            final String errorMessage = format(
                    "Failed to download template id %1$s from S3 because S3 id %2$s does not exist.",
                    templateId, templateS3VO);
            LOGGER.error(errorMessage);
            return errorMessage;
        }

        final HostVO secondaryStorageHost = secondaryStorageVMManager
                .findSecondaryStorageHost(dataCenterId);
        if (secondaryStorageHost == null) {
            final String errorMessage = format(
                    "Unable to find secondary storage host for zone id %1$s.",
                    dataCenterId);
            LOGGER.error(errorMessage);
            throw new CloudRuntimeException(errorMessage);
        }

        final long accountId = template.getAccountId();
        final DownloadTemplateFromS3ToSecondaryStorageCommand cmd = new DownloadTemplateFromS3ToSecondaryStorageCommand(
                s3, accountId, templateId, secondaryStorageHost.getName(),
                primaryStorageDownloadWait);

        try {

            executeWithNoWaitLock(determineLockId(accountId, templateId),
                    new Callable<Void>() {

                @Override
                public Void call() throws Exception {

                    final Answer answer = agentManager.sendToSSVM(
                            dataCenterId, cmd);

                    if (answer == null || !answer.getResult()) {
                        final String errMsg = String
                                .format("Failed to download template from S3 to secondary storage due to %1$s",
                                        (answer == null ? "answer is null"
                                                : answer.getDetails()));
                        LOGGER.error(errMsg);
                        throw new CloudRuntimeException(errMsg);
                    }

                    final String installPath = join(
                            asList("template", "tmpl", accountId,
                                    templateId), File.separator);
                    final VMTemplateHostVO tmpltHost = new VMTemplateHostVO(
                            secondaryStorageHost.getId(), templateId,
                            now(), 100, Status.DOWNLOADED, null, null,
                            null, installPath, template.getUrl());
                    tmpltHost.setSize(templateS3VO.getSize());
                    tmpltHost.setPhysicalSize(templateS3VO
                            .getPhysicalSize());
                    vmTemplateHostDao.persist(tmpltHost);

                    return null;
View Full Code Here

Examples of com.cloud.storage.VMTemplateS3VO

                        LOGGER.debug(format(
                                "Creating VMTemplateS3VO instance using template id %1s.",
                                templateId));
                    }

                    final VMTemplateS3VO vmTemplateS3VO = new VMTemplateS3VO(
                            s3.getId(), templateId, now(),
                            templateHostRef.getSize(), templateHostRef
                            .getPhysicalSize());

                    if (LOGGER.isDebugEnabled()) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.