use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class ImportVmCommand method moveOrCopyAllImageGroups.
protected void moveOrCopyAllImageGroups(Guid containerID, Iterable<DiskImage> disks) {
for (DiskImage disk : disks) {
ActionReturnValue vdcRetValue = runInternalActionWithTasksContext(ActionType.CopyImageGroup, buildMoveOrCopyImageGroupParametersForDisk(disk, containerID));
if (!vdcRetValue.getSucceeded()) {
throw new EngineException(vdcRetValue.getFault().getError(), "Failed to copy disk!");
}
// TODO: Currently REST-API doesn't support coco for async commands, remove when bug 1199011 fixed
getTaskIdList().addAll(vdcRetValue.getVdsmTaskIdList());
}
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class ImportVmCommand method copyAllMemoryImages.
private void copyAllMemoryImages(Guid containerId) {
Set<Guid> handledMemoryDisks = new HashSet<>();
for (Snapshot snapshot : getVm().getSnapshots()) {
if (!snapshot.containsMemory()) {
continue;
}
Guid memoryDiskId = snapshot.getMemoryDiskId();
if (!handledMemoryDisks.contains(memoryDiskId)) {
handledMemoryDisks.add(memoryDiskId);
// copy the memory dump image
ActionReturnValue vdcRetValue = runInternalActionWithTasksContext(ActionType.CopyImageGroup, buildMoveOrCopyImageGroupParametersForMemoryDumpImage(containerId, memoryDiskDomainMap.get(memoryDiskId), memoryDiskId, getMemoryDiskImageId(memoryDiskId)));
if (!vdcRetValue.getSucceeded()) {
throw new EngineException(vdcRetValue.getFault().getError(), "Failed to copy memory image");
}
// TODO: Currently REST-API doesn't support coco for async commands, remove when bug 1199011 fixed
getTaskIdList().addAll(vdcRetValue.getVdsmTaskIdList());
}
Guid confDiskId = snapshot.getMetadataDiskId();
if (!handledMemoryDisks.contains(confDiskId)) {
handledMemoryDisks.add(confDiskId);
// copy the memory configuration (of the VM) image
ActionReturnValue vdcRetValue = runInternalActionWithTasksContext(ActionType.CopyImageGroup, buildMoveOrCopyImageGroupParametersForMemoryConfImage(containerId, memoryDiskDomainMap.get(confDiskId), confDiskId, getMemoryDiskImageId(confDiskId)));
if (!vdcRetValue.getSucceeded()) {
throw new EngineException(vdcRetValue.getFault().getError(), "Failed to copy metadata image");
}
// TODO: Currently REST-API doesn't support coco for async commands, remove when bug 1199011 fixed
getTaskIdList().addAll(vdcRetValue.getVdsmTaskIdList());
}
}
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class CreateBrickCommand method runAnsibleCreateBrickPlaybook.
private void runAnsibleCreateBrickPlaybook() throws IOException, InterruptedException {
List<String> disks = new ArrayList<>();
Double totalSize = 0.0;
for (StorageDevice device : getParameters().getDisks()) {
disks.add(device.getDevPath());
// size is returned in MiB
totalSize += device.getSize();
}
if (totalSize < MIN_VG_SIZE) {
totalSize = totalSize - MIN_METADATA_PERCENT * totalSize;
} else {
totalSize = totalSize - DEFAULT_METADATA_SIZE_MB;
}
Pair<SizeUnit, Double> convertedSize = SizeConverter.autoConvert(totalSize.longValue(), SizeUnit.MiB);
String deviceSize = convertedSize.getSecond() + convertedSize.getFirst().toString();
String ssdDevice = "";
if (getParameters().getCacheDevice() != null) {
ssdDevice = getParameters().getCacheDevice().getDevPath();
}
int diskCount = getParameters().getNoOfPhysicalDisksInRaidVolume() == null ? 1 : getParameters().getNoOfPhysicalDisksInRaidVolume();
AnsibleCommandBuilder command = new AnsibleCommandBuilder().hostnames(getVds().getHostName()).variables(new Pair<>("ssd", ssdDevice), new Pair<>("disks", JsonHelper.objectToJson(disks, false)), new Pair<>("vgname", "RHGS_vg_" + getParameters().getLvName()), new Pair<>("size", deviceSize), new Pair<>("diskcount", diskCount), new Pair<>("stripesize", getParameters().getStripeSize()), new Pair<>("wipefs", "yes"), new Pair<>("disktype", getParameters().getRaidType().toString()), new Pair<>("lvname", getParameters().getLvName() + "_lv"), new Pair<>("cache_lvname", getParameters().getLvName() + "_cache_lv"), new Pair<>("cache_lvsize", getParameters().getCacheSize() + "GiB"), new Pair<>("cachemode", getParameters().getCacheMode()), new Pair<>("fstype", GlusterConstants.FS_TYPE_XFS), new Pair<>("mntpath", getParameters().getMountPoint())).logFileDirectory(CreateBrickCommand.CREATE_BRICK_LOG_DIRECTORY).logFilePrefix("ovirt-gluster-brick-ansible").logFileName(getVds().getHostName()).logFileSuffix(getCorrelationId()).playbook(AnsibleConstants.CREATE_BRICK_PLAYBOOK);
AnsibleReturnValue ansibleReturnValue = ansibleExecutor.runCommand(command);
if (ansibleReturnValue.getAnsibleReturnCode() != AnsibleReturnCode.OK) {
log.error("Failed to execute Ansible create brick role. Please check logs for more details: {}", command.logFile());
throw new EngineException(EngineError.GeneralException, String.format("Failed to execute Ansible create brick role. Please check logs for more details: %1$s", command.logFile()));
}
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class AbstractVmProviderProxy method testConnection.
@Override
public void testConnection() {
chooseDcForCheckingIfGetNamesFromExternalProviderSupported();
QueryReturnValue retVal = Backend.getInstance().runInternalQuery(QueryType.GetVmsFromExternalProvider, buildGetVmsFromExternalProviderQueryParameters());
if (!retVal.getSucceeded()) {
throw new EngineException(EngineError.PROVIDER_FAILURE, retVal.getExceptionString());
}
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class BaseProviderProxy method runHttpMethod.
protected byte[] runHttpMethod(HttpMethodType httpMethod, String contentType, String body, HttpURLConnection connection) {
byte[] result = null;
try {
connection.setRequestProperty("Content-Type", contentType);
connection.setDoInput(true);
connection.setDoOutput(httpMethod != HttpMethodType.GET);
connection.setRequestMethod(httpMethod.toString());
if (body != null) {
byte[] bytes = body.getBytes(StandardCharsets.UTF_8);
connection.setRequestProperty("Content-Length", String.valueOf(bytes.length));
try (OutputStream outputStream = connection.getOutputStream()) {
outputStream.write(bytes);
}
}
result = getResponse(connection);
} catch (SSLException e) {
throw new EngineException(EngineError.PROVIDER_SSL_FAILURE, e.getMessage());
} catch (IOException e) {
handleException(e);
} finally {
if (connection != null) {
connection.disconnect();
}
}
return result;
}
Aggregations