harikrishna-patnala commented on a change in pull request #4553:
URL: https://github.com/apache/cloudstack/pull/4553#discussion_r547692898
##########
File path:
engine/storage/src/main/java/org/apache/cloudstack/storage/image/deployasis/DeployAsIsHelperImpl.java
##########
@@ -174,8 +174,25 @@ private void handleGuestOsFromOVFDescriptor(long
templateId, String guestOsType,
hypervisor.toString(), minimumHypervisorVersion);
if (CollectionUtils.isNotEmpty(guestOsMappings)) {
- GuestOSHypervisorVO mapping = guestOsMappings.get(0);
- long guestOsId = 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) {
+ GuestOSVO guestOSVO =
guestOSDao.findById(guestOSHypervisorVO.getGuestOsId());
+ if
(guestOsDescription.equalsIgnoreCase(guestOSVO.getDisplayName())) {
+ guestOsId = guestOSHypervisorVO.getGuestOsId();
+ break;
+ }
+ }
+ }
+ if (null == guestOsId) {
Review comment:
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
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]