use of org.ovirt.engine.core.common.action.hostdeploy.UpdateVdsActionParameters in project ovirt-engine by oVirt.
the class RegisterVdsQuery method updateExistingHost.
private boolean updateExistingHost(VDS vds, boolean pending) {
boolean returnValue = true;
vds.setHostName(vds.getHostName());
vds.setPort(getParameters().getVdsPort());
log.debug("RegisterVdsQuery::register - Will try now to update VDS with existing unique id; Name: '{}', Hostname: '{}', Unique: '{}', VdsPort: '{}', isPending: '{}' with force synchronize", getParameters().getVdsHostName(), getStrippedVdsUniqueId(), getStrippedVdsUniqueId(), getParameters().getVdsPort(), pending);
UpdateVdsActionParameters p = new UpdateVdsActionParameters(vds.getStaticData(), "", false);
p.setInstallHost(!pending);
p.setReinstallOrUpgrade(!pending);
p.setAuthMethod(VdsOperationActionParameters.AuthenticationMethod.PublicKey);
if (vds.isFenceAgentsExist()) {
p.setFenceAgents(vds.getFenceAgents());
}
p.setTransactionScopeOption(TransactionScopeOption.RequiresNew);
ActionReturnValue rc = Backend.getInstance().runInternalAction(ActionType.UpdateVds, p);
if (!rc.getSucceeded()) {
error = AuditLogType.VDS_REGISTER_EXISTING_VDS_UPDATE_FAILED;
log.debug("RegisterVdsQuery::register - Failed to update existing VDS Name: '{}', Hostname: '{}', Unique: '{}', VdsPort: '{}', isPending: '{}'", getParameters().getVdsHostName(), getStrippedVdsUniqueId(), getStrippedVdsUniqueId(), getParameters().getVdsPort(), pending);
captureCommandErrorsToLogger(rc, "RegisterVdsQuery::register");
returnValue = false;
} else {
log.info("RegisterVdsQuery::register - Updated a '{}' registered VDS - Name: '{}', Hostname: '{}', UniqueID: '{}'", vds.getStatus() == VDSStatus.PendingApproval ? "Pending " : "", getParameters().getVdsName(), getParameters().getVdsHostName(), getStrippedVdsUniqueId());
}
return returnValue;
}
use of org.ovirt.engine.core.common.action.hostdeploy.UpdateVdsActionParameters in project ovirt-engine by oVirt.
the class RegisterVdsQuery method handleOldVdssWithSameName.
/**
* Check if another host has the same name as hostToRegister and if yes append a number to it. Eventually if the
* host is in the db, persist the changes.
*/
private boolean handleOldVdssWithSameName(VDS hostToRegister) {
log.debug("Entering");
boolean returnValue = true;
VDS storedHost = vdsDao.getByName(getParameters().getVdsName());
List<String> allHostNames = getAllHostNames(vdsDao.getAll());
boolean hostExistInDB = hostToRegister != null;
if (storedHost != null) {
log.debug("found VDS with the same name {0}. Will try to register with a new name", getParameters().getVdsName());
String nameToRegister = getParameters().getVdsName();
String uniqueIdToRegister = getParameters().getVdsUniqueId();
String newName;
// check different uniqueIds but same name
if (!uniqueIdToRegister.equals(storedHost.getUniqueId()) && nameToRegister.equals(storedHost.getName())) {
if (hostExistInDB) {
// update the registered host if exist in db
allHostNames.remove(hostToRegister.getName());
newName = generateUniqueName(nameToRegister, allHostNames);
hostToRegister.setVdsName(newName);
UpdateVdsActionParameters parameters = new UpdateVdsActionParameters(hostToRegister.getStaticData(), "", false);
if (hostToRegister.isFenceAgentsExist()) {
parameters.setFenceAgents(hostToRegister.getFenceAgents());
}
ActionReturnValue ret = Backend.getInstance().runInternalAction(ActionType.UpdateVds, parameters);
if (!ret.getSucceeded()) {
error = AuditLogType.VDS_REGISTER_ERROR_UPDATING_NAME;
logable.addCustomValue("VdsName2", newName);
log.error("could not update VDS '{}'", nameToRegister);
captureCommandErrorsToLogger(ret, "RegisterVdsQuery::handleOldVdssWithSameName");
return false;
} else {
log.info("Another VDS was using this name with IP '{}'. Changed to '{}'", nameToRegister, newName);
}
} else {
// host doesn't exist in db yet. not persisting changes just object values.
newName = generateUniqueName(nameToRegister, allHostNames);
getParameters().setVdsName(newName);
}
}
}
log.debug("Leaving with value '{}'", returnValue);
return returnValue;
}
Aggregations