abh1sar commented on code in PR #10140:
URL: https://github.com/apache/cloudstack/pull/10140#discussion_r2230365467


##########
server/src/main/java/org/apache/cloudstack/backup/BackupManagerImpl.java:
##########
@@ -282,18 +319,75 @@ public boolean deleteBackupOffering(final Long 
offeringId) {
             throw new CloudRuntimeException("Could not find a backup offering 
with id: " + offeringId);
         }
 
-        if (vmInstanceDao.listByZoneWithBackups(offering.getZoneId(), 
offering.getId()).size() > 0) {
+        if (backupDao.listByOfferingId(offering.getId()).size() > 0) {
+            throw new CloudRuntimeException("Backup Offering cannot be removed 
as it has backups associated with it.");
+        }
+
+        if (vmInstanceDao.listByZoneAndBackupOffering(offering.getZoneId(), 
offering.getId()).size() > 0) {
             throw new CloudRuntimeException("Backup offering is assigned to 
VMs, remove the assignment(s) in order to remove the offering.");
         }
 
-        validateForZone(offering.getZoneId());
+        validateBackupForZone(offering.getZoneId());
         return backupOfferingDao.remove(offering.getId());
     }
 
-    public static String createVolumeInfoFromVolumes(List<VolumeVO> vmVolumes) 
{
+    @Override
+    public Map<String, String> getBackupDetailsFromVM(VirtualMachine vm) {
+        HashMap<String, String> details = new HashMap<>();
+
+        ServiceOffering serviceOffering = 
serviceOfferingDao.findById(vm.getServiceOfferingId());
+        details.put(ApiConstants.SERVICE_OFFERING_ID, 
serviceOffering.getUuid());
+        VirtualMachineTemplate template = 
vmTemplateDao.findById(vm.getTemplateId());
+        details.put(ApiConstants.TEMPLATE_ID, template.getUuid());
+
+        List<VMInstanceDetailVO> vmDetails = 
vmInstanceDetailsDao.listDetails(vm.getId());
+        HashMap<String, String> settings = new HashMap<>();
+        for (VMInstanceDetailVO detail : vmDetails) {
+            settings.put(detail.getName(), detail.getValue());
+        }
+        if (!settings.isEmpty()) {
+            details.put(ApiConstants.VM_SETTINGS, new Gson().toJson(settings));
+        }
+
+        List<UserVmJoinVO> userVmJoinVOs = 
userVmJoinDao.searchByIds(vm.getId());
+        if (userVmJoinVOs != null && !userVmJoinVOs.isEmpty()) {
+            List<Map<String, String>> nics = new ArrayList<>();
+            Set<String> seen = new HashSet<>();
+
+            for (UserVmJoinVO userVmJoinVO : userVmJoinVOs) {
+                Map<String, String> nicInfo = new HashMap<>();
+                String key = userVmJoinVO.getNetworkUuid();
+                if (seen.add(key)) {
+                    nicInfo.put(ApiConstants.NETWORK_ID, 
userVmJoinVO.getNetworkUuid());
+                    nicInfo.put(ApiConstants.IP_ADDRESS, 
userVmJoinVO.getIpAddress());
+                    nicInfo.put(ApiConstants.IP6_ADDRESS, 
userVmJoinVO.getIp6Address());
+                    nicInfo.put(ApiConstants.MAC_ADDRESS, 
userVmJoinVO.getMacAddress());
+                    nics.add(nicInfo);
+                }
+            }
+
+            if (!nics.isEmpty()) {
+                String nicJson = new Gson().toJson(nics);
+                details.put("nics", nicJson);
+            }

Review Comment:
   Done



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