python libvirt appi openAuth()
tcpを使ってlibvirtサービスを接続して、パスワードを適用しません.
http://blog.csdn.net/gaoxingnengjisuan/article/details/9674315
http://blog.csdn.net/qq_2198167/articale/details/4642583
転載先:https://www.cnblogs.com/pdjun/p/7410821.html
/etc/libvirt/libvirtd.conf
auth_tcp="none"
service libvirtd restart
import libvirt
conn = libvirt.open("qemu+tcp://localhost/system")
print conn.getHostname()
tcpでパスワードを入れてlibvirtを接続します.auth_tcp="sasl"
saslpasswd2 -a libvirt admin
sasldblistusers2 -f /etc/libvirt/passwd.db
service libvirtd restart
接続コードimport libvirt
USER = "root"
PASSWD = "mypasswd"
def authcb(credentials, user_data):
for credential in credentials:
if credential[0] == libvirt.VIR_CRED_AUTHNAME:
credential[4] = USER
elif credential[0] == libvirt.VIR_CRED_PASSPHRASE:
credential[4] = PASSWD
return 0
auth = [[libvirt.VIR_CRED_AUTHNAME, libvirt.VIR_CRED_PASSPHRASE], authcb, None]
conn = libvirt.openAuth("qemu+ssh://localhost/system", auth, 0)
print conn.getHostname()
参考文献:http://blog.csdn.net/gaoxingnengjisuan/article/details/9674315
http://blog.csdn.net/qq_2198167/articale/details/4642583
転載先:https://www.cnblogs.com/pdjun/p/7410821.html