浏览代码

update docker.py

TooY 2 年之前
父节点
当前提交
a2e28c36e8
共有 1 个文件被更改,包括 3 次插入4 次删除
  1. 3 4
      appmanage/api/utils/docker.py

+ 3 - 4
appmanage/api/utils/docker.py

@@ -48,13 +48,12 @@ def check_vm_resource(app_name):
         myLogger.info_logger("Check complete: The number of CPU cores is insufficient!")
         return False
     need_mem_total = int(requirements_var['memory'])
-    mem_total = float(
-        shell_execute.execute_command_output_all("free -m | grep Mem | awk \'{print $2}\'")["result"]) / 1024
+    mem = shell_execute.execute_command_output_all("free -m | grep Mem")["result"].split()
+    mem_total = float(mem[1]) / 1024
     if mem_total < need_mem_total:
         myLogger.info_logger("Check complete: The total amount of memory is insufficient!")
         return False
-    mem_free = float(
-        shell_execute.execute_command_output_all("free -m | grep Mem | awk \'{print $4}\'")["result"]) / 1024
+    mem_free = float(mem[3]) /1024
     if need_mem_total > 4 and mem_free < 4:
         myLogger.info_logger("Check complete: There is not enough memory left!")
         return False