use of org.ovirt.engine.core.common.action.VdsActionParameters in project ovirt-engine by oVirt.
the class SaveNetworkConfigAction method execute.
public void execute() {
Frontend.getInstance().runAction(ActionType.CommitNetworkChanges, new VdsActionParameters(host.getId()), result -> {
ActionReturnValue returnValueBase = result.getReturnValue();
if (returnValueBase != null && returnValueBase.getSucceeded()) {
if (windowModel != null) {
windowModel.stopProgress();
listModel.setWindow(null);
listModel.setConfirmWindow(null);
listModel.search();
}
}
}, null);
}
use of org.ovirt.engine.core.common.action.VdsActionParameters in project ovirt-engine by oVirt.
the class UpgradeHostInternalCommand method executeCommand.
@Override
protected void executeCommand() {
getCompensationContext().snapshotEntityStatus(getVds().getDynamicData(), getParameters().getInitialStatus());
getCompensationContext().stateChanged();
VDSType vdsType = getVds().getVdsType();
if (vdsType == VDSType.VDS || vdsType == VDSType.oVirtNode) {
try {
setVdsStatus(VDSStatus.Installing);
upgradeManager.update(getVds());
if (vdsType == VDSType.oVirtNode || getParameters().isReboot()) {
VdsActionParameters params = new VdsActionParameters(getVds().getId());
params.setPrevVdsStatus(getParameters().getInitialStatus());
ActionReturnValue returnValue = runInternalAction(ActionType.SshHostReboot, params, ExecutionHandler.createInternalJobContext());
if (!returnValue.getSucceeded()) {
setVdsStatus(VDSStatus.InstallFailed);
log.error("Engine failed to restart via ssh host '{}' ('{}') after upgrade", getVds().getName(), getVds().getId());
return;
}
} else {
// letting the host a chance to recover from restarting the VDSM service after the upgrade
if (!new HostConnectivityChecker().check(getVds())) {
log.warn("Engine failed to communicate with VDSM agent on host '{}' with address '{}' ('{}') " + "after upgrade", getVds().getName(), getVds().getHostName(), getVds().getId());
}
}
} catch (Exception e) {
setVdsStatus(VDSStatus.InstallFailed);
return;
}
} else if (getVds().isOvirtVintageNode()) {
InstallVdsParameters parameters = new InstallVdsParameters(getVdsId());
parameters.setIsReinstallOrUpgrade(true);
parameters.setoVirtIsoFile(getParameters().getoVirtIsoFile());
parameters.setActivateHost(getParameters().getInitialStatus() == VDSStatus.Up);
ActionReturnValue result = runInternalAction(ActionType.UpgradeOvirtNodeInternal, parameters);
if (!result.getSucceeded()) {
setVdsStatus(VDSStatus.InstallFailed);
propagateFailure(result);
return;
}
}
try {
updateHostStatusAfterSuccessfulUpgrade();
setSucceeded(true);
} catch (Exception e) {
log.error("Failed to set new status for host '{}' after upgrade has ended.", getVdsName());
log.error("Exception", e);
setVdsStatus(VDSStatus.InstallFailed);
}
}
use of org.ovirt.engine.core.common.action.VdsActionParameters in project ovirt-engine by oVirt.
the class PowerSavingBalancePolicyUnit method processPmAction.
private void processPmAction(Pair<VDS, VDSStatus> action) {
VDS vds = action.getFirst();
VDSStatus currentStatus = vds.getStatus();
VDSStatus targetStatus = action.getSecond();
if (targetStatus == VDSStatus.Maintenance && currentStatus == VDSStatus.Up) {
logAction(vds, AuditLogType.PM_POLICY_UP_TO_MAINTENANCE);
/* Up -> Maint */
Guid[] vdsList = new Guid[] { vds.getId() };
MaintenanceNumberOfVdssParameters parameters = new MaintenanceNumberOfVdssParameters(Arrays.asList(vdsList), true, true);
Backend.getInstance().runInternalAction(ActionType.MaintenanceNumberOfVdss, parameters, ExecutionHandler.createInternalJobContext());
} else if (targetStatus == VDSStatus.Down && currentStatus == VDSStatus.Maintenance) {
logAction(vds, AuditLogType.PM_POLICY_MAINTENANCE_TO_DOWN);
/* Maint -> Down */
VdsPowerDownParameters parameters = new VdsPowerDownParameters(vds.getId());
parameters.setKeepPolicyPMEnabled(true);
Backend.getInstance().runInternalAction(ActionType.VdsPowerDown, parameters, ExecutionHandler.createInternalJobContext());
} else if (targetStatus == VDSStatus.Up && currentStatus == VDSStatus.Maintenance) {
logAction(vds, AuditLogType.PM_POLICY_TO_UP);
/* Maint -> Up */
VdsActionParameters parameters = new VdsActionParameters(vds.getId());
Backend.getInstance().runInternalAction(ActionType.ActivateVds, parameters, ExecutionHandler.createInternalJobContext());
} else if (targetStatus == VDSStatus.Up && currentStatus == VDSStatus.Down) {
logAction(vds, AuditLogType.PM_POLICY_TO_UP);
/* Down -> Up */
FenceVdsActionParameters parameters = new FenceVdsActionParameters(vds.getId());
Backend.getInstance().runInternalAction(ActionType.StartVds, parameters, ExecutionHandler.createInternalJobContext());
} else {
/* Should not ever happen... */
log.error("Unknown host power management transition '{}' -> '{}'", currentStatus, targetStatus);
}
}
use of org.ovirt.engine.core.common.action.VdsActionParameters 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);
}
use of org.ovirt.engine.core.common.action.VdsActionParameters in project ovirt-engine by oVirt.
the class ClusterHostListModel method updateMomPolicy.
private void updateMomPolicy() {
ArrayList<ActionParametersBase> list = new ArrayList<>();
for (VDS vds : getSelectedItems()) {
list.add(new VdsActionParameters(vds.getId()));
}
Frontend.getInstance().runMultipleAction(ActionType.UpdateMomPolicy, list, result -> {
}, null);
}
Aggregations