Oved Ourfali has uploaded a new change for review.

Change subject: core: adding remote console related events
......................................................................

core: adding remote console related events

When users connect to the console, no event notification is available to
specify that it happened.

This patch adds two events:
1. SetVmTicket event - when the user initiated the session
2. ClientIp changed event - when the user connects (this event requires
having a guest agent installed on the guest)

Change-Id: Id345f413f83d82ef3a14fa35c1be7b65699d3298
Bug-Url: https://bugzilla.redhat.com/1039862
Signed-off-by: Oved Ourfali <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsEventListener.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcEventNotificationUtils.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
M 
backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
M 
frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
M 
frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
A packaging/dbscripts/upgrade/03_04_0180_add_console_events.sql
8 files changed, 30 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/23/22223/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsEventListener.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsEventListener.java
index 30e492b..8ca91c2 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsEventListener.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsEventListener.java
@@ -195,11 +195,18 @@
     @Override
     public void processOnClientIpChange(final VDS vds, final Guid vmId) {
         final VmDynamic vmDynamic = 
DbFacade.getInstance().getVmDynamicDao().get(vmId);
+        final AuditLogableBase event = new AuditLogableBase();
+        event.setVmId(vmId);
+        event.setUserName(vmDynamic.getConsoleCurrentUserName());
+
         // in case of empty clientIp we clear the logged in user.
         // (this happened when user close the console to spice/vnc)
         if (StringUtils.isEmpty(vmDynamic.getClientIp())) {
             vmDynamic.setConsoleCurrentUserName(null);
             DbFacade.getInstance().getVmDynamicDao().update(vmDynamic);
+            AuditLogDirector.log(event, AuditLogType.VM_CONSOLE_DISCONNECTED);
+        } else {
+            AuditLogDirector.log(event, AuditLogType.VM_CONSOLE_CONNECTED);
         }
     }
 
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
index 18b5dfe..a678403 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
@@ -386,6 +386,8 @@
     VM_STATUS_RESTORED(163),
     VM_SET_TICKET(164),
     VM_SET_TICKET_FAILED(165),
+    VM_CONSOLE_CONNECTED(167),
+    VM_CONSOLE_DISCONNECTED(168),
 
     VM_MIGRATION_FAILED_DURING_MOVE_TO_MAINTENANCE(140),
     VM_SET_TO_UNKNOWN_STATUS(142),
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcEventNotificationUtils.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcEventNotificationUtils.java
index 0349cc9..b653142 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcEventNotificationUtils.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcEventNotificationUtils.java
@@ -42,6 +42,10 @@
         AddEventNotificationEntry(EventNotificationEntity.Vm, 
AuditLogType.VM_STATUS_RESTORED);
         AddEventNotificationEntry(EventNotificationEntity.Vm, 
AuditLogType.HA_VM_RESTART_FAILED);
         AddEventNotificationEntry(EventNotificationEntity.Vm, 
AuditLogType.HA_VM_FAILED);
+        AddEventNotificationEntry(EventNotificationEntity.Vm, 
AuditLogType.VM_CONSOLE_CONNECTED);
+        AddEventNotificationEntry(EventNotificationEntity.Vm, 
AuditLogType.VM_CONSOLE_DISCONNECTED);
+        AddEventNotificationEntry(EventNotificationEntity.Vm, 
AuditLogType.VM_SET_TICKET);
+
         // IRS
         AddEventNotificationEntry(EventNotificationEntity.Storage, 
AuditLogType.VDS_SLOW_STORAGE_RESPONSE_TIME);
         AddEventNotificationEntry(EventNotificationEntity.Storage, 
AuditLogType.IRS_FAILURE);
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
index d264e89..a07af4d 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
@@ -661,6 +661,8 @@
         severities.put(AuditLogType.VM_SET_TICKET, AuditLogSeverity.NORMAL);
         severities.put(AuditLogType.VM_SET_TICKET_FAILED, 
AuditLogSeverity.ERROR);
         severities.put(AuditLogType.ADD_VM_FROM_SNAPSHOT_INVALID_INTERFACES, 
AuditLogSeverity.WARNING);
+        severities.put(AuditLogType.VM_CONSOLE_CONNECTED, 
AuditLogSeverity.NORMAL);
+        severities.put(AuditLogType.VM_CONSOLE_DISCONNECTED, 
AuditLogSeverity.NORMAL);
     }
 
     private static void initClusterSeverities() {
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
index 75bd170..c4f8083 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -706,3 +706,5 @@
 DISK_ALIGNMENT_SCAN_FAILURE=Alignment scan of disk '${DiskAlias}' failed.
 DISK_ALIGNMENT_SCAN_SUCCESS=Alignment scan of disk '${DiskAlias}' is complete.
 VM_MEMORY_NOT_IN_RECOMMENDED_RANGE=VM ${VmName} was configured with 
${VmMemInMb}mb of memory while the recommended value range is ${VmMinMemInMb}mb 
- ${VmMaxMemInMb}mb
+VM_CONSOLE_CONNECTED=User ${UserName} is connected to VM ${VmName}.
+VM_CONSOLE_DISCONNECTED=User ${UserName} got disconnected from VM ${VmName}.
diff --git 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
index 1a3bbd9..e349b11 100644
--- 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
+++ 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
@@ -843,6 +843,12 @@
 
     String AuditLogType___USER_UPDATE_VM_TEMPLATE_FROM_UNTRUSTED_TO_TRUSTED();
 
+    String AuditLogType___VM_CONSOLE_CONNECTED();
+
+    String AuditLogType___VM_CONSOLE_DISCONNECTED();
+
+    String AuditLogType___VM_SET_TICKET();
+
     String UnitVmModel$CpuSharesAmount___DISABLED();
 
     String UnitVmModel$CpuSharesAmount___HIGH();
diff --git 
a/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
 
b/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
index 5446f53..40e7ef5 100644
--- 
a/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
+++ 
b/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
@@ -419,6 +419,9 @@
 AuditLogType___USER_ADD_VM_TEMPLATE_FROM_UNTRUSTED_TO_TRUSTED=A trusted 
Template was created from non-trusted VM
 AuditLogType___USER_UPDATE_VM_TEMPLATE_FROM_TRUSTED_TO_UNTRUSTED=Template 
moved from trusted cluster to non-trusted cluster
 AuditLogType___USER_UPDATE_VM_TEMPLATE_FROM_UNTRUSTED_TO_TRUSTED=Template 
moved from non-trusted cluster to trusted cluster
+AuditLogType___VM_CONSOLE_CONNECTED=VM console connected
+AuditLogType___VM_CONSOLE_DISCONNECTED=VM console disconnected
+AuditLogType___VM_SET_TICKET=VM console session initiated
 UnitVmModel$CpuSharesAmount___DISABLED=Disabled
 UnitVmModel$CpuSharesAmount___HIGH=High
 UnitVmModel$CpuSharesAmount___MEDIUM=Medium
diff --git a/packaging/dbscripts/upgrade/03_04_0180_add_console_events.sql 
b/packaging/dbscripts/upgrade/03_04_0180_add_console_events.sql
new file mode 100644
index 0000000..d96a54c
--- /dev/null
+++ b/packaging/dbscripts/upgrade/03_04_0180_add_console_events.sql
@@ -0,0 +1,4 @@
+-- Add new notifications
+insert into event_map(event_up_name, event_down_name) 
values('VM_CONSOLE_CONNECTED', '');
+insert into event_map(event_up_name, event_down_name) 
values('VM_CONSOLE_DISCONNECTED', '');
+insert into event_map(event_up_name, event_down_name) values('VM_SET_TICKET', 
'');


-- 
To view, visit http://gerrit.ovirt.org/22223
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id345f413f83d82ef3a14fa35c1be7b65699d3298
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Oved Ourfali <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to