update execution for vm shutdown
This commit is contained in:
@@ -12,11 +12,11 @@ def get_time():
|
||||
|
||||
def client_shutdown(client_type, clientid):
|
||||
lxc_filepath = "/usr/bin/lxc-stop"
|
||||
qemu_filepath = "/usr/sbin/qm"
|
||||
qemu_filepath = f"/usr/sbin/qm shutdown {clientid}"
|
||||
try:
|
||||
print(f'Stopping {clientid}')
|
||||
if client_type == 'vm':
|
||||
process_id = os.spawnv(os.P_NOWAIT, qemu_filepath, ['shutdown', clientid])
|
||||
process_id = os.spawnv(os.P_NOWAIT, qemu_filepath, ['--skip-lock', 'true'])
|
||||
elif client_type == 'lxc':
|
||||
process_id = os.spawnv(os.P_NOWAIT, lxc_filepath, [client_type, clientid])
|
||||
print(process_id)
|
||||
@@ -37,6 +37,7 @@ def main():
|
||||
print(f'Start time: {timestamp}')
|
||||
for clientid in client_list:
|
||||
client_shutdown(client_type, clientid)
|
||||
sleep(1)
|
||||
else:
|
||||
print(f'Successfully stopped client list.')
|
||||
|
||||
@@ -47,4 +48,4 @@ def main():
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
# sys.exit(0)
|
||||
# sys.exit(1)
|
||||
# sys.exit(1)
|
||||
Reference in New Issue
Block a user