use of org.ovirt.engine.api.model.Action in project ovirt-engine by oVirt.
the class BackendHostResource method install.
@Override
public Response install(Action action) {
// REVISIT fencing options
VDS vds = getEntity();
UpdateVdsActionParameters params = new UpdateVdsActionParameters(vds.getStaticData(), action.getRootPassword(), true);
// Explicitly set null, to be clear we don't want to update fence agents.
params.setFenceAgents(null);
params.setHostedEngineDeployConfiguration(HostResourceParametersUtil.getHostedEngineDeployConfiguration(this));
params = (UpdateVdsActionParameters) getMapper(Action.class, VdsOperationActionParameters.class).map(action, params);
if (vds.isOvirtVintageNode()) {
params.setReinstallOrUpgrade(true);
if (action.isSetImage()) {
params.setoVirtIsoFile(action.getImage());
return doAction(ActionType.UpgradeOvirtNode, params, action);
}
}
return doAction(ActionType.UpdateVds, params, action);
}
use of org.ovirt.engine.api.model.Action in project ovirt-engine by oVirt.
the class BackendHostResource method approve.
@Override
public Response approve(Action action) {
if (action.isSetCluster() && (action.getCluster().isSetId() || action.getCluster().isSetName())) {
update(setCluster(get(), action.getCluster()));
}
ApproveVdsParameters params = new ApproveVdsParameters(guid);
params = (ApproveVdsParameters) getMapper(Action.class, VdsOperationActionParameters.class).map(action, params);
// Set pk authentication as default
params.setAuthMethod(VdsOperationActionParameters.AuthenticationMethod.PublicKey);
if (action.isSetRootPassword()) {
params.setAuthMethod(VdsOperationActionParameters.AuthenticationMethod.Password);
params.setRootPassword(action.getRootPassword());
} else if (action.isSetSsh() && action.getSsh().isSetAuthenticationMethod()) {
if (action.getSsh().getAuthenticationMethod() == SshAuthenticationMethod.PASSWORD) {
params.setAuthMethod(VdsOperationActionParameters.AuthenticationMethod.Password);
if (action.getSsh().isSetUser() && action.getSsh().getUser().isSetPassword()) {
params.setPassword(action.getSsh().getUser().getPassword());
}
}
}
return doAction(ActionType.ApproveVds, params, action);
}
use of org.ovirt.engine.api.model.Action in project ovirt-engine by oVirt.
the class BackendStorageDomainResource method isAttached.
@Override
public Response isAttached(Action action) {
validateParameters(action, "host.id|name");
Guid hostId = getHostId(action);
org.ovirt.engine.core.common.businessentities.StorageDomain storageDomainToAttach = getEntity(org.ovirt.engine.core.common.businessentities.StorageDomain.class, QueryType.GetStorageDomainById, new IdQueryParameters(guid), guid.toString());
StorageDomainsAndStoragePoolIdQueryParameters parameters = new StorageDomainsAndStoragePoolIdQueryParameters(storageDomainToAttach, null, hostId);
parameters.setCheckStoragePoolStatus(false);
List<StorageDomainStatic> attachedStorageDomains = getEntity(List.class, QueryType.GetStorageDomainsWithAttachedStoragePoolGuid, parameters, guid.toString(), true);
// This is an atypical action, as it doesn't invoke a backend action, but a query. As a result we need to
// create and populate the returned action object so that it looks like a real action result.
Action result = new Action();
result.setIsAttached(!attachedStorageDomains.isEmpty());
result.setStatus(CreationStatus.COMPLETE.value());
return Response.ok().entity(result).build();
}
use of org.ovirt.engine.api.model.Action in project ovirt-engine by oVirt.
the class BackendResource method performAction.
protected Response performAction(ActionType task, ActionParametersBase params, Action action, boolean getEntityWhenDone) {
try {
if (isAsync() || expectNonBlocking()) {
return performNonBlockingAction(task, params, action);
} else {
ActionReturnValue actionResult = doAction(task, params);
if (action == null) {
action = new Action();
}
if (actionResult.getJobId() != null) {
setJobLink(action, actionResult);
}
action.setStatus(CreationStatus.COMPLETE.value());
if (getEntityWhenDone) {
setActionItem(action, getEntity());
}
return Response.ok().entity(action).build();
}
} catch (Exception e) {
return handleError(Response.class, e, false);
}
}
use of org.ovirt.engine.api.model.Action in project ovirt-engine by oVirt.
the class BackendVmDiskResourceTest method testDeactivate.
@Test
public void testDeactivate() throws Exception {
setUriInfo(setUpActionExpectations(ActionType.HotUnPlugDiskFromVm, VmDiskOperationParameterBase.class, new String[] { "DiskVmElement" }, new Object[] { new DiskVmElement(DISK_ID, VM_ID) }, true, true));
Response response = resource.deactivate(new Action());
assertEquals(200, response.getStatus());
}
Aggregations