Search in sources :

Example 16 with EndPoint

use of com.cloud.engine.subsystem.api.storage.EndPoint in project cosmic by MissionCriticalCloud.

the class VolumeServiceImpl method resizeVolumeOnHypervisor.

@Override
public void resizeVolumeOnHypervisor(final long volumeId, final long newSize, final long destHostId, final String instanceName) {
    final String errMsg = "Resize command failed";
    try {
        Answer answer = null;
        final Host destHost = _hostDao.findById(destHostId);
        final EndPoint ep = RemoteHostEndPoint.getHypervisorHostEndPoint(destHost);
        if (ep != null) {
            final VolumeVO volume = volDao.findById(volumeId);
            final PrimaryDataStore primaryDataStore = this.dataStoreMgr.getPrimaryDataStore(volume.getPoolId());
            final ResizeVolumeCommand resizeCmd = new ResizeVolumeCommand(volume.getPath(), new StorageFilerTO(primaryDataStore), volume.getSize(), newSize, true, instanceName);
            answer = ep.sendMessage(resizeCmd);
        } else {
            throw new CloudRuntimeException("Could not find a remote endpoint to send command to. Check if host or SSVM is down.");
        }
        if (answer == null || !answer.getResult()) {
            throw new CloudRuntimeException(answer != null ? answer.getDetails() : errMsg);
        }
    } catch (final Exception e) {
        throw new CloudRuntimeException(errMsg, e);
    }
}
Also used : Answer(com.cloud.agent.api.Answer) CopyCmdAnswer(com.cloud.storage.command.CopyCmdAnswer) ListVolumeAnswer(com.cloud.agent.api.storage.ListVolumeAnswer) VolumeVO(com.cloud.storage.VolumeVO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ResizeVolumeCommand(com.cloud.agent.api.storage.ResizeVolumeCommand) Host(com.cloud.host.Host) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint) RemoteHostEndPoint(com.cloud.storage.RemoteHostEndPoint) StorageFilerTO(com.cloud.agent.api.to.StorageFilerTO) ResourceAllocationException(com.cloud.exception.ResourceAllocationException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ExecutionException(java.util.concurrent.ExecutionException) PrimaryDataStore(com.cloud.engine.subsystem.api.storage.PrimaryDataStore)

Example 17 with EndPoint

use of com.cloud.engine.subsystem.api.storage.EndPoint in project cosmic by MissionCriticalCloud.

the class CloudStackImageStoreDriverImpl method createEntityExtractUrl.

@Override
public String createEntityExtractUrl(final DataStore store, final String installPath, final ImageFormat format, final DataObject dataObject) {
    // find an endpoint to send command
    final EndPoint ep = _epSelector.select(store);
    // Create Symlink at ssvm
    final String path = installPath;
    final String uuid = UUID.randomUUID().toString() + "" + format.getFileExtension();
    final CreateEntityDownloadURLCommand cmd = new CreateEntityDownloadURLCommand(((ImageStoreEntity) store).getMountPoint(), path, uuid, dataObject.getTO());
    Answer ans = null;
    if (ep == null) {
        final String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
        s_logger.error(errMsg);
        ans = new Answer(cmd, false, errMsg);
    } else {
        ans = ep.sendMessage(cmd);
    }
    if (ans == null || !ans.getResult()) {
        final String errorString = "Unable to create a link for entity at " + installPath + " on ssvm," + ans.getDetails();
        s_logger.error(errorString);
        throw new CloudRuntimeException(errorString);
    }
    // Construct actual URL locally now that the symlink exists at SSVM
    return generateCopyUrl(ep.getPublicAddr(), uuid);
}
Also used : CreateEntityDownloadURLCommand(com.cloud.agent.api.storage.CreateEntityDownloadURLCommand) Answer(com.cloud.agent.api.Answer) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint)

Example 18 with EndPoint

use of com.cloud.engine.subsystem.api.storage.EndPoint in project cosmic by MissionCriticalCloud.

the class CloudStackPrimaryDataStoreDriverImpl method takeSnapshot.

@Override
public void takeSnapshot(final SnapshotInfo snapshot, final AsyncCompletionCallback<CreateCmdResult> callback) {
    CreateCmdResult result = null;
    try {
        final SnapshotObjectTO snapshotTO = (SnapshotObjectTO) snapshot.getTO();
        final Object payload = snapshot.getPayload();
        if (payload != null && payload instanceof CreateSnapshotPayload) {
            final CreateSnapshotPayload snapshotPayload = (CreateSnapshotPayload) payload;
            snapshotTO.setQuiescevm(snapshotPayload.getQuiescevm());
        }
        final CreateObjectCommand cmd = new CreateObjectCommand(snapshotTO);
        final EndPoint ep = epSelector.select(snapshot, StorageAction.TAKESNAPSHOT);
        Answer answer = null;
        if (ep == null) {
            final String errMsg = "No remote endpoint to send createObjectCommand, check if host or ssvm is down?";
            s_logger.error(errMsg);
            answer = new Answer(cmd, false, errMsg);
        } else {
            answer = ep.sendMessage(cmd);
        }
        result = new CreateCmdResult(null, answer);
        if (answer != null && !answer.getResult()) {
            result.setResult(answer.getDetails());
        }
        callback.complete(result);
        return;
    } catch (final Exception e) {
        s_logger.debug("Failed to take snapshot: " + snapshot.getId(), e);
        result = new CreateCmdResult(null, null);
        result.setResult(e.toString());
    }
    callback.complete(result);
}
Also used : SnapshotObjectTO(com.cloud.storage.to.SnapshotObjectTO) ResizeVolumeAnswer(com.cloud.agent.api.storage.ResizeVolumeAnswer) Answer(com.cloud.agent.api.Answer) CopyCmdAnswer(com.cloud.storage.command.CopyCmdAnswer) CreateSnapshotPayload(com.cloud.storage.CreateSnapshotPayload) VolumeObject(com.cloud.storage.volume.VolumeObject) DataObject(com.cloud.engine.subsystem.api.storage.DataObject) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint) CreateCmdResult(com.cloud.engine.subsystem.api.storage.CreateCmdResult) CreateObjectCommand(com.cloud.storage.command.CreateObjectCommand) StorageUnavailableException(com.cloud.exception.StorageUnavailableException)

Example 19 with EndPoint

use of com.cloud.engine.subsystem.api.storage.EndPoint in project cosmic by MissionCriticalCloud.

the class TemplateManagerImpl method getChecksum.

@Override
public String getChecksum(final DataStore store, final String templatePath) {
    final EndPoint ep = _epSelector.select(store);
    final ComputeChecksumCommand cmd = new ComputeChecksumCommand(store.getTO(), templatePath);
    final Answer answer;
    if (ep == null) {
        final String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
        s_logger.error(errMsg);
        answer = new Answer(cmd, false, errMsg);
    } else {
        answer = ep.sendMessage(cmd);
    }
    if (answer != null && answer.getResult()) {
        return answer.getDetails();
    }
    return null;
}
Also used : Answer(com.cloud.agent.api.Answer) ComputeChecksumCommand(com.cloud.agent.api.ComputeChecksumCommand) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint)

Example 20 with EndPoint

use of com.cloud.engine.subsystem.api.storage.EndPoint in project cosmic by MissionCriticalCloud.

the class XenServerGuru method getCommandHostDelegation.

@Override
public Pair<Boolean, Long> getCommandHostDelegation(final long hostId, final Command cmd) {
    LOGGER.debug("getCommandHostDelegation: " + cmd.getClass());
    if (cmd instanceof StorageSubSystemCommand) {
        final StorageSubSystemCommand c = (StorageSubSystemCommand) cmd;
        c.setExecuteInSequence(true);
    }
    if (cmd instanceof CopyCommand) {
        final CopyCommand cpyCommand = (CopyCommand) cmd;
        final DataTO srcData = cpyCommand.getSrcTO();
        final DataTO destData = cpyCommand.getDestTO();
        if (srcData.getHypervisorType() == HypervisorType.XenServer && srcData.getObjectType() == DataObjectType.SNAPSHOT && destData.getObjectType() == DataObjectType.TEMPLATE) {
            final DataStoreTO srcStore = srcData.getDataStore();
            final DataStoreTO destStore = destData.getDataStore();
            if (srcStore instanceof NfsTO && destStore instanceof NfsTO) {
                HostVO host = hostDao.findById(hostId);
                final EndPoint ep = endPointSelector.selectHypervisorHost(new ZoneScope(host.getDataCenterId()));
                host = hostDao.findById(ep.getId());
                hostDao.loadDetails(host);
                final String hypervisorVersion = host.getHypervisorVersion();
                final String snapshotHotFixVersion = host.getDetail(XenserverConfigs.XS620HotFix);
                if (hypervisorVersion != null && !hypervisorVersion.equalsIgnoreCase("6.1.0")) {
                    if (!(hypervisorVersion.equalsIgnoreCase("6.2.0") && !(snapshotHotFixVersion != null && snapshotHotFixVersion.equalsIgnoreCase(XenserverConfigs.XSHotFix62ESP1004)))) {
                        return new Pair<>(Boolean.TRUE, new Long(ep.getId()));
                    }
                }
            }
        }
    }
    return new Pair<>(Boolean.FALSE, new Long(hostId));
}
Also used : ZoneScope(com.cloud.engine.subsystem.api.storage.ZoneScope) DataStoreTO(com.cloud.agent.api.to.DataStoreTO) StorageSubSystemCommand(com.cloud.storage.command.StorageSubSystemCommand) DataTO(com.cloud.agent.api.to.DataTO) CopyCommand(com.cloud.storage.command.CopyCommand) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint) NfsTO(com.cloud.agent.api.to.NfsTO) HostVO(com.cloud.host.HostVO) Pair(com.cloud.utils.Pair)

Aggregations

EndPoint (com.cloud.engine.subsystem.api.storage.EndPoint)36 Answer (com.cloud.agent.api.Answer)25 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)17 DataStore (com.cloud.engine.subsystem.api.storage.DataStore)14 RemoteHostEndPoint (com.cloud.storage.RemoteHostEndPoint)12 DataObject (com.cloud.engine.subsystem.api.storage.DataObject)8 CopyCmdAnswer (com.cloud.storage.command.CopyCmdAnswer)8 CopyCommand (com.cloud.storage.command.CopyCommand)8 Date (java.util.Date)8 MigrateVolumeAnswer (com.cloud.agent.api.storage.MigrateVolumeAnswer)7 ZoneScope (com.cloud.engine.subsystem.api.storage.ZoneScope)6 ResizeVolumeAnswer (com.cloud.agent.api.storage.ResizeVolumeAnswer)5 CopyCommandResult (com.cloud.engine.subsystem.api.storage.CopyCommandResult)4 VolumeVO (com.cloud.storage.VolumeVO)4 CreateEntityDownloadURLCommand (com.cloud.agent.api.storage.CreateEntityDownloadURLCommand)3 ListVolumeAnswer (com.cloud.agent.api.storage.ListVolumeAnswer)3 VolumeInfo (com.cloud.engine.subsystem.api.storage.VolumeInfo)3 StorageUnavailableException (com.cloud.exception.StorageUnavailableException)3 UploadVO (com.cloud.storage.UploadVO)3 CommandResult (com.cloud.storage.command.CommandResult)3