Skip to content

Instantly share code, notes, and snippets.

@ernetas
Created December 15, 2017 09:57
Show Gist options
  • Save ernetas/97bcd2a732fb4ab5984a2960e73ce201 to your computer and use it in GitHub Desktop.
Save ernetas/97bcd2a732fb4ab5984a2960e73ce201 to your computer and use it in GitHub Desktop.
get xen domains with python
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