[ovirt-devel] Ruby SDK NIC search
Juan Hernández
jhernand at redhat.com
Tue Feb 21 13:27:32 UTC 2017
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' }
More information about the Devel
mailing list