<html><head><meta name="Generator" content="Z-Push"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body><SPAN style="font-size: 11pt"><div dir='auto'><div><br><div class="gmail_extra"><br><div class="gmail_quote">Den 29 mars 2018 14:15 skrev Alexander Wels &lt;awels@redhat.com&gt;:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>On Thursday, March 29, 2018 7:59:36 AM EDT Ondra Machacek wrote:<br>&gt; On 03/29/2018 01:02 PM, Karli Sjöberg wrote:<br>&gt; &gt; On Thu, 2018-03-29 at 11:21 +0200, Ondra Machacek wrote:<br>&gt; &gt;&gt; On 03/29/2018 11:09 AM, Hari Prasanth Loganathan wrote:<br>&gt; &gt;&gt;&gt; Hi Team,<br>&gt; &gt;&gt;&gt; <br>&gt; &gt;&gt;&gt; 1) I perform the VM clone using the following API<br>&gt; &gt;&gt;&gt; <br>&gt; &gt;&gt;&gt; api/vms/{vmId}/clone<br>&gt; &gt;&gt;&gt; <br>&gt; &gt;&gt;&gt; 2) The above API is returning the job id<br>&gt; &gt;&gt;&gt; 3) Using the job Id, we continuously query the oVirt to get the<br>&gt; &gt;&gt;&gt; status<br>&gt; &gt;&gt;&gt; of the clone operation.<br>&gt; &gt;&gt;&gt; /api/jobs/${vmCloneJobId}<br>&gt; &gt;&gt;&gt; <br>&gt; &gt;&gt;&gt;       We are able to successfully get the status of the clone<br>&gt; &gt;&gt;&gt; <br>&gt; &gt;&gt;&gt; operation.<br>&gt; &gt;&gt;&gt; <br>&gt; &gt;&gt;&gt; But the problem is, we are not able to identify the newly created<br>&gt; &gt;&gt;&gt; VM<br>&gt; &gt;&gt;&gt; (created using clone).<br>&gt; &gt;&gt;&gt; <br>&gt; &gt;&gt;&gt; AFAIK, The only way to get the newly created VM is to get all the<br>&gt; &gt;&gt;&gt; VM<br>&gt; &gt;&gt;&gt; list from oVirt. Is there an easy way to identify the newly created<br>&gt; &gt;&gt;&gt; VM<br>&gt; &gt;&gt;&gt; using the jobId?<br>&gt; &gt;&gt; <br>&gt; &gt;&gt; In order to run the clone operation you must pas the VM name, so you<br>&gt; &gt;&gt; know the name, so later to fetch the VM you can just run:<br>&gt; &gt;&gt; <br>&gt; &gt;&gt; api/vms?search=name=thenameofclonnedvm<br>&gt; &gt; <br>&gt; &gt; Hijacking this a little, because I got curious about something:)<br>&gt; &gt; <br>&gt; &gt; Is it possible to do regex searches? Because I remember working on<br>&gt; &gt; something different, the searches could potentially end up with<br>&gt; &gt; multiple matched objects, like "thenameofclonnedvm",<br>&gt; &gt; "thenameofclonnedvm-berta", "thenameofclonnedvm3" and so on. So I was<br>&gt; &gt; always forced to treat the result as a potential array, loop the<br>&gt; &gt; objects (this was with Python) and test for an exact match, even if it<br>&gt; &gt; was just one object. So it would be nicer if you could go like:<br>&gt; &gt; <br>&gt; &gt; api/vms?search=name='^thenameofclonnedvm$'<br>&gt; &gt; <br>&gt; &gt; And be sure to have an exact match every time. Is that possible?<br>&gt; <br>&gt; You can read more about search engine here:<br>&gt; <br>&gt; <br>&gt; https://www.ovirt.org/documentation/admin-guide/appe-Using_Search_Bookmarks_<br>&gt; and_Tags/<br>&gt; <br>&gt; So if you have for example following VMs in system:<br>&gt; <br>&gt;   vm<br>&gt;   vm1<br>&gt;   vm2<br>&gt;   vm3<br>&gt; <br>&gt; And you do search like:<br>&gt; <br>&gt;    api/vms?search=name=vm<br>&gt; <br>&gt; It will return only single Vm called 'vm', but it always return a<br>&gt; collection, but with just single item.<br>&gt; <br>&gt; And you do search like:<br>&gt; <br>&gt;   api/vms?search=name=vm*<br>&gt; <br>&gt; It will return all VMs starting on 'vm' string. So it's collection of<br>&gt; vm, vm1, vm2 and vm3.<br>&gt; <br>&gt; So by default it search for exact string, but you may use wildcards to<br>&gt; improve the search.<br>&gt; <br><br>You can also 'and' and 'or' different parameters, for instance<br><br>api/vms?search=name%3DVM1+or+name%3DVM2<br><br>which will return VM1 and VM2 if they exist. Note that you will need to URL <br>encode your search string to replace all the '=' with %3D and space with +, <br>etc. The only = that shouldn't be encoded is the = after search.<br><br>For an easy way to find what is available to search on for a particular <br>entity, if you go into the webadmin in the search bar you can start typing and <br>it will auto complete the different available options. AFAIC those match <br>exactly to the search in the REST api.<br></div></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">OK, cool, so that's changed since when I did it (admittedly a while ago now), good to know! Thanks for the explanation!</div><div dir="auto"><br></div><div dir="auto">/K</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><br>&gt; &gt; TIA<br>&gt; &gt; <br>&gt; &gt; /K<br>&gt; &gt; <br>&gt; &gt;&gt; Is this approach OK for you?<br>&gt; &gt;&gt; <br>&gt; &gt;&gt;&gt; Thanks,<br>&gt; &gt;&gt;&gt; Hari<br>&gt; &gt;&gt;&gt; <br>&gt; &gt;&gt;&gt; DISCLAIMER<br>&gt; &gt;&gt;&gt; <br>&gt; &gt;&gt;&gt; The information in this e-mail is confidential and may be subject<br>&gt; &gt;&gt;&gt; to<br>&gt; &gt;&gt;&gt; legal privilege. It is intended solely for the addressee. Access to<br>&gt; &gt;&gt;&gt; this<br>&gt; &gt;&gt;&gt; e-mail by anyone else is unauthorized. If you have received this<br>&gt; &gt;&gt;&gt; communication in error, please address with the subject heading<br>&gt; &gt;&gt;&gt; "Received in error," send to it@msystechnologies.com<br>&gt; &gt;&gt;&gt; ,  then delete the e-mail and<br>&gt; &gt;&gt;&gt; destroy<br>&gt; &gt;&gt;&gt; any copies of it. If you are not the intended recipient, any<br>&gt; &gt;&gt;&gt; disclosure,<br>&gt; &gt;&gt;&gt; copying, distribution or any action taken or omitted to be taken<br>&gt; &gt;&gt;&gt; in<br>&gt; &gt;&gt;&gt; reliance on it, is prohibited and may be unlawful. The views,<br>&gt; &gt;&gt;&gt; opinions,<br>&gt; &gt;&gt;&gt; conclusions and other information expressed in this electronic mail<br>&gt; &gt;&gt;&gt; and<br>&gt; &gt;&gt;&gt; any attachments are not given or endorsed by the company unless<br>&gt; &gt;&gt;&gt; otherwise indicated by an authorized representative independent of<br>&gt; &gt;&gt;&gt; this<br>&gt; &gt;&gt;&gt; message.<br>&gt; &gt;&gt;&gt; <br>&gt; &gt;&gt;&gt; MSys cannot guarantee that e-mail communications are secure or<br>&gt; &gt;&gt;&gt; error-free, as information could be intercepted, corrupted,<br>&gt; &gt;&gt;&gt; amended,<br>&gt; &gt;&gt;&gt; lost, destroyed, arrive late or incomplete, or contain viruses,<br>&gt; &gt;&gt;&gt; though<br>&gt; &gt;&gt;&gt; all reasonable precautions have been taken to ensure no viruses<br>&gt; &gt;&gt;&gt; are<br>&gt; &gt;&gt;&gt; present in this e-mail. As our company cannot accept responsibility<br>&gt; &gt;&gt;&gt; for<br>&gt; &gt;&gt;&gt; any loss or damage arising from the use of this e-mail or<br>&gt; &gt;&gt;&gt; attachments we<br>&gt; &gt;&gt;&gt; recommend that you subject these to your virus checking procedures<br>&gt; &gt;&gt;&gt; prior<br>&gt; &gt;&gt;&gt; to use<br>&gt; &gt;&gt;&gt; <br>&gt; &gt;&gt;&gt; <br>&gt; &gt;&gt;&gt; _______________________________________________<br>&gt; &gt;&gt;&gt; Users mailing list<br>&gt; &gt;&gt;&gt; Users@ovirt.org<br>&gt; &gt;&gt;&gt; http://lists.ovirt.org/mailman/listinfo/users<br>&gt; &gt;&gt; <br>&gt; &gt;&gt; _______________________________________________<br>&gt; &gt;&gt; Users mailing list<br>&gt; &gt;&gt; Users@ovirt.org<br>&gt; &gt;&gt; http://lists.ovirt.org/mailman/listinfo/users<br>&gt; <br>&gt; _______________________________________________<br>&gt; Users mailing list<br>&gt; Users@ovirt.org<br>&gt; http://lists.ovirt.org/mailman/listinfo/users<br><br><br><br><br></div></blockquote></div><br></div></div></div></SPAN>On Thursday, March 29, 2018 7:59:36 AM EDT Ondra Machacek wrote:<BR>> On 03/29/2018 01:02 PM, Karli Sjöberg wrote:<BR>> > On Thu, 2018-03-29 at 11:21 +0200, Ondra Machacek wrote:<BR>> >> On 03/29/2018 11:09 AM, Hari Prasanth Loganathan wrote:<BR>> >>> Hi Team,<BR>> >>> <BR>> >>> 1) I perform the VM clone using the following API<BR>> >>> <BR>> >>> api/vms/{vmId}/clone<BR>> >>> <BR>> >>> 2) The above API is returning the job id<BR>> >>> 3) Using the job Id, we continuously query the oVirt to get the<BR>> >>> status<BR>> >>> of the clone operation.<BR>> >>> /api/jobs/${vmCloneJobId}<BR>> >>> <BR>> >>>       We are able to successfully get the status of the clone<BR>> >>> <BR>> >>> operation.<BR>> >>> <BR>> >>> But the problem is, we are not able to identify the newly created<BR>> >>> VM<BR>> >>> (created using clone).<BR>> >>> <BR>> >>> AFAIK, The only way to get the newly created VM is to get all the<BR>> >>> VM<BR>> >>> list from oVirt. Is there an easy way to identify the newly created<BR>> >>> VM<BR>> >>> using the jobId?<BR>> >> <BR>> >> In order to run the clone operation you must pas the VM name, so you<BR>> >> know the name, so later to fetch the VM you can just run:<BR>> >> <BR>> >> api/vms?search=name=thenameofclonnedvm<BR>> > <BR>> > Hijacking this a little, because I got curious about something:)<BR>> > <BR>> > Is it possible to do regex searches? Because I remember working on<BR>> > something different, the searches could potentially end up with<BR>> > multiple matched objects, like "thenameofclonnedvm",<BR>> > "thenameofclonnedvm-berta", "thenameofclonnedvm3" and so on. So I was<BR>> > always forced to treat the result as a potential array, loop the<BR>> > objects (this was with Python) and test for an exact match, even if it<BR>> > was just one object. So it would be nicer if you could go like:<BR>> > <BR>> > api/vms?search=name='^thenameofclonnedvm$'<BR>> > <BR>> > And be sure to have an exact match every time. Is that possible?<BR>> <BR>> You can read more about search engine here:<BR>> <BR>> <BR>> https://www.ovirt.org/documentation/admin-guide/appe-Using_Search_Bookmarks_<BR>> and_Tags/<BR>> <BR>> So if you have for example following VMs in system:<BR>> <BR>>   vm<BR>>   vm1<BR>>   vm2<BR>>   vm3<BR>> <BR>> And you do search like:<BR>> <BR>>    api/vms?search=name=vm<BR>> <BR>> It will return only single Vm called 'vm', but it always return a<BR>> collection, but with just single item.<BR>> <BR>> And you do search like:<BR>> <BR>>   api/vms?search=name=vm*<BR>> <BR>> It will return all VMs starting on 'vm' string. So it's collection of<BR>> vm, vm1, vm2 and vm3.<BR>> <BR>> So by default it search for exact string, but you may use wildcards to<BR>> improve the search.<BR>> <BR><BR>You can also 'and' and 'or' different parameters, for instance<BR><BR>api/vms?search=name%3DVM1+or+name%3DVM2<BR><BR>which will return VM1 and VM2 if they exist. Note that you will need to URL <BR>encode your search string to replace all the '=' with %3D and space with +, <BR>etc. The only = that shouldn't be encoded is the = after search.<BR><BR>For an easy way to find what is available to search on for a particular <BR>entity, if you go into the webadmin in the search bar you can start typing and <BR>it will auto complete the different available options. AFAIC those match <BR>exactly to the search in the REST api.<BR><BR>> > TIA<BR>> > <BR>> > /K<BR>> > <BR>> >> Is this approach OK for you?<BR>> >> <BR>> >>> Thanks,<BR>> >>> Hari<BR>> >>> <BR>> >>> DISCLAIMER<BR>> >>> <BR>> >>> The information in this e-mail is confidential and may be subject<BR>> >>> to<BR>> >>> legal privilege. It is intended solely for the addressee. Access to<BR>> >>> this<BR>> >>> e-mail by anyone else is unauthorized. If you have received this<BR>> >>> communication in error, please address with the subject heading<BR>> >>> "Received in error," send to it@msystechnologies.com<BR>> >>> <mailto:it@msystechnologies.com>,  then delete the e-mail and<BR>> >>> destroy<BR>> >>> any copies of it. If you are not the intended recipient, any<BR>> >>> disclosure,<BR>> >>> copying, distribution or any action taken or omitted to be taken<BR>> >>> in<BR>> >>> reliance on it, is prohibited and may be unlawful. The views,<BR>> >>> opinions,<BR>> >>> conclusions and other information expressed in this electronic mail<BR>> >>> and<BR>> >>> any attachments are not given or endorsed by the company unless<BR>> >>> otherwise indicated by an authorized representative independent of<BR>> >>> this<BR>> >>> message.<BR>> >>> <BR>> >>> MSys cannot guarantee that e-mail communications are secure or<BR>> >>> error-free, as information could be intercepted, corrupted,<BR>> >>> amended,<BR>> >>> lost, destroyed, arrive late or incomplete, or contain viruses,<BR>> >>> though<BR>> >>> all reasonable precautions have been taken to ensure no viruses<BR>> >>> are<BR>> >>> present in this e-mail. As our company cannot accept responsibility<BR>> >>> for<BR>> >>> any loss or damage arising from the use of this e-mail or<BR>> >>> attachments we<BR>> >>> recommend that you subject these to your virus checking procedures<BR>> >>> prior<BR>> >>> to use<BR>> >>> <BR>> >>> <BR>> >>> _______________________________________________<BR>> >>> Users mailing list<BR>> >>> Users@ovirt.org<BR>> >>> http://lists.ovirt.org/mailman/listinfo/users<BR>> >> <BR>> >> _______________________________________________<BR>> >> Users mailing list<BR>> >> Users@ovirt.org<BR>> >> http://lists.ovirt.org/mailman/listinfo/users<BR>> <BR>> _______________________________________________<BR>> Users mailing list<BR>> Users@ovirt.org<BR>> http://lists.ovirt.org/mailman/listinfo/users<BR><BR></body></html>