address comments

This commit is contained in:
Pearl Dsilva 2026-02-11 09:45:07 -05:00
parent 425d8c7e70
commit ec53d6f745
9 changed files with 19 additions and 11 deletions

View File

@ -380,6 +380,7 @@ public class EventTypes {
// Disk Offerings
public static final String EVENT_DISK_OFFERING_CREATE = "DISK.OFFERING.CREATE";
public static final String EVENT_DISK_OFFERING_CLONE = "DISK.OFFERING.CLONE";
public static final String EVENT_DISK_OFFERING_EDIT = "DISK.OFFERING.EDIT";
public static final String EVENT_DISK_OFFERING_DELETE = "DISK.OFFERING.DELETE";
@ -400,6 +401,7 @@ public class EventTypes {
// Network offerings
public static final String EVENT_NETWORK_OFFERING_CREATE = "NETWORK.OFFERING.CREATE";
public static final String EVENT_NETWORK_OFFERING_CLONE = "NETWORK.OFFERING.CLONE";
public static final String EVENT_NETWORK_OFFERING_ASSIGN = "NETWORK.OFFERING.ASSIGN";
public static final String EVENT_NETWORK_OFFERING_EDIT = "NETWORK.OFFERING.EDIT";
public static final String EVENT_NETWORK_OFFERING_REMOVE = "NETWORK.OFFERING.REMOVE";
@ -599,6 +601,7 @@ public class EventTypes {
// VPC offerings
public static final String EVENT_VPC_OFFERING_CREATE = "VPC.OFFERING.CREATE";
public static final String EVENT_VPC_OFFERING_CLONE = "VPC.OFFERING.CLONE";
public static final String EVENT_VPC_OFFERING_UPDATE = "VPC.OFFERING.UPDATE";
public static final String EVENT_VPC_OFFERING_DELETE = "VPC.OFFERING.DELETE";
@ -631,7 +634,7 @@ public class EventTypes {
// Backup and Recovery events
public static final String EVENT_VM_BACKUP_IMPORT_OFFERING = "BACKUP.IMPORT.OFFERING";
public static final String EVENT_VM_BACKUP_CLONE_OFFERING = "BACKUP.CLONE.OFFERING";
public static final String EVENT_VM_BACKUP_OFFERING_CLONE = "BACKUP.OFFERING.CLONE";
public static final String EVENT_VM_BACKUP_OFFERING_ASSIGN = "BACKUP.OFFERING.ASSIGN";
public static final String EVENT_VM_BACKUP_OFFERING_REMOVE = "BACKUP.OFFERING.REMOVE";
public static final String EVENT_VM_BACKUP_CREATE = "BACKUP.CREATE";
@ -1047,11 +1050,13 @@ public class EventTypes {
// Service Offerings
entityEventDetails.put(EVENT_SERVICE_OFFERING_CREATE, ServiceOffering.class);
entityEventDetails.put(EVENT_SERVICE_OFFERING_CLONE, ServiceOffering.class);
entityEventDetails.put(EVENT_SERVICE_OFFERING_EDIT, ServiceOffering.class);
entityEventDetails.put(EVENT_SERVICE_OFFERING_DELETE, ServiceOffering.class);
// Disk Offerings
entityEventDetails.put(EVENT_DISK_OFFERING_CREATE, DiskOffering.class);
entityEventDetails.put(EVENT_DISK_OFFERING_CLONE, DiskOffering.class);
entityEventDetails.put(EVENT_DISK_OFFERING_EDIT, DiskOffering.class);
entityEventDetails.put(EVENT_DISK_OFFERING_DELETE, DiskOffering.class);
@ -1072,6 +1077,7 @@ public class EventTypes {
// Network offerings
entityEventDetails.put(EVENT_NETWORK_OFFERING_CREATE, NetworkOffering.class);
entityEventDetails.put(EVENT_NETWORK_OFFERING_CLONE, NetworkOffering.class);
entityEventDetails.put(EVENT_NETWORK_OFFERING_ASSIGN, NetworkOffering.class);
entityEventDetails.put(EVENT_NETWORK_OFFERING_EDIT, NetworkOffering.class);
entityEventDetails.put(EVENT_NETWORK_OFFERING_REMOVE, NetworkOffering.class);

View File

@ -82,7 +82,6 @@ public class CloneBackupOfferingCmd extends BaseAsyncCmd implements DomainAndZon
@Parameter(name = ApiConstants.DOMAIN_ID,
type = CommandType.STRING,
description = "the ID of the containing domain(s) as comma separated string, public for public offerings",
since = "4.23.0",
length = 4096)
private String domainIds;

View File

@ -45,7 +45,7 @@ public class CloneNetworkOfferingCmd extends NetworkOfferingBaseCmd {
type = BaseCmd.CommandType.UUID,
entityType = NetworkOfferingResponse.class,
required = true,
description = "The ID of the network offering to clone")
description = "The ID of the source network offering to clone from")
private Long sourceOfferingId;
@Parameter(name = "addservices",

View File

@ -42,7 +42,7 @@ public class CloneDiskOfferingCmd extends CreateDiskOfferingCmd {
type = BaseCmd.CommandType.UUID,
entityType = DiskOfferingResponse.class,
required = true,
description = "The ID of the disk offering to clone")
description = "The ID of the source disk offering to clone from")
private Long sourceOfferingId;
/////////////////////////////////////////////////////

View File

@ -41,7 +41,7 @@ public class CloneServiceOfferingCmd extends CreateServiceOfferingCmd {
type = CommandType.UUID,
entityType = ServiceOfferingResponse.class,
required = true,
description = "The ID of the service offering to clone")
description = "The ID of the source service offering to clone from")
private Long sourceOfferingId;
/////////////////////////////////////////////////////

View File

@ -45,7 +45,7 @@ public class CloneVPCOfferingCmd extends CreateVPCOfferingCmd {
type = BaseCmd.CommandType.UUID,
entityType = VpcOfferingResponse.class,
required = true,
description = "The ID of the VPC offering to clone")
description = "The ID of the source VPC offering to clone from")
private Long sourceOfferingId;
@Parameter(name = "addservices",

View File

@ -4134,6 +4134,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
}
@Override
@ActionEvent(eventType = EventTypes.EVENT_DISK_OFFERING_CLONE, eventDescription = "cloning disk offering")
public DiskOffering cloneDiskOffering(final CloneDiskOfferingCmd cmd) {
final long userId = CallContext.current().getCallingUserId();
final DiskOfferingVO sourceOffering = getAndValidateSourceDiskOffering(cmd.getSourceOfferingId());
@ -8276,7 +8277,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
}
@Override
@ActionEvent(eventType = EventTypes.EVENT_NETWORK_OFFERING_CREATE, eventDescription = "cloning network offering")
@ActionEvent(eventType = EventTypes.EVENT_NETWORK_OFFERING_CLONE, eventDescription = "cloning network offering")
public NetworkOffering cloneNetworkOffering(final CloneNetworkOfferingCmd cmd) {
final Long sourceOfferingId = cmd.getSourceOfferingId();

View File

@ -819,6 +819,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
}
@Override
@ActionEvent(eventType = EventTypes.EVENT_VPC_OFFERING_CLONE, eventDescription = "cloning VPC offering")
public VpcOffering cloneVPCOffering(CloneVPCOfferingCmd cmd) {
Long sourceVpcOfferingId = cmd.getSourceOfferingId();

View File

@ -327,7 +327,7 @@ public class BackupManagerImpl extends ManagerBase implements BackupManager {
}
@Override
@ActionEvent(eventType = EventTypes.EVENT_VM_BACKUP_CLONE_OFFERING, eventDescription = "cloning backup offering", create = true)
@ActionEvent(eventType = EventTypes.EVENT_VM_BACKUP_OFFERING_CLONE, eventDescription = "cloning backup offering")
public BackupOffering cloneBackupOffering(final CloneBackupOfferingCmd cmd) {
final BackupOfferingVO sourceOffering = backupOfferingDao.findById(cmd.getSourceOfferingId());
if (sourceOffering == null) {
@ -343,15 +343,16 @@ public class BackupManagerImpl extends ManagerBase implements BackupManager {
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();
final Long zoneId = cmd.getZoneId() != null ? cmd.getZoneId() : sourceOffering.getZoneId();
if (!externalId.equals(sourceOffering.getExternalId())) {
if (!Objects.equals(sourceOffering.getExternalId(), externalId)) {
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())) {
if (!Objects.equals(sourceOffering.getExternalId(), externalId)) {
final BackupOffering existingOffering = backupOfferingDao.findByExternalId(externalId, sourceOffering.getZoneId());
if (existingOffering != null) {
throw new CloudRuntimeException("A backup offering with external ID '" + externalId + "' already exists in this zone");
@ -359,7 +360,7 @@ public class BackupManagerImpl extends ManagerBase implements BackupManager {
}
final BackupOfferingVO clonedOffering = new BackupOfferingVO(
sourceOffering.getZoneId(),
zoneId,
externalId,
sourceOffering.getProvider(),
cmd.getName(),