Skip to content

Commit

Permalink
Add 'event.latest' method for retrieving the latest event from a vSph…
Browse files Browse the repository at this point in the history
…ere hostx
  • Loading branch information
dnaeon committed Mar 31, 2014
1 parent 63a7515 commit e319aa6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/vpoller/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,29 @@ def _get_object_properties(self, properties, obj_type, obj_property_name, obj_pr

return result

def event_latest(self, msg):
"""
Get the latest event registered
Example client message would be:
{
"method": "event.latest",
"hostname": "vc01.example.org",
}
Returns:
The discovered objects in JSON format
"""
result = {
'msg': 'Successfully retrieved event',
'success': 0,
'result': self.si.content.eventManager.latestEvent.fullFormattedMessage,
}

return result

def datacenter_discover(self, msg):
"""
Discover all pyVmomi.vim.Datacenter managed objects
Expand Down
4 changes: 4 additions & 0 deletions src/vpoller/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ def process_client_msg(self, msg):
# tuple/list of required attributes the message must have in order for this
# request to be passed to and processed by the vSphere Agent
methods = {
'event.latest': {
'method': self.agents[vsphere_host].event_latest,
'msg_attr': ('method', 'hostname'),
},
'datacenter.discover': {
'method': self.agents[vsphere_host].datacenter_discover,
'msg_attr': ('method', 'hostname'),
Expand Down

0 comments on commit e319aa6

Please sign in to comment.