Bug 1023151

Summary: hammer: apparently cannot delete proxy via --name
Product: Red Hat Satellite Reporter: Corey Welton <cwelton>
Component: ProvisioningAssignee: jmagen <jmagen>
Status: CLOSED WORKSFORME QA Contact: Tazim Kolhar <tkolhar>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.0.2CC: asaleh, cwelton, dcleal, skottler, tkolhar
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/3524
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-05-26 17:56:04 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:

Description Corey Welton 2013-10-24 17:41:15 UTC
Description of problem:
Attempting to delete a proxy via --name fails with a 404, depsite assuring you have the proper name. --id works ok.

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


How reproducible:


Steps to Reproduce:
1.  create some proxies
2.  'hammer -u admin -p admin proxy list' to get a list of proxy names.  note that it may be too long to appear in CLI output -- if so, verify, copy/paste from UI
3.   hammer -u admin -p admin proxy delete --name <name>

Actual results:

[root@cloud-qe-21 ~]# hammer -u admin -p admin proxy delete --name "mgmt2.rhq.lab.eng.bos.redhat.com"
Could not delete the proxy:
  404 Resource Not Found
[root@cloud-qe-21 ~]# hammer -u admin -p admin proxy list
--------------------------------------------------------------------
URL                            | ID | NAME                          
--------------------------------------------------------------------
https://cloud-qe-21.idm.lab... | 1  | cloud-qe-21.idm.lab.bos.red...
https://lenovo-rd230-01.lab... | 2  | lenovo-rd230-01.lab.bos.red...
https://mgmt2.rhq.lab.eng.b... | 3  | mgmt2.rhq.lab.eng.bos.redha...
--------------------------------------------------------------------

[root@cloud-qe-21 ~]# hammer -u admin -p admin proxy delete --id 3
Smart proxy deleted


Expected results:

Should be able to use --name parameter.

Additional info:

Comment 1 Corey Welton 2013-10-24 17:41:52 UTC
Satellite-6.0.2-RHEL-6-20131023.1

Comment 3 Dominic Cleal 2013-10-25 11:16:09 UTC
Could you provide /var/log/foreman/production.log please?  I hope we'll see the request causing the 404 there.  I can't reproduce this with upstream Foreman and Hammer at the moment.

[root@rhel6b ~]# hammer proxy delete --name test
Smart proxy deleted

[root@rhel6b ~]# tail -5 /var/log/foreman/production.log
Started DELETE "/api/smart_proxies/test" for ::1 at 2013-10-25 11:12:58 +0000
Processing by Api::V1::SmartProxiesController#destroy as JSON
  Parameters: {"id"=>"test", "smart_proxy"=>{}}
Authorized user admin(Admin User)
Completed 200 OK in 35ms (Views: 0.6ms | ActiveRecord: 0.0ms)

foreman-1.3.0-1.el6.noarch
rubygem-foreman_api-0.1.7-1.el6.noarch
rubygem-hammer_cli-0.0.7-1.el6.noarch
rubygem-hammer_cli_foreman-0.0.8-1.el6.noarch

Comment 4 Dominic Cleal 2013-10-25 14:27:14 UTC
Got it, the bug's in the API when the proxy name contains a ".", which it will if it's an FQDN.  As a workaround, use the ID or web UI.

Comment 5 Dominic Cleal 2013-12-05 15:47:16 UTC
Fixed in develop in 78ced7bb10d0324db16b2a19851d228fb6dfc61c.

Comment 9 Tazim Kolhar 2014-05-14 11:07:06 UTC
# hammer proxy list
---|---------------------------------------------|---------------------------------------------------------
ID | NAME                                        | URL                                                     
---|---------------------------------------------|---------------------------------------------------------
1  | ibm-x3650m4-01-vm-16.lab.eng.bos.redhat.com | https://ibm-x3650m4-01-vm-16.lab.eng.bos.redhat.com:9090
---|---------------------------------------------|---------------------------------------------------------

# hammer proxy delete --name ibm-x3650m4-01-vm-16.lab.eng.bos.redhat.com
Could not delete the proxy:
  ERROR:  update or delete on table "smart_proxies" violates foreign key constraint "hosts_puppet_ca_proxy_id_fk" on table "hosts"
  DETAIL:  Key (id)=(1) is still referenced from table "hosts".

Failed

Comment 10 jmagen@redhat.com 2014-05-19 12:58:40 UTC
Tazim, the error you are getting is different than the original bug which was fixed in develop in 78ced7bb10d0324db16b2a19851d228fb6dfc61c

This "new" bug is that it's not giving the correct error message and it's now fixed in https://github.com/theforeman/foreman/pull/1453 and awaiting merge into develop.

After this is merge, you should get an error such as 
    "ibm-x3650m4-01-vm-16.lab.eng.bos.redhat.com is used by h01.sat.lab.tlv.redhat.com"

Comment 11 Dominic Cleal 2014-05-20 15:49:44 UTC
Merged in f20ddfe.

Note to QE that this will still block deletion of smart proxies that are in use, but should give a clearer error message.  Remove resources that are using the proxy, or add a new proxy containing dots in the name and remove that.

Comment 13 Tazim Kolhar 2014-05-23 08:04:30 UTC
# hammer proxy list
undefined local variable or method `session' for Foreman::Controller::UsersMixin:Module

Hammer proxy list itself is failing

Comment 14 Dominic Cleal 2014-05-23 08:11:13 UTC
(In reply to Tazim Kolhar from comment #13)
> # hammer proxy list
> undefined local variable or method `session' for
> Foreman::Controller::UsersMixin:Module
> 
> Hammer proxy list itself is failing

This is bug #1096223, check you're using snap 6 (foreman-1.6.0.10-1-sat or higher).

Comment 15 Tazim Kolhar 2014-05-23 08:27:16 UTC
I am using Snap 5 Compose 4

Comment 16 Adam Saleh 2014-05-26 17:56:04 UTC
On snap 6, it seems to work.

hammer -u admin -p changeme proxy delete --name  qetello02.usersys.redhat.com
Smart proxy deleted