[prev in list] [next in list] [prev in thread] [next in thread] 

List:       vdsm-devel
Subject:    Re: [ovirt-devel] Ruby SDK NIC search
From:       Marc Young <3vilpenguin () gmail ! com>
Date:       2017-02-21 13:30:52
Message-ID: CAJgSuAX6cbOUJ+NaiMoJy_5P04=ftZ0B5QMj332xMuoYCx-2cA () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Thanks. I was relying on an method missing exception to distinguish if it
was available. I'll update accordingly.

On Tue, Feb 21, 2017 at 7:27 AM, Juan Hernández <jhernand@redhat.com> wrote:

> On 02/21/2017 02:16 PM, Marc Young wrote:
> > Is there something malformed in this? Based on previous usages of
> > `.list(search: "...")` this does not seem like correct behavior
> >
> >
> >     > env[:connection].system_service.vnic_profiles_service.list(search:
> >     "name=#{iface_options[:network_name]}").map(&:name)
> >     => ["ovirtmgmt", "ovirtmgmt"]
> >
> >     > env[:connection].system_service.vnic_profiles_service.list(search:
> >     "name=foo").map(&:name)
> >     => ["ovirtmgmt", "ovirtmgmt"]
> >
> >     > env[:connection].system_service.vnic_profiles_service.
> list.map(&:name)
> >     => ["ovirtmgmt", "ovirtmgmt"]
> >
> >
> > No matter what I provide it always returns all
> >
> > Search works for other services:
> >
> >     > env[:connection].system_service.vms_service.list(search:
> >     'name=myvm').map(&:name)
> >     => []
> >
> >     > env[:connection].system_service.vms_service.list(search:
> >     'name=testing').map(&:name)
> >     => ["testing"]
> >
> >     > env[:connection].system_service.vms_service.list(search:
> >     'name=e').map(&:name)
> >     => []
> >
>
> Not all the services provide the search mechanism, only those that have
> the "search" parameter. The vNIC profiles service doesn't have it:
>
>
> http://www.rubydoc.info/gems/ovirt-engine-sdk/OvirtSDK4/
> VnicProfilesService#list-instance_method
>
> For services that don't support search, if you provide the "search"
> option, it will just be silently ignored. This should be checked, and we
> have a bug already open for that:
>
>   sdk should raise an exception when unknown parameter is used
>   https://bugzilla.redhat.com/1378113
>
> So you need to do the search yourself, explicitly. For example, using
> the 'detect' method:
>
>   vnic_profiles_service.list.detect { |x| x.name == 'myprofile' }
>
>

[Attachment #5 (text/html)]

<div dir="ltr">Thanks. I was relying on an method missing exception to distinguish if \
it was available. I&#39;ll update accordingly.</div><div class="gmail_extra"><br><div \
class="gmail_quote">On Tue, Feb 21, 2017 at 7:27 AM, Juan Hernández <span \
dir="ltr">&lt;<a href="mailto:jhernand@redhat.com" \
target="_blank">jhernand@redhat.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 02/21/2017 02:16 PM, \
Marc Young wrote:<br> &gt; Is there something malformed in this? Based on previous \
usages of<br> &gt; `.list(search: &quot;...&quot;)` this does not seem like correct \
behavior<br> &gt;<br>
&gt;<br>
&gt;        &gt; env[:connection].system_<wbr>service.vnic_profiles_service.<wbr>list(search:<br>
 &gt;        &quot;name=#{iface_options[:<wbr>network_name]}&quot;).map(&amp;:name)<br>
 &gt;        =&gt; [&quot;ovirtmgmt&quot;, &quot;ovirtmgmt&quot;]<br>
&gt;<br>
&gt;        &gt; env[:connection].system_<wbr>service.vnic_profiles_service.<wbr>list(search:<br>
 &gt;        &quot;name=foo&quot;).map(&amp;:name)<br>
&gt;        =&gt; [&quot;ovirtmgmt&quot;, &quot;ovirtmgmt&quot;]<br>
&gt;<br>
&gt;        &gt; env[:connection].system_<wbr>service.vnic_profiles_service.<wbr>list.map(&amp;:name)<br>
 &gt;        =&gt; [&quot;ovirtmgmt&quot;, &quot;ovirtmgmt&quot;]<br>
&gt;<br>
&gt;<br>
&gt; No matter what I provide it always returns all<br>
&gt;<br>
&gt; Search works for other services:<br>
&gt;<br>
&gt;        &gt; env[:connection].system_<wbr>service.vms_service.list(<wbr>search:<br>
 &gt;        &#39;name=myvm&#39;).map(&amp;:name)<br>
&gt;        =&gt; []<br>
&gt;<br>
&gt;        &gt; env[:connection].system_<wbr>service.vms_service.list(<wbr>search:<br>
 &gt;        &#39;name=testing&#39;).map(&amp;:name)<br>
&gt;        =&gt; [&quot;testing&quot;]<br>
&gt;<br>
&gt;        &gt; env[:connection].system_<wbr>service.vms_service.list(<wbr>search:<br>
 &gt;        &#39;name=e&#39;).map(&amp;:name)<br>
&gt;        =&gt; []<br>
&gt;<br>
<br>
</div></div>Not all the services provide the search mechanism, only those that \
have<br> the &quot;search&quot; parameter. The vNIC profiles service doesn&#39;t have \
it:<br> <br>
<br>
<a href="http://www.rubydoc.info/gems/ovirt-engine-sdk/OvirtSDK4/VnicProfilesService#list-instance_method" \
rel="noreferrer" target="_blank">http://www.rubydoc.info/gems/<wbr>ovirt-engine-sdk/OvirtSDK4/<wbr>VnicProfilesService#list-<wbr>instance_method</a><br>
 <br>
For services that don&#39;t support search, if you provide the &quot;search&quot;<br>
option, it will just be silently ignored. This should be checked, and we<br>
have a bug already open for that:<br>
<br>
   sdk should raise an exception when unknown parameter is used<br>
   <a href="https://bugzilla.redhat.com/1378113" rel="noreferrer" \
target="_blank">https://bugzilla.redhat.com/<wbr>1378113</a><br> <br>
So you need to do the search yourself, explicitly. For example, using<br>
the &#39;detect&#39; method:<br>
<br>
   vnic_profiles_service.list.<wbr>detect { |x| <a href="http://x.name" \
rel="noreferrer" target="_blank">x.name</a> == &#39;myprofile&#39; }<br> <br>
</blockquote></div><br></div>



_______________________________________________
Devel mailing list
Devel@ovirt.org
http://lists.ovirt.org/mailman/listinfo/devel

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic