Skip to content
Merged
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 @@ -167,8 +167,26 @@ public Long retrieveTemplateGuestOsIdFromGuestOsInfo(long templateId, String gue
hypervisor.toString(), minimumHypervisorVersion);

if (CollectionUtils.isNotEmpty(guestOsMappings)) {
GuestOSHypervisorVO mapping = guestOsMappings.get(0);
return mapping.getGuestOsId();
Long guestOsId = null;
if (guestOsMappings.size() == 1) {
GuestOSHypervisorVO mapping = guestOsMappings.get(0);
guestOsId = mapping.getGuestOsId();
} else {
if (!StringUtils.isEmpty(guestOsDescription)) {
for (GuestOSHypervisorVO guestOSHypervisorVO : guestOsMappings) {
Comment thread
DaanHoogland marked this conversation as resolved.
GuestOSVO guestOSVO = guestOSDao.findById(guestOSHypervisorVO.getGuestOsId());
if (guestOsDescription.equalsIgnoreCase(guestOSVO.getDisplayName())) {
guestOsId = guestOSHypervisorVO.getGuestOsId();
break;
}
}
}
if (null == guestOsId) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit - I think variable == null maybe more readable, but as I said that's not picking

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

depends on how accustomed you are in right to left reading ;)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

making habit of this to avoid setting null to the variable by mistake, in that case IDE also don't know if it is logically wrong "if (guestOsId = null)" :p

GuestOSHypervisorVO mapping = guestOsMappings.get(guestOsMappings.size()-1);
guestOsId = mapping.getGuestOsId();
}
}
return guestOsId;
} else {
throw new CloudRuntimeException("Did not find a guest OS with type " + guestOsType);
}
Expand Down Expand Up @@ -301,7 +319,7 @@ private void persistTemplateDeployAsIsInformationTOList(long templateId,
}
String propValue = null;
try {
propValue = getValueFromInformationTO(informationTO);
propValue = getValueFromInformationTO(informationTO);
} catch (RuntimeException re) {
LOGGER.error("gson marshalling of property object fails: " + propKey,re);
} catch (IOException e) {
Expand Down