Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ public interface ResourceManager extends ResourceService, Configurable {

public HostVO findHostByGuid(String guid);

HostVO findHostByGuidPrefix(String guid);

public HostVO findHostByName(String name);

HostStats getHostStatistics(Host host);
Expand Down
27 changes: 24 additions & 3 deletions server/src/main/java/com/cloud/resource/ResourceManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2261,15 +2261,26 @@ private boolean checkCIDR(final HostPodVO pod, final String serverPrivateIP, fin
private HostVO getNewHost(StartupCommand[] startupCommands) {
StartupCommand startupCommand = startupCommands[0];

HostVO host = findHostByGuid(startupCommand.getGuid());
String fullGuid = startupCommand.getGuid();
logger.debug(String.format("Trying to find Host by guid %s", fullGuid));
HostVO host = findHostByGuid(fullGuid);

if (host != null) {
logger.debug(String.format("Found Host by guid %s: %s", fullGuid, host));
return host;
}

host = findHostByGuid(startupCommand.getGuidWithoutResource());
String guidPrefix = startupCommand.getGuidWithoutResource();
logger.debug(String.format("Trying to find Host by guid prefix %s", guidPrefix));
host = findHostByGuidPrefix(guidPrefix);

return host; // even when host == null!
if (host != null) {
logger.debug(String.format("Found Host by guid prefix %s: %s", guidPrefix, host));
return host;
}

logger.debug(String.format("Could not find Host by guid %s", fullGuid));
return null;
}

protected HostVO createHostVO(final StartupCommand[] cmds, final ServerResource resource, final Map<String, String> details, List<String> hostTags,
Expand Down Expand Up @@ -3296,13 +3307,23 @@ public List<HypervisorType> listAvailHypervisorInZone(final Long zoneId) {
public HostVO findHostByGuid(final String guid) {
final QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);
sc.and(sc.entity().getGuid(), Op.EQ, guid);
sc.and(sc.entity().getRemoved(), Op.NULL);
return sc.find();
}

@Override
public HostVO findHostByGuidPrefix(String guid) {
final QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);
sc.and(sc.entity().getGuid(), Op.LIKE, guid + "%");
sc.and(sc.entity().getRemoved(), Op.NULL);
return sc.find();
}

@Override
public HostVO findHostByName(final String name) {
final QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);
sc.and(sc.entity().getName(), Op.EQ, name);
sc.and(sc.entity().getRemoved(), Op.NULL);
return sc.find();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,11 @@ public HostVO findHostByGuid(final String guid) {
return null;
}

@Override
public HostVO findHostByGuidPrefix(String guid) {
return null;
}

/* (non-Javadoc)
* @see com.cloud.resource.ResourceManager#findHostByName(java.lang.String)
*/
Expand Down