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);
}
}
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);
}
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);
}
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;
}
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));
}
Aggregations