SDN Controller Programming Guide
185
Figure 60 Alerts View
Auditing with Logs
In order to illustrate how audit logs may be posted using the AuditLogService published by the
controller, SwitchManager of the sample application will post an audit log when a device is
added. See Audit Logging on page 18 to get more information.
The AuditLogService dependency must be added as any other service to consume; see Consuming
Services with OSGi Declarative Services on page 134. The following listings illustrates an extract
of a modified SwitchManager that posts audit logs.
SwitchManager.java Posting Audit Logs:
package com.hp.hm.impl;
import com.hp.sdn.adm.auditlog.AuditLogService;
...
public class SwitchManager implements SwitchService {
...
private AuditLogService auditLogService;
...
public void setAuditLogService(AuditLogService auditLogService) {
this.auditLogService = auditLogService;
}
@Override
public Switch add(Switch device) {
...
devices.put(deviceToAdd.getId(), deviceToAdd);
if (auditLogService != null) {