Created
February 18, 2014 14:48
-
-
Save apahim/9072359 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/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