Skip to content

Commit

Permalink
Add 'datastore.get' method for retrieving properties of a single
Browse files Browse the repository at this point in the history
Datastore managed object
  • Loading branch information
dnaeon committed Mar 30, 2014
1 parent ca13bbd commit aac6b38
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 @@ -510,3 +510,36 @@ def datastore_discover(self, msg):
properties.extend(msg['properties'])

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

def datastore_get(self, msg):
"""
Get properties of a single pyVmomi.vim.Datastore managed object
Example client message would be:
{
"method": "datastore.get",
"hostname": "vc01.example.org",
"name": "ds:///vmfs/volumes/643f118a-a970df28/",
"properties": [
"name",
"summary.accessible",
"summary.capacity"
]
}
Returns:
The managed object properties in JSON format
"""
# Property names to be collected
properties = ['name']
if msg.has_key('properties') and msg['properties']:
properties.extend(msg['properties'])

return self._get_object_properties(
properties=properties,
obj_type=pyVmomi.vim.Datastore,
obj_property_name='name',
obj_property_value=msg['name']
)
4 changes: 4 additions & 0 deletions src/vpoller/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,10 @@ def process_client_msg(self, msg):
'method': self.agents[vsphere_host].datastore_discover,
'msg_attr': ('method', 'hostname'),
},
'datastore.get': {
'method': self.agents[vsphere_host].datastore_get,
'msg_attr': ('method', 'hostname', 'name', 'properties'),
},
}

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

0 comments on commit aac6b38

Please sign in to comment.