Compare commits
2 Commits
main
...
development
| Author | SHA1 | Date | |
|---|---|---|---|
| 0b843113b6 | |||
| d2965d4439 |
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Client Type: $1"
|
||||||
|
echo "Client IDs: $2"
|
||||||
|
client_string=$2
|
||||||
|
client_list=()
|
||||||
|
|
||||||
|
IFS=', ' read -a array <<< "${client_string}"; echo "${array[@]}"
|
||||||
|
|
||||||
|
for index in "${!array[@]}"
|
||||||
|
do
|
||||||
|
echo "Starting container: ${array[index]}"
|
||||||
|
lxc-start ${array[index]}
|
||||||
|
done
|
||||||
@@ -12,11 +12,11 @@ def get_time():
|
|||||||
|
|
||||||
def client_shutdown(client_type, clientid):
|
def client_shutdown(client_type, clientid):
|
||||||
lxc_filepath = "/usr/bin/lxc-stop"
|
lxc_filepath = "/usr/bin/lxc-stop"
|
||||||
qemu_filepath = "/usr/sbin/qm"
|
qemu_filepath = f"/usr/sbin/qm shutdown {clientid}"
|
||||||
try:
|
try:
|
||||||
print(f'Stopping {clientid}')
|
print(f'Stopping {clientid}')
|
||||||
if client_type == 'vm':
|
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':
|
elif client_type == 'lxc':
|
||||||
process_id = os.spawnv(os.P_NOWAIT, lxc_filepath, [client_type, clientid])
|
process_id = os.spawnv(os.P_NOWAIT, lxc_filepath, [client_type, clientid])
|
||||||
print(process_id)
|
print(process_id)
|
||||||
@@ -37,6 +37,7 @@ def main():
|
|||||||
print(f'Start time: {timestamp}')
|
print(f'Start time: {timestamp}')
|
||||||
for clientid in client_list:
|
for clientid in client_list:
|
||||||
client_shutdown(client_type, clientid)
|
client_shutdown(client_type, clientid)
|
||||||
|
sleep(1)
|
||||||
else:
|
else:
|
||||||
print(f'Successfully stopped client list.')
|
print(f'Successfully stopped client list.')
|
||||||
|
|
||||||
@@ -47,4 +48,4 @@ def main():
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
# sys.exit(0)
|
# sys.exit(0)
|
||||||
# sys.exit(1)
|
# sys.exit(1)
|
||||||
Reference in New Issue
Block a user