Bug 1298330 - Template name with a space causes problems
Summary: Template name with a space causes problems
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Virtualization Manager
Classification: Red Hat
Component: ovirt-engine
Version: 3.5.6
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ovirt-3.6.5
: ---
Assignee: Shahar Havivi
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-01-13 19:21 UTC by Jesus M. Rodriguez
Modified: 2019-04-28 13:45 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-02-23 12:01:40 UTC
oVirt Team: Virt
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
ovirt-engine export domain template screen (95.45 KB, image/png)
2016-01-13 19:27 UTC, Jesus M. Rodriguez
no flags Details
ovirt engine template display (103.77 KB, image/png)
2016-01-13 19:27 UTC, Jesus M. Rodriguez
no flags Details
screenshot showing RHEV engine version (20.79 KB, image/png)
2016-01-13 19:32 UTC, Jesus M. Rodriguez
no flags Details
ovirt engine logs (306.97 KB, application/x-gzip)
2016-01-13 19:35 UTC, Jesus M. Rodriguez
no flags Details

Description Jesus M. Rodriguez 2016-01-13 19:21:48 UTC
Description of problem:
Using the python-sdk I am able to import a template with a space in the name. But I am unable to use the python-sdk to get the template and check its status. None is returned.

Version-Release number of selected component (if applicable):
3.5.6

How reproducible:
Using the python-sdk we import a template giving it a name with a space in it.
  api = API(url=url, username=api_user, password=api_pass, insecure=True)
  data_center = api.datacenters.get(data_center_name)
  export_domain = data_center.storagedomains.get(export_domain_name)
  # Import appliance as a VM template
  export_domain = api.storagedomains.get(export_domain_name)
  storage_domain = api.storagedomains.get(storage_domain_name)
  cluster = api.clusters.get(name=cluster_name)
  import_template_params = params.Action(storage_domain=storage_domain, cluster=cluster)
  import_template(export_domain, vm_template_name, import_template_params)
  while api.templates.get(vm_template_name).status.state != 'ok':
    time.sleep(1)

api.templates.get(vm_template_name) returns None for our template if the name has a space in it. If the name does NOT have a space, the above works as expected.

The import_template method is defined as such:

def import_template(export_domain, vm_template_name, import_template_params, attempts=20):
    try:
        vm_templ = export_domain.templates.get(vm_template_name)
        vm_templ.import_template(import_template_params)
    except RequestError, e:
        if "Missing OVF file from VM" in e.detail and attempts > 0:
            print "Waiting to retry importing template...sleeping 30 seconds"
            time.sleep(30)
            return import_template(export_domain, vm_template_name, import_template_params, attempts=attempts-1)
        print e
        return False
    except Exception, e:
        print e
        return False
    return True

This returns True and I can see it in the RHEV Engine UI.


Actual results:
Template with a name is created in RHEV Engine but api.templates.get(vm_template_name) returns None.

Expected results:
I expect either to get back the Template that I can call status on OR a validation error that the template name is invalid.

Comment 1 Jesus M. Rodriguez 2016-01-13 19:27:14 UTC
Created attachment 1114491 [details]
ovirt-engine export domain template screen

This screenshot shows the template was successfully imported.

Comment 2 Jesus M. Rodriguez 2016-01-13 19:27:56 UTC
Created attachment 1114492 [details]
ovirt engine template display

This screenshot shows the template in the list of templates.

Comment 5 Jesus M. Rodriguez 2016-01-13 19:32:18 UTC
Created attachment 1114495 [details]
screenshot showing RHEV engine version

Comment 6 Jesus M. Rodriguez 2016-01-13 19:35:17 UTC
Created attachment 1114496 [details]
ovirt engine logs

engine.log shows the following when using a name with a space:

2016-01-13 19:32:50,296 INFO  [org.ovirt.engine.core.bll.SearchQuery] (ajp-/127.0.0.1:8702-8) ResourceManager::searchBusinessObjects - erroneous search text - Template : name=test space deployment-cfme-template
2016-01-13 19:32:50,324 INFO  [org.ovirt.engine.core.bll.SearchQuery] (ajp-/127.0.0.1:8702-6) ResourceManager::searchBusinessObjects - erroneous search text - Template : name=test space deployment-cfme-template
2016-01-13 19:32:50,353 INFO  [org.ovirt.engine.core.bll.SearchQuery] (ajp-/127.0.0.1:8702-7) ResourceManager::searchBusinessObjects - erroneous search text - Template : name=test space deployment-cfme-template

Comment 7 Jesus M. Rodriguez 2016-01-13 19:39:28 UTC
Also searching with the search bar in the UI causes the following invalid SQL to cause an exception:

  Position: 707: org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [SELECT * FROM (SELECT * FROM vm_templates_view WHERE ( vmt_guid IN (SELECT distinct vm_templates_storage_domain.vmt_guid FROM  vm_templates_storage_domain   WHERE  vm_templates_view.storage_pool_name ILIKE 'Default'  AND  (  vm_templates_storage_domain.name ILIKE '%deployment-cfme-template%' OR  vm_templates_storage_domain.description ILIKE '%deployment-cfme-template%' OR  vm_templates_storage_domain.quota_name ILIKE '%deployment-cfme-template%' OR  vm_templates_storage_domain.storage_pool_name ILIKE '%deployment-cfme-template%' OR  vm_templates_storage_domain.vds_group_name ILIKE '%deployment-cfme-template%' OR  vm_templates_storage_domain.free_text_comment ILIKE '%deployment-cfme-template%' OR  vm_templates_storage_domain.template_version_name, template_version_number ILIKE '%deployment-cfme-template%' ) ))  ORDER BY name ASC ) as T1 OFFSET (1 -1) LIMIT 100]; nested exception is org.postgresql.util.PSQLException: ERROR: argument of OR must be type boolean, not type character varying
  Position: 707


The offending piece is:

  OR  vm_templates_storage_domain.template_version_name,

Seems it should have a value to result in a boolean, ILIKE or == etc. I'm not sure if this is related to the fact that I'm searching for a template with a space in it or not.

Comment 8 Jesus M. Rodriguez 2016-01-13 19:42:32 UTC
Script as a github gist for posterity: https://gist.github.com/jmrodri/546b26f7fd9fb302355f

Comment 9 Shahar Havivi 2016-01-18 07:35:57 UTC
How did you exported the template with space in the name for the first place?
This should be prevented...

Comment 10 Tomas Jelinek 2016-02-17 11:38:22 UTC
@Jesus: ping

Comment 11 Tomas Jelinek 2016-02-23 12:01:40 UTC
Templates with space in name are not supported in oVirt. It is validated both when creating from frontend and REST.

We could introduce support for this but it would not be simple to handle all cases where it could fail for not too big gain.

So, closing as not a bug considering the template has been created externally with a name not compatible with the ovirt's standards.

Please feel free to reopen if the above is not true.


Note You need to log in before you can comment on or make changes to this bug.