Examples of CopyVolumeAnswer


Examples of com.cloud.agent.api.storage.CopyVolumeAnswer

            }
            String value = _configs.get(Config.CopyVolumeWait.toString());
            int copyvolumewait = NumbersUtil.parseInt(value, Integer.parseInt(Config.CopyVolumeWait.getDefaultValue()));
            // Copy the volume from the source storage pool to secondary storage
            CopyVolumeCommand cvCmd = new CopyVolumeCommand(volume.getId(), volume.getPath(), srcPool, secondaryStorageURL, true, copyvolumewait);
            CopyVolumeAnswer cvAnswer = null;
            try {
                cvAnswer = (CopyVolumeAnswer) _storageMgr.sendToPool(srcPool, cvCmd);
            } catch (StorageUnavailableException e) {
                s_logger.debug("Storage unavailable");
            }

            // Check if you got a valid answer.
            if (cvAnswer == null || !cvAnswer.getResult()) {
                String errorString = "Failed to copy the volume from the source primary storage pool to secondary storage.";

                // Update the async job.
                resultObj.setResultString(errorString);
                resultObj.setUploadStatus(UploadVO.Status.COPY_ERROR.toString());
                if (asyncExecutor != null) {
                    _asyncMgr.completeAsyncJob(job.getId(), AsyncJobResult.STATUS_FAILED, 0, resultObj);
                }

                // Update the DB that volume couldn't be copied
                uploadJob.setUploadState(UploadVO.Status.COPY_ERROR);
                uploadJob.setErrorString(errorString);
                uploadJob.setLastUpdated(new Date());
                _uploadDao.update(uploadJob.getId(), uploadJob);

                throw new CloudRuntimeException(errorString);
            }

            String volumeLocalPath = "volumes/" + volume.getId() + "/" + cvAnswer.getVolumePath() + "." + getFormatForPool(srcPool);
            // Update the DB that volume is copied and volumePath
            uploadJob.setUploadState(UploadVO.Status.COPY_COMPLETE);
            uploadJob.setLastUpdated(new Date());
            uploadJob.setInstallPath(volumeLocalPath);
            _uploadDao.update(uploadJob.getId(), uploadJob);
View Full Code Here

Examples of com.cloud.agent.api.storage.CopyVolumeAnswer

                invalidateServiceContext();
            }

            String msg = "CopyVolumeCommand failed due to " + VmwareHelper.getExceptionMessage(e);
            s_logger.error(msg, e);
            return new CopyVolumeAnswer(cmd, false, msg, null, null);
        }
    }
View Full Code Here

Examples of com.cloud.agent.api.storage.CopyVolumeAnswer

            String secStorageMountPath = uri.getHost() + ":" + uri.getPath();
            String volumeFolderOnSecStorage = "volumes/" + String.valueOf(cmd.getVolumeId());
            String storagePoolUuid = cmd.getPool().getUuid();
            Boolean toSec = cmd.toSecondaryStorage();
            String res = OvmStoragePool.copyVolume(_conn, secStorageMountPath, volumeFolderOnSecStorage, volumePath, storagePoolUuid, toSec, wait);
            return new CopyVolumeAnswer(cmd, true, null, null, res);
        } catch (Exception e) {
            s_logger.debug("Copy volume failed", e);
            return new CopyVolumeAnswer(cmd, false, e.getMessage(), null, null);
        }
    }
View Full Code Here

Examples of com.cloud.agent.api.storage.CopyVolumeAnswer

                    primaryPool = _storagePoolMgr.createStoragePool(cmd.getPool().getUuid(),
                                      cmd.getPool().getHost(), cmd.getPool().getPort(),
                                      cmd.getPool().getPath(), cmd.getPool().getUserInfo(),
                                      cmd.getPool().getType());
                } else {
                    return new CopyVolumeAnswer(cmd, false, e.getMessage(), null, null);
                }
            }

            String volumeName = UUID.randomUUID().toString();

            if (copyToSecondary) {
                String destVolumeName = volumeName + ".qcow2";
                KVMPhysicalDisk volume = primaryPool.getPhysicalDisk(cmd
                        .getVolumePath());
                String volumeDestPath = "/volumes/" + cmd.getVolumeId()
                        + File.separator;
                secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(
                        secondaryStorageUrl);
                secondaryStoragePool.createFolder(volumeDestPath);
                _storagePoolMgr.deleteStoragePool(secondaryStoragePool.getType(),secondaryStoragePool.getUuid());
                secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(
                        secondaryStorageUrl
                        + volumeDestPath);
                _storagePoolMgr.copyPhysicalDisk(volume,
                        destVolumeName,secondaryStoragePool, 0);
                return new CopyVolumeAnswer(cmd, true, null, null, volumeName);
            } else {
                volumePath = "/volumes/" + cmd.getVolumeId() + File.separator;
                secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(
                        secondaryStorageUrl
                        + volumePath);
                KVMPhysicalDisk volume = secondaryStoragePool
                        .getPhysicalDisk(cmd.getVolumePath() + ".qcow2");
                _storagePoolMgr.copyPhysicalDisk(volume, volumeName,
                        primaryPool, 0);
                return new CopyVolumeAnswer(cmd, true, null, null, volumeName);
            }
        } catch (CloudRuntimeException e) {
            return new CopyVolumeAnswer(cmd, false, e.toString(), null, null);
        } finally {
            if (secondaryStoragePool != null) {
                _storagePoolMgr.deleteStoragePool(secondaryStoragePool.getType(),secondaryStoragePool.getUuid());
            }
        }
View Full Code Here

Examples of com.cloud.agent.api.storage.CopyVolumeAnswer

                        hyperHost, volumeId,
                        new DatastoreMO(context, morDatastore),
                        secondaryStorageURL, volumePath);
                deleteVolumeDirOnSecondaryStorage(volumeId, secondaryStorageURL);
            }
            return new CopyVolumeAnswer(cmd, true, null, result.first(), result.second());
        } catch (Throwable e) {
            if (e instanceof RemoteException) {
                hostService.invalidateServiceContext(context);
            }

            String msg = "Unable to execute CopyVolumeCommand due to exception";
            s_logger.error(msg, e);
            return new CopyVolumeAnswer(cmd, false, "CopyVolumeCommand failed due to exception: " + StringUtils.getExceptionStackInfo(e), null, null);
        }
    }
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.