Skip to content

Instantly share code, notes, and snippets.

@apahim
Created February 18, 2014 14:48
Show Gist options
  • Save apahim/9072359 to your computer and use it in GitHub Desktop.
Save apahim/9072359 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
from ovirtsdk.xml import params
from ovirtsdk.api import API
import sys
ENGINE_SERVER = "https://t420s.pahim.org"
ENGINE_USER = "admin@internal"
ENGINE_PASS = "admin"
ENGINE_CERT = "/etc/pki/ovirt-engine/ca.pem"
def Connect(url,username,password,ca_file):
global api
api = API(url = url,
username = username,
password = password,
ca_file = ca_file)
def Disconnect(exitcode):
api.disconnect()
sys.exit(exitcode)
try:
Connect(ENGINE_SERVER,ENGINE_USER,ENGINE_PASS,ENGINE_CERT)
for vm in api.vms.list():
print vm.name, api.vms.get(vm.name).status.state
Disconnect(0)
except Exception as e:
print 'Error:\n%s' % str(e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment