Quellcode durchsuchen

修正创建虚拟机时,host选举bug

James Iter vor 9 Jahren
Ursprung
Commit
79bae478b2
2 geänderte Dateien mit 5 neuen und 2 gelöschten Zeilen
  1. 3 1
      api/guest.py
  2. 2 1
      docs/todo.md

+ 3 - 1
api/guest.py

@@ -149,6 +149,7 @@ def r_create():
                     replace('{DNS1}', config.dns1). \
                     replace('{DNS2}', config.dns2)
 
+            # 负载最小的宿主机
             lightest_host = None
             for k, v in db.r.hgetall(app.config['hosts_info']).items():
                 v = json.loads(v)
@@ -156,7 +157,8 @@ def r_create():
                 if lightest_host is None:
                     lightest_host = v
 
-                if float(lightest_host['system_load'][0]) / lightest_host['cpu'] > float(v['system_load'][0]) / v['cpu']:
+                if float(lightest_host['system_load'][0]) / lightest_host['cpu'] > \
+                        float(v['system_load'][0]) / v['cpu']:
                     lightest_host = v
 
             create_vm_msg = {

+ 2 - 1
docs/todo.md

@@ -31,6 +31,7 @@
 > 2. 给宿主机替换手动指定的任意 IP。此时需要判断手动分配的 IP 是否与已用的 IP 冲突;
 - [x] 宿主机性能状态展现
 - [ ] 设计、实现 Dashboard 页面
-- [ ] 重新设计创建虚拟机时的机制,虚拟机创建分配由 JimV-C 角色实现
+- [x] 重新设计创建虚拟机时的机制,虚拟机创建分配由 JimV-C 角色实现
 - [ ] 虚拟机状态变化时时展现在前端页面上
 - [ ] 迁移时计算出剩余时间
+- [ ] 重新设计 JimV-N 到 JimV-C 的回调机制,现有实现比较混乱。改进为基于对象的回调