Skip to content

Commit 0df7f8d

Browse files
committed
Added events to add/update backup repository
1 parent 7449646 commit 0df7f8d

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.apache.cloudstack.api.response.HostResponse;
2828
import org.apache.cloudstack.api.response.PodResponse;
2929
import org.apache.cloudstack.api.response.ZoneResponse;
30+
import org.apache.cloudstack.backup.BackupRepositoryService;
3031
import org.apache.cloudstack.config.Configuration;
3132
import org.apache.cloudstack.datacenter.DataCenterIpv4GuestSubnet;
3233
import org.apache.cloudstack.extension.Extension;
@@ -852,6 +853,10 @@ public class EventTypes {
852853
// Custom Action
853854
public static final String EVENT_CUSTOM_ACTION = "CUSTOM.ACTION";
854855

856+
// Backup Repository
857+
public static final String EVENT_BACKUP_REPOSITORY_ADD = "BACKUP.REPOSITORY.ADD";
858+
public static final String EVENT_BACKUP_REPOSITORY_UPDATE = "BACKUP.REPOSITORY.UPDATE";
859+
855860
static {
856861

857862
// TODO: need a way to force author adding event types to declare the entity details as well, with out braking
@@ -1385,6 +1390,10 @@ public class EventTypes {
13851390
entityEventDetails.put(EVENT_EXTENSION_CUSTOM_ACTION_ADD, ExtensionCustomAction.class);
13861391
entityEventDetails.put(EVENT_EXTENSION_CUSTOM_ACTION_UPDATE, ExtensionCustomAction.class);
13871392
entityEventDetails.put(EVENT_EXTENSION_CUSTOM_ACTION_DELETE, ExtensionCustomAction.class);
1393+
1394+
// Backup Repository
1395+
entityEventDetails.put(EVENT_BACKUP_REPOSITORY_ADD, BackupRepositoryService.class);
1396+
entityEventDetails.put(EVENT_BACKUP_REPOSITORY_UPDATE, BackupRepositoryService.class);
13881397
}
13891398

13901399
public static boolean isNetworkEvent(String eventType) {

plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRestoreBackupCommandWrapperTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,4 +496,4 @@ public void testExecuteWithMultipleVolumes() throws Exception {
496496
}
497497
}
498498
}
499-
}
499+
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
package org.apache.cloudstack.backup;
2121

22+
import com.cloud.event.ActionEvent;
23+
import com.cloud.event.EventTypes;
2224
import com.cloud.user.AccountManager;
2325
import com.cloud.utils.Pair;
2426
import com.cloud.utils.component.ManagerBase;
@@ -52,13 +54,15 @@ public class BackupRepositoryServiceImpl extends ManagerBase implements BackupRe
5254
private AccountManager accountManager;
5355

5456
@Override
57+
@ActionEvent(eventType = EventTypes.EVENT_BACKUP_REPOSITORY_ADD, eventDescription = "add backup repository")
5558
public BackupRepository addBackupRepository(AddBackupRepositoryCmd cmd) {
5659
BackupRepositoryVO repository = new BackupRepositoryVO(cmd.getZoneId(), cmd.getProvider(), cmd.getName(),
5760
cmd.getType(), cmd.getAddress(), cmd.getMountOptions(), cmd.getCapacityBytes(), cmd.isDraasEnabled());
5861
return repositoryDao.persist(repository);
5962
}
6063

6164
@Override
65+
@ActionEvent(eventType = EventTypes.EVENT_BACKUP_REPOSITORY_UPDATE, eventDescription = "update backup repository")
6266
public BackupRepository updateBackupRepository(UpdateBackupRepositoryCmd cmd) {
6367
Long id = cmd.getId();
6468
String name = cmd.getName();
@@ -99,7 +103,7 @@ public BackupRepository updateBackupRepository(UpdateBackupRepositoryCmd cmd) {
99103

100104
BackupRepositoryVO repositoryVO = repositoryDao.findById(id);
101105
CallContext.current().setEventDetails(String.format("Backup Repository updated [%s].",
102-
ReflectionToStringBuilderUtils.reflectOnlySelectedFields(repositoryVO, "id", "name", "description", "userDrivenBackupAllowed", "externalId")));
106+
ReflectionToStringBuilderUtils.reflectOnlySelectedFields(repositoryVO, "id", "name", "description", "userDrivenBackupAllowed", "externalId", "draasEnabled")));
103107
return repositoryVO;
104108
}
105109

0 commit comments

Comments
 (0)