Skip to content
This repository has been archived by the owner on Jul 23, 2018. It is now read-only.

Commit

Permalink
Refs #15. Manage disconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
rverchere committed Sep 10, 2017
1 parent db38caf commit 4395c7f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions vmware_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def collect(self, target=None, section='default'):
labels=['host_name']),
}

print("[{0}] Start collecting vcenter metrics for {1}".format(datetime.utcnow().replace(tzinfo=pytz.utc), target))
print("[{0}] Start collecting vmware metrics for {1}".format(datetime.utcnow().replace(tzinfo=pytz.utc), target))

self.si = self._vmware_connect(target, section)
if not self.si:
Expand Down Expand Up @@ -192,9 +192,9 @@ def collect(self, target=None, section='default'):
# Fill Hosts Informations
self._vmware_get_hosts(content, metrics)

print("[{0}] Stop collecting vcenter metrics for {1}".format(datetime.utcnow().replace(tzinfo=pytz.utc), target))
print("[{0}] Stop collecting vmware metrics for {1}".format(datetime.utcnow().replace(tzinfo=pytz.utc), target))

self._vmware_disconnect()
self._vmware_disconnect(self.si)

for metricname, metric in metrics.items():
yield metric
Expand Down Expand Up @@ -224,7 +224,7 @@ def _vmware_get_obj(self, content, vimtype, name=None):

def _vmware_connect(self, target, section):
"""
Connect to Vcenter and get connection
Connect to VMWare and get connection
"""

context = None
Expand All @@ -244,11 +244,11 @@ def _vmware_connect(self, target, section):
print("Caught vmodl fault: " + error.msg)
return None

def _vmware_disconnect(self):
def _vmware_disconnect(self, si):
"""
Disconnect from Vcenter
Disconnect from VMWare
"""
connect.Disconnect(self.si)
connect.Disconnect(si)

def _vmware_perf_metrics(self, content):
# create a mapping from performance stats to their counterIDs
Expand Down

0 comments on commit 4395c7f

Please sign in to comment.