mirror of
https://github.com/ansible/awx.git
synced 2026-05-17 14:27:42 -02:30
Make get_system_task_capacity portable
Signed-off-by: Steve Wills <steve@mouf.net>
This commit is contained in:
@@ -17,6 +17,7 @@ import threading
|
|||||||
import contextlib
|
import contextlib
|
||||||
import tempfile
|
import tempfile
|
||||||
import six
|
import six
|
||||||
|
import psutil
|
||||||
|
|
||||||
# Decorator
|
# Decorator
|
||||||
from decorator import decorator
|
from decorator import decorator
|
||||||
@@ -581,12 +582,8 @@ def get_system_task_capacity():
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
if hasattr(settings, 'SYSTEM_TASK_CAPACITY'):
|
if hasattr(settings, 'SYSTEM_TASK_CAPACITY'):
|
||||||
return settings.SYSTEM_TASK_CAPACITY
|
return settings.SYSTEM_TASK_CAPACITY
|
||||||
try:
|
mem = psutil.virtual_memory()
|
||||||
out = subprocess.check_output(['free', '-m'])
|
total_mem_value = mem.total/1024/1024
|
||||||
except subprocess.CalledProcessError:
|
|
||||||
logger.exception('Problem obtaining capacity from system.')
|
|
||||||
return 0
|
|
||||||
total_mem_value = out.split()[7]
|
|
||||||
if int(total_mem_value) <= 2048:
|
if int(total_mem_value) <= 2048:
|
||||||
return 50
|
return 50
|
||||||
return 50 + ((int(total_mem_value) / 1024) - 2) * 75
|
return 50 + ((int(total_mem_value) / 1024) - 2) * 75
|
||||||
|
|||||||
Reference in New Issue
Block a user