debian/scripts/xen-init-list
raw| 1 | #!/usr/bin/python3 |
| 2 | |
| 3 | import json |
| 4 | import subprocess |
| 5 | |
| 6 | """ |
| 7 | This little script is used by the xendomains init script. It prints all running |
| 8 | domUs with their domain id and name. |
| 9 | """ |
| 10 | |
| 11 | cmd = ('xen', 'list', '-l') |
| 12 | xen_list_json = subprocess.check_output(cmd) |
| 13 | for domU_info in json.loads(xen_list_json): |
| 14 | domid = domU_info['domid'] |
| 15 | if domid == 0: |
| 16 | continue |
| 17 | name = domU_info['config']['c_info']['name'] |
| 18 | print(domid, name) |