소스 검색

update docker.py

童颖佳 2 년 전
부모
커밋
aeb37cbc82
1개의 변경된 파일4개의 추가작업 그리고 3개의 파일을 삭제
  1. 4 3
      appmanage/api/utils/docker.py

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

@@ -31,8 +31,9 @@ def check_vm_resource(app_name):
     cpu_count = p.cpu_count()
     cpu_count = p.cpu_count()
     mem = p.virtual_memory()
     mem = p.virtual_memory()
     mem_total = float(mem.total) / 1024 / 1024 / 1024
     mem_total = float(mem.total) / 1024 / 1024 / 1024
-    need_cpu_count = int(read_var(app_name, 'cpu'))
-    need_mem = int(read_var(app_name, 'memory'))
+    requirements_var = read_var(app_name, 'requirements')
+    need_cpu_count = int(requirements_var['cpu'])
+    need_mem = int(requirements_var['memory'])
     if cpu_count<need_cpu_count or mem_total<need_mem:
     if cpu_count<need_cpu_count or mem_total<need_mem:
         return False
         return False
 
 
@@ -40,7 +41,7 @@ def check_vm_resource(app_name):
     if mem_total>=8 and mem_free<=4:
     if mem_total>=8 and mem_free<=4:
         return False
         return False
 
 
-    need_disk = int(read_var(app_name, 'disk'))
+    need_disk = int(requirements_var['disk'])
     disk = p.disk_usage('/')
     disk = p.disk_usage('/')
     disk_total = float(disk.total) / 1024 / 1024 / 1024
     disk_total = float(disk.total) / 1024 / 1024 / 1024
     disk_free = float(disk.free) / 1024 / 1024 / 1024
     disk_free = float(disk.free) / 1024 / 1024 / 1024