Skip to content

Commit f03bef5

Browse files
committed
address comments
1 parent 15c6090 commit f03bef5

File tree

9 files changed

+21
-13
lines changed

9 files changed

+21
-13
lines changed

api/src/main/java/com/cloud/event/EventTypes.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ public class EventTypes {
380380

381381
// Disk Offerings
382382
public static final String EVENT_DISK_OFFERING_CREATE = "DISK.OFFERING.CREATE";
383+
public static final String EVENT_DISK_OFFERING_CLONE = "DISK.OFFERING.CLONE";
383384
public static final String EVENT_DISK_OFFERING_EDIT = "DISK.OFFERING.EDIT";
384385
public static final String EVENT_DISK_OFFERING_DELETE = "DISK.OFFERING.DELETE";
385386

@@ -400,6 +401,7 @@ public class EventTypes {
400401

401402
// Network offerings
402403
public static final String EVENT_NETWORK_OFFERING_CREATE = "NETWORK.OFFERING.CREATE";
404+
public static final String EVENT_NETWORK_OFFERING_CLONE = "NETWORK.OFFERING.CLONE";
403405
public static final String EVENT_NETWORK_OFFERING_ASSIGN = "NETWORK.OFFERING.ASSIGN";
404406
public static final String EVENT_NETWORK_OFFERING_EDIT = "NETWORK.OFFERING.EDIT";
405407
public static final String EVENT_NETWORK_OFFERING_REMOVE = "NETWORK.OFFERING.REMOVE";
@@ -599,6 +601,7 @@ public class EventTypes {
599601

600602
// VPC offerings
601603
public static final String EVENT_VPC_OFFERING_CREATE = "VPC.OFFERING.CREATE";
604+
public static final String EVENT_VPC_OFFERING_CLONE = "VPC.OFFERING.CLONE";
602605
public static final String EVENT_VPC_OFFERING_UPDATE = "VPC.OFFERING.UPDATE";
603606
public static final String EVENT_VPC_OFFERING_DELETE = "VPC.OFFERING.DELETE";
604607

@@ -631,7 +634,7 @@ public class EventTypes {
631634

632635
// Backup and Recovery events
633636
public static final String EVENT_VM_BACKUP_IMPORT_OFFERING = "BACKUP.IMPORT.OFFERING";
634-
public static final String EVENT_VM_BACKUP_CLONE_OFFERING = "BACKUP.CLONE.OFFERING";
637+
public static final String EVENT_VM_BACKUP_OFFERING_CLONE = "BACKUP.OFFERING.CLONE";
635638
public static final String EVENT_VM_BACKUP_OFFERING_ASSIGN = "BACKUP.OFFERING.ASSIGN";
636639
public static final String EVENT_VM_BACKUP_OFFERING_REMOVE = "BACKUP.OFFERING.REMOVE";
637640
public static final String EVENT_VM_BACKUP_CREATE = "BACKUP.CREATE";
@@ -1047,11 +1050,13 @@ public class EventTypes {
10471050

10481051
// Service Offerings
10491052
entityEventDetails.put(EVENT_SERVICE_OFFERING_CREATE, ServiceOffering.class);
1053+
entityEventDetails.put(EVENT_SERVICE_OFFERING_CLONE, ServiceOffering.class);
10501054
entityEventDetails.put(EVENT_SERVICE_OFFERING_EDIT, ServiceOffering.class);
10511055
entityEventDetails.put(EVENT_SERVICE_OFFERING_DELETE, ServiceOffering.class);
10521056

10531057
// Disk Offerings
10541058
entityEventDetails.put(EVENT_DISK_OFFERING_CREATE, DiskOffering.class);
1059+
entityEventDetails.put(EVENT_DISK_OFFERING_CLONE, DiskOffering.class);
10551060
entityEventDetails.put(EVENT_DISK_OFFERING_EDIT, DiskOffering.class);
10561061
entityEventDetails.put(EVENT_DISK_OFFERING_DELETE, DiskOffering.class);
10571062

@@ -1072,6 +1077,7 @@ public class EventTypes {
10721077

10731078
// Network offerings
10741079
entityEventDetails.put(EVENT_NETWORK_OFFERING_CREATE, NetworkOffering.class);
1080+
entityEventDetails.put(EVENT_NETWORK_OFFERING_CLONE, NetworkOffering.class);
10751081
entityEventDetails.put(EVENT_NETWORK_OFFERING_ASSIGN, NetworkOffering.class);
10761082
entityEventDetails.put(EVENT_NETWORK_OFFERING_EDIT, NetworkOffering.class);
10771083
entityEventDetails.put(EVENT_NETWORK_OFFERING_REMOVE, NetworkOffering.class);

api/src/main/java/org/apache/cloudstack/api/command/admin/backup/CloneBackupOfferingCmd.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ public class CloneBackupOfferingCmd extends BaseAsyncCmd implements DomainAndZon
8282
@Parameter(name = ApiConstants.DOMAIN_ID,
8383
type = CommandType.STRING,
8484
description = "the ID of the containing domain(s) as comma separated string, public for public offerings",
85-
since = "4.23.0",
8685
length = 4096)
8786
private String domainIds;
8887

@@ -157,7 +156,7 @@ public long getEntityOwnerId() {
157156

158157
@Override
159158
public String getEventType() {
160-
return EventTypes.EVENT_VM_BACKUP_CLONE_OFFERING;
159+
return EventTypes.EVENT_VM_BACKUP_OFFERING_CLONE;
161160
}
162161

163162
@Override

api/src/main/java/org/apache/cloudstack/api/command/admin/network/CloneNetworkOfferingCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class CloneNetworkOfferingCmd extends NetworkOfferingBaseCmd {
4545
type = BaseCmd.CommandType.UUID,
4646
entityType = NetworkOfferingResponse.class,
4747
required = true,
48-
description = "The ID of the network offering to clone")
48+
description = "The ID of the source network offering to clone from")
4949
private Long sourceOfferingId;
5050

5151
@Parameter(name = "addservices",

api/src/main/java/org/apache/cloudstack/api/command/admin/offering/CloneDiskOfferingCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class CloneDiskOfferingCmd extends CreateDiskOfferingCmd {
4242
type = BaseCmd.CommandType.UUID,
4343
entityType = DiskOfferingResponse.class,
4444
required = true,
45-
description = "The ID of the disk offering to clone")
45+
description = "The ID of the source disk offering to clone from")
4646
private Long sourceOfferingId;
4747

4848
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/command/admin/offering/CloneServiceOfferingCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class CloneServiceOfferingCmd extends CreateServiceOfferingCmd {
4141
type = CommandType.UUID,
4242
entityType = ServiceOfferingResponse.class,
4343
required = true,
44-
description = "The ID of the service offering to clone")
44+
description = "The ID of the source service offering to clone from")
4545
private Long sourceOfferingId;
4646

4747
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/command/admin/vpc/CloneVPCOfferingCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class CloneVPCOfferingCmd extends CreateVPCOfferingCmd {
4545
type = BaseCmd.CommandType.UUID,
4646
entityType = VpcOfferingResponse.class,
4747
required = true,
48-
description = "The ID of the VPC offering to clone")
48+
description = "The ID of the source VPC offering to clone from")
4949
private Long sourceOfferingId;
5050

5151
@Parameter(name = "addservices",

server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4141,6 +4141,7 @@ private static class LeaseParams {
41414141
}
41424142

41434143
@Override
4144+
@ActionEvent(eventType = EventTypes.EVENT_DISK_OFFERING_CLONE, eventDescription = "cloning disk offering")
41444145
public DiskOffering cloneDiskOffering(final CloneDiskOfferingCmd cmd) {
41454146
final long userId = CallContext.current().getCallingUserId();
41464147
final DiskOfferingVO sourceOffering = getAndValidateSourceDiskOffering(cmd.getSourceOfferingId());
@@ -8284,7 +8285,7 @@ public boolean deleteNetworkOffering(final DeleteNetworkOfferingCmd cmd) {
82848285
}
82858286

82868287
@Override
8287-
@ActionEvent(eventType = EventTypes.EVENT_NETWORK_OFFERING_CREATE, eventDescription = "cloning network offering")
8288+
@ActionEvent(eventType = EventTypes.EVENT_NETWORK_OFFERING_CLONE, eventDescription = "cloning network offering")
82888289
public NetworkOffering cloneNetworkOffering(final CloneNetworkOfferingCmd cmd) {
82898290
final Long sourceOfferingId = cmd.getSourceOfferingId();
82908291

server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,7 @@ protected void checkCapabilityPerServiceProvider(final Set<Provider> providers,
819819
}
820820

821821
@Override
822+
@ActionEvent(eventType = EventTypes.EVENT_VPC_OFFERING_CLONE, eventDescription = "cloning VPC offering")
822823
public VpcOffering cloneVPCOffering(CloneVPCOfferingCmd cmd) {
823824
Long sourceVpcOfferingId = cmd.getSourceOfferingId();
824825

server/src/main/java/org/apache/cloudstack/backup/BackupManagerImpl.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,6 @@ public BackupOffering importBackupOffering(final ImportBackupOfferingCmd cmd) {
326326
return savedOffering;
327327
}
328328

329-
@Override
330329
public List<Long> getBackupOfferingDomains(Long offeringId) {
331330
final BackupOffering backupOffering = backupOfferingDao.findById(offeringId);
332331
if (backupOffering == null) {
@@ -335,7 +334,8 @@ public List<Long> getBackupOfferingDomains(Long offeringId) {
335334
return backupOfferingDetailsDao.findDomainIds(offeringId);
336335
}
337336

338-
@ActionEvent(eventType = EventTypes.EVENT_VM_BACKUP_CLONE_OFFERING, eventDescription = "cloning backup offering", create = true)
337+
@Override
338+
@ActionEvent(eventType = EventTypes.EVENT_VM_BACKUP_OFFERING_CLONE, eventDescription = "cloning backup offering")
339339
public BackupOffering cloneBackupOffering(final CloneBackupOfferingCmd cmd) {
340340
final BackupOfferingVO sourceOffering = backupOfferingDao.findById(cmd.getSourceOfferingId());
341341
if (sourceOffering == null) {
@@ -351,23 +351,24 @@ public BackupOffering cloneBackupOffering(final CloneBackupOfferingCmd cmd) {
351351
final String description = cmd.getDescription() != null ? cmd.getDescription() : sourceOffering.getDescription();
352352
final String externalId = cmd.getExternalId() != null ? cmd.getExternalId() : sourceOffering.getExternalId();
353353
final boolean userDrivenBackups = cmd.getUserDrivenBackups() != null ? cmd.getUserDrivenBackups() : sourceOffering.isUserDrivenBackupAllowed();
354+
final Long zoneId = cmd.getZoneId() != null ? cmd.getZoneId() : sourceOffering.getZoneId();
354355

355-
if (!externalId.equals(sourceOffering.getExternalId())) {
356+
if (!Objects.equals(sourceOffering.getExternalId(), externalId)) {
356357
final BackupProvider provider = getBackupProvider(sourceOffering.getZoneId());
357358
if (!provider.isValidProviderOffering(sourceOffering.getZoneId(), externalId)) {
358359
throw new CloudRuntimeException("Backup offering '" + externalId + "' does not exist on provider " + provider.getName() + " on zone " + sourceOffering.getZoneId());
359360
}
360361
}
361362

362-
if (!externalId.equals(sourceOffering.getExternalId())) {
363+
if (!Objects.equals(sourceOffering.getExternalId(), externalId)) {
363364
final BackupOffering existingOffering = backupOfferingDao.findByExternalId(externalId, sourceOffering.getZoneId());
364365
if (existingOffering != null) {
365366
throw new CloudRuntimeException("A backup offering with external ID '" + externalId + "' already exists in this zone");
366367
}
367368
}
368369

369370
final BackupOfferingVO clonedOffering = new BackupOfferingVO(
370-
sourceOffering.getZoneId(),
371+
zoneId,
371372
externalId,
372373
sourceOffering.getProvider(),
373374
cmd.getName(),

0 commit comments

Comments
 (0)