DaanHoogland commented on code in PR #7799:
URL: https://github.com/apache/cloudstack/pull/7799#discussion_r1281520648


##########
engine/schema/src/main/java/com/cloud/upgrade/GuestOsMapper.java:
##########
@@ -74,18 +74,19 @@ private long 
getGuestOsIdFromHypervisorMapping(GuestOSHypervisorMapping mapping)
     }
 
     public void addGuestOsAndHypervisorMappings(long categoryId, String 
displayName, List<GuestOSHypervisorMapping> mappings) {
-        if (!addGuestOs(categoryId, displayName)) {
-            LOG.warn("Couldn't add the guest OS with category id: " + 
categoryId + " and display name: " + displayName);
-            return;
-        }
-
-        if (CollectionUtils.isEmpty(mappings)) {
-            return;
-        }
-
         long guestOsId = getGuestOsId(categoryId, displayName);
         if (guestOsId == 0) {
             LOG.debug("No guest OS found with category id: " + categoryId + " 
and display name: " + displayName);
+            if (!addGuestOs(categoryId, displayName)) {
+                LOG.warn("Couldn't add the guest OS with category id: " + 
categoryId + " and display name: " + displayName);
+                return;
+            }
+            guestOsId = getGuestOsId(categoryId, displayName);
+        } else {
+            // TODO: update is_user_defined to false

Review Comment:
   we can use the user_defined flag to decide which ones to remove and only 
keep the system defined one. In this case we, will have to allow for the ectra 
definition to begin with and deduplicate it right away.



-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to