Skip to content

Instantly share code, notes, and snippets.

@dhilst
Created November 3, 2017 19:08
Show Gist options
  • Select an option

  • Save dhilst/96ecbba9f26fe5ac33f63f3d89efc536 to your computer and use it in GitHub Desktop.

Select an option

Save dhilst/96ecbba9f26fe5ac33f63f3d89efc536 to your computer and use it in GitHub Desktop.
Xen grab vm metadata
#!/usr/bin/env python
import XenAPI
from getpass import getpass
host = 'https://localhost'
user = 'root'
password = getpass('Password: ')
session = XenAPI.Session(host)
session.login_with_password(user, password)
for vm in session.xenapi.VM.get_all():
vmobj = session.xenapi.VM.get_record(vm)
for k, v in vmobj.items():
print(u'{}: {} => {}'.format(
vmobj['name_label'], k, v))
session.logout()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment