File: xen-init-name

package info (click to toggle)
xen 4.14.6-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 36,700 kB
  • sloc: ansic: 492,012; asm: 8,191; python: 6,969; makefile: 6,926; sh: 6,593; ml: 5,122; perl: 4,420; cpp: 1,885; lex: 813; yacc: 644; pascal: 489; sed: 4
file content (21 lines) | stat: -rwxr-xr-x 698 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/python3

import json
import subprocess
import sys

"""
This little script is used by the xendomains init script. It gets a filename of
a domU guest config file as argument and uses xen create --dryrun to parse the
config file and extract the domU name from it.

Note that there is no proper error handling. So, if a user symlinks something
else than a correctly formatted domU config file into /etc/xen/auto (or a
different path configured to use, of course) then this will just do ugly things
and explode.
"""

cmd = ('xen', 'create', '--quiet', '--dryrun', '--defconfig', sys.argv[1])
domU_json = subprocess.check_output(cmd)
name = json.loads(domU_json)['c_info']['name']
print(name)