Skip to content

Commit

Permalink
Add 'net.discover' method for discovering all vim.Network managed obj…
Browse files Browse the repository at this point in the history
…ects
  • Loading branch information
dnaeon committed Apr 2, 2014
1 parent 9b42e0a commit 4870ee5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/vpoller/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,39 @@ def about(self, msg):

return result

def net_discover(self, msg):
"""
Discover all pyVmomi.vim.Network managed objects
Example client message would be:
{
"method": "net.discover",
"hostname": "vc01.example.org",
}
Example client message which also requests additional properties:
{
"method": "net.discover",
"hostname": "vc01.example.org",
"properties": [
"name",
"summary.accessible"
]
}
Returns:
The discovered objects in JSON format
"""
# Property names to be collected
properties = ['name']
if msg.has_key('properties') and msg['properties']:
properties.extend(msg['properties'])

return self._discover_objects(properties=properties, obj_type=pyVmomi.vim.Network)

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 @@ -306,6 +306,10 @@ def process_client_msg(self, msg):
'method': self.agents[vsphere_host].event_latest,
'msg_attr': ('method', 'hostname'),
},
'net.discover': {
'method': self.agents[vsphere_host].net_discover,
'msg_attr': ('method', 'hostname'),
},
'datacenter.discover': {
'method': self.agents[vsphere_host].datacenter_discover,
'msg_attr': ('method', 'hostname'),
Expand Down

0 comments on commit 4870ee5

Please sign in to comment.