use of org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters in project ovirt-engine by oVirt.
the class HostListModel method onApproveInternal.
private void onApproveInternal() {
HostModel model = (HostModel) getWindow();
VDS vds = getSelectedItem();
ApproveVdsParameters params = new ApproveVdsParameters(vds.getId());
if (model.getUserPassword().getEntity() != null) {
params.setPassword(model.getUserPassword().getEntity().toString());
}
params.setAuthMethod(model.getAuthenticationMethod());
Frontend.getInstance().runMultipleAction(ActionType.ApproveVds, new ArrayList<>(Arrays.asList(new ActionParametersBase[] { params })), result -> {
}, null);
}
use of org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters in project ovirt-engine by oVirt.
the class DataCenterGuideModel method onSelectHost.
public void onSelectHost() {
MoveHost model = (MoveHost) getWindow();
if (model.getProgress() != null) {
return;
}
if (!model.validate()) {
return;
}
model.setSelectedHosts(new ArrayList<MoveHostData>());
for (MoveHostData a : model.getItems()) {
if (a.getIsSelected()) {
model.getSelectedHosts().add(a);
}
}
Cluster cluster = model.getCluster().getSelectedItem();
final List<ActionParametersBase> parameterList = new ArrayList<>();
for (MoveHostData hostData : model.getSelectedHosts()) {
VDS host = hostData.getEntity();
// Try to change host's cluster as neccessary.
if (host.getClusterId() != null && !host.getClusterId().equals(cluster.getId())) {
parameterList.add(new ChangeVDSClusterParameters(cluster.getId(), host.getId()));
}
}
model.startProgress();
Frontend.getInstance().runMultipleAction(ActionType.ChangeVDSCluster, parameterList, new IFrontendMultipleActionAsyncCallback() {
@Override
public void executed(FrontendMultipleActionAsyncResult result) {
final DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) result.getState();
List<MoveHostData> hosts = ((MoveHost) dataCenterGuideModel.getWindow()).getSelectedHosts();
List<ActionReturnValue> retVals = result.getReturnValue();
final List<ActionParametersBase> activateVdsParameterList = new ArrayList<>();
if (retVals != null && hosts.size() == retVals.size()) {
int i = 0;
for (MoveHostData selectedHostData : hosts) {
VDS selectedHost = selectedHostData.getEntity();
if (selectedHost.getStatus() == VDSStatus.PendingApproval && retVals.get(i) != null && retVals.get(i).getSucceeded()) {
Frontend.getInstance().runAction(ActionType.ApproveVds, new ApproveVdsParameters(selectedHost.getId()), null, this);
} else if (selectedHostData.getActivateHost()) {
activateVdsParameterList.add(new VdsActionParameters(selectedHostData.getEntity().getId()));
}
i++;
}
}
if (activateVdsParameterList.isEmpty()) {
dataCenterGuideModel.getWindow().stopProgress();
dataCenterGuideModel.cancel();
dataCenterGuideModel.postAction();
} else {
final String searchString = getVdsSearchString((MoveHost) dataCenterGuideModel.getWindow());
Timer timer = new Timer() {
public void run() {
checkVdsClusterChangeSucceeded(searchString, parameterList, activateVdsParameterList);
}
};
timer.schedule(2000);
}
}
}, this);
}
use of org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters 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.core.common.action.hostdeploy.ApproveVdsParameters in project ovirt-engine by oVirt.
the class RegisterVdsQuery method dispatchOvirtApprovalCommand.
private boolean dispatchOvirtApprovalCommand(Guid oVirtId) {
boolean isApprovalDispatched = true;
final ApproveVdsParameters params = new ApproveVdsParameters();
params.setVdsId(oVirtId);
params.setApprovedByRegister(true);
try {
ThreadPoolUtil.execute(() -> {
try {
ActionReturnValue ret = Backend.getInstance().runInternalAction(ActionType.ApproveVds, params);
if (ret == null || !ret.getSucceeded()) {
log.error("Approval of oVirt '{}' failed. ", params.getVdsId());
} else if (ret.getSucceeded()) {
log.info("Approval of oVirt '{}' ended successfully. ", params.getVdsId());
}
} catch (RuntimeException ex) {
log.error("Failed to Approve host", ex);
}
});
} catch (Exception e) {
isApprovalDispatched = false;
}
return isApprovalDispatched;
}
use of org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters in project ovirt-engine by oVirt.
the class ClusterGuideModel method onSelectHost.
public void onSelectHost() {
MoveHost model = (MoveHost) getWindow();
if (model.getProgress() != null) {
return;
}
if (!model.validate()) {
return;
}
model.setSelectedHosts(new ArrayList<MoveHostData>());
for (EntityModel a : model.getItems()) {
if (a.getIsSelected()) {
model.getSelectedHosts().add((MoveHostData) a);
}
}
Cluster cluster = model.getCluster().getSelectedItem();
final List<ActionParametersBase> parameterList = new ArrayList<>();
for (MoveHostData hostData : model.getSelectedHosts()) {
VDS host = hostData.getEntity();
// Try to change host's cluster as neccessary.
if (host.getClusterId() != null && !host.getClusterId().equals(cluster.getId())) {
parameterList.add(new ChangeVDSClusterParameters(cluster.getId(), host.getId()));
}
}
model.startProgress();
Frontend.getInstance().runMultipleAction(ActionType.ChangeVDSCluster, parameterList, result -> {
List<MoveHostData> hosts = ((MoveHost) getWindow()).getSelectedHosts();
List<ActionReturnValue> retVals = result.getReturnValue();
final List<ActionParametersBase> activateVdsParameterList = new ArrayList<>();
if (retVals != null && hosts.size() == retVals.size()) {
int i = 0;
for (MoveHostData selectedHostData : hosts) {
VDS selectedHost = selectedHostData.getEntity();
if (selectedHost.getStatus() == VDSStatus.PendingApproval && retVals.get(i) != null && retVals.get(i).getSucceeded()) {
Frontend.getInstance().runAction(ActionType.ApproveVds, new ApproveVdsParameters(selectedHost.getId()));
} else if (selectedHostData.getActivateHost()) {
activateVdsParameterList.add(new VdsActionParameters(selectedHostData.getEntity().getId()));
}
i++;
}
}
if (activateVdsParameterList.isEmpty()) {
getWindow().stopProgress();
cancel();
postAction();
} else {
final String searchString = getVdsSearchString((MoveHost) getWindow());
Timer timer = new Timer() {
public void run() {
checkVdsClusterChangeSucceeded(searchString, parameterList, activateVdsParameterList);
}
};
timer.schedule(2000);
}
}, this);
}
Aggregations