I'm in a situation where I need to pass some texts to a prompt generate by a API (seems for API it's a pretty weird behavior, this is the first time I ran into this), like below:
kvm_cli = libvirt.open("qemu+ssh://[email protected]/system")
then a prompt shows up asking for the ssh password (password for 10.0.10.8 is:
), I have to manually type it there in order to move on and yield the kvm_cli
object I needed.
I tried to use the pexpect
module to deal with this however it's for OS command line instead of API.
It's also possible to work around this by using ssh certification files but it's not a favorable authentication approach in our scenario.
Since our wrapper to the 'open' method is not interactive, we cannot ask the user to input the password, do you guys have any thought how could I address it?
To interact with an API, specifically a web API in python we can make use of the standard requests module to make the request, because most web service APIs return a response in a format known as JSON it will be useful to know little about it. JSON is a way to store data in an organized, logical manner.
Supported languages currently include Python, Java, C++, and . NET. There is also support for Microsoft's ActiveX framework as well as DDE to establish a connection within Excel. What makes IB unique is that a connection is made to the IB client software which acts as an intermediary to the IB servers.
By the end of this tutorial, you'll be able to use Python to consume most APIs you come across. If you're a developer, knowing how to consume APIs with Python will make you much more proficient, especially when it comes to integrating your work with third-party applications.
I am not a libvirt user, but I believe that the problem is not in the library, but in the connection method. You seem to be connecting via ssh, so you need to authenticate yourself.
I've been reading the libvirt page on ArchWiki, and I think that you could try:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With