theforeman / hammer-cli-foreman-templates

CLI plugin with import and export commands
GNU General Public License v3.0
0 stars 6 forks source link

Getting 404 with import-templates #3

Closed treydock closed 6 years ago

treydock commented 6 years ago

I think this CLI tool may be using wrong API path? Using Foreman 1.17.1 , foreman_templates 5.0.1 and this project's 0.1.0:

[root@foreman ~]# hammer import-templates 
[Foreman] Username: tdockendorf
[Foreman] Password for tdockendorf: 
Could not import:
  404 Not Found

Foreman logs:

2018-06-07T15:00:30 13cb275a [app] [I] Started POST "/api/template/import" for 10.20.0.1 at 2018-06-07 15:00:30 -0400
2018-06-07T15:00:30 13cb275a [app] [F]   
2018-06-07T15:00:30 13cb275a [app] [F] ActionController::RoutingError (No route matches [POST] "/api/template/import"):
2018-06-07T15:00:30 13cb275a [app] [F]   
2018-06-07T15:00:30 13cb275a [app] [F] lib/middleware/tagged_logging.rb:18:in `call'

Looking at foreman-rake routes I see /api/templates/import not /api/template/import.

ofedoren commented 6 years ago

@treydock, I apologize for taking so long to reply. I'd recommend you to upgrade foreman_templates to 6.0.0 or 5.0.2 at least, because this plugin does not support foreman_templates <= 5.0.1.

treydock commented 6 years ago

I'm now on foreman_templates 6.0.2 and using hammer CLI for templates at version 0.1.0:

tfm-rubygem-foreman_templates-6.0.2-1.fm1_18.el7.noarch
tfm-rubygem-hammer_cli_foreman_templates-0.1.0-1.fm1_18.el7.noarch

[root@foreman-test ~]# hammer import-templates 
[Foreman] Username: tdockendorf
[Foreman] Password for tdockendorf: 
Could not import:
  404 Not Found
treydock commented 6 years ago

Looks like still using route API path:

2018-07-06T08:52:34 [I|app|] Started POST "/api/template/import" for 10.20.0.24 at 2018-07-06 08:52:34 -0400
2018-07-06T08:52:35 [I|app|] Started HEAD "/" for 127.0.0.1 at 2018-07-06 08:52:35 -0400
2018-07-06T08:52:35 [I|app|6cc4a] Processing by DashboardController#index as HTML
2018-07-06T08:52:35 [I|app|6cc4a] Redirected to https://foreman-test.ten.osc.edu/users/login
2018-07-06T08:52:35 [I|app|6cc4a] Filter chain halted as :require_login rendered or redirected
2018-07-06T08:52:35 [I|app|6cc4a] Completed 302 Found in 42ms (ActiveRecord: 7.3ms)
2018-07-06T08:52:36 [F|app|]   
2018-07-06T08:52:36 [F|app|] ActionController::RoutingError (No route matches [POST] "/api/template/import"):
2018-07-06T08:52:36 [F|app|]   

Route listed by routes rake task:

                                             import_api_templates POST   /api(/:apiv)/templates/import(.:format)                                                                                                                api/v2/template#import {:format=>"json", :apiv=>/v1|v2/}
ofedoren commented 6 years ago

@treydock are you using the latest apidoc? After upgrading to a newer version of any foreman plugin there is a possibility that hammer uses the old Apipie cache.

Try hammer -r import-templates. -r or --reload-cache will reload the cache.

treydock commented 6 years ago

Reloading the cache solved my problem.