Skip to content

Commit

Permalink
Add 'resource.pool.get' method for retrieving properties of a single
Browse files Browse the repository at this point in the history
ResourcePool managed object
  • Loading branch information
dnaeon committed Mar 30, 2014
1 parent 5e06694 commit ca13bbd
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
38 changes: 36 additions & 2 deletions src/vpoller/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def cluster_get(self, msg):
Example client message would be:
{
"method": "datacenter.get",
"method": "cluster.get",
"hostname": "vc01.example.org",
"name": "MyCluster",
"properties": [
Expand Down Expand Up @@ -313,7 +313,41 @@ def resource_pool_discover(self, msg):
properties.extend(msg['properties'])

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


def resource_pool_get(self, msg):
"""
Get properties of a single pyVmomi.vim.ResourcePool managed object
Example client message would be:
{
"method": "resource.pool.get",
"hostname": "vc01.example.org",
"name": "MyResourcePool",
"properties": [
"name",
"runtime.cpu",
"runtime.memory",
"runtime.overallStatus"
]
}
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.ResourcePool,
obj_property_name='name',
obj_property_value=msg['name']
)

def host_discover(self, msg):
"""
Discover all pyVmomi.vim.HostSystem 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 @@ -310,6 +310,10 @@ def process_client_msg(self, msg):
'method': self.agents[vsphere_host].resource_pool_discover,
'msg_attr': ('method', 'hostname'),
},
'resource.pool.get': {
'method': self.agents[vsphere_host].resource_pool_get,
'msg_attr': ('method', 'hostname', 'name', 'properties'),
},
'host.discover': {
'method': self.agents[vsphere_host].host_discover,
'msg_attr': ('method', 'hostname'),
Expand Down

0 comments on commit ca13bbd

Please sign in to comment.