Project

General

Profile

Bug #15257

Default per_page configuration enables pagination, including in CSV mode

Added by Dominic Cleal over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Category:
Foreman commands (obsolete)
Target version:
-
Team Backlog:
Fixed in Releases:
Found in Releases:
In Kanboard:

Description

Pagination was disabled in both table and CSV formats by default since #10534 (in 0.3.0), but #14530 in master changed hammer_cli_foreman to paginate according to the config file's per_page value if set.

This value is set in the default hammer_cli config file (https://github.com/theforeman/hammer-cli/blob/0.6.1/config/cli_config.template.yml), so pagination is now enabled by default, even in CSV mode.

I think the configured setting should probably be ignored in CSV output mode (it is described as a 'ui' setting too), or remove the default per_page value of 20.


Related issues

Related to Hammer CLI - Bug #14530: hammer queries defaults to 1000 items per pageClosed2016-04-07
Related to Katello - Bug #15542: SAT6.1 Pagination control not supported for listing content hosts in host collection with Satellite 6 command-lineRejected2016-06-29
Has duplicate Katello - Bug #15274: [Sat6] hammer content-view filter rule list shows only 20 entriesDuplicate2016-06-02

Associated revisions

Revision 7904f9a6 (diff)
Added by Tomas Strachota over 4 years ago

Fixes #15257 - let print adapters decide whether to paginate

Revision 1466da4e (diff)
Added by Tomas Strachota over 4 years ago

Fixes #15257 - let print adapters decide whether to paginate

History

#1 Updated by Dominic Cleal over 4 years ago

  • Related to Bug #14530: hammer queries defaults to 1000 items per page added

#2 Updated by Dominic Cleal over 4 years ago

Tested on current master versions:

tfm-rubygem-hammer_cli-0.6.0-2.201605301239git17e9b68.el7.noarch
tfm-rubygem-hammer_cli_foreman-0.6.0-2.201605271002git382103d.el7.noarch

$ hammer -d fact list
[ INFO 2016-06-01 09:38:03 Init] Initialization of Hammer CLI (0.6.0) has started...
[DEBUG 2016-06-01 09:38:03 Init] Running at ruby 2.2.2-p95
[ INFO 2016-06-01 09:38:03 Init] Configuration from the file /etc/hammer/cli_config.yml has been loaded
[ INFO 2016-06-01 09:38:03 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman.yml has been loaded
[ INFO 2016-06-01 09:38:03 Init] Configuration from the file /root/.hammer/cli.modules.d/foreman.yml has been loaded
[DEBUG 2016-06-01 09:38:03 Connection] Registered: foreman
[DEBUG 2016-06-01 09:38:03 API] Global headers: {
        :content_type => "application/json",
              :accept => "application/json;version=2",
    "Accept-Language" => "en_GB" 
}
[DEBUG 2016-06-01 09:38:03 API] Follow redirects: never
[ INFO 2016-06-01 09:38:03 Modules] Extension module hammer_cli_foreman (0.6.0) loaded
[DEBUG 2016-06-01 09:38:03 Init] Using locale 'en_GB'
[DEBUG 2016-06-01 09:38:03 Init] 'mo' files for locale domain 'hammer-cli' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.6.0/locale'
[DEBUG 2016-06-01 09:38:03 Init] 'mo' files for locale domain 'hammer-cli-foreman' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.6.0/locale'
[ INFO 2016-06-01 09:38:03 HammerCLI::MainCommand] Called with options: {"option_debug"=>true}
[ INFO 2016-06-01 09:38:03 HammerCLIForeman::Fact] Called with options: {}
[ INFO 2016-06-01 09:38:03 HammerCLIForeman::Fact::ListCommand] Called with options: {}
[ INFO 2016-06-01 09:38:03 API] Server: https://foreman.example.com
[ INFO 2016-06-01 09:38:03 API] GET /api/fact_values
[DEBUG 2016-06-01 09:38:03 API] Params: {
        "page" => 1,
    "per_page" => 20
}
[DEBUG 2016-06-01 09:38:03 API] Headers: {
    :params => {
            "page" => 1,
        "per_page" => 20
    }
}
[DEBUG 2016-06-01 09:38:03 API] Response: {
       "total" => 93,
    "subtotal" => 93,
        "page" => 1,
    "per_page" => 20,
      "search" => "",
        "sort" => {
           "by" => nil,
        "order" => nil
    },
     "results" => {
        "foreman.example.com" => {
                       "uptime_days" => "0",
                       "swapsize_mb" => "0.00",
                       "swapfree_mb" => "0.00",
                          "swapsize" => "0.00 MB",
                          "swapfree" => "0.00 MB",
                          "uniqueid" => "007f0100",
                 "bios_release_date" => "04/01/2014",
            "blockdevice_vda_vendor" => "0x1af4",
                    "processorcount" => "1",
            "physicalprocessorcount" => "1",
                      "uptime_hours" => "1",
              "blockdevice_vda_size" => "10737418240",
                        "network_lo" => "127.0.0.0",
                      "ipaddress_lo" => "127.0.0.1",
                            "uptime" => "1:38 hours",
                     "augeasversion" => "1.4.0",
                          "mtu_eth1" => "1500",
                          "mtu_eth0" => "1500",
                      "bios_version" => "1.8.2-20150715_102347-",
                      "network_eth0" => "192.168.122.0" 
        }
    }
}
[DEBUG 2016-06-01 09:38:03 API] Response headers: {
                      :date => "Wed, 01 Jun 2016 09:38:03 GMT",
                    :server => "Apache/2.4.6 (CentOS)",
             :cache_control => "max-age=0, private, must-revalidate",
          :x_xss_protection => "1; mode=block",
              :x_request_id => "241eaf2a-2214-432e-bf91-95e126c1cacd",
           :x_frame_options => "SAMEORIGIN",
           :foreman_version => "1.13.0-develop",
    :x_content_type_options => "nosniff",
       :foreman_api_version => "2",
           :apipie_checksum => "8ab4cc7c24acf9cca77f2593780c64a1",
                 :x_runtime => "0.081729",
              :x_powered_by => "Phusion Passenger 5.0.28",
                :set_cookie => [
        [0] "_session_id=c9fb2bccad9b46e2063c17da83406c0f; path=/; secure; HttpOnly" 
    ],
                      :etag => "W/\"649408b53ad3ac94e444fb50d675210d-gzip\"",
                    :status => "200 OK",
                      :vary => "Accept-Encoding",
          :content_encoding => "gzip",
            :content_length => "363",
              :content_type => "application/json; charset=utf-8" 
}
--------------------|------------------------|-----------------------
HOST                | FACT                   | VALUE                 
--------------------|------------------------|-----------------------
foreman.example.com | uptime_days            | 0                     
foreman.example.com | swapsize_mb            | 0.00                  
foreman.example.com | swapfree_mb            | 0.00                  
foreman.example.com | swapsize               | 0.00 MB               
foreman.example.com | swapfree               | 0.00 MB               
foreman.example.com | uniqueid               | 007f0100              
foreman.example.com | bios_release_date      | 04/01/2014            
foreman.example.com | blockdevice_vda_vendor | 0x1af4                
foreman.example.com | processorcount         | 1                     
foreman.example.com | physicalprocessorcount | 1                     
foreman.example.com | uptime_hours           | 1                     
foreman.example.com | blockdevice_vda_size   | 10737418240           
foreman.example.com | network_lo             | 127.0.0.0             
foreman.example.com | ipaddress_lo           | 127.0.0.1             
foreman.example.com | uptime                 | 1:38 hours            
foreman.example.com | augeasversion          | 1.4.0                 
foreman.example.com | mtu_eth1               | 1500                  
foreman.example.com | mtu_eth0               | 1500                  
foreman.example.com | bios_version           | 1.8.2-20150715_102347-
foreman.example.com | network_eth0           | 192.168.122.0         
--------------------|------------------------|-----------------------
Page 1 of 5 (use --page and --per-page for navigation)
$ head /etc/hammer/cli_config.yml
# User interface related settings
:ui:
  # Enable interactive queries?
  :interactive: true
  # Number of records listed per page
  :per_page: 20
  # Location of shell history file
  :history_file: '~/.hammer/history'

#3 Updated by Martin Bacovsky over 4 years ago

  • Status changed from New to Assigned
  • Assignee set to Martin Bacovsky

#4 Updated by Dominic Cleal over 4 years ago

Sorry, I included the wrong log (in table, not CSV mode).

$ hammer -d --csv fact list
[ INFO 2016-06-01 09:53:14 Init] Initialization of Hammer CLI (0.6.0) has started...
[DEBUG 2016-06-01 09:53:14 Init] Running at ruby 2.2.2-p95
[ INFO 2016-06-01 09:53:14 Init] Configuration from the file /etc/hammer/cli_config.yml has been loaded
[ INFO 2016-06-01 09:53:14 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman.yml has been loaded
[ INFO 2016-06-01 09:53:14 Init] Configuration from the file /root/.hammer/cli.modules.d/foreman.yml has been loaded
[DEBUG 2016-06-01 09:53:14 Connection] Registered: foreman
[DEBUG 2016-06-01 09:53:14 API] Global headers: {
        :content_type => "application/json",
              :accept => "application/json;version=2",
    "Accept-Language" => "en_GB" 
}
[DEBUG 2016-06-01 09:53:14 API] Follow redirects: never
[ INFO 2016-06-01 09:53:14 Modules] Extension module hammer_cli_foreman (0.6.0) loaded
[DEBUG 2016-06-01 09:53:14 Init] Using locale 'en_GB'
[DEBUG 2016-06-01 09:53:14 Init] 'mo' files for locale domain 'hammer-cli' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.6.0/locale'
[DEBUG 2016-06-01 09:53:14 Init] 'mo' files for locale domain 'hammer-cli-foreman' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.6.0/locale'
[ INFO 2016-06-01 09:53:14 HammerCLI::MainCommand] Called with options: {"option_debug"=>true}
[ INFO 2016-06-01 09:53:14 HammerCLIForeman::Fact] Called with options: {}
[ INFO 2016-06-01 09:53:14 HammerCLIForeman::Fact::ListCommand] Called with options: {}
[ INFO 2016-06-01 09:53:14 API] Server: https://foreman.example.com
[ INFO 2016-06-01 09:53:14 API] GET /api/fact_values
[DEBUG 2016-06-01 09:53:14 API] Params: {
        "page" => 1,
    "per_page" => 20
}
[DEBUG 2016-06-01 09:53:14 API] Headers: {
    :params => {
            "page" => 1,
        "per_page" => 20
    }
}
[DEBUG 2016-06-01 09:53:14 API] Response: {
       "total" => 93,
    "subtotal" => 93,
        "page" => 1,
    "per_page" => 20,
      "search" => "",
        "sort" => {
           "by" => nil,
        "order" => nil
    },
     "results" => {
        "foreman.example.com" => {
                       "uptime_days" => "0",
                       "swapsize_mb" => "0.00",
                       "swapfree_mb" => "0.00",
                          "swapsize" => "0.00 MB",
                          "swapfree" => "0.00 MB",
                          "uniqueid" => "007f0100",
                 "bios_release_date" => "04/01/2014",
            "blockdevice_vda_vendor" => "0x1af4",
                    "processorcount" => "1",
            "physicalprocessorcount" => "1",
                      "uptime_hours" => "1",
              "blockdevice_vda_size" => "10737418240",
                        "network_lo" => "127.0.0.0",
                      "ipaddress_lo" => "127.0.0.1",
                            "uptime" => "1:38 hours",
                     "augeasversion" => "1.4.0",
                          "mtu_eth1" => "1500",
                          "mtu_eth0" => "1500",
                      "bios_version" => "1.8.2-20150715_102347-",
                      "network_eth0" => "192.168.122.0" 
        }
    }
}
[DEBUG 2016-06-01 09:53:14 API] Response headers: {
                      :date => "Wed, 01 Jun 2016 09:53:14 GMT",
                    :server => "Apache/2.4.6 (CentOS)",
             :cache_control => "max-age=0, private, must-revalidate",
          :x_xss_protection => "1; mode=block",
              :x_request_id => "01645703-1411-4024-b6fb-41e333908b07",
           :x_frame_options => "SAMEORIGIN",
           :foreman_version => "1.13.0-develop",
    :x_content_type_options => "nosniff",
       :foreman_api_version => "2",
           :apipie_checksum => "8ab4cc7c24acf9cca77f2593780c64a1",
                 :x_runtime => "0.043445",
              :x_powered_by => "Phusion Passenger 5.0.28",
                :set_cookie => [
        [0] "_session_id=f319f8716a1d39c3680bac8f893ff0e6; path=/; secure; HttpOnly" 
    ],
                      :etag => "W/\"649408b53ad3ac94e444fb50d675210d-gzip\"",
                    :status => "200 OK",
                      :vary => "Accept-Encoding",
          :content_encoding => "gzip",
            :content_length => "363",
              :content_type => "application/json; charset=utf-8" 
}
Host,Fact,Value
foreman.example.com,uptime_days,0
foreman.example.com,swapsize_mb,0.00
foreman.example.com,swapfree_mb,0.00
foreman.example.com,swapsize,0.00 MB
foreman.example.com,swapfree,0.00 MB
foreman.example.com,uniqueid,007f0100
foreman.example.com,bios_release_date,04/01/2014
foreman.example.com,blockdevice_vda_vendor,0x1af4
foreman.example.com,processorcount,1
foreman.example.com,physicalprocessorcount,1
foreman.example.com,uptime_hours,1
foreman.example.com,blockdevice_vda_size,10737418240
foreman.example.com,network_lo,127.0.0.0
foreman.example.com,ipaddress_lo,127.0.0.1
foreman.example.com,uptime,1:38 hours
foreman.example.com,augeasversion,1.4.0
foreman.example.com,mtu_eth1,1500
foreman.example.com,mtu_eth0,1500
foreman.example.com,bios_version,1.8.2-20150715_102347-
foreman.example.com,network_eth0,192.168.122.0

#5 Updated by Martin Bacovsky over 4 years ago

  • Assignee changed from Martin Bacovsky to Tomáš Strachota

#6 Updated by The Foreman Bot over 4 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/hammer-cli/pull/208 added

#7 Updated by The Foreman Bot over 4 years ago

  • Pull request https://github.com/theforeman/hammer-cli-foreman/pull/243 added

#8 Updated by Anonymous over 4 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#9 Updated by Andrew Kofink over 4 years ago

  • Has duplicate Bug #15274: [Sat6] hammer content-view filter rule list shows only 20 entries added

#10 Updated by Andrew Kofink over 4 years ago

  • Related to Bug #15542: SAT6.1 Pagination control not supported for listing content hosts in host collection with Satellite 6 command-line added

Also available in: Atom PDF