Skip to content

Commit

Permalink
Add a method for retrieving all managed objects
Browse files Browse the repository at this point in the history
  • Loading branch information
dnaeon committed Mar 27, 2014
1 parent c7353cf commit 67da45a
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/vpoller/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def connect(self):
)
except Exception as e:
raise VConnectorException, 'Cannot connect to %s: %s' % (self.host, e)

def disconnect(self):
"""
Disconnect from the VMware vSphere host
Expand Down Expand Up @@ -138,3 +138,26 @@ def get_capability(self):
"""
return self.capability

def _get_all_objects(self, obj_type):
"""
Get all managed objects of type 'obj_type'
Args:
obj_type (list): A list of managed object types
Returns:
A list of managed objects
"""
view_ref = self.si.content.viewManager.CreateContainerView(
container=self.si.content.rootFolder,
type=obj_type,
recursive=True
)

result = view_ref.view
view_ref.DestroyView()

return result

0 comments on commit 67da45a

Please sign in to comment.