Examples of VMTemplateHostVO


Examples of com.cloud.storage.VMTemplateHostVO

            throw new CloudRuntimeException(
                    format("Attempt to sync template id %1$s that is not attached to a host.",
                            templateId));
        }

        final VMTemplateHostVO templateHostRef = templateHostRefs.get(0);

        if (!isS3Enabled()) {
            return;
        }

        final S3TO s3 = getS3TO();
        if (s3 == null) {
            LOGGER.warn("S3 Template Sync Failed: Attempt to sync templates with S3, but no S3 instance defined.");
            return;
        }

        final HostVO secondaryHost = this.hostDao.findById(templateHostRef
                .getHostId());
        if (secondaryHost == null) {
            throw new CloudRuntimeException(format(
                    "Unable to find secondary storage host id %1$s.",
                    templateHostRef.getHostId()));
        }

        final Long dataCenterId = secondaryHost.getDataCenterId();
        final Long accountId = template.getAccountId();

        try {

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

                @Override
                public Void call() throws Exception {

                    final UploadTemplateToS3FromSecondaryStorageCommand cmd = new UploadTemplateToS3FromSecondaryStorageCommand(
                            s3, secondaryHost.getStorageUrl(),
                            dataCenterId, accountId, templateId);

                    final Answer answer = agentManager.sendToSSVM(
                            dataCenterId, cmd);
                    if (answer == null || !answer.getResult()) {

                        final String reason = answer != null ? answer
                                .getDetails()
                                : "S3 template sync failed due to an unspecified error.";
                                throw new CloudRuntimeException(
                                        format("Failed to upload template id %1$s to S3 from secondary storage due to %2$s.",
                                                templateId, reason));

                    }

                    if (LOGGER.isDebugEnabled()) {
                        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()) {
                        LOGGER.debug(format("Persisting %1$s",
                                vmTemplateS3VO));
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.