<div><div dir="auto">Thanks Martin for help. I will give it a shot.</div></div><div dir="auto"><br></div><div dir="auto">Regards</div><div dir="auto">Rohit Singh</div><div><br><div class="gmail_quote"><div dir="ltr">On Thu, 6 Dec 2018 at 2:55 PM, Martin Kletzander <<a href="mailto:mkletzan@redhat.com">mkletzan@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Wed, Dec 05, 2018 at 09:44:17PM +0530, ROHIT SINGH wrote:<br>
>Hi Martin,<br>
><br>
>Could you please help me with below issue, I am not sure what’s wrong here.<br>
>Please find below code and error snippet.<br>
><br>
>Thanks for help.<br>
><br>
>Code Snippet: -<br>
><br>
>from __future__ import print_function<br>
>import sys<br>
>import libvirt<br>
>SASL_USER = <username><br>
>SASL_PASS = <password><br>
>def request_cred(credentials, user_data):<br>
>    for credential in credentials:<br>
>        if credential[0] == libvirt.VIR_CRED_AUTHNAME:<br>
>            credential[4] = SASL_USER<br>
>        elif credential[0] == libvirt.VIR_CRED_PASSPHRASE:<br>
>            credential[4] = SASL_PASS<br>
>    return 0<br>
>auth = [[libvirt.VIR_CRED_AUTHNAME, libvirt.VIR_CRED_PASSPHRASE],<br>
>request_cred, None]<br>
>conn = libvirt.openAuth("esx://<vm name>?no_verify=1", auth, 0)<br>
<br>
I don't know.  I don't have any ESX machine handy.  Try to do some debugging.<br>
Maybe the fact that you have the VM name here instead of the ESX server.<br>
<br>
Does the esxlist.py from python examples work?  Maybe you can differentiate with<br>
that.  Maybe you're not handling some of the credentials right.<br>
<br>
>if conn == None:<br>
>    print('Failed to open connection to qemu+tcp://localhost/system',<br>
>file=sys.stderr)<br>
>    exit(1)<br>
>conn.close()<br>
><br>
><br>
>Error Snippet: -<br>
>File<br>
>"/usr/software/pkgs/Python-3.4.3/lib/python3.4/site-packages/libvirt.py",<br>
>line 105, in openAuth<br>
>if ret is None:raise libvirtError('virConnectOpenAuth() failed')<br>
>libvirt.libvirtError: internal error: HTTP response code 404 for call to<br>
>'RetrieveServiceContent'<br>
><br>
><br>
>Regards<br>
>Rohit Singh<br>
><br>
>On Thu, 29 Nov 2018 at 11:13 PM, ROHIT SINGH <<a href="mailto:rohit.singh0908@gmail.com" target="_blank">rohit.singh0908@gmail.com</a>><br>
>wrote:<br>
><br>
>> Thanks a lot Martin for help.<br>
>> Really appreciate it. You’re life saver.<br>
>><br>
>> I will go through these links and will get back to you in case I need<br>
>> anymore information.<br>
>><br>
>> Once again, thanks for help.<br>
>><br>
>> Regards<br>
>> Rohit Singh<br>
>><br>
>> On Thu, 29 Nov 2018 at 2:34 PM, Martin Kletzander <<a href="mailto:mkletzan@redhat.com" target="_blank">mkletzan@redhat.com</a>><br>
>> wrote:<br>
>><br>
>>> On Wed, Nov 28, 2018 at 10:24:55PM +0530, ROHIT SINGH wrote:<br>
>>> >Hi Martin,<br>
>>> ><br>
>>> >Could you please point me to any example codes in python present for esx?<br>
>>> >Suppose, I have to power off and power on esx virtual machine, can i get<br>
>>> >this code somewhere on python to develop some understanding.<br>
>>> ><br>
>>><br>
>>> <a href="https://www.mail-archive.com/libvir-list@redhat.com/msg17903.html" rel="noreferrer" target="_blank">https://www.mail-archive.com/libvir-list@redhat.com/msg17903.html</a><br>
>>><br>
>>> >Actually, I am not able to find sample code related to esx in python,<br>
>>> >please point me if any such link available.<br>
>>> ><br>
>>><br>
>>> <a href="https://github.com/libvirt/libvirt-python/blob/master/examples/esxlist.py" rel="noreferrer" target="_blank">https://github.com/libvirt/libvirt-python/blob/master/examples/esxlist.py</a><br>
>>><br>
>>> and all other examples:<br>
>>><br>
>>> <a href="https://github.com/libvirt/libvirt-python/tree/master/examples" rel="noreferrer" target="_blank">https://github.com/libvirt/libvirt-python/tree/master/examples</a><br>
>>><br>
>>> The point of libvirt is that the code doesn't have to be (way) different<br>
>>> depending on the hypervisor.<br>
>>><br>
>>> >Appreciate your help !!<br>
>>> ><br>
>>> >Thanks.<br>
>>> ><br>
>>> >Regards<br>
>>> >Rohit Singh<br>
>>> ><br>
>>> >On Wed, 28 Nov 2018 at 9:54 PM, ROHIT SINGH <<a href="mailto:rohit.singh0908@gmail.com" target="_blank">rohit.singh0908@gmail.com</a>><br>
>>> >wrote:<br>
>>> ><br>
>>> >> Thanks, I'll check it out.<br>
>>> >><br>
>>> >> On Wed, 28 Nov 2018 at 9:31 PM, Martin Kletzander <<a href="mailto:mkletzan@redhat.com" target="_blank">mkletzan@redhat.com</a><br>
>>> ><br>
>>> >> wrote:<br>
>>> >><br>
>>> >>> On Mon, Nov 26, 2018 at 04:11:20PM +0530, ROHIT SINGH wrote:<br>
>>> >>> >Hi,<br>
>>> >>> ><br>
>>> >>> >I am doing poc for using libvirt api for implementation of esx in<br>
>>> python.<br>
>>> >>> ><br>
>>> >>> >I tried researching through module but did not find a way how it<br>
>>> works<br>
>>> >>> for<br>
>>> >>> >esx.<br>
>>> >>> >Any help on how to proceed specifically for esx would be of great<br>
>>> help.<br>
>>> >>> ><br>
>>> >>><br>
>>> >>> See <a href="https://libvirt.org/drvesx.html" rel="noreferrer" target="_blank">https://libvirt.org/drvesx.html</a> for ESX-related stuff.  But<br>
>>> mainly<br>
>>> >>> it is the<br>
>>> >>> URI you need to use.  Then look at <a href="https://libvirt.org/hvsupport.html" rel="noreferrer" target="_blank">https://libvirt.org/hvsupport.html</a><br>
>>> >>> where you<br>
>>> >>> can see what APIs are available for that HV driver.<br>
>>> >>><br>
>>> >>> >Please let me know as soon as possible, lagging on deliverables.<br>
>>> >>> ><br>
>>> >>> >Thanks for help!!<br>
>>> >>> ><br>
>>> >>> >Regards<br>
>>> >>> >Rohit Singh<br>
>>> >>><br>
>>> >>> >_______________________________________________<br>
>>> >>> >libvirt-users mailing list<br>
>>> >>> ><a href="mailto:libvirt-users@redhat.com" target="_blank">libvirt-users@redhat.com</a><br>
>>> >>> ><a href="https://www.redhat.com/mailman/listinfo/libvirt-users" rel="noreferrer" target="_blank">https://www.redhat.com/mailman/listinfo/libvirt-users</a><br>
>>> >>><br>
>>> >>><br>
>>><br>
>><br>
</blockquote></div></div>