Skip to content

Commit

Permalink
Destroy Views when no longer needed
Browse files Browse the repository at this point in the history
  • Loading branch information
dnaeon committed Apr 5, 2014
1 parent d931f77 commit 159fd91
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/vpoller/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ def _discover_objects(self, properties, obj_type):
except Exception as e:
return { 'success': 1, 'msg': 'Cannot collect properties: %s' % e }

view_ref.DestroyView()

result = {
'success': 0,
'msg': 'Successfully discovered objects',
Expand Down Expand Up @@ -144,6 +146,8 @@ def _get_object_properties(self, properties, obj_type, obj_property_name, obj_pr
except Exception as e:
return { 'success': 1, 'msg': 'Cannot collect properties: %s' % e }

view_ref.DestroyView()

result = {
'success': 0,
'msg': 'Successfully retrieved object properties',
Expand Down Expand Up @@ -201,6 +205,8 @@ def _object_datastore_get(self, obj_type, name):
path_set=['name', 'info.url']
)

view_ref.DestroyView()

r = {
'success': 0,
'msg': 'Successfully discovered objects',
Expand Down Expand Up @@ -390,6 +396,8 @@ def net_host_get(self, msg):
path_set=['name']
)

view_ref.DestroyView()

r = {
'success': 0,
'msg': 'Successfully discovered objects',
Expand Down Expand Up @@ -442,6 +450,8 @@ def net_vm_get(self, msg):
path_set=['name']
)

view_ref.DestroyView()

r = {
'success': 0,
'msg': 'Successfully discovered objects',
Expand Down Expand Up @@ -756,6 +766,8 @@ def host_vm_get(self, msg):
path_set=['name']
)

view_ref.DestroyView()

r = {
'success': 0,
'msg': 'Successfully discovered objects',
Expand Down Expand Up @@ -808,6 +820,8 @@ def host_net_get(self, msg):
path_set=['name']
)

view_ref.DestroyView()

r = {
'success': 0,
'msg': 'Successfully discovered objects',
Expand Down Expand Up @@ -1053,6 +1067,8 @@ def vm_net_get(self, msg):
path_set=['name']
)

view_ref.DestroyView()

r = {
'success': 0,
'msg': 'Successfully discovered objects',
Expand Down
6 changes: 6 additions & 0 deletions src/vpoller/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ def get_container_view(self, obj_type, container=None):
"""
Get a vSphere Container View reference to all objects of type 'obj_type'
It is up to the caller to take care of destroying the View when no longer needed.
Args:
obj_type (list): A list of managed object types
Expand All @@ -242,6 +244,8 @@ def get_list_view(self, obj):
"""
Get a vSphere List View reference
It is up to the caller to take care of destroying the View when no longer needed.
Args:
obj (list): A list of managed object to include in the List View
Expand Down Expand Up @@ -277,6 +281,8 @@ def get_object_by_property(self, property_name, property_value, obj_type):
include_mors=True
)

view_ref.DestroyView()

for each_obj in props:
if each_obj[property_name] == property_value:
return each_obj['obj']
Expand Down

0 comments on commit 159fd91

Please sign in to comment.