Hammer cli can not download bootdisk ISO after upgrade to 3.4

Problem:
I have been using the hammer cli to download the bootdisk ISO for newly created Foreman hosts, to then upload to ovirt - we don’t have DHCP available everywhere.
Since upgrading to Foreman 3.4/Katello 4.6, this no longer works. Instead of downloading an ISO, it just downloads a text file containing the host info from the API.

Expected outcome:
To download the bootdisk ISO.

Perhaps its possible to download the bootdisk ISO via the API, instead of having to use hammer?
I’ve tried but can also only seem to download the host info…

Foreman and Proxy versions:
Foreman 3.4/Katello 4.6

Foreman and Proxy plugin versions:
rubygem-hammer_cli_foreman_tasks-0.0.17-1.fm3_2.el8.noarch
rubygem-foreman_bootdisk-21.0.0-1.fm3_4.el8.noarch
foreman-ovirt-3.4.0-1.el8.noarch
rubygem-hammer_cli_foreman-3.4.0-1.el8.noarch
rubygem-hammer_cli_foreman_bootdisk-0.3.0-2.el8.noarch

Distribution and version:
CentOS Stream release 8

Other relevant data:

@ofedoren does this sound familiar at all?

It rings a bell somewhat. Could you please run it once more with hammer --verbose --debug --refresh-cache $REST_OF_THE_COMMAND and post the output here?

Thanks for the quick response.
There doesn’t seem to be a ‘–refresh-cache’ option. Debug and verbose work though so output below…

$ hammer --verbose --debug bootdisk host --host host.abc.net --full true --file files/host.abc.net.iso [ INFO 2022-11-01T09:59:33 Init] Initialization of Hammer CLI (3.1.1) has started...
[DEBUG 2022-11-01T09:59:33 Init] Running at ruby 2.7.6-p219
[ INFO 2022-11-01T09:59:33 Init] Configuration from the file /etc/hammer/cli_config.yml has been loaded
[ INFO 2022-11-01T09:59:33 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman.yml has been loaded
[ INFO 2022-11-01T09:59:33 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_bootdisk.yml has been loaded
[ INFO 2022-11-01T09:59:33 Init] Configuration from the file /home/rob.backhurst/.hammer/cli.modules.d/foreman.yml has been loaded
[DEBUG 2022-11-01T09:59:34 SSLoptions] SSL options: {
    :verify_ssl => true
}
[DEBUG 2022-11-01T09:59:34 API] Global headers: {
        :content_type => "application/json",
              :accept => "application/json;version=2",
    "Accept-Language" => "en_GB"
}
[DEBUG 2022-11-01T09:59:34 API] Follow redirects: never
[DEBUG 2022-11-01T09:59:34 Connection] Registered: foreman
[DEBUG 2022-11-01T09:59:34 HammerCLIForeman::CommandExtensions::OptionSources] Added predefined options for HammerCLIForeman::Command:
[ INFO 2022-11-01T09:59:34 Extensions] Applied HammerCLIForeman::CommandExtensions::OptionSources for *all* except *nothing* on HammerCLIForeman::Command.
[DEBUG 2022-11-01T09:59:34 HammerCLIForeman::CommandExtensions::Fields] Added predefined options for HammerCLIForeman::ListCommand: [:fields]
[ INFO 2022-11-01T09:59:34 Extensions] Applied HammerCLIForeman::CommandExtensions::Fields for *all* except *nothing* on HammerCLIForeman::ListCommand.
[DEBUG 2022-11-01T09:59:34 HammerCLIForeman::CommandExtensions::Fields] Added predefined options for HammerCLIForeman::InfoCommand: [:fields]
[ INFO 2022-11-01T09:59:34 Extensions] Applied HammerCLIForeman::CommandExtensions::Fields for *all* except *nothing* on HammerCLIForeman::InfoCommand.
[DEBUG 2022-11-01T09:59:34 HammerCLIForeman::CommandExtensions::UpdateCommon] Added predefined options for HammerCLIForeman::UpdateCommand:
[ INFO 2022-11-01T09:59:34 Extensions] Applied HammerCLIForeman::CommandExtensions::UpdateCommon for *all* except *nothing* on HammerCLIForeman::UpdateCommand.
[ INFO 2022-11-01T09:59:34 Modules] Extension module hammer_cli_foreman (3.1.0) loaded.
[ INFO 2022-11-01T09:59:34 Modules] Extension module hammer_cli_foreman_bootdisk (0.3.0) loaded.
[DEBUG 2022-11-01T09:59:34 Init] Using locale 'en_GB'
[DEBUG 2022-11-01T09:59:34 Init] 'mo' files for locale domain 'hammer-cli' loaded from '/usr/share/gems/gems/hammer_cli-3.1.1/locale'
[DEBUG 2022-11-01T09:59:34 Init] 'mo' files for locale domain 'hammer-cli-foreman' loaded from '/usr/share/gems/gems/hammer_cli_foreman-3.1.0/locale'
[ INFO 2022-11-01T09:59:34 HammerCLI::MainCommand] Called with options: {"option_verbose"=>2, "option_debug"=>true}
[DEBUG 2022-11-01T09:59:34 HammerCLIForeman::CommandExtensions::OptionSources] Called block for HammerCLIForeman::Command option sources:
        #<Proc:0x0000559e38a21580 /usr/share/gems/gems/hammer_cli_foreman-3.1.0/lib/hammer_cli_foreman/command_extensions/option_sources.rb:6>
[ INFO 2022-11-01T09:59:34 HammerCLIForemanBootdisk::Bootdisk] Called with options: {}
[DEBUG 2022-11-01T09:59:34 HammerCLIForeman::CommandExtensions::OptionSources] Called block for HammerCLIForeman::Command option sources:
        #<Proc:0x0000559e38a21580 /usr/share/gems/gems/hammer_cli_foreman-3.1.0/lib/hammer_cli_foreman/command_extensions/option_sources.rb:6>
[ INFO 2022-11-01T09:59:34 API] Server: https://foreman-server.abc.net/
[ INFO 2022-11-01T09:59:34 API] GET /api/hosts
[DEBUG 2022-11-01T09:59:34 API] Params: {
      :search => "name = \"host.abc.net\"",
    :per_page => 1000,
        :page => 1
}
[DEBUG 2022-11-01T09:59:34 API] Headers: {
    :params => {
          :search => "name = \"host.abc.net\"",
        :per_page => 1000,
            :page => 1
    }
}
[DEBUG 2022-11-01T09:59:34 API] Using authenticator: HammerCLIForeman::Api::InteractiveBasicAuth
[DEBUG 2022-11-01T09:59:34 API] Cache expired. (cb3b4305f7a6698fb57f76dd67c01afc9a176fdb -> 89b9841c46b932e9f3da8f57cb9e66af8124a1ac)
[DEBUG 2022-11-01T09:59:34 API] Response: {
       "total" => 6,
    "subtotal" => 1,
        "page" => 1,
    "per_page" => 1000,
      "search" => "name = \"host.abc.net\"",
        "sort" => {
           "by" => nil,
        "order" => nil
    },
     "results" => [
        [0] {
                                       "ip" => "10.10.10.1",
                                      "ip6" => nil,
                              "last_report" => "2022-10-31 17:08:55 UTC",
                                      "mac" => "56:6f:e3:4e:00:89",
                                 "realm_id" => 1,
                               "realm_name" => "abc.net",
                                   "sp_mac" => nil,
                                    "sp_ip" => nil,
                                  "sp_name" => nil,
                                "domain_id" => 2,
                              "domain_name" => "abc.net",
                          "architecture_id" => 1,
                        "architecture_name" => "x86_64",
                       "operatingsystem_id" => 4,
                     "operatingsystem_name" => "AlmaLinux 8.6",
                                "subnet_id" => 18,
                              "subnet_name" => "ABC_dhcp",
                               "subnet6_id" => nil,
                             "subnet6_name" => nil,
                             "sp_subnet_id" => nil,
                                "ptable_id" => 216,
                              "ptable_name" => "Kickstart custom",
                                "medium_id" => nil,
                              "medium_name" => nil,
                               "pxe_loader" => "PXELinux BIOS",
                                    "build" => false,
                                  "comment" => "",
                                     "disk" => "",
                             "installed_at" => "2022-10-31 17:02:03 UTC",
                                 "model_id" => 3,
                             "hostgroup_id" => 2,
                                 "owner_id" => 4,
                               "owner_name" => "Admin User",
                               "owner_type" => "User",
                                  "enabled" => true,
                                  "managed" => true,
                                "use_image" => nil,
                               "image_file" => "",
                                     "uuid" => "ce17efbf-c4eb-413b-b8ef-9d763d6d3381",
                      "compute_resource_id" => 1,
                    "compute_resource_name" => "oVirt",
                       "compute_profile_id" => 4,
                     "compute_profile_name" => "small",
                             "capabilities" => [
                [0] "build",
                [1] "image",
                [2] "new_volume"
            ],
                         "provision_method" => "build",
                                 "certname" => "host.abc.net",
                                 "image_id" => nil,
                               "image_name" => nil,
                               "created_at" => "2022-10-31 16:44:13 UTC",
                               "updated_at" => "2022-10-31 18:39:24 UTC",
                             "last_compile" => "2022-10-31 18:39:23 UTC",
                            "global_status" => 1,
                      "global_status_label" => "Warning",
                            "bmc_available" => false,
                          "organization_id" => 1,
                        "organization_name" => "ABC",
                              "location_id" => 2,
                            "location_name" => "UK",
                            "puppet_status" => 2199023255555,
                               "model_name" => "RHEL",
                     "configuration_status" => 2199023255555,
               "configuration_status_label" => "Out of sync",
                             "build_status" => 0,
                       "build_status_label" => "Installed",
                         "execution_status" => 0,
                   "execution_status_label" => "Last execution succeeded",
                            "errata_status" => 0,
                      "errata_status_label" => "All errata applied",
                      "subscription_status" => 0,
                "subscription_status_label" => "Fully entitled",
                       "purpose_sla_status" => 3,
                 "purpose_sla_status_label" => "Not specified",
                      "purpose_role_status" => 3,
                "purpose_role_status_label" => "Not specified",
                     "purpose_usage_status" => 3,
               "purpose_usage_status_label" => "Not specified",
                    "purpose_addons_status" => 3,
              "purpose_addons_status_label" => "Not specified",
                           "purpose_status" => 3,
                     "purpose_status_label" => "Not specified",
                                     "name" => "host.abc.net",
                                       "id" => 93,
                          "puppet_proxy_id" => nil,
                        "puppet_proxy_name" => nil,
                       "puppet_ca_proxy_id" => nil,
                     "puppet_ca_proxy_name" => nil,
                        "openscap_proxy_id" => 2,
                      "openscap_proxy_name" => "foreman-proxy.abc.net",
                             "puppet_proxy" => nil,
                          "puppet_ca_proxy" => nil,
                           "openscap_proxy" => {
                "name" => "foreman-proxy.abc.net",
                  "id" => 2,
                 "url" => "https://foreman-proxy.abc.net:9090"
            },
                              "cockpit_url" => nil,
                           "hostgroup_name" => "dev-8",
                          "hostgroup_title" => "uk/dev-8",
                 "content_facet_attributes" => {
                                            "id" => 91,
                                          "uuid" => "234615b6-5886-45b7-841e-acd4dcd3cf29",
                               "content_view_id" => 3,
                             "content_view_name" => "AlmaLinux_8",
                      "lifecycle_environment_id" => 2,
                    "lifecycle_environment_name" => "dev",
                             "content_source_id" => 2,
                           "content_source_name" => "foreman-proxy.abc.net",
                       "kickstart_repository_id" => nil,
                     "kickstart_repository_name" => nil,
                                 "errata_counts" => {
                       "security" => 0,
                         "bugfix" => 0,
                    "enhancement" => 0,
                          "total" => 0
                },
                          "applicable_deb_count" => 0,
                          "upgradable_deb_count" => 0,
                      "applicable_package_count" => 0,
                      "upgradable_package_count" => 0,
                "applicable_module_stream_count" => 0,
                "upgradable_module_stream_count" => 0,
                                  "content_view" => {
                           "id" => 3,
                         "name" => "AlmaLinux_8",
                    "composite" => false
                },
                         "lifecycle_environment" => {
                      "id" => 2,
                    "name" => "dev"
                },
                                "content_source" => {
                      "id" => 2,
                    "name" => "foreman-proxy.abc.net",
                     "url" => "https://foreman-proxy.abc.net:9090"
                },
                          "kickstart_repository" => nil
            },
               "subscription_global_status" => 0,
            "subscription_facet_attributes" => {
                                "id" => 40,
                              "uuid" => "234615b6-5886-45b7-841e-acd4dcd3cf29",
                      "last_checkin" => "2022-11-01 08:52:23 UTC",
                     "service_level" => "",
                   "release_version" => nil,
                          "autoheal" => true,
                     "registered_at" => "2022-10-31 17:01:42 UTC",
                "registered_through" => "foreman-proxy.abc.net",
                      "purpose_role" => "",
                     "purpose_usage" => "",
                        "hypervisor" => false,
                              "user" => nil,
                    "purpose_addons" => []
            },
                            "reported_data" => {
                  "boot_time" => "2022-10-31 17:02:21 UTC",
                      "cores" => 1,
                    "sockets" => 2,
                "disks_total" => nil
            },
                           "uptime_seconds" => 61033
        }
    ]
}
[DEBUG 2022-11-01T09:59:34 API] Response headers: {
                                 :date => "Tue, 01 Nov 2022 09:59:34 GMT",
                               :server => "Apache",
                      :foreman_version => "3.4.0",
                  :foreman_api_version => "2",
         :foreman_current_organization => "; ANY",
             :foreman_current_location => "; ANY",
                         :content_type => "application/json; charset=utf-8",
                      :apipie_checksum => "89b9841c46b932e9f3da8f57cb9e66af8124a1ac",
                                 :etag => "W/\"5c09ed09bac42eda6a9cc03b389ea14a\"",
                        :cache_control => "max-age=0, private, must-revalidate",
                         :x_request_id => "d620786d-7e35-43a5-8035-44b3b450bbd0",
                            :x_runtime => "0.435260",
            :strict_transport_security => "max-age=631139040; includeSubdomains",
                      :x_frame_options => "sameorigin",
               :x_content_type_options => "nosniff",
                     :x_xss_protection => "1; mode=block",
                   :x_download_options => "noopen",
    :x_permitted_cross_domain_policies => "none",
              :content_security_policy => "default-src 'self'; child-src 'self'; connect-src 'self' ws: wss:; img-src 'self' data:; script-src 'unsafe-eval' 'unsafe-inline' 'self'; style-src 'unsafe-inline' 'self'",
                           :set_cookie => [
        [0] "_session_id=eead7f93434075616473724a2a18388e; path=/; secure; HttpOnly; SameSite=Lax"
    ],
                                  :via => "1.1 foreman-server.abc.net",
                    :transfer_encoding => "chunked"
}
[ INFO 2022-11-01T09:59:34 API] Server: https://foreman-server.abc.net/
[ INFO 2022-11-01T09:59:34 API] GET /apidoc/v2.en_GB.json
[DEBUG 2022-11-01T09:59:34 API] Params: {}
[DEBUG 2022-11-01T09:59:34 API] Headers: {
    :accept => "application/json",
    :params => {}
}
[DEBUG 2022-11-01T09:59:38 API] Response: Received OK
[DEBUG 2022-11-01T09:59:38 API] Response headers: {
                                 :date => "Tue, 01 Nov 2022 09:59:34 GMT",
                               :server => "Apache",
                         :content_type => "application/json; charset=utf-8",
                      :apipie_checksum => "89b9841c46b932e9f3da8f57cb9e66af8124a1ac",
                                 :etag => "W/\"8f7b5d68b580ab468037f2a3727f30de\"",
                        :cache_control => "max-age=0, private, must-revalidate",
                         :x_request_id => "68bac5b3-d3fe-4f24-8889-6a273ebc6b9c",
                            :x_runtime => "3.596227",
            :strict_transport_security => "max-age=631139040; includeSubdomains",
                      :x_frame_options => "sameorigin",
               :x_content_type_options => "nosniff",
                     :x_xss_protection => "1; mode=block",
                   :x_download_options => "noopen",
    :x_permitted_cross_domain_policies => "none",
              :content_security_policy => "default-src 'self'; child-src 'self'; connect-src 'self' ws: wss:; img-src 'self' data:; script-src 'unsafe-eval' 'unsafe-inline' 'self'; style-src 'unsafe-inline' 'self'",
                                  :via => "1.1 foreman-server.abc.net",
                    :transfer_encoding => "chunked"
}
[DEBUG 2022-11-01T09:59:38 API] New apidoc loaded from the server
[ INFO 2022-11-01T09:59:38 HammerCLIForemanBootdisk::Bootdisk::HostCommand] Called with options: {"option_full"=>true, "option_host_name"=>"host.abc.net", "option_file"=>"files/host.abc.net.iso", "option_host_id"=>93}
[ INFO 2022-11-01T09:59:38 API] Server: https://foreman-server.abc.net/
[ INFO 2022-11-01T09:59:38 API] GET /api/hosts/93
[DEBUG 2022-11-01T09:59:38 API] Params: {
    "full" => true
}
[DEBUG 2022-11-01T09:59:38 API] Headers: {
    :params => {
        "full" => true
    }
}
[DEBUG 2022-11-01T09:59:38 API] Using authenticator: HammerCLIForeman::Api::InteractiveBasicAuth
[DEBUG 2022-11-01T09:59:39 API] Response: <RestClient::Response 200 "{\"ip\":\"10.1...">
[DEBUG 2022-11-01T09:59:39 API] Response headers: {
                                 :date => "Tue, 01 Nov 2022 09:59:38 GMT",
                               :server => "Apache",
                      :foreman_version => "3.4.0",
                  :foreman_api_version => "2",
         :foreman_current_organization => "; ANY",
             :foreman_current_location => "; ANY",
                         :content_type => "application/json; charset=utf-8",
                      :apipie_checksum => "89b9841c46b932e9f3da8f57cb9e66af8124a1ac",
                                 :etag => "W/\"2e7fda7eacc911d712568d48605a3455\"",
                        :cache_control => "max-age=0, private, must-revalidate",
                         :x_request_id => "79705da1-b005-4dd8-aca8-b1668394341a",
                            :x_runtime => "0.550123",
            :strict_transport_security => "max-age=631139040; includeSubdomains",
                      :x_frame_options => "sameorigin",
               :x_content_type_options => "nosniff",
                     :x_xss_protection => "1; mode=block",
                   :x_download_options => "noopen",
    :x_permitted_cross_domain_policies => "none",
              :content_security_policy => "default-src 'self'; child-src 'self'; connect-src 'self' ws: wss:; img-src 'self' data:; script-src 'unsafe-eval' 'unsafe-inline' 'self'; style-src 'unsafe-inline' 'self'",
                           :set_cookie => [
        [0] "_session_id=56bbc637b5992a4894cf36957dcfae53; path=/; secure; HttpOnly; SameSite=Lax"
    ],
                                  :via => "1.1 foreman-server.abc.net",
                    :transfer_encoding => "chunked"
}
Successfully downloaded host disk image to files/host.abc.net.iso

$ file files/host.abc.net.net.iso
files/host.abc.net.iso: ASCII text, with very long lines, with no line terminators

Hmm, looks like the routes are all sorts of wrong. Opened an issue[1] to keep track of this

[1] - Bug #35700: Bootdisk api routes are not mapped correctly - Boot disk - Foreman

Thanks.

The issue caused by changes from this PR, added to my backlog, try to look at it asap

Perhaps its possible to download the bootdisk ISO via the API, instead of having to use hammer?

Problem is in API, not in the Foreman, you can download the image in UI on host detail page

Ok thanks - this is part of an automated job so needs the API to be working.

@robb @aruzicka Fix: https://github.com/theforeman/foreman_bootdisk/pull/132

Great thanks - how do i try this before new packages are released?
Can I simply replace the changed files…?

You can do this:

cd /usr/share/gems/gems

# Do the gem backup
cp -r foreman_bootdisk-21.0.0 foreman_bootdisk-21.0.0.BAK

# Download patch
cd foreman_bootdisk-21.0.0
wget https://github.com/theforeman/foreman_bootdisk/pull/132.patch -O boot.patch

# Edit boot.patch and remove everything after 
# "diff --git a/test/functional/foreman_bootdisk/api/v2/disks_controller_test.rb ..." line
# (including the line)
vim boot.patch

# Apply path
git apply boot.patch

# Restart foreman services
foreman-maintain service restart 

@robb if you confirm that the fix is ok I’ll merge the PR and release new version ASAP.

Yep that works, thanks for fixing so quickly!

1 Like