def retrieve_credentials(self, credentials, user_data):
"""
Retrieves the libvirt credentials in a strange format and hand it to
the API in order to communicate with the hypervisor.
To be honest, I have no idea why this has to be done this way. I have
taken this function from the official libvirt documentation.
:param credentials: libvirt credentials object
:param user_data: some data that will never be used
:type user_data: None
"""
#get credentials for libvirt
for credential in credentials:
if credential[0] == libvirt.VIR_CRED_AUTHNAME:
credential[4] = self.USERNAME
if len(credential[4]) == 0:
credential[4] = credential[3]
elif credential[0] == libvirt.VIR_CRED_PASSPHRASE:
credential[4] = self.PASSWORD
else:
return -1
return 0
评论列表
文章目录