question about using openAuth with Python

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi guys

Is anybody can help me how to use openAuth to connect a remote URI without input the boring  password? we assume the password of root for remote machine is "123456".

Even I running the example in libvirt library esxlist.py(change uri to a qemu type and assign the username and password).

Bellow is my simple test code, unfortunately it still need me to input the password.

import libvirt

def authcb(ncred, cbdata):
for cred in  ncred:
if cred[0] == libvirt.VIR_CRED_AUTHNAME:
cred[4] = "root"
elif cred == libvirt.VIR_CRED_PASSPHRASE:
cred[4] = "123456"
return 0
class connection:
def __init__(self, uri):
self.uri = uri
def open(self):
auth = [[libvirt.VIR_CRED_AUTHNAME, libvirt.VIR_CRED_PASSPHRASE], authcb, None]
vm_conn =  libvirt.openAuth(self.uri, auth, 0);
print self.uri
if vm_conn == None:
print 'Failed to open connection to %s' % self.uri

for name in vm_conn.listDefinedDomains():
print name
vm = vm_conn.lookupByName(name)

if __name__ == '__main__':
conn = connection('qemu+ssh://root@192.168.1.203/system')
conn.open()
Thanks


fan
_______________________________________________
libvirt-users mailing list
libvirt-users@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvirt-users

[Index of Archives]     [Virt Tools]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]

  Powered by Linux