In case we cannot update the password of all hosts in a cluster, please stop and notify the user about the failure.

- The host id that failed to get updated will be informed in the error.

Signed-off-by: wilderrodrigues <wrodrigues@schubergphilis.com>
This commit is contained in:
wilderrodrigues 2015-06-25 11:14:31 +02:00
parent ea9db195ed
commit 284e2d68e1
1 changed files with 8 additions and 5 deletions

View File

@ -2234,28 +2234,31 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
nv = _hostDetailsDao.findDetail(hostId, ApiConstants.PASSWORD);
final String password = nv.getValue();
final UpdateHostPasswordCommand cmd = new UpdateHostPasswordCommand(username, password);
_agentMgr.easySend(hostId, cmd);
return true;
final Answer answer = _agentMgr.easySend(hostId, cmd);
return answer != null;
}
@Override
public boolean updateClusterPassword(final UpdateHostPasswordCmd command) {
// get agents for the cluster
final List<HostVO> hosts = listAllHostsInCluster(command.getClusterId());
for (final HostVO h : hosts) {
for (final HostVO host : hosts) {
try {
/*
* FIXME: this is a buggy logic, check with alex. Shouldn't
* return if propagation return non null
*/
final Boolean result = propagateResourceEvent(h.getId(), ResourceState.Event.UpdatePassword);
final Boolean result = propagateResourceEvent(host.getId(), ResourceState.Event.UpdatePassword);
if (result != null) {
return result;
}
} catch (final AgentUnavailableException e) {
s_logger.error("Agent is not availbale!", e);
}
doUpdateHostPassword(h.getId());
final boolean isUpdated = doUpdateHostPassword(host.getId());
if (!isUpdated) {
throw new CloudRuntimeException("CloudStack failed to update the password of the Host with ID ==> " + host.getId() + ". Please make sure you are still able to connect to your hosts.");
}
}
return true;