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:
Satellite-6.0.2-RHEL-6-20131023.1
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
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.
Fixed in develop in 78ced7bb10d0324db16b2a19851d228fb6dfc61c.
# 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
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"
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.
# hammer proxy list undefined local variable or method `session' for Foreman::Controller::UsersMixin:Module Hammer proxy list itself is failing
(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).
I am using Snap 5 Compose 4
On snap 6, it seems to work. hammer -u admin -p changeme proxy delete --name qetello02.usersys.redhat.com Smart proxy deleted