Bug 1281350

Summary: None admin users cant do bulk actions on hosts
Product: Red Hat Satellite Reporter: Kamudini Gazdikova <kshirsal>
Component: ProvisioningAssignee: Katello Bug Bin <katello-bugs>
Status: CLOSED ERRATA QA Contact: Corey Welton <cwelton>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.1.3CC: bbuckingham, chpeters, cwelton, daobrien, tkolhar
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: All   
OS: All   
URL: http://projects.theforeman.org/issues/12452
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Non admin users were blocked from performing bulk actions on hosts. This restriction was removed.
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-01-21 07:42:38 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:
Bug Depends On: 1215659, 1296877    
Bug Blocks:    

Description Kamudini Gazdikova 2015-11-12 11:08:56 UTC
Description of problem:
None admin users cant do balk actions on hosts

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


How reproducible:
When trying to do bulk action on hosts with non admin user causes:
~~~
ActionView::Template::Error (PG::AmbiguousColumn: ERROR:  column reference "id" is ambiguous
 | LINE 1: ... (1) AND "hosts"."type" IN ('Host::Managed') AND (id IN ('5'...
 |                                                              ^
 | : SELECT "hosts"."id" AS t0_r0, "hosts"."name" AS t0_r1, "hosts"."last_compile" AS t0_r2, "hosts"."last_report" AS t0_r3, "hosts"."updated_at" AS t0_r4, "hosts"."created_at" AS t0_r5, "hosts"."root_pass" AS t0_r6, "hosts"."architecture_id" AS t0_r7, "hosts"."operatingsystem_id" AS t0_r8, "hosts"."environment_id" AS t0_r9, "hosts"."ptable_id" AS t0_r10, "hosts"."medium_id" AS t0_r11, "hosts"."build" AS t0_r12, "hosts"."comment" AS t0_r13, "hosts"."disk" AS t0_r14, "hosts"."installed_at" AS t0_r15, "hosts"."model_id" AS t0_r16, "hosts"."hostgroup_id" AS t0_r17, "hosts"."owner_id" AS t0_r18, "hosts"."owner_type" AS t0_r19, "hosts"."enabled" AS t0_r20, "hosts"."puppet_ca_proxy_id" AS t0_r21, "hosts"."managed" AS t0_r22, "hosts"."use_image" AS t0_r23, "hosts"."image_file" AS t0_r24, "hosts"."uuid" AS t0_r25, "hosts"."compute_resource_id" AS t0_r26, "hosts"."puppet_proxy_id" AS t0_r27, "hosts"."certname" AS t0_r28, "hosts"."image_id" AS t0_r29, "hosts"."organization_id" AS t0_r30, "hosts"."location_id" AS t0_r31, "hosts"."type" AS t0_r32, "hosts"."otp" AS t0_r33, "hosts"."realm_id" AS t0_r34, "hosts"."compute_profile_id" AS t0_r35, "hosts"."provision_method" AS t0_r36, "hosts"."grub_pass" AS t0_r37, "hosts"."discovery_rule_id" AS t0_r38, "hosts"."global_status" AS t0_r39, "hosts"."lookup_value_matcher" AS t0_r40, "hostgroups"."id" AS t1_r0, "hostgroups"."name" AS t1_r1, "hostgroups"."created_at" AS t1_r2, "hostgroups"."updated_at" AS t1_r3, "hostgroups"."environment_id" AS t1_r4, "hostgroups"."operatingsystem_id" AS t1_r5, "hostgroups"."architecture_id" AS t1_r6, "hostgroups"."medium_id" AS t1_r7, "hostgroups"."ptable_id" AS t1_r8, "hostgroups"."root_pass" AS t1_r9, "hostgroups"."puppet_ca_proxy_id" AS t1_r10, "hostgroups"."use_image" AS t1_r11, "hostgroups"."image_file" AS t1_r12, "hostgroups"."ancestry" AS t1_r13, "hostgroups"."vm_defaults" AS t1_r14, "hostgroups"."subnet_id" AS t1_r15, "hostgroups"."domain_id" AS t1_r16, "hostgroups"."puppet_proxy_id" AS t1_r17, "hostgroups"."title" AS t1_r18, "hostgroups"."realm_id" AS t1_r19, "hostgroups"."compute_profile_id" AS t1_r20, "hostgroups"."grub_pass" AS t1_r21, "hostgroups"."lookup_value_matcher" AS t1_r22, "environments"."id" AS t2_r0, "environments"."name" AS t2_r1, "environments"."created_at" AS t2_r2, "environments"."updated_at" AS t2_r3, "environments"."hosts_count" AS t2_r4, "environments"."hostgroups_count" AS t2_r5, "taxonomies"."id" AS t3_r0, "taxonomies"."name" AS t3_r1, "taxonomies"."type" AS t3_r2, "taxonomies"."created_at" AS t3_r3, "taxonomies"."updated_at" AS t3_r4, "taxonomies"."ignore_types" AS t3_r5, "taxonomies"."ancestry" AS t3_r6, "taxonomies"."title" AS t3_r7, "taxonomies"."description" AS t3_r8, "locations_hosts"."id" AS t4_r0, "locations_hosts"."name" AS t4_r1, "locations_hosts"."type" AS t4_r2, "locations_hosts"."created_at" AS t4_r3, "locations_hosts"."updated_at" AS t4_r4, "locations_hosts"."ignore_types" AS t4_r5, "locations_hosts"."ancestry" AS t4_r6, "locations_hosts"."title" AS t4_r7, "locations_hosts"."description" AS t4_r8 FROM "hosts" LEFT OUTER JOIN "hostgroups" ON "hostgroups"."id" = "hosts"."hostgroup_id" LEFT OUTER JOIN "environments" ON "environments"."id" = "hosts"."environment_id" LEFT OUTER JOIN "taxonomies" ON "taxonomies"."id" = "hosts"."organization_id" AND "taxonomies"."type" IN ('Organization') LEFT OUTER JOIN "taxonomies" "locations_hosts" ON "locations_hosts"."id" = "hosts"."location_id" AND "locations_hosts"."type" IN ('Location') WHERE "hosts"."organization_id" IN (2) AND "hosts"."location_id" IN (1) AND "hosts"."type" IN ('Host::Managed') AND (id IN ('5') or name IN (NULL))):
 |     20:         <% associations = [:hostgroup, :environment] %>
 |     21:         <% associations << :organization if SETTINGS[:organizations_enabled]  %>
 |     22:         <% associations << :location     if SETTINGS[:locations_enabled]  %>
 |     23:         <% hosts.includes(*associations).each do |host| %>
 |     24:           <tr>
 |     25:             <td><%=h host %>
 |     26:             </td>
 |   app/views/hosts/_selected_hosts.html.erb:23:in `_43aecc12a5aa4e08714fb03fd85fb355'
 |   app/views/hosts/multiple_build.html.erb:1:in `_77b9227ac525b2e63e519dc40c5fc266'
 |   app/controllers/concerns/application_shared.rb:13:in `set_timezone'
 |   app/models/concerns/foreman/thread_session.rb:32:in `clear_thread'
 |   lib/middleware/catch_json_parse_errors.rb:9:in `call'
 | 
~~~

Additional info:
Issue is similar as described in http://projects.theforeman.org/issues/12452 and seems to be fixed.

Comment 2 Bryan Kearney 2015-11-13 16:41:26 UTC
Upstream bug component is Provisioning

Comment 4 Bryan Kearney 2015-12-08 13:00:22 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/12452 has been closed
-------------
Alon Goldboim
Applied in changeset commit:935bc248287083b57c1c2bdf68e59c5a0035a4af.

Comment 6 Tazim Kolhar 2016-01-12 12:35:42 UTC
this bz is still failing:
# hammer -u admin -p changeme host create --medium-id 7 --root-pass dog8code --organization-id 1 --location-id 1 --architecture-id 1 --operatingsystem-id 2 --name test6 --environment-id 2 --compute-resource-id 1 --domain-id 1 --puppet-proxy-id 1 --partition-table-id 7 --hostgroup host_test_grp 
Could not create the host:
  Failed to create a compute comp_resource (Libvirt) instance test6.rhts.englab.brq.redhat.com: can't convert nil into String
   

# rpm -qa | grep foreman
dell-pe-sc1435-02.rhts.englab.brq.redhat.com-foreman-proxy-1.0-1.noarch
ruby193-rubygem-foreman_hooks-0.3.7-2.el7sat.noarch
foreman-vmware-1.7.2.50-1.el7sat.noarch
rubygem-hammer_cli_foreman_tasks-0.0.3.5-1.el7sat.noarch
foreman-ovirt-1.7.2.50-1.el7sat.noarch
ruby193-rubygem-foreman_gutterball-0.0.1.9-1.el7sat.noarch
foreman-1.7.2.50-1.el7sat.noarch
ruby193-rubygem-foreman_docker-1.2.0.24-1.el7sat.noarch
ruby193-rubygem-foreman-tasks-0.6.15.7-1.el7sat.noarch
rubygem-hammer_cli_foreman_bootdisk-0.1.2.7-1.el7sat.noarch
rubygem-hammer_cli_foreman_docker-0.0.3.10-1.el7sat.noarch
foreman-debug-1.7.2.50-1.el7sat.noarch
foreman-proxy-1.7.2.8-1.el7sat.noarch
foreman-postgresql-1.7.2.50-1.el7sat.noarch
dell-pe-sc1435-02.rhts.englab.brq.redhat.com-foreman-proxy-client-1.0-1.noarch
foreman-libvirt-1.7.2.50-1.el7sat.noarch
foreman-gce-1.7.2.50-1.el7sat.noarch
rubygem-hammer_cli_foreman-0.1.4.15-1.el7sat.noarch
dell-pe-sc1435-02.rhts.englab.brq.redhat.com-foreman-client-1.0-1.noarch
ruby193-rubygem-foreman_discovery-2.0.0.23-1.el7sat.noarch
foreman-selinux-1.7.2.17-1.el7sat.noarch
foreman-compute-1.7.2.50-1.el7sat.noarch
ruby193-rubygem-foreman-redhat_access-0.2.4-1.el7sat.noarch
rubygem-hammer_cli_foreman_discovery-0.0.1.10-1.el7sat.noarch
ruby193-rubygem-foreman_bootdisk-4.0.2.14-1.el7sat.noarch

Comment 7 Corey Welton 2016-01-15 23:39:05 UTC
I think we can mark this verified in 6.1.6 compose #5

* I created a user, 'hostuser' which has only access to view/edit hosts - this user does not have any admin rights.
* In hostuser's organization, I selected a variety of systems and performed a bulk action (Select Action > Delete Hosts)



result:

4 tasks, 4 success, 0 fail

Subtasks:

Destroy Host	stopped	success	2016-01-15 23:33:52 UTC	2016-01-15 23:33:53 UTC	hostuser
Destroy Host	stopped	success	2016-01-15 23:33:53 UTC	2016-01-15 23:33:53 UTC	hostuser
Destroy Host	stopped	success	2016-01-15 23:33:53 UTC	2016-01-15 23:33:53 UTC	hostuser
Destroy Host	stopped	success	2016-01-15 23:33:52 UTC	2016-01-15 23:33:53 UTC	hostuser

Comment 8 Tazim Kolhar 2016-01-16 14:50:45 UTC
Hi,

this worked for me too for sat6.1.6 compose 5:

# rpm -qa | grep foreman
hp-dl180g6-01.rhts.eng.bos.redhat.com-foreman-proxy-1.0-1.noarch
ruby193-rubygem-foreman_hooks-0.3.7-2.el7sat.noarch
foreman-vmware-1.7.2.50-1.el7sat.noarch
rubygem-hammer_cli_foreman_tasks-0.0.3.5-1.el7sat.noarch
foreman-selinux-1.7.2.17-1.el7sat.noarch
ruby193-rubygem-foreman_bootdisk-4.0.2.14-1.el7sat.noarch
foreman-ovirt-1.7.2.50-1.el7sat.noarch
foreman-1.7.2.50-1.el7sat.noarch
ruby193-rubygem-foreman_docker-1.2.0.24-1.el7sat.noarch
ruby193-rubygem-foreman-tasks-0.6.15.7-1.el7sat.noarch
rubygem-hammer_cli_foreman_bootdisk-0.1.2.7-1.el7sat.noarch
rubygem-hammer_cli_foreman_docker-0.0.3.10-1.el7sat.noarch
foreman-debug-1.7.2.50-1.el7sat.noarch
foreman-proxy-1.7.2.8-1.el7sat.noarch
hp-dl180g6-01.rhts.eng.bos.redhat.com-foreman-client-1.0-1.noarch
hp-dl180g6-01.rhts.eng.bos.redhat.com-foreman-proxy-client-1.0-1.noarch
foreman-discovery-image-3.0.5-3.el7sat.noarch
ruby193-rubygem-foreman_gutterball-0.0.1.9-1.el7sat.noarch
foreman-libvirt-1.7.2.50-1.el7sat.noarch
foreman-gce-1.7.2.50-1.el7sat.noarch
rubygem-hammer_cli_foreman-0.1.4.15-1.el7sat.noarch
ruby193-rubygem-foreman_discovery-2.0.0.23-1.el7sat.noarch
foreman-postgresql-1.7.2.50-1.el7sat.noarch
foreman-compute-1.7.2.50-1.el7sat.noarch
ruby193-rubygem-foreman-redhat_access-0.2.4-1.el7sat.noarch
rubygem-hammer_cli_foreman_discovery-0.0.1.10-1.el7sat.noarch



2 tasks, 2 success, 0 fail

SubTasks
Action 	State 	Result 	Started at 	Ended at 	User
Destroy Host 	stopped 	success 	2016-01-16 14:45:34 UTC 	2016-01-16 14:45:50 UTC 	testuser
Destroy Host 	stopped 	success 	2016-01-16 14:45:36 UTC 	2016-01-16 14:45:54 UTC 	testuser



Thanks and Regards,
Tazim

Comment 9 David O'Brien 2016-01-19 04:57:47 UTC
If this bug requires doc text for errata release, please provide draft
text in the doc text field in the following format:
 Cause:
 Consequence:
 Fix:
 Result:
The documentation team will review, edit, and approve the text.
If this bug does not require doc text, please set the
'requires_doc_text' flag to -.

Comment 12 errata-xmlrpc 2016-01-21 07:42:38 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2016:0052