Project

General

Profile

Bug #20742

Updated by Tomáš Strachota about 7 years ago

hammer host reports allow specifying the host by either --id or --name. None of the methods actually work. 

 *Using --name* 
 Ends up with 400 error 
 <pre> 
 > hammer host reports --name sandy-oberdorf.tstracho-laptop 
 Error: 400 Bad Request 
 </pre> 

 caused by: 
 <pre> 
 [ INFO 2017-08-25 12:27:34 API] GET /api/reports 
 [DEBUG 2017-08-25 12:27:34 API] Params: { 
     :search => "name = \"sandy-oberdorf.tstracho-laptop\"" 
 } 
 [DEBUG 2017-08-25 12:27:34 API] Headers: { 
     :params => { 
         :search => "name = \"sandy-oberdorf.tstracho-laptop\"" 
     } 
 } 
 [ERROR 2017-08-25 12:27:34 API] 400 Bad Request 
 [DEBUG 2017-08-25 12:27:34 API] { 
     "error" => { 
         "message" => "Field 'name' not recognized for searching!", 
           "class" => "ScopedSearch::QueryNotSupported" 
     } 
 } 
 </pre> 

 *Using --id* 
 Returns empty list 
 <pre> 
 hammer host reports --id 13 
 ---|------|-------------|---------|-----------|--------|------------------|---------|-------- 
 ID | HOST | LAST REPORT | APPLIED | RESTARTED | FAILED | RESTART FAILURES | SKIPPED | PENDING 
 ---|------|-------------|---------|-----------|--------|------------------|---------|-------- 
 </pre> 

 which is caused by wrong search condition: 
 <pre> 
 [ INFO 2017-08-25 12:54:59 API] GET /api/reports 
 [DEBUG 2017-08-25 12:54:59 API] Params: { 
         "page" => 1, 
     "per_page" => 1000, 
           "id" => "13", 
      "host_id" => "13" 
 } 
 [DEBUG 2017-08-25 12:54:59 API] Headers: { 
     :params => { 
             "page" => 1, 
         "per_page" => 1000, 
               "id" => "13", 
          "host_id" => "13" 
     } 
 } 
 [DEBUG 2017-08-25 12:54:59 API] Using authenticator: HammerCLIForeman::Api::SessionAuthenticatorWrapper 
 [DEBUG 2017-08-25 12:54:59 API] Response: { 
        "total" => 135, 
     "subtotal" => 0, 
         "page" => 1, 
     "per_page" => 1000, 
       "search" => " host = 13", 
         "sort" => { 
            "by" => nil, 
         "order" => nil 
     }, 
      "results" => [] 
 } 

 </pre> 
 Note that searching by "host = <HOSTNAME>" would work as intended (tested in the UI). 


 The fix should be quite simple: modify the command to use "host = X" or "host.id = X" search query according to what parameters were used.

Back