Bug 1065945

Summary: OVIRT-CLI: search by description doesn't return expected result
Product: [Retired] oVirt Reporter: Ilia Meerovich <iliam>
Component: ovirt-engine-cliAssignee: Juan Hernández <juan.hernandez>
Status: CLOSED CURRENTRELEASE QA Contact: Ilia Meerovich <iliam>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 3.4CC: acathrow, gklein, iheim, iliam, oramraz, yeylon
Target Milestone: ---   
Target Release: 3.4.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: infra
Fixed In Version: ovirt-engine-cli-3.4.0.4-1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-03-31 12:32:27 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ilia Meerovich 2014-02-17 11:18:57 UTC
[oVirt shell (connected)]# list datacenters --query "description='The default Data Center'" --max -1 --case_sensitive true

[oVirt shell (connected)]# list datacenters

id         : 00000002-0002-0002-0002-000000000002                                                                                                                                                                                            
name       : Default                                                                                                                                                                                                                         
description: The default Data Center                                                                                                                                                                                                         

[oVirt shell (connected)]#

Comment 1 Juan Hernández 2014-02-17 11:51:15 UTC
Ilia, from the description I don't understand what is the problem. Can you elaborate?

Comment 2 Ilia Meerovich 2014-02-17 12:32:23 UTC
I tried to run query by description field that exists in datacenter. 
<data_centers><data_center href="/api/datacenters/00000002-0002-0002-0002-000000000002" id="00000002-0002-0002-0002-000000000002"><name>Default</name><description>The default Data Center</description><link href="/api/datacenters/00000002-0002-0002-0002-000000000002/storagedomains" rel="storagedomains"/><link href="/api/datacenters/00000002-0002-0002-0002-000000000002/clusters" rel="clusters"/><link href="/api/datacenters/00000002-0002-0002-0002-000000000002/networks" rel="networks"/><link href="/api/datacenters/00000002-0002-0002-0002-000000000002/permissions" rel="permissions"/><link href="/api/datacenters/00000002-0002-0002-0002-000000000002/quotas" rel="quotas"/><local>false</local><version major="3" minor="4"/><supported_versions><version major="3" minor="4"/></supported_versions><status><state>uninitialized</state></status></data_center></data_centers>


I expected form such query to show datacenter that matches description in the description field.

Comment 3 Juan Hernández 2014-02-17 12:35:32 UTC
But you got the data center with description "The default Data Center", and that is what you requested. What am I missing?

Comment 4 Ilia Meerovich 2014-02-17 12:47:30 UTC
Please take a look again:
i got datacenters for simple 'list datcenters' query just to show that such datacenter exists. However 'list datacenters --query "description='The default Data Center'" --max -1 --case_sensitive true' didn't return any result

Comment 5 Juan Hernández 2014-02-17 13:11:40 UTC
Ok, I understand, thanks.

Comment 6 Juan Hernández 2014-02-17 13:37:13 UTC
The problem here is that the search capability of the engine requires double quotes for free text. Please try the following:

list datacenters --query 'description="The default Data Center"' --max -1 --case_sensitive true

If this works correctly I think we should close this as NOTABUG.

Comment 7 Ilia Meerovich 2014-02-17 13:40:49 UTC
[oVirt shell (connected)]# list datacenters --query 'description="The default Data Center"' --max -1 --case_sensitive true

id         : 00000002-0002-0002-0002-000000000002                                                                                                                                                                                            
name       : Default                                                                                                                                                                                                                         
description: The default Data Center                                                                                                                                                                                                         

[oVirt shell (connected)]# 


I wonder how end user will know about that ...

Comment 8 Juan Hernández 2014-02-17 15:00:31 UTC
The syntax is documented here:

https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Virtualization/3.3/html-single/Administration_Guide/index.html#Search_syntax_and_examples

I understand that users usually don't read documentation.

We can improve this a bit adding to the help for the list command something like this:

---8<---
- This example lists all virtual machines that have a given description:

  $ list vms --query 'description="The description"'

  Note that the the syntax of the search queries requires double quotes
  when the text includes spaces.
--->8---

Would that solve this issue?

Comment 9 Ilia Meerovich 2014-02-18 06:06:36 UTC
Good Idea - I think that it will solve this issue in cli.
In cli users mostly read cli help or use auto completion. 
So more examples will improve usability (i count myself as an user with some experience and still I faced this issue...)

Comment 10 Juan Hernández 2014-02-18 13:47:10 UTC
The packages containing the fix are available here:

http://jhernand.fedorapeople.org/rpms/ovirt-engine-cli/3.4.0.4-1/

Comment 11 Ilia Meerovich 2014-02-19 08:57:03 UTC
[oVirt shell (connected)]# help list

USAGE
  
  list <type> [parent identifiers] [command options]
  
DESCRIPTION
  
  List or search for objects of a certain type. There are two forms. If
  only <type> is provided, all objects of the specified type are
  returned. If a search query is given, it must be a valid oVirt search
  query. In that case objects matching the query are returned.
  
SUPPORTED HELP FORMATS
  
  - This help will list all available attribute options for listing 
    collection of given types
    
    * format      - help list types
    * example     - help list vms
  
  - This help will list all available attribute options for listing 
    subcollection of given types
    
    * format      - help list subtypes --parent-identifier
    * example     - help list disks --vm-identifier myvm
  
AVAILABLE TYPES
  
  The <type> parameter must be one of the following.
  
    * applications (contexts: [['vm']])
    * bricks (contexts: [['cluster', 'glustervolume'], ['datacenter', 'cluster', 'glustervolume']])
    * cdroms (contexts: [['template'], ['vm'], ['vm', 'snapshot']])
    * clusters (contexts: [[], ['datacenter']])
    * datacenters (contexts: [[]])
    * disks (contexts: [[], ['datacenter', 'storagedomain'], ['storagedomain'], ['storagedomain', 'template'], ['storagedomain', 'vm'], ['template'], ['vm'], ['vm', 'snapshot']])
    * domains (contexts: [[]])
    * events (contexts: [[]])
    * files (contexts: [['storagedomain']])
    * glusterhooks (contexts: [['cluster'], ['datacenter', 'cluster']])
    * glustervolumes (contexts: [['cluster'], ['datacenter', 'cluster']])
    * groups (contexts: [[], ['domain']])
    * hooks (contexts: [['host']])
    * hosts (contexts: [[]])
    * images (contexts: [['storagedomain']])
    * jobs (contexts: [[]])
    * labels (contexts: [['datacenter', 'network'], ['host', 'nic'], ['network']])
    * networks (contexts: [[], ['cluster'], ['datacenter'], ['datacenter', 'cluster']])
    * nics (contexts: [['host'], ['template'], ['vm'], ['vm', 'snapshot']])
    * permissions (contexts: [[], ['cluster'], ['datacenter'], ['datacenter', 'cluster'], ['datacenter', 'network'], ['datacenter', 'network', 'vnicprofile'], ['datacenter', 'storagedomain', 'disk'], ['disk'], ['group'], ['host'], ['network'], ['network', 'vnicprofile'], ['storagedomain'], ['storagedomain', 'disk'], ['template'], ['user'], ['vm'], ['vm', 'disk'], ['vmpool'], ['vnicprofile']])
    * permits (contexts: [['group', 'role'], ['role'], ['user', 'role']])
    * quotas (contexts: [['datacenter']])
    * reporteddevices (contexts: [['vm'], ['vm', 'nic']])
    * roles (contexts: [[], ['group'], ['user']])
    * snapshots (contexts: [['vm']])
    * statistics (contexts: [['cluster', 'glustervolume', 'brick'], ['datacenter', 'cluster', 'glustervolume', 'brick'], ['datacenter', 'storagedomain', 'disk'], ['disk'], ['host'], ['host', 'nic'], ['job', 'step'], ['storagedomain', 'disk'], ['vm'], ['vm', 'disk'], ['vm', 'nic']])
    * steps (contexts: [['job']])
    * storageconnections (contexts: [[], ['storagedomain']])
    * storagedomains (contexts: [[], ['datacenter']])
    * tags (contexts: [[], ['group'], ['host'], ['user'], ['vm']])
    * templates (contexts: [[], ['storagedomain']])
    * users (contexts: [[], ['domain']])
    * vmpools (contexts: [[]])
    * vms (contexts: [[], ['storagedomain']])
    * vnicprofiles (contexts: [[], ['datacenter', 'network'], ['network']])
    * watchdogs (contexts: [['template'], ['vm']])
  
OBJECT IDENTIFIERS
  
  Some objects can only exist inside other objects. For example, a disk
  can only exist in the content of a virtual machine. In this case, one
  or more object identifier opties needs to be provided to identify the
  containing object.
  
  An object identifier is an option of the form '--<type>id <id>'. This
  would identify an object with type <type> and id <id>. See the
  examples section below for a few examples.
  
EXAMPLES
  
  - This example lists all virtual machines:
  
    $ list vms
  
  - This example lists all virtual machines with all (not empty) properties,
    (by default only id/name/description properties displayed, using
    --show-all option, all not empty properties will be displayed,
    to see entire resource - use 'show' command)
  
    $ list vms --show-all
  
  - This example lists only virtual machines that have a name that starts 
    with "myvm":
  
    $ list vms --query "name=myvm*"
  
  - This example lists all virtual machines that have a given description:
  
    $ list vms --query 'description="The description"'
  
    Note that the the syntax of the search queries requires double quotes
    when the text includes spaces.
  
  - This example list all disks by vm_id in virtual machine 'myvm':
  
    $ list disks --vm-identifier myvm
    
  - This example list all vms having memory size of 1073741824 using client 
    side filtering (this kind of filtering is useful on non queryable collections
    or for filtering resources based on properties which are not supported by oVirt
    querying dialect)
  
    $ list vms --kwargs "memory=1073741824"
    
  - This example retrieves vm disk with name 'Disk 3' using client side filtering 
    as oVirt dialect is not available on vm disks collection.          
    
    $ list disks --vm-identifier myvm --kwargs "name=Disk 3"
  
RETURN VALUES
  
  This command will exit with one of the following statuses. To see the
  exit status of the last command, type 'status'.
  
    * 006 (AUTHENTICATION_ERROR)
    * 002 (COMMAND_ERROR)
    * 005 (COMMUNICATION_ERROR)
    * 003 (INTERRUPTED)
    * 011 (NOT_FOUND)
    * 000 (OK)
    * 010 (REMOTE_ERROR)
    * 001 (SYNTAX_ERROR)
    * 004 (UNKNOWN_ERROR)
  

[oVirt shell (connected)]# exit


  =========================================================================================================================================================================================================================================
                                                                                                   >>> disconnected from oVirt manager <<<
  =========================================================================================================================================================================================================================================

imeerovi@imeerovi ~/git/ART (RHEVM-979-dc-search) $ rpm -qa | grep ovirt
ovirt-engine-cli-3.4.0.4-1.el6.noarch
ovirt-engine-sdk-python-3.4.0.4-1.el6.noarch

Comment 12 Sandro Bonazzola 2014-03-31 12:32:27 UTC
this is an automated message: moving to Closed CURRENT RELEASE since oVirt 3.4.0 has been released