Created
December 15, 2017 09:57
-
-
Save ernetas/97bcd2a732fb4ab5984a2960e73ce201 to your computer and use it in GitHub Desktop.
get xen domains with python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_xen_domains(): | |
p = subprocess.Popen(['xl', 'list', '-l'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) | |
out, _ = p.communicate(timeout=60) | |
out = out.decode('utf-8') | |
domains = [] | |
for domain in json.loads(out): | |
domain_name = domain['config']['c_info']['name'] | |
if not domain_name == 'Domain-0': | |
domains.append(domain_name) | |
return domains |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment