Skip to content

Commit 5e4c2c8

Browse files
sanjaytripathiminchen07
authored andcommitted
CLOUDSTACK-874 Ability to delete Events and Alerts
Signed-off-by: Min Chen <min.chen@citrix.com>
1 parent ae3eeca commit 5e4c2c8

17 files changed

Lines changed: 475 additions & 120 deletions

File tree

api/src/com/cloud/alert/Alert.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ public interface Alert extends Identity, InternalIdentity {
3030
Date getCreatedDate();
3131
Date getLastSent();
3232
Date getResolved();
33+
boolean getArchived();
3334
}

api/src/com/cloud/event/Event.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ public enum State {
4040
String getLevel();
4141
long getStartId();
4242
String getParameters();
43+
boolean getArchived();
4344
}

api/src/com/cloud/server/ManagementService.java

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import org.apache.cloudstack.api.command.admin.host.ListHostsCmd;
3030
import org.apache.cloudstack.api.command.admin.host.UpdateHostPasswordCmd;
3131
import org.apache.cloudstack.api.command.admin.pod.ListPodsByCmd;
32+
import org.apache.cloudstack.api.command.admin.resource.ArchiveAlertsCmd;
33+
import org.apache.cloudstack.api.command.admin.resource.DeleteAlertsCmd;
3234
import org.apache.cloudstack.api.command.admin.resource.ListAlertsCmd;
3335
import org.apache.cloudstack.api.command.admin.resource.ListCapacityCmd;
3436
import org.apache.cloudstack.api.command.admin.resource.UploadCustomCertificateCmd;
@@ -40,12 +42,12 @@
4042
import org.apache.cloudstack.api.command.admin.vlan.ListVlanIpRangesCmd;
4143
import org.apache.cloudstack.api.command.user.address.ListPublicIpAddressesCmd;
4244
import org.apache.cloudstack.api.command.user.config.ListCapabilitiesCmd;
45+
import org.apache.cloudstack.api.command.user.event.ArchiveEventsCmd;
46+
import org.apache.cloudstack.api.command.user.event.DeleteEventsCmd;
4347
import org.apache.cloudstack.api.command.user.guest.ListGuestOsCategoriesCmd;
4448
import org.apache.cloudstack.api.command.user.guest.ListGuestOsCmd;
4549
import org.apache.cloudstack.api.command.user.iso.ListIsosCmd;
4650
import org.apache.cloudstack.api.command.user.iso.UpdateIsoCmd;
47-
import org.apache.cloudstack.api.command.user.offering.ListDiskOfferingsCmd;
48-
import org.apache.cloudstack.api.command.user.offering.ListServiceOfferingsCmd;
4951
import org.apache.cloudstack.api.command.user.ssh.CreateSSHKeyPairCmd;
5052
import org.apache.cloudstack.api.command.user.ssh.DeleteSSHKeyPairCmd;
5153
import org.apache.cloudstack.api.command.user.ssh.ListSSHKeyPairsCmd;
@@ -55,12 +57,10 @@
5557
import org.apache.cloudstack.api.command.user.vm.GetVMPasswordCmd;
5658
import org.apache.cloudstack.api.command.user.vmgroup.UpdateVMGroupCmd;
5759
import org.apache.cloudstack.api.command.user.volume.ExtractVolumeCmd;
58-
import org.apache.cloudstack.api.command.user.zone.ListZonesByCmd;
5960

6061
import com.cloud.alert.Alert;
6162
import com.cloud.capacity.Capacity;
6263
import com.cloud.configuration.Configuration;
63-
import com.cloud.dc.DataCenter;
6464
import com.cloud.dc.Pod;
6565
import com.cloud.dc.Vlan;
6666
import com.cloud.domain.Domain;
@@ -72,8 +72,6 @@
7272
import com.cloud.hypervisor.Hypervisor.HypervisorType;
7373
import com.cloud.hypervisor.HypervisorCapabilities;
7474
import com.cloud.network.IpAddress;
75-
import com.cloud.offering.DiskOffering;
76-
import com.cloud.offering.ServiceOffering;
7775
import com.cloud.org.Cluster;
7876
import com.cloud.storage.GuestOS;
7977
import com.cloud.storage.GuestOsCategory;
@@ -194,6 +192,34 @@ public interface ManagementService {
194192
*/
195193
Pair<List<? extends Alert>, Integer> searchForAlerts(ListAlertsCmd cmd);
196194

195+
/**
196+
* Archive alerts
197+
* @param cmd
198+
* @return True on success. False otherwise.
199+
*/
200+
boolean archiveAlerts(ArchiveAlertsCmd cmd);
201+
202+
/**
203+
* Delete alerts
204+
* @param cmd
205+
* @return True on success. False otherwise.
206+
*/
207+
boolean deleteAlerts(DeleteAlertsCmd cmd);
208+
209+
/**
210+
* Archive events
211+
* @param cmd
212+
* @return True on success. False otherwise.
213+
*/
214+
boolean archiveEvents(ArchiveEventsCmd cmd);
215+
216+
/**
217+
* Delete events
218+
* @param cmd
219+
* @return True on success. False otherwise.
220+
*/
221+
boolean deleteEvents(DeleteEventsCmd cmd);
222+
197223
/**
198224
* list all the capacity rows in capacity operations table
199225
*

api/src/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ public class ApiConstants {
459459
public static final String UCS_BLADE_DN = "bladedn";
460460
public static final String UCS_BLADE_ID = "bladeid";
461461
public static final String VM_GUEST_IP = "vmguestip";
462+
public static final String OLDER_THAN = "olderthan";
462463

463464
public enum HostDetails {
464465
all, capacity, events, stats, min;

client/tomcatconf/commands.properties.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,13 @@ listZones=15
218218
#### events commands
219219
listEvents=15
220220
listEventTypes=15
221+
archiveEvents=15
222+
deleteEvents=15
221223

222224
#### alerts commands
223225
listAlerts=3
226+
archiveAlerts=1
227+
deleteAlerts=1
224228

225229
#### system capacity commands
226230
listCapacity=3

core/src/com/cloud/alert/AlertVO.java

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@
2828
import javax.persistence.Temporal;
2929
import javax.persistence.TemporalType;
3030

31-
import org.apache.cloudstack.api.Identity;
3231
import com.cloud.utils.db.GenericDao;
33-
import org.apache.cloudstack.api.InternalIdentity;
3432

3533
@Entity
3634
@Table(name="alert")
@@ -68,16 +66,19 @@ public class AlertVO implements Alert {
6866
@Temporal(TemporalType.TIMESTAMP)
6967
@Column(name="resolved", updatable=true, nullable=true)
7068
private Date resolved;
71-
69+
7270
@Column(name="uuid")
7371
private String uuid;
7472

73+
@Column(name="archived")
74+
private boolean archived;
75+
7576
public AlertVO() {
76-
this.uuid = UUID.randomUUID().toString();
77+
this.uuid = UUID.randomUUID().toString();
7778
}
7879
public AlertVO(Long id) {
7980
this.id = id;
80-
this.uuid = UUID.randomUUID().toString();
81+
this.uuid = UUID.randomUUID().toString();
8182
}
8283

8384
@Override
@@ -103,12 +104,12 @@ public void setSubject(String subject) {
103104
}
104105

105106
public Long getClusterId() {
106-
return clusterId;
107-
}
108-
public void setClusterId(Long clusterId) {
109-
this.clusterId = clusterId;
110-
}
111-
@Override
107+
return clusterId;
108+
}
109+
public void setClusterId(Long clusterId) {
110+
this.clusterId = clusterId;
111+
}
112+
@Override
112113
public Long getPodId() {
113114
return podId;
114115
}
@@ -164,10 +165,19 @@ public void setResolved(Date resolved) {
164165

165166
@Override
166167
public String getUuid() {
167-
return this.uuid;
168+
return this.uuid;
168169
}
169-
170+
170171
public void setUuid(String uuid) {
171-
this.uuid = uuid;
172+
this.uuid = uuid;
173+
}
174+
175+
@Override
176+
public boolean getArchived() {
177+
return archived;
178+
}
179+
180+
public void setArchived(Boolean archived) {
181+
this.archived = archived;
172182
}
173183
}

0 commit comments

Comments
 (0)