From 379e1a49cb225c9e04a2a6c2236d8c16baa727d2 Mon Sep 17 00:00:00 2001 From: dewey hylton Date: Mon, 30 Jun 2014 17:23:55 -0400 Subject: [PATCH] fix swap translation on 4.x openbsd with 2.5.4 python --- lib/ansible/module_utils/facts.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index 9515bd1fffe..bb559ba8517 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -31,6 +31,8 @@ import getpass import ConfigParser import StringIO +from string import maketrans + try: import selinux HAVE_SELINUX=True @@ -910,9 +912,10 @@ class OpenBSDHardware(Hardware): # total: 69268k bytes allocated = 0k used, 69268k available rc, out, err = module.run_command("/sbin/swapctl -sk") if rc == 0: + swaptrans = maketrans(' ', ' ') data = out.split() - self.facts['swapfree_mb'] = long(data[-2].translate(None, "kmg")) / 1024 - self.facts['swaptotal_mb'] = long(data[1].translate(None, "kmg")) / 1024 + self.facts['swapfree_mb'] = long(data[-2].translate(swaptrans, "kmg")) / 1024 + self.facts['swaptotal_mb'] = long(data[1].translate(swaptrans, "kmg")) / 1024 def get_processor_facts(self): processor = []