use of org.apache.cloudstack.engine.subsystem.api.storage.EndPoint in project cloudstack by apache.
the class HypervisorHelperImpl method introduceObject.
@Override
public DataTO introduceObject(DataTO object, Scope scope, Long storeId) {
EndPoint ep = selector.select(scope, storeId);
IntroduceObjectCmd cmd = new IntroduceObjectCmd(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();
throw new CloudRuntimeException("Failed to introduce object, due to " + errMsg);
}
IntroduceObjectAnswer introduceObjectAnswer = (IntroduceObjectAnswer) answer;
return introduceObjectAnswer.getDataTO();
}
use of org.apache.cloudstack.engine.subsystem.api.storage.EndPoint in project cloudstack by apache.
the class SimulatorImageStoreDriverImpl method createEntityExtractUrl.
@Override
public String createEntityExtractUrl(DataStore store, String installPath, Storage.ImageFormat format, DataObject dataObject) {
EndPoint ep = _epSelector.select(store);
if (ep == null) {
String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
s_logger.error(errMsg);
return null;
}
// Create Symlink at ssvm
String path = installPath;
String uuid = UUID.randomUUID().toString() + "." + format.getFileExtension();
// Construct actual URL locally now that the symlink exists at SSVM
return generateCopyUrl(ep.getPublicAddr(), uuid);
}
use of org.apache.cloudstack.engine.subsystem.api.storage.EndPoint in project cloudstack by apache.
the class SamplePrimaryDataStoreDriverImpl method createAsync.
/*
* private class CreateVolumeFromBaseImageContext<T> extends
* AsyncRpcContext<T> { private final VolumeObject volume;
*
* public CreateVolumeFromBaseImageContext(AsyncCompletionCallback<T>
* callback, VolumeObject volume) { super(callback); this.volume = volume; }
*
* public VolumeObject getVolume() { return this.volume; }
*
* }
*
* @Override public void createVolumeFromBaseImageAsync(VolumeObject volume,
* TemplateInfo template, AsyncCompletionCallback<CommandResult> callback) {
* VolumeTO vol = this.dataStore.getVolumeTO(volume); List<EndPoint>
* endPoints = this.dataStore.getEndPoints(); EndPoint ep =
* endPoints.get(0); String templateUri =
* template.getDataStore().grantAccess(template, ep);
* CreateVolumeFromBaseImageCommand cmd = new
* CreateVolumeFromBaseImageCommand(vol, templateUri);
*
* CreateVolumeFromBaseImageContext<CommandResult> context = new
* CreateVolumeFromBaseImageContext<CommandResult>(callback, volume);
* AsyncCallbackDispatcher<DefaultPrimaryDataStoreDriverImpl, Answer> caller
* = AsyncCallbackDispatcher.create(this); caller.setContext(context)
* .setCallback
* (caller.getTarget().createVolumeFromBaseImageAsyncCallback(null, null));
*
* ep.sendMessageAsync(cmd, caller); }
*/
/*
* public Object
* createVolumeFromBaseImageAsyncCallback(AsyncCallbackDispatcher
* <DefaultPrimaryDataStoreDriverImpl, Answer> callback,
* CreateVolumeFromBaseImageContext<CommandResult> context) {
* CreateVolumeAnswer answer = (CreateVolumeAnswer)callback.getResult();
* CommandResult result = new CommandResult(); if (answer == null ||
* answer.getDetails() != null) { result.setSuccess(false); if (answer !=
* null) { result.setResult(answer.getDetails()); } } else {
* result.setSuccess(true); VolumeObject volume = context.getVolume();
* volume.setPath(answer.getVolumeUuid()); }
* AsyncCompletionCallback<CommandResult> parentCall =
* context.getParentCallback(); parentCall.complete(result); return null; }
*/
@Override
public void createAsync(DataStore dataStore, DataObject vol, AsyncCompletionCallback<CreateCmdResult> callback) {
EndPoint ep = selector.select(vol);
if (ep == null) {
String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
s_logger.error(errMsg);
throw new CloudRuntimeException(errMsg);
}
CreateObjectCommand createCmd = new CreateObjectCommand(null);
CreateVolumeContext<CreateCmdResult> context = new CreateVolumeContext<CreateCmdResult>(callback, vol);
AsyncCallbackDispatcher<SamplePrimaryDataStoreDriverImpl, Answer> caller = AsyncCallbackDispatcher.create(this);
caller.setContext(context).setCallback(caller.getTarget().createAsyncCallback(null, null));
ep.sendMessageAsync(createCmd, caller);
}
use of org.apache.cloudstack.engine.subsystem.api.storage.EndPoint in project cloudstack by apache.
the class CloudStackPrimaryDataStoreDriverImpl method createVolume.
public Answer createVolume(VolumeInfo volume) throws StorageUnavailableException {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Creating volume: " + volume);
}
CreateObjectCommand cmd = new CreateObjectCommand(volume.getTO());
EndPoint ep = epSelector.select(volume);
Answer answer = null;
if (ep == null) {
String errMsg = "No remote endpoint to send DeleteCommand, check if host or ssvm is down?";
s_logger.error(errMsg);
answer = new Answer(cmd, false, errMsg);
} else {
answer = ep.sendMessage(cmd);
}
return answer;
}
use of org.apache.cloudstack.engine.subsystem.api.storage.EndPoint in project cloudstack by apache.
the class SwiftImageStoreDriverImpl method createAsync.
@Override
public void createAsync(DataStore dataStore, DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
Long maxTemplateSizeInBytes = getMaxTemplateSizeInBytes();
VirtualMachineTemplate tmpl = _templateDao.findById(data.getId());
DataStore cacheStore = cacheManager.getCacheStorage(dataStore.getScope());
DownloadCommand dcmd = new DownloadCommand((TemplateObjectTO) (data.getTO()), maxTemplateSizeInBytes);
dcmd.setCacheStore(cacheStore.getTO());
dcmd.setProxy(getHttpProxy());
EndPoint ep = _epSelector.select(data);
if (ep == null) {
String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
s_logger.error(errMsg);
throw new CloudRuntimeException(errMsg);
}
CreateContext<CreateCmdResult> context = new CreateContext<CreateCmdResult>(callback, data);
AsyncCallbackDispatcher<SwiftImageStoreDriverImpl, DownloadAnswer> caller = AsyncCallbackDispatcher.create(this);
caller.setContext(context);
if (data.getType() == DataObjectType.TEMPLATE) {
caller.setCallback(caller.getTarget().createTemplateAsyncCallback(null, null));
} else if (data.getType() == DataObjectType.VOLUME) {
caller.setCallback(caller.getTarget().createVolumeAsyncCallback(null, null));
}
ep.sendMessageAsync(dcmd, caller);
}
Aggregations