The
EventManager.EventEx method allows
you to create an event that contains an arbitrary dictionary of key-value
pairs. This kind of custom event allows greater flexibility to store
application data that is not associated with a managed entity, and is not
limited to a single string value. The custom event structure also contains more
sophisticated metadata than user log events.
The following steps show pseudocode examples of
the operations you need to do in your client code.
Procedure
-
Obtain the managed object reference to the
EventManager.
si = connection.retrieveServiceContent(svc_ref);
em = si.eventManager;
-
Choose a severity for the custom event.
severity = EventEventSeverity.warning;
-
Create a local copy of an extended event
with metadata.
e = vim.event.EventEx(severity,
eventTypeId=”com.example.events.Total_System_Backup”,
createdTime = si.CurrentTime(),
chainId=0,
key=0,
userName=local_account_name);
-
Create a set of key-value pairs to store the
information you want to associate with the event.
arg_list = {};
arg1 = vmodl.KeyAnyValue(key=”reason”, value=”Upcoming governance audit”);
arg2 = vmodl.KeyAnyValue(key=”datacenter”, value=”Washington South”);
arg3 = vmodl.KeyAnyValue(key=”organization”, value=”IT Cloud Services”);
arg_list.append(arg1, arg2, arg3);
-
Add the set of key-value pairs to the event
object.
-
Use the Event Manager to post the event to
the server.