Change use of subprocess lib for calculating system capacity

Suggested by Ryan Petrello as a part of the PR feedback
for the isolated instance setup work.
This commit is contained in:
AlanCoding
2017-06-19 12:05:26 -04:00
parent 1d9f2be0e4
commit 7eb8fdd0f1
2 changed files with 10 additions and 4 deletions

View File

@@ -25,8 +25,11 @@ def main():
argument_spec = dict()
)
# Duplicated with awx.main.utils.common.get_system_task_capacity
proc = subprocess.Popen(['free', '-m'], stdout=subprocess.PIPE)
out,err = proc.communicate()
try:
out = subprocess.check_output(['free', '-m'])
except subprocess.CalledProcessError as e:
module.fail_json(msg=str(e))
return
total_mem_value = out.split()[7]
if int(total_mem_value) <= 2048:
cap = 50