Search in sources :

Example 51 with EndPoint

use of org.apache.cloudstack.engine.subsystem.api.storage.EndPoint in project cloudstack by apache.

the class HypervisorHelperImpl method forgetObject.

@Override
public boolean forgetObject(DataTO object, Scope scope, Long storeId) {
    EndPoint ep = selector.select(scope, storeId);
    ForgetObjectCmd cmd = new ForgetObjectCmd(object);
    Answer answer = null;
    if (ep == null) {
        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()) {
        String errMsg = answer == null ? null : answer.getDetails();
        if (errMsg != null) {
            s_logger.debug("Failed to forget object: " + errMsg);
        }
        return false;
    }
    return true;
}
Also used : CreateVMSnapshotAnswer(com.cloud.agent.api.CreateVMSnapshotAnswer) Answer(com.cloud.agent.api.Answer) IntroduceObjectAnswer(org.apache.cloudstack.storage.command.IntroduceObjectAnswer) EndPoint(org.apache.cloudstack.engine.subsystem.api.storage.EndPoint) ForgetObjectCmd(org.apache.cloudstack.storage.command.ForgetObjectCmd)

Example 52 with EndPoint

use of org.apache.cloudstack.engine.subsystem.api.storage.EndPoint in project cloudstack by apache.

the class VolumeServiceImpl method resizeVolumeOnHypervisor.

@Override
public void resizeVolumeOnHypervisor(long volumeId, long newSize, long destHostId, String instanceName) {
    final String errMsg = "Resize command failed";
    try {
        Answer answer = null;
        Host destHost = _hostDao.findById(destHostId);
        EndPoint ep = RemoteHostEndPoint.getHypervisorHostEndPoint(destHost);
        if (ep != null) {
            VolumeVO volume = volDao.findById(volumeId);
            PrimaryDataStore primaryDataStore = this.dataStoreMgr.getPrimaryDataStore(volume.getPoolId());
            ResizeVolumeCommand resizeCmd = new ResizeVolumeCommand(volume.getPath(), new StorageFilerTO(primaryDataStore), volume.getSize(), newSize, true, instanceName, primaryDataStore.isManaged(), volume.get_iScsiName());
            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 (Exception e) {
        throw new CloudRuntimeException(errMsg, e);
    }
}
Also used : CopyCmdAnswer(org.apache.cloudstack.storage.command.CopyCmdAnswer) ListVolumeAnswer(com.cloud.agent.api.storage.ListVolumeAnswer) Answer(com.cloud.agent.api.Answer) VolumeVO(com.cloud.storage.VolumeVO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ResizeVolumeCommand(com.cloud.agent.api.storage.ResizeVolumeCommand) Host(com.cloud.host.Host) EndPoint(org.apache.cloudstack.engine.subsystem.api.storage.EndPoint) RemoteHostEndPoint(org.apache.cloudstack.storage.RemoteHostEndPoint) StorageFilerTO(com.cloud.agent.api.to.StorageFilerTO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) StorageAccessException(com.cloud.exception.StorageAccessException) ExecutionException(java.util.concurrent.ExecutionException) ResourceAllocationException(com.cloud.exception.ResourceAllocationException) PrimaryDataStore(org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore)

Example 53 with EndPoint

use of org.apache.cloudstack.engine.subsystem.api.storage.EndPoint in project cloudstack by apache.

the class VolumeServiceImpl method registerVolumeForPostUpload.

@Override
public Pair<EndPoint, DataObject> registerVolumeForPostUpload(VolumeInfo volume, DataStore store) {
    EndPoint ep = _epSelector.select(store);
    if (ep == null) {
        String errorMessage = "There is no secondary storage VM for image store " + store.getName();
        s_logger.warn(errorMessage);
        throw new CloudRuntimeException(errorMessage);
    }
    DataObject volumeOnStore = store.create(volume);
    return new Pair<>(ep, volumeOnStore);
}
Also used : DataObject(org.apache.cloudstack.engine.subsystem.api.storage.DataObject) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) EndPoint(org.apache.cloudstack.engine.subsystem.api.storage.EndPoint) RemoteHostEndPoint(org.apache.cloudstack.storage.RemoteHostEndPoint) Pair(com.cloud.utils.Pair)

Aggregations

EndPoint (org.apache.cloudstack.engine.subsystem.api.storage.EndPoint)53 Answer (com.cloud.agent.api.Answer)35 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)28 DataStore (org.apache.cloudstack.engine.subsystem.api.storage.DataStore)20 RemoteHostEndPoint (org.apache.cloudstack.storage.RemoteHostEndPoint)16 CopyCommand (org.apache.cloudstack.storage.command.CopyCommand)13 DataObject (org.apache.cloudstack.engine.subsystem.api.storage.DataObject)12 CopyCmdAnswer (org.apache.cloudstack.storage.command.CopyCmdAnswer)11 Date (java.util.Date)9 MigrateVolumeAnswer (com.cloud.agent.api.storage.MigrateVolumeAnswer)8 HostVO (com.cloud.host.HostVO)8 ZoneScope (org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope)8 CopyCommandResult (org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult)7 DownloadAnswer (com.cloud.agent.api.storage.DownloadAnswer)6 ClusterScope (org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope)6 Scope (org.apache.cloudstack.engine.subsystem.api.storage.Scope)6 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)5 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)5 URISyntaxException (java.net.URISyntaxException)5 ArrayList (java.util.ArrayList)5