Pearl1594 commented on code in PR #12357:
URL: https://github.com/apache/cloudstack/pull/12357#discussion_r2793982408
##########
server/src/main/java/org/apache/cloudstack/backup/BackupManagerImpl.java:
##########
@@ -325,6 +326,79 @@ public BackupOffering importBackupOffering(final
ImportBackupOfferingCmd cmd) {
return savedOffering;
}
+ @Override
+ @ActionEvent(eventType = EventTypes.EVENT_VM_BACKUP_CLONE_OFFERING,
eventDescription = "cloning backup offering", create = true)
+ public BackupOffering cloneBackupOffering(final CloneBackupOfferingCmd
cmd) {
Review Comment:
addressed.
##########
server/src/main/java/org/apache/cloudstack/backup/BackupManagerImpl.java:
##########
@@ -325,6 +326,79 @@ public BackupOffering importBackupOffering(final
ImportBackupOfferingCmd cmd) {
return savedOffering;
}
+ @Override
+ @ActionEvent(eventType = EventTypes.EVENT_VM_BACKUP_CLONE_OFFERING,
eventDescription = "cloning backup offering", create = true)
+ public BackupOffering cloneBackupOffering(final CloneBackupOfferingCmd
cmd) {
+ final BackupOfferingVO sourceOffering =
backupOfferingDao.findById(cmd.getSourceOfferingId());
+ if (sourceOffering == null) {
+ throw new InvalidParameterValueException("Unable to find backup
offering with ID: " + cmd.getSourceOfferingId());
+ }
+
+ validateBackupForZone(sourceOffering.getZoneId());
+
+ if (backupOfferingDao.findByName(cmd.getName(),
sourceOffering.getZoneId()) != null) {
+ throw new CloudRuntimeException("A backup offering with the name
'" + cmd.getName() + "' already exists in this zone");
+ }
+
+ final String description = cmd.getDescription() != null ?
cmd.getDescription() : sourceOffering.getDescription();
+ final String externalId = cmd.getExternalId() != null ?
cmd.getExternalId() : sourceOffering.getExternalId();
+ final boolean userDrivenBackups = cmd.getUserDrivenBackups() != null ?
cmd.getUserDrivenBackups() : sourceOffering.isUserDrivenBackupAllowed();
+
+ if (!externalId.equals(sourceOffering.getExternalId())) {
+ final BackupProvider provider =
getBackupProvider(sourceOffering.getZoneId());
+ if (!provider.isValidProviderOffering(sourceOffering.getZoneId(),
externalId)) {
+ throw new CloudRuntimeException("Backup offering '" +
externalId + "' does not exist on provider " + provider.getName() + " on zone "
+ sourceOffering.getZoneId());
+ }
+ }
+
+ if (!externalId.equals(sourceOffering.getExternalId())) {
Review Comment:
yes - combined the check.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]