Skip to content

Commit

Permalink
Handle exceptions while collecting vSphere object properties
Browse files Browse the repository at this point in the history
  • Loading branch information
dnaeon committed Mar 28, 2014
1 parent 90d360e commit a6aad2c
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/vpoller/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,19 @@ def datacenter_discover(self, msg):
logging.info('[%s] Discovering pyVmomi.vim.Datacenter managed objects', self.host)

# Property names to be collected
propeties = ['name']
properties = ['name']
if msg.has_key('properties') and msg['properties']:
properties.extend(msg['properties'])

# TODO: Handle exceptions
view_ref = self.get_datacenter_view()
data = self.collect_properties(
view_ref=view_ref,
obj_type=pyVmomi.vim.Datacenter,
path_set=properties
)
try:
data = self.collect_properties(
view_ref=view_ref,
obj_type=pyVmomi.vim.Datacenter,
path_set=properties
)
except Exception as e:
return { 'success': -1, 'msg': 'Cannot discover objects: %s' % e}

result = {
'success': 0,
Expand Down

0 comments on commit a6aad2c

Please sign in to comment.