Juan Hernandez has posted comments on this change.
Change subject: restapi: 'concurrent' Not Displayed For Primary PM Agent
......................................................................
Patch Set 1:
(2 comments)
....................................................
File
backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/HostMapper.java
Line 488: if (!StringUtils.isEmpty(entity.getPmSecondaryIp())) {
Line 489: boolean concurrent = entity.isPmSecondaryConcurrent();
Line 490: // When a second agent exists, 'concurrent' field is
relevant for both agents, so here we
Line 491: // set it retroactively in the first agent.
Line 492:
model.getAgents().getAgents().get(0).setConcurrent(concurrent);
Can we make this iterating the list of agents instead of explicitly get(0) ?
That would work even if there are more than two agents.
Something like this:
// The concurrent parameter of all agents should be implicitly set to true is
there is at least one agent
// that has been explicitly set to true:
boolean atLeastOneConcurrent = false;
for (Agent i : model.getAgents().getAgents()) {
if (i.isSetConcurrent() && i.isConcurrent()) {
atLeastOneConcurrent = true;
break;
}
}
for (Agent i : model.getAgents().getAgents()) {
i.setConcurrent(atLeastOneConcurrent);
}
And I would suggest to put this "rule" outside the setup of the secondary
agent, that way it can survive (or be removed) even if we introduce a more
generic treatment of more than two agents.
Line 493: agent = new Agent();
Line 494: agent.setType(entity.getPmSecondaryType());
Line 495: agent.setAddress(entity.getPmSecondaryIp());
Line 496: agent.setUsername(entity.getPmSecondaryUser());
Line 499: }
Line 500: agent.setOrder(2);
Line 501: agent.setConcurrent(concurrent);
Line 502: model.getAgents().getAgents().add(agent);
Line 503: }
This is where I would suggest to put the "rule".
Line 504: }
Line 505: return model;
Line 506: }
Line 507:
--
To view, visit http://gerrit.ovirt.org/21781
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: If0882d1db6c13b24c767e0cb40b9b797e8b61860
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Ori Liel <[email protected]>
Gerrit-Reviewer: Eli Mesika <[email protected]>
Gerrit-Reviewer: Juan Hernandez <[email protected]>
Gerrit-Reviewer: Michael Pasternak <[email protected]>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches