bugfix
This commit is contained in:
parent
6618ab5a10
commit
6dba583380
|
@ -4,6 +4,8 @@ import subprocess as sp
|
|||
import json
|
||||
import time, re
|
||||
|
||||
qmbin = "/usr/sbin/qm"
|
||||
|
||||
# Read DB from file
|
||||
def read_json_from_file(filepath):
|
||||
with open(filepath, 'r') as file:
|
||||
|
@ -17,7 +19,7 @@ def ping(ip):
|
|||
|
||||
def vmstat(id):
|
||||
vm_status = "dnd"
|
||||
status,result = sp.getstatusoutput("qm status 114")
|
||||
status,result = sp.getstatusoutput(qmbin + " status " + str(id))
|
||||
match = re.search(r"status: (.+)", result)
|
||||
if match:
|
||||
vm_status = match.group(1)
|
||||
|
@ -42,10 +44,10 @@ for vm in vms:
|
|||
else:
|
||||
vm['down'] = down + 1
|
||||
if vmstat(vm['id']) == 'runnnig' and vm['down'] >= shutdown_timeout:
|
||||
status,result = sp.getstatusoutput("qm stop " + str(vm['id']) + " --overrule-shutdown 1")
|
||||
status,result = sp.getstatusoutput(qmbin + " stop " + str(vm['id']) + " --overrule-shutdown 1")
|
||||
else:
|
||||
if vmstat(vm['id']) == 'stopped' and vm['down'] >= shutdown_timeout:
|
||||
status,result = sp.getstatusoutput("qm start " + str(vm['id']))
|
||||
status,result = sp.getstatusoutput(qmbin + " start " + str(vm['id']))
|
||||
vm['down'] = 0
|
||||
|
||||
# Update the status
|
||||
|
|
Loading…
Reference in New Issue