Forráskód Böngészése

调整 node_id 传入类型

James Iter 8 éve
szülő
commit
12cac368ed
2 módosított fájl, 2 hozzáadás és 2 törlés
  1. 1 1
      api/disk.py
  2. 1 1
      api/guest.py

+ 1 - 1
api/disk.py

@@ -95,7 +95,7 @@ def r_create():
             disk.size = size
             disk.uuid = uuid4().__str__()
             disk.remark = request.json.get('remark', '')
-            disk.node_id = node_id
+            disk.node_id = int(node_id)
             disk.sequence = -1
             disk.format = 'qcow2'
             disk.path = config.storage_path + '/' + disk.uuid + '.' + disk.format

+ 1 - 1
api/guest.py

@@ -100,7 +100,6 @@ def r_create():
 
         # 当指定了 host 时,取全部活着的 hosts
         if node_id is not None:
-            node_id = int(node_id)
             available_hosts = Host.get_available_hosts(nonrandom=None)
 
         if available_hosts.__len__() == 0:
@@ -162,6 +161,7 @@ def r_create():
             if node_id is not None:
                 guest.node_id = node_id
 
+            guest.node_id = int(guest.node_id)
             guest.create()
 
             # 替换占位符为有效内容