haproxy: Fix compatibility when map is actually imap. (#3350)

While I still have no idea why or how the `map` call is being swapped out while still running in python 2.7, this change will fix the following error, as well as improve py3 compatibility.
This commit is contained in:
Christophe Biocca 2016-11-09 16:42:27 -05:00 committed by Matt Clay
parent b3795322e9
commit 55130b960b

View file

@ -211,7 +211,7 @@ class HAProxy(object):
""" """
data = self.execute('show stat', 200, False).lstrip('# ') data = self.execute('show stat', 200, False).lstrip('# ')
r = csv.DictReader(data.splitlines()) r = csv.DictReader(data.splitlines())
return map(lambda d: d['pxname'], filter(lambda d: d['svname'] == 'BACKEND', r)) return tuple(map(lambda d: d['pxname'], filter(lambda d: d['svname'] == 'BACKEND', r)))
def execute_for_backends(self, cmd, pxname, svname, wait_for_status = None): def execute_for_backends(self, cmd, pxname, svname, wait_for_status = None):
@ -244,7 +244,7 @@ class HAProxy(object):
""" """
data = self.execute('show stat', 200, False).lstrip('# ') data = self.execute('show stat', 200, False).lstrip('# ')
r = csv.DictReader(data.splitlines()) r = csv.DictReader(data.splitlines())
state = map(lambda d: { 'status': d['status'], 'weight': d['weight'] }, filter(lambda d: (pxname is None or d['pxname'] == pxname) and d['svname'] == svname, r)) state = tuple(map(lambda d: { 'status': d['status'], 'weight': d['weight'] }, filter(lambda d: (pxname is None or d['pxname'] == pxname) and d['svname'] == svname, r)))
return state or None return state or None