forked from Ulexus/docker-qemu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.py
29 lines (26 loc) · 1013 Bytes
/
entrypoint.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from procwrapper import EtcdLock, Qemu
import os
import signal
import sys
if __name__ == "__main__":
vm = Qemu(
prog_args=sys.argv[1:],
lock=EtcdLock(
lock_file=os.environ.get('LOCK'),
lock_ttl=os.environ.get('TTL',30),
endpoints=[{
'protocol': endpoint.split(':')[0],
'host': endpoint.split(':')[1],
'port': int(endpoint.split(':')[2]),
} for endpoint in os.environ.get('ETCD_ENDPOINTS').replace('/','').split(',')]
) if 'LOCK' in os.environ else None,
cloud_config_url=os.environ.get('CLOUD_CONFIG', None),
bridge_if=os.environ.get('BRIDGE_IF', 'qemu0'),
shutdown_timeout=300
)
signal.signal(signal.SIGTERM, vm.sigterm_handler)
sys.exit(
vm.start().communicate()
)