use of org.ovirt.engine.core.common.action.RngDeviceParameters in project ovirt-engine by oVirt.
the class UpdateVmCommand method updateRngDevice.
private void updateRngDevice() {
if (!getParameters().isUpdateRngDevice()) {
return;
}
QueryReturnValue query = runInternalQuery(QueryType.GetRngDevice, new IdQueryParameters(getParameters().getVmId()));
List<VmRngDevice> rngDevs = query.getReturnValue();
ActionReturnValue rngCommandResult = null;
if (rngDevs.isEmpty()) {
if (getParameters().getRngDevice() != null) {
RngDeviceParameters params = new RngDeviceParameters(getParameters().getRngDevice(), true);
rngCommandResult = runInternalAction(ActionType.AddRngDevice, params, cloneContextAndDetachFromParent());
}
} else {
if (getParameters().getRngDevice() == null) {
RngDeviceParameters params = new RngDeviceParameters(rngDevs.get(0), true);
rngCommandResult = runInternalAction(ActionType.RemoveRngDevice, params, cloneContextAndDetachFromParent());
} else {
RngDeviceParameters params = new RngDeviceParameters(getParameters().getRngDevice(), true);
params.getRngDevice().setDeviceId(rngDevs.get(0).getDeviceId());
rngCommandResult = runInternalAction(ActionType.UpdateRngDevice, params, cloneContextAndDetachFromParent());
}
}
if (rngCommandResult != null && !rngCommandResult.getSucceeded()) {
log.error("Updating RNG device of VM {} ({}) failed. Old RNG device = {}. New RNG device = {}.", getVm().getName(), getVm().getId(), rngDevs.isEmpty() ? null : rngDevs.get(0), getParameters().getRngDevice());
}
}
use of org.ovirt.engine.core.common.action.RngDeviceParameters in project ovirt-engine by oVirt.
the class VmTemplateManagementCommand method updateRngDevice.
protected void updateRngDevice(Guid templateId) {
// do not update if this flag is not set
if (getParameters().isUpdateRngDevice()) {
QueryReturnValue query = runInternalQuery(QueryType.GetRngDevice, new IdQueryParameters(templateId));
List<VmRngDevice> rngDevs = query.getReturnValue();
if (getParameters().getRngDevice() != null) {
getParameters().getRngDevice().setVmId(templateId);
}
ActionReturnValue rngCommandResult = null;
if (rngDevs.isEmpty()) {
if (getParameters().getRngDevice() != null) {
RngDeviceParameters params = new RngDeviceParameters(getParameters().getRngDevice(), false);
rngCommandResult = runInternalAction(ActionType.AddRngDevice, params, cloneContextAndDetachFromParent());
}
} else {
if (getParameters().getRngDevice() == null) {
RngDeviceParameters params = new RngDeviceParameters(rngDevs.get(0), false);
rngCommandResult = runInternalAction(ActionType.RemoveRngDevice, params, cloneContextAndDetachFromParent());
} else {
RngDeviceParameters params = new RngDeviceParameters(getParameters().getRngDevice(), false);
params.getRngDevice().setDeviceId(rngDevs.get(0).getDeviceId());
rngCommandResult = runInternalAction(ActionType.UpdateRngDevice, params, cloneContextAndDetachFromParent());
}
}
if (rngCommandResult != null && !rngCommandResult.getSucceeded()) {
getReturnValue().setSucceeded(false);
}
}
}
use of org.ovirt.engine.core.common.action.RngDeviceParameters in project ovirt-engine by oVirt.
the class AddVmCommand method addVmRngDevice.
private void addVmRngDevice() {
VmRngDevice rngDev = getParameters().getRngDevice();
if (rngDev != null) {
rngDev.setVmId(getVmId());
RngDeviceParameters params = new RngDeviceParameters(rngDev, true);
ActionReturnValue result = runInternalAction(ActionType.AddRngDevice, params, cloneContextAndDetachFromParent());
if (!result.getSucceeded()) {
log.error("Couldn't add RNG device for new VM.");
throw new IllegalArgumentException("Couldn't add RNG device for new VM.");
}
}
}
Aggregations