<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 <awels@redhat.com>:<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>> 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></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>> > 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>> >>> , 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><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>