use of org.ovirt.engine.core.bll.context.CommandContext in project ovirt-engine by oVirt.
the class ImportHostedEngineStorageDomainCommandTest method prepareCommand.
protected void prepareCommand() {
parameters.setStoragePoolId(HE_SP_ID);
parameters.setVdsId(HE_VDS_ID);
parameters.setStorageDomainId(HE_SD_ID);
// vds
VDS vds = new VDS();
vds.setId(Guid.Empty);
vds.setStoragePoolId(HE_SP_ID);
when(vdsDao.get(any())).thenReturn(vds);
List<BaseDisk> baseDisks = Collections.singletonList(new BaseDisk());
when(baseDiskDao.getDisksByAlias(any())).thenReturn(baseDisks);
// Data center
StoragePool pool = new StoragePool();
pool.setStatus(StoragePoolStatus.Up);
pool.setId(HE_SP_ID);
when(storagePoolDao.get(HE_SP_ID)).thenReturn(pool);
// compensation
CompensationContext compensationContext = mock(CompensationContext.class);
when(cmd.getCompensationContext()).thenReturn(compensationContext);
when(cmd.getContext()).thenReturn(new CommandContext(new EngineContext()));
}
use of org.ovirt.engine.core.bll.context.CommandContext in project ovirt-engine by oVirt.
the class TryBackToAllSnapshotsOfVmCommand method updateVm.
private boolean updateVm(VmStatic vm, Version oldClusterVersion, boolean disableLock) {
VmManagementParametersBase updateParams = new VmManagementParametersBase(vm);
updateParams.setClusterLevelChangeFromVersion(oldClusterVersion);
CommandContext context;
if (disableLock) {
updateParams.setLockProperties(LockProperties.create(LockProperties.Scope.None));
context = cloneContextAndDetachFromParent();
} else {
// Wait for VM lock
EngineLock updateVmLock = createUpdateVmLock();
// will be released by UpdateVmCommand
lockManager.acquireLockWait(updateVmLock);
context = ExecutionHandler.createInternalJobContext(updateVmLock);
}
ActionReturnValue result = runInternalAction(ActionType.UpdateVm, updateParams, context);
if (!result.getSucceeded()) {
getReturnValue().setFault(result.getFault());
return false;
}
return true;
}
use of org.ovirt.engine.core.bll.context.CommandContext in project ovirt-engine by oVirt.
the class InitVdsOnUpCommand method refreshHostDeviceList.
private void refreshHostDeviceList() {
try {
CommandContext ctx = cloneContext();
ctx.getExecutionContext().setJobRequired(false);
runInternalAction(ActionType.RefreshHostDevices, new VdsActionParameters(getVdsId()), ctx);
} catch (EngineException e) {
log.error("Could not refresh host devices for host '{}'", getVds().getName());
}
}
use of org.ovirt.engine.core.bll.context.CommandContext in project ovirt-engine by oVirt.
the class NetworkClustersToSetupNetworksParametersTransformerImpl method createSetupNetworksParameters.
private List<PersistentHostSetupNetworksParameters> createSetupNetworksParameters(Map<Guid, List<Network>> attachNetworksByHost, Map<Guid, Map<String, VdsNetworkInterface>> labelsToNicsByHost, Map<Guid, List<Network>> detachNetworksByHost, Map<Guid, List<Network>> updates) {
final List<PersistentHostSetupNetworksParameters> parameters = new ArrayList<>(attachNetworksByHost.size());
final ManageNetworksParametersBuilder builder = manageNetworksParametersBuilderFactory.create(commandContext, interfaceDao, vdsStaticDao, networkClusterDao, networkAttachmentDao);
Set<Guid> hostIds = Stream.of(attachNetworksByHost, detachNetworksByHost, updates).flatMap(e -> e.keySet().stream()).collect(Collectors.toSet());
for (Guid hostId : hostIds) {
final Map<String, VdsNetworkInterface> nicsByLabel = labelsToNicsByHost.get(hostId);
parameters.add(builder.buildParameters(hostId, nullToEmptyList(attachNetworksByHost.get(hostId)), nullToEmptyList(detachNetworksByHost.get(hostId)), nicsByLabel == null ? Collections.emptyMap() : nicsByLabel, nullToEmptyList(updates.get(hostId))));
}
return parameters;
}
use of org.ovirt.engine.core.bll.context.CommandContext in project ovirt-engine by oVirt.
the class CommandHelper method buildCommand.
public static CommandBase<?> buildCommand(ActionType actionType, ActionParametersBase parameters, ExecutionContext executionContext, CommandStatus cmdStatus) {
ExecutionContext cmdExecutionContext = executionContext == null ? new ExecutionContext() : executionContext;
CommandBase<?> command = CommandsFactory.createCommand(actionType, parameters, new CommandContext(new EngineContext()).withExecutionContext(cmdExecutionContext));
command.setCommandStatus(cmdStatus, false);
return command;
}
Aggregations