This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/master by this push:
new b1ddd7c vmware: Fix for mapping guest OS type read from OVF to
existing guest OS in C… (#4553)
b1ddd7c is described below
commit b1ddd7c2e6bbe2713fc79680e2bd451876cffa0d
Author: Harikrishna <[email protected]>
AuthorDate: Wed Dec 23 19:37:21 2020 +0530
vmware: Fix for mapping guest OS type read from OVF to existing guest OS in
C… (#4553)
* Fix for mapping guest OS type read from OVF to existing guest OS in
CloudStack database while registering VMware template
* Added unit tests to String Utils methods and updated the code
* Updated the java doc section
* Updated os description logic to keep equals ignore match with guest os
display name
---
.../image/deployasis/DeployAsIsHelperImpl.java | 24 +++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git
a/engine/storage/src/main/java/org/apache/cloudstack/storage/image/deployasis/DeployAsIsHelperImpl.java
b/engine/storage/src/main/java/org/apache/cloudstack/storage/image/deployasis/DeployAsIsHelperImpl.java
index 6610966..6d05af3 100644
---
a/engine/storage/src/main/java/org/apache/cloudstack/storage/image/deployasis/DeployAsIsHelperImpl.java
+++
b/engine/storage/src/main/java/org/apache/cloudstack/storage/image/deployasis/DeployAsIsHelperImpl.java
@@ -167,8 +167,26 @@ public class DeployAsIsHelperImpl implements
DeployAsIsHelper {
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) {
+ GuestOSVO guestOSVO =
guestOSDao.findById(guestOSHypervisorVO.getGuestOsId());
+ if
(guestOsDescription.equalsIgnoreCase(guestOSVO.getDisplayName())) {
+ guestOsId = guestOSHypervisorVO.getGuestOsId();
+ break;
+ }
+ }
+ }
+ if (null == guestOsId) {
+ 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);
}
@@ -301,7 +319,7 @@ public class DeployAsIsHelperImpl implements
DeployAsIsHelper {
}
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) {