Hammer commands fails with error "Could not load the API description from the server - is the server down?"
Environment
- Red Hat Satellite 6.x
- Hammer CLI
Issue
-
Hammer commands fails with error "Could not load the API description from the server - is the server down?"
[root@satellite ~]# hammer -h Could not load the API description from the server - is the server down? - was 'foreman-rake apipie:cache' run on the server when using apipie cache? (typical production settings) Warning: An error occured while loading module hammer_cli_csv Could not load the API description from the server - is the server down? - was 'foreman-rake apipie:cache' run on the server when using apipie cache? (typical production settings) Warning: An error occured while loading module hammer_cli_foreman Could not load the API description from the server - is the server down? - was 'foreman-rake apipie:cache' run on the server when using apipie cache? (typical production settings) Warning: An error occured while loading module hammer_cli_foreman_bootdisk Could not load the API description from the server - is the server down? - was 'foreman-rake apipie:cache' run on the server when using apipie cache? (typical production settings) Warning: An error occured while loading module hammer_cli_foreman_docker Could not load the API description from the server - is the server down? - was 'foreman-rake apipie:cache' run on the server when using apipie cache? (typical production settings) Warning: An error occured while loading module hammer_cli_foreman_remote_execution Warning: An error occured while loading module hammer_cli_foreman_tasks Could not load the API description from the server - is the server down? - was 'foreman-rake apipie:cache' run on the server when using apipie cache? (typical production settings) Warning: An error occured while loading module hammer_cli_katello Usage: hammer [OPTIONS] SUBCOMMAND [ARG] ...[root@satellite ~]# hammer -d ping [ INFO 2020-12-08T14:52:46 Init] Initialization of Hammer CLI (2.1.2) has started... [DEBUG 2020-12-08T14:52:46 Init] Running at ruby 2.5.5-p157 ... [ INFO 2020-12-08T14:52:47 API] GET /apidoc/v2.en.json [DEBUG 2020-12-08T14:52:47 API] Params: {} [DEBUG 2020-12-08T14:52:47 API] Headers: { :accept => "application/json", :params => {} } [ERROR 2020-12-08T14:52:47 API] 404 Not Found [DEBUG 2020-12-08T14:52:47 API] Cache expired. (default -> bf21a9e8fbc5a3846fb05b4fa0859e0917b2202f) [ INFO 2020-12-08T14:52:47 API] Server: https://satellite.example.com/ [ INFO 2020-12-08T14:52:47 API] GET /apidoc/v2.json [DEBUG 2020-12-08T14:52:47 API] Params: {} [DEBUG 2020-12-08T14:52:47 API] Headers: { :accept => "application/json", :params => {} } [ERROR 2020-12-08T14:52:47 API] 404 Not Found [DEBUG 2020-12-08T14:52:47 API] "" [DEBUG 2020-12-08T14:52:47 Exception] Using exception handler HammerCLIForeman::ExceptionHandler#handle_apipie_docloading_error [ERROR 2020-12-08T14:52:47 Exception] Could not load the API description from the server: 404 Not Found - is the server down? - was 'foreman-rake apipie:cache' run on the server when using apipie cache? (typical production settings) [ WARN 2020-12-08T14:52:47 HammerCLI::Output::Output] Required adapter '' was not found, using 'base' instead Could not load the API description from the server:
Resolution
- Confirm the syntax of
/root/.hammer/cli.modules.d/foreman.yml(or/etc/hammer/cli_config.ymlon some old Sat releases) - use proper FQDN of your Satellite:
[root@satellite ~]# cat /root/.hammer/cli.modules.d/foreman.yml
:foreman:
:host: 'https://satellite.example.com/'
:username: 'admin'
:password: 'changeme'
[root@satellite ~]#
**Note:** Usually this issue occurs, if the `/etc/hammer/cli_config.yml` and `/root/.hammer/cli.modules.d/foreman.yml` have incorrect entries, any white spaces or incorrect indentation.
-
If hammer command reports the same error in spite of correct values, then execute following commands to generate apipie cache.
# foreman-rake apipie:cache # satellite-maintain service restart # hammer ping
For more KB articles/solutions related to Red Hat Satellite 6.x hammer Issues, please refer to the Consolidated Troubleshooting Article for Red Hat Satellite 6.x hammer-related Issues
Root Cause
- Incorrect syntax of the
/root/.hammer/cli.modules.d/foreman.ymlor/etc/hammer/cli_config.ymlconfig file or expired apipie cache.
Diagnostic Steps
-
Confirm if
hammerreturnsOKby-passing the reference tocli_config.ymlfile[root@satellite ~]# hammer -u admin -p changeme -s https://$(hostname -f):443 ping candlepin: Status: ok Server Response: Duration: 20ms candlepin_auth: Status: ok Server Response: Duration: 24ms pulp: Status: ok Server Response: Duration: 50ms pulp_auth: Status: ok Server Response: Duration: 25ms elasticsearch: Status: ok Server Response: Duration: 17ms foreman_tasks: Status: ok Server Response: Duration: 1ms -
If reporting is
OK, then execute the hammer CLI with the debug option, which would reveal the inconsistency[root@satellite ~]# hammer -d ping
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.