| 1 |
#!/usr/bin/python3 |
| 2 |
|
| 3 |
import json |
| 4 |
import subprocess |
| 5 |
import sys |
| 6 |
|
| 7 |
""" |
| 8 |
This little script is used by the xendomains init script. It gets a filename of |
| 9 |
a domU guest config file as argument and uses xen create --dryrun to parse the |
| 10 |
config file and extract the domU name from it. |
| 11 |
|
| 12 |
Note that there is no proper error handling. So, if a user symlinks something |
| 13 |
else than a correctly formatted domU config file into /etc/xen/auto (or a |
| 14 |
different path configured to use, of course) then this will just do ugly things |
| 15 |
and explode. |
| 16 |
""" |
| 17 |
|
| 18 |
cmd = ('xen', 'create', '--quiet', '--dryrun', '--defconfig', sys.argv[1]) |
| 19 |
domU_json = subprocess.check_output(cmd) |
| 20 |
name = json.loads(domU_json)['c_info']['name'] |
| 21 |
print(name) |