Bug 1023151 - hammer: apparently cannot delete proxy via --name
hammer: apparently cannot delete proxy via --name
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Provisioning (Show other bugs)
Unspecified Unspecified
unspecified Severity medium (vote)
: Unspecified
: --
Assigned To: jmagen@redhat.com
Tazim Kolhar
: Triaged
Depends On:
  Show dependency treegraph
Reported: 2013-10-24 13:41 EDT by Corey Welton
Modified: 2016-04-22 11:34 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2014-05-26 13:56:04 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

External Trackers
Tracker ID Priority Status Summary Last Updated
Foreman Issue Tracker 3524 None None None 2016-04-22 11:34 EDT

  None (edit)
Description Corey Welton 2013-10-24 13:41:15 EDT
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 13:41:52 EDT
Comment 3 Dominic Cleal 2013-10-25 07:16:09 EDT
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)

Comment 4 Dominic Cleal 2013-10-25 10:27:14 EDT
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 10:47:16 EST
Fixed in develop in 78ced7bb10d0324db16b2a19851d228fb6dfc61c.
Comment 9 Tazim Kolhar 2014-05-14 07:07:06 EDT
# 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".

Comment 10 jmagen@redhat.com 2014-05-19 08:58:40 EDT
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 11:49:44 EDT
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 04:04:30 EDT
# 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 04:11:13 EDT
(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- or higher).
Comment 15 Tazim Kolhar 2014-05-23 04:27:16 EDT
I am using Snap 5 Compose 4
Comment 16 Adam Saleh 2014-05-26 13:56:04 EDT
On snap 6, it seems to work.

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

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