Package org.apache.cloudstack.storage.volume.VolumeServiceImpl

Examples of org.apache.cloudstack.storage.volume.VolumeServiceImpl.CreateBaseImageResult


                freshNewTemplate = true;
            } catch (Throwable e) {
                obj = objectInDataStoreMgr.findObject(template.getId(),
                        template.getType(), store.getId(), store.getRole());
                if (obj == null) {
                    CreateBaseImageResult result = new CreateBaseImageResult(
                            null);
                    result.setSucess(false);
                    result.setResult(e.toString());
                    callback.complete(result);
                    return null;
                }
            }
        }

        if (!freshNewTemplate
                && obj.getState() != ObjectInDataStoreStateMachine.State.Ready) {
            try {
                templateOnPrimaryStoreObj = waitingForTemplateDownload(
                        template, store);
            } catch (Exception e) {
                CreateBaseImageResult result = new CreateBaseImageResult(null);
                result.setSucess(false);
                result.setResult(e.toString());
                callback.complete(result);
                return null;
            }

            CreateBaseImageResult result = new CreateBaseImageResult(
                    templateOnPrimaryStoreObj);
            callback.complete(result);
            return null;
        }

        try {
            objectInDataStoreMgr.update(templateOnPrimaryStoreObj,
                    ObjectInDataStoreStateMachine.Event.CreateRequested);
        } catch (NoTransitionException e) {
            try {
                objectInDataStoreMgr.update(templateOnPrimaryStoreObj,
                        ObjectInDataStoreStateMachine.Event.OperationFailed);
            } catch (NoTransitionException e1) {
                s_logger.debug("state transation failed", e1);
            }
            CreateBaseImageResult result = new CreateBaseImageResult(null);
            result.setSucess(false);
            result.setResult(e.toString());
            callback.complete(result);
            return null;
        }

        InstallContext<CreateBaseImageResult> context = new InstallContext<CreateBaseImageResult>(
View Full Code Here


    protected Void installTemplateCallback(
            AsyncCallbackDispatcher<TemplateInstallStrategyImpl, CreateCmdResult> callback,
            InstallContext<CreateBaseImageResult> context) {
        CreateCmdResult result = callback.getResult();
        TemplateInfo templateOnPrimaryStoreObj = context.destTemplate;
        CreateBaseImageResult upResult = new CreateBaseImageResult(
                templateOnPrimaryStoreObj);
        if (result.isFailed()) {
            upResult.setResult(result.getResult());
            context.getParentCallback().complete(upResult);
            return null;
        }

        ObjectInDataStoreVO obj = objectInDataStoreMgr.findObject(
                templateOnPrimaryStoreObj.getId(), templateOnPrimaryStoreObj
                        .getType(), templateOnPrimaryStoreObj.getDataStore()
                        .getId(), templateOnPrimaryStoreObj.getDataStore()
                        .getRole());

        obj.setInstallPath(result.getPath());
        obj.setSize(result.getSize());
        try {
            objectInDataStoreMgr.update(obj,
                    ObjectInDataStoreStateMachine.Event.OperationSuccessed);
        } catch (NoTransitionException e) {
            try {
                objectInDataStoreMgr.update(obj,
                        ObjectInDataStoreStateMachine.Event.OperationFailed);
            } catch (NoTransitionException e1) {
                s_logger.debug("failed to change state", e1);
            }

            upResult.setResult(e.toString());
            context.getParentCallback().complete(upResult);
            return null;
        }

        moveTemplate(context.srcTemplate, templateOnPrimaryStoreObj, obj,
View Full Code Here

                objectInDataStoreMgr.update(destTemplate,
                        ObjectInDataStoreStateMachine.Event.OperationFailed);
            } catch (NoTransitionException e1) {

            }
            CreateBaseImageResult res = new CreateBaseImageResult(destTemplate);
            res.setResult("Failed to change state: " + e.toString());
            callback.complete(res);
        }

        CopyTemplateContext<CreateBaseImageResult> anotherCall = new CopyTemplateContext<CreateBaseImageResult>(
                callback, destTemplate);
View Full Code Here

            AsyncCallbackDispatcher<TemplateInstallStrategyImpl, CopyCommandResult> callback,
            CopyTemplateContext<CreateBaseImageResult> context) {
        CopyCommandResult result = callback.getResult();
        TemplateInfo templateOnPrimaryStoreObj = context.template;
        if (result.isFailed()) {
            CreateBaseImageResult res = new CreateBaseImageResult(
                    templateOnPrimaryStoreObj);
            res.setResult(result.getResult());
            context.getParentCallback().complete(res);
        }
        ObjectInDataStoreVO obj = objectInDataStoreMgr.findObject(
                templateOnPrimaryStoreObj.getId(), templateOnPrimaryStoreObj
                        .getType(), templateOnPrimaryStoreObj.getDataStore()
                        .getId(), templateOnPrimaryStoreObj.getDataStore()
                        .getRole());

        obj.setInstallPath(result.getPath());
        CreateBaseImageResult res = new CreateBaseImageResult(
                templateOnPrimaryStoreObj);
        try {
            objectInDataStoreMgr.update(obj,
                    ObjectInDataStoreStateMachine.Event.OperationSuccessed);
        } catch (NoTransitionException e) {
            s_logger.debug("Failed to update copying state: ", e);
            try {
                objectInDataStoreMgr.update(templateOnPrimaryStoreObj,
                        ObjectInDataStoreStateMachine.Event.OperationFailed);
            } catch (NoTransitionException e1) {
            }

            res.setResult("Failed to update copying state: " + e.toString());
            context.getParentCallback().complete(res);
        }
        context.getParentCallback().complete(res);
        return null;
    }
View Full Code Here

TOP

Related Classes of org.apache.cloudstack.storage.volume.VolumeServiceImpl.CreateBaseImageResult

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.