Skip to content

Commit 84d8f67

Browse files
committed
Fix backup events - set resource type and id of the VM
1 parent 5893ba5 commit 84d8f67

6 files changed

Lines changed: 97 additions & 53 deletions

File tree

api/src/main/java/org/apache/cloudstack/api/command/user/backup/AssignVirtualMachineToBackupOfferingCmd.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.apache.cloudstack.acl.RoleType;
2323
import org.apache.cloudstack.api.APICommand;
24+
import org.apache.cloudstack.api.ApiCommandResourceType;
2425
import org.apache.cloudstack.api.ApiConstants;
2526
import org.apache.cloudstack.api.ApiErrorCode;
2627
import org.apache.cloudstack.api.BaseAsyncCmd;
@@ -102,6 +103,16 @@ public long getEntityOwnerId() {
102103
return CallContext.current().getCallingAccount().getId();
103104
}
104105

106+
@Override
107+
public Long getApiResourceId() {
108+
return vmId;
109+
}
110+
111+
@Override
112+
public ApiCommandResourceType getApiResourceType() {
113+
return ApiCommandResourceType.VirtualMachine;
114+
}
115+
105116
@Override
106117
public String getEventType() {
107118
return EventTypes.EVENT_VM_BACKUP_OFFERING_ASSIGN;

api/src/main/java/org/apache/cloudstack/api/command/user/backup/CreateBackupCmd.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,12 @@ public void execute() throws ResourceUnavailableException, InsufficientCapacityE
123123

124124
@Override
125125
public ApiCommandResourceType getApiResourceType() {
126-
return ApiCommandResourceType.Backup;
126+
return ApiCommandResourceType.VirtualMachine;
127+
}
128+
129+
@Override
130+
public Long getApiResourceId() {
131+
return vmId;
127132
}
128133

129134
@Override

api/src/main/java/org/apache/cloudstack/api/command/user/backup/CreateBackupScheduleCmd.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.apache.cloudstack.acl.RoleType;
2323
import org.apache.cloudstack.api.APICommand;
24+
import org.apache.cloudstack.api.ApiCommandResourceType;
2425
import org.apache.cloudstack.api.ApiConstants;
2526
import org.apache.cloudstack.api.ApiErrorCode;
2627
import org.apache.cloudstack.api.BaseCmd;
@@ -81,7 +82,7 @@ public class CreateBackupScheduleCmd extends BaseCmd {
8182
@Parameter(name = ApiConstants.QUIESCE_VM,
8283
type = CommandType.BOOLEAN,
8384
required = false,
84-
description = "Quiesce the instance before checkpointing the disks for backup. Applicable only to NAS backup provider. " +
85+
description = "Quiesce the Instance before checkpointing the disks for backup. Applicable only to NAS backup provider. " +
8586
"The filesystem is frozen before the backup starts and thawed immediately after. " +
8687
"Requires the instance to have the QEMU Guest Agent installed and running.",
8788
since = "4.21.0")
@@ -139,4 +140,14 @@ public void execute() throws ServerApiException {
139140
public long getEntityOwnerId() {
140141
return CallContext.current().getCallingAccount().getId();
141142
}
143+
144+
@Override
145+
public Long getApiResourceId() {
146+
return vmId;
147+
}
148+
149+
@Override
150+
public ApiCommandResourceType getApiResourceType() {
151+
return ApiCommandResourceType.VirtualMachine;
152+
}
142153
}

api/src/main/java/org/apache/cloudstack/api/command/user/backup/RemoveVirtualMachineFromBackupOfferingCmd.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.apache.cloudstack.acl.RoleType;
2323
import org.apache.cloudstack.api.APICommand;
24+
import org.apache.cloudstack.api.ApiCommandResourceType;
2425
import org.apache.cloudstack.api.ApiConstants;
2526
import org.apache.cloudstack.api.ApiErrorCode;
2627
import org.apache.cloudstack.api.BaseAsyncCmd;
@@ -99,6 +100,16 @@ public long getEntityOwnerId() {
99100
return CallContext.current().getCallingAccount().getId();
100101
}
101102

103+
@Override
104+
public Long getApiResourceId() {
105+
return vmId;
106+
}
107+
108+
@Override
109+
public ApiCommandResourceType getApiResourceType() {
110+
return ApiCommandResourceType.VirtualMachine;
111+
}
112+
102113
@Override
103114
public String getEventType() {
104115
return EventTypes.EVENT_VM_BACKUP_OFFERING_REMOVE;

api/src/main/java/org/apache/cloudstack/api/command/user/backup/RestoreVolumeFromBackupAndAttachToVMCmd.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.apache.cloudstack.acl.RoleType;
2323
import org.apache.cloudstack.api.ACL;
2424
import org.apache.cloudstack.api.APICommand;
25+
import org.apache.cloudstack.api.ApiCommandResourceType;
2526
import org.apache.cloudstack.api.ApiConstants;
2627
import org.apache.cloudstack.api.ApiErrorCode;
2728
import org.apache.cloudstack.api.BaseAsyncCmd;
@@ -127,4 +128,14 @@ public String getEventType() {
127128
public String getEventDescription() {
128129
return "Restoring volume "+ volumeUuid + " from backup " + getResourceUuid(ApiConstants.BACKUP_ID) + " and attaching it to Instance " + getResourceUuid(ApiConstants.VIRTUAL_MACHINE_ID);
129130
}
131+
132+
@Override
133+
public Long getApiResourceId() {
134+
return vmId;
135+
}
136+
137+
@Override
138+
public ApiCommandResourceType getApiResourceType() {
139+
return ApiCommandResourceType.VirtualMachine;
140+
}
130141
}

0 commit comments

Comments
 (0)