Skip to content

Commit

Permalink
Set the host to the given allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
splhack committed Mar 25, 2021
1 parent c93e862 commit db80636
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,28 @@ public DispatchHost createHost(HostReport report) {

@Transactional(propagation = Propagation.REQUIRED)
public DispatchHost createHost(RenderHost rhost) {
return createHost(rhost, getDefaultAllocationDetail());
// Find suitable allocation with facility and tags.
AllocationEntity alloc = null;
if (rhost.getTagsCount() > 0) {
String facility = rhost.getFacility();
for (String tag : rhost.getTagsList()) {
try {
alloc = allocationDao.findAllocationEntity(facility, tag);
logger.info("set " + rhost.getName() +
" to the given allocation " + alloc.getName());
break;
}
catch (Exception e) {
// Allocation doesn't exist. ignore.
}
}
}
if (alloc == null) {
alloc = getDefaultAllocationDetail();
logger.info("set " + rhost.getName() +
" to the default allocation " + alloc.getName());
}
return createHost(rhost, alloc);
}

@Transactional(propagation = Propagation.REQUIRED)
Expand Down

0 comments on commit db80636

Please sign in to comment.