<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 24, 2015 at 9:56 PM, Juan Hernández <span dir="ltr"><<a href="mailto:jhernand@redhat.com" target="_blank">jhernand@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On 11/24/2015 02:49 PM, John Hunter wrote:<br>
><br>
><br>
> On Tue, Nov 24, 2015 at 9:15 PM, Juan Hernández <<a href="mailto:jhernand@redhat.com" target="_blank">jhernand@redhat.com</a><br>
</span><span>> <mailto:<a href="mailto:jhernand@redhat.com" target="_blank">jhernand@redhat.com</a>>> wrote:<br>
><br>
> On 11/24/2015 01:40 PM, John Hunter wrote:<br>
> > Hi,<br>
> ><br>
> > On Tue, Nov 24, 2015 at 5:18 PM, Oved Ourfali <<a href="mailto:oourfali@redhat.com" target="_blank">oourfali@redhat.com</a> <mailto:<a href="mailto:oourfali@redhat.com" target="_blank">oourfali@redhat.com</a>><br>
</span><div><div>> > <mailto:<a href="mailto:oourfali@redhat.com" target="_blank">oourfali@redhat.com</a> <mailto:<a href="mailto:oourfali@redhat.com" target="_blank">oourfali@redhat.com</a>>>> wrote:<br>
> ><br>
> > Hi<br>
> ><br>
> > I discussed it with Juan (cc-ed).<br>
> ><br>
> > There used to be a bug in the JDBC authenticion extension that<br>
> > artificially delayed RESTAPI responses by 5 seconds:<br>
> ><br>
> > brute force prevention login delay should not be applied to successful<br>
> > login requests<br>
> > <a href="https://bugzilla.redhat.com/1255814" rel="noreferrer" target="_blank">https://bugzilla.redhat.com/1255814</a><br>
> ><br>
> > That matches the description of the issue, but in theory it has been<br>
> > fixed. I would suggest him to check that he is using the right version<br>
> > of the extension.<br>
> ><br>
> > I did not use the extension ovirt-engine-extension-aaa-jdbc, and I don't<br>
> > think this bug matches my problem, because even there is only one line<br>
> > in the python script, it still cost like 3 seconds, I don't think this is a<br>
> > reasonable time as when I import other package, it cost almost no time.<br>
> ><br>
> > Can you explain why this import line costs so much time?<br>
> ><br>
><br>
> If you are using 3.6 then you are using ovirt-engine-extension-aaa-jdbc,<br>
> as it is enabled by default, but looks like it isn't related to your<br>
> problem.<br>
><br>
> That line takes a long time to execute because it has to process two<br>
> large Python modules: the "params" module that contains a class per each<br>
> type used by the API (393 classes) and the "brokers" module that<br>
> contains a class per each resource used by the API (358 classes). That<br>
> makes a total of 751 classes. In my environment it takes 0.9 seconds,<br>
> approx. You may want to use the python profile in your environment and<br>
> share the results:<br>
><br>
> $ cat > profile.py <<.<br>
> import cProfile<br>
> cProfile.run("from ovirtsdk.api import API")<br>
> .<br>
><br>
> $ python profile.py<br>
><br>
> I won't be surprised to see this taking those 3 seconds in a slower<br>
> environment.<br>
><br>
> But even if this takes those 3 seconds it shouldn't be a big problem,<br>
> because you shouldn't be running that "from ... import ..." line<br>
> frequently. Your program should do this once only, when it starts.<br>
><br>
> Assume that I have two functions to implement, one is to list all the<br>
> vms belong<br>
> to the user, and the other is to retrieve one vm's virt-viewer<br>
> connection file, as<br>
> far as I can see, I have to write two python scripts and import the<br>
> ovirtsdk.api in both<br>
> scripts, each script has to take the 3 seconds :(<br>
><br>
> How can I run the "from ... import ..." just once ?<br>
><br>
<br>
</div></div>I don't know what technology or tools are you using to write that<br>
program, but if you are using Python then you don't need to import it twice.<br>
<br></blockquote><div>Yeah, I am just using Python scripts to access the RESTAPI, since I am</div><div>not skillful in python, I might have asked some stupid question.</div><div><br></div><div>I will try to learn more about Python.</div><div><br></div><div>Anyway, thanks for your patience.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
If for whatever the reason you decide to call external python scripts<br>
from another program then you will have to pay the price of the startup<br>
of the Python SDK. If that is unacceptable because of performance then<br>
you should look for a different way to access the RESTAPI, like sending<br>
XML or JSON directly, or using the Java SDK, or rbovirt, it all depends<br>
on the technology that you are using for your application.<br>
<span><br>
><br>
> ><br>
> > In addition we also know that retrieving large lists of objects with the<br>
> > SDK is slow:<br>
> ><br>
> > [RFE][performance] - generate large scale list running to slow.<br>
> > <a href="https://bugzilla.redhat.com/1221238" rel="noreferrer" target="_blank">https://bugzilla.redhat.com/1221238</a><br>
> ><br>
> > We don't have a solution for that yet.<br>
> ><br>
> > CC-ing Juan in case you have additional questions.<br>
> ><br>
> ><br>
> > On Mon, Nov 23, 2015 at 11:27 AM, John Hunter <<a href="mailto:zhjwpku@gmail.com" target="_blank">zhjwpku@gmail.com</a> <mailto:<a href="mailto:zhjwpku@gmail.com" target="_blank">zhjwpku@gmail.com</a>><br>
</span><div><div>> > <mailto:<a href="mailto:zhjwpku@gmail.com" target="_blank">zhjwpku@gmail.com</a> <mailto:<a href="mailto:zhjwpku@gmail.com" target="_blank">zhjwpku@gmail.com</a>>>> wrote:<br>
> ><br>
> > Hi guys,<br>
> ><br>
> > I am using the ovirt-engine-sdk-python to communicate with the<br>
> > ovirt-engine,<br>
> > I am ok to list the vms but the processing time is too long,<br>
> > like 4.5 seconds,<br>
> > and this line:<br>
> > from ovirtsdk.api import API<br>
> > take almost 3 seconds.<br>
> ><br>
> > This seems a little bit longer than I expected it to be, so I am<br>
> > asking is there<br>
> > a quicker way to communicate with the ovirt-engine?<br>
> ><br>
><br>
<br>
--<br>
Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta<br>
3ºD, 28016 Madrid, Spain<br>
Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr"><div><div dir="ltr"><div>Best regards<br></div><div>Junwang Zhao</div><div>Department of Computer Science &Technology</div><div>Peking University</div><div>Beijing, 100871, PRC</div></div></div></div></div>
</div></div>