Bug #26083
closedRename default search definition for templates
Description
Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1678300
Description of problem: Searching template for string "default" returns the wrong result
→ hammer --no-headers --csv template list --search "TEST defaul"
137,TEST default,provision
→ hammer --no-headers --csv template list --search "TEST default"
No Result
Other test result
--------
Satellite 6.5
----
→ hammer --no-headers --csv template list --search "default" | wc -l
93
→ hammer --no-headers --csv template list --search "defaul" | wc -l
61
Satellite 6.3(Correct result)
---
→ hammer --csv template list --search "default" | wc -l
122
→ hammer --csv template list --search "defaul" | wc -l
122
*Version-Release number of selected component (if applicable):*6.5.0
How reproducible: Always
Additional info:
Sql Query in Satellite 6.3
Satellite 6.3:
------
SELECT COUNT FROM "templates" LEFT OUTER JOIN "operatingsystems_provisioning_templates" ON "operatingsystems_provisioning_templates"."provisioning_template_id" = "templates"."id" LEFT OUTER JOIN "operatingsystems" ON "operatingsystems"."id" = "operatingsystems_provisioning_templates"."operatingsystem_id" LEFT OUTER JOIN "template_combinations" ON "template_combinations"."provisioning_template_id" = "templates"."id" LEFT OUTER JOIN "environments" ON "environments"."id" = "template_combinations"."environment_id" LEFT OUTER JOIN "template_combinations" "template_combinations_templates_join" ON "template_combinations_templates_join"."provisioning_template_id" = "templates"."id" LEFT OUTER JOIN "hostgroups" ON "hostgroups"."id" = "template_combinations_templates_join"."hostgroup_id" LEFT OUTER JOIN "template_kinds" ON "template_kinds"."id" = "templates"."template_kind_id" WHERE "templates"."type" IN ('ProvisioningTemplate') AND ((("templates"."name" ILIKE '%UNSW%' OR "templates"."template" ILIKE '%UNSW%' OR "operatingsystems"."name" ILIKE '%UNSW%' OR "environments"."name" ILIKE '%UNSW%' OR "hostgroups"."name" ILIKE '%UNSW%' OR "template_kinds"."name" ILIKE '%UNSW%') AND ("templates"."name" ILIKE '%default%' OR "templates"."template" ILIKE '%default%' OR "operatingsystems"."name" ILIKE '%default%' OR "environments"."name" ILIKE '%default%' OR "hostgroups"."name" ILIKE '%default%' OR "template_kinds"."name" ILIKE '%default%')))
Satellite 6.5:
-------
irb(main):010:0> ProvisioningTemplate.search_for("UNSW default").count
D, [2019-02-18T16:39:01.316511 #28441] DEBUG -- : (14.2ms) SELECT COUNT FROM "templates" LEFT OUTER JOIN "operatingsystems_provisioning_templates" ON "operatingsystems_provisioning_templates"."provisioning_template_id" = "templates"."id" LEFT OUTER JOIN "operatingsystems" ON "operatingsystems"."id" = "operatingsystems_provisioning_templates"."operatingsystem_id" LEFT OUTER JOIN "template_combinations" ON "template_combinations"."provisioning_template_id" = "templates"."id" LEFT OUTER JOIN "environments" ON "environments"."id" = "template_combinations"."environment_id" LEFT OUTER JOIN "template_combinations" "template_combinations_templates_join" ON "template_combinations_templates_join"."provisioning_template_id" = "templates"."id" LEFT OUTER JOIN "hostgroups" ON "hostgroups"."id" = "template_combinations_templates_join"."hostgroup_id" LEFT OUTER JOIN "template_kinds" ON "template_kinds"."id" = "templates"."template_kind_id" WHERE "templates"."type" IN ('ProvisioningTemplate') AND ((("templates"."name" ILIKE '%UNSW%' OR "templates"."template" ILIKE '%UNSW%' OR "operatingsystems"."name" ILIKE '%UNSW%' OR "environments"."name" ILIKE '%UNSW%' OR "hostgroups"."name" ILIKE '%UNSW%' OR "template_kinds"."name" ILIKE '%UNSW%') AND (("templates"."default" <> 'f'))))
In Satellite 6.5: the sql query search only in the default template
AND (("templates"."default" <> 'f'))
Workaround: Set default = true in the template