Skip to content

Commit

Permalink
Add 'datastore.discover' method for discovering Datastore managed obj…
Browse files Browse the repository at this point in the history
…ects
  • Loading branch information
dnaeon committed Mar 29, 2014
1 parent fdd5bff commit 326eec4
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 @@ -252,3 +252,36 @@ def vm_discover(self, msg):
properties.extend(msg['properties'])

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

def datastore_discover(self, msg):
"""
Discover all pyVmomi.vim.Datastore managed objects
Example client message would be:
{
"method": "datastore.discover",
"hostname": "vc01.example.org",
}
Example client message which also requests additional properties:
{
"method": "datastore.discover",
"hostname": "vc01.example.org",
"properties": [
"name",
"summary.url"
]
}
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.Datastore)
4 changes: 4 additions & 0 deletions src/vpoller/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ def process_client_msg(self, msg):
'method': self.agents[vsphere_host].vm_discover,
'msg_attr': ('method', 'hostname'),
},
'datastore.discover': {
'method': self.agents[vsphere_host].datastore_discover,
'msg_attr': ('method', 'hostname'),
},
}

if msg['method'] not in methods:
Expand Down

0 comments on commit 326eec4

Please sign in to comment.