Project

General

Custom queries

Profile

Actions

Bug #25341

closed

CSV export of nested host groups fails with wrong REST-URI (leading to a 404) on third level

Added by Dirk Doerflinger over 6 years ago. Updated over 6 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Category:
-
Difficulty:
Triaged:
Yes
Fixed in Releases:
Found in Releases:

Description

We have nested hostgroups. CSV export of host-groups fails with the wrong ID.

Our groups are nested like this:

base
..division
....group
......tier
........subgroup

e.g. (including the hostgroup IDs)

base (6)
..backend (200)
....infra (201)
......production (202)
........storage (203)
......test (205)
........storage (206)

When running the export, the following happens:

$ hammer -d csv host-groups --export --continue-on-error

...

     "results" => [
        [  0] {
                       "subnet_id" => nil,
                     "subnet_name" => nil,
              "operatingsystem_id" => nil,
            "operatingsystem_name" => nil,
                       "domain_id" => nil,
                     "domain_name" => nil,
                  "environment_id" => nil,
                "environment_name" => nil,
              "compute_profile_id" => nil,
            "compute_profile_name" => nil,
                        "ancestry" => nil,
                       "parent_id" => nil,
                     "parent_name" => nil,
                       "ptable_id" => nil,
                     "ptable_name" => nil,
                       "medium_id" => nil,
                     "medium_name" => nil,
                      "subnet6_id" => nil,
                    "subnet6_name" => nil,
                 "architecture_id" => nil,
               "architecture_name" => nil,
                        "realm_id" => nil,
                      "realm_name" => nil,
                      "created_at" => "2016-11-23 09:44:10 UTC",
                      "updated_at" => "2018-07-06 11:20:00 UTC",
                              "id" => 6,
                            "name" => "base",
                           "title" => "base",
                     "description" => "",
                 "puppet_proxy_id" => nil,
               "puppet_proxy_name" => nil,
              "puppet_ca_proxy_id" => nil,
            "puppet_ca_proxy_name" => nil,
                    "puppet_proxy" => nil,
                 "puppet_ca_proxy" => nil
        },
        [  1] {
                       "subnet_id" => nil,
                     "subnet_name" => nil,
              "operatingsystem_id" => nil,
            "operatingsystem_name" => nil,
                       "domain_id" => nil,
                     "domain_name" => nil,
                  "environment_id" => nil,
                "environment_name" => nil,
              "compute_profile_id" => nil,
            "compute_profile_name" => nil,
                        "ancestry" => "6",
                       "parent_id" => 6,
                     "parent_name" => "base",
                       "ptable_id" => nil,
                     "ptable_name" => nil,
                       "medium_id" => nil,
                     "medium_name" => nil,
                      "subnet6_id" => nil,
                    "subnet6_name" => nil,
                 "architecture_id" => nil,
               "architecture_name" => nil,
                        "realm_id" => nil,
                      "realm_name" => nil,
                      "created_at" => "2018-06-26 09:15:18 UTC",
                      "updated_at" => "2018-06-26 09:15:18 UTC",
                              "id" => 200,
                            "name" => "backend",
                           "title" => "base/backend",
                     "description" => "",
                 "puppet_proxy_id" => nil,
               "puppet_proxy_name" => nil,
              "puppet_ca_proxy_id" => nil,
            "puppet_ca_proxy_name" => nil,
                    "puppet_proxy" => nil,
                 "puppet_ca_proxy" => nil
        },
        [  2] {
                       "subnet_id" => nil,
                     "subnet_name" => nil,
              "operatingsystem_id" => nil,
            "operatingsystem_name" => nil,
                       "domain_id" => nil,
                     "domain_name" => nil,
                  "environment_id" => nil,
                "environment_name" => nil,
              "compute_profile_id" => nil,
            "compute_profile_name" => nil,
                        "ancestry" => "6/200",
                       "parent_id" => 200,
                     "parent_name" => "base/backend",
                       "ptable_id" => nil,
                     "ptable_name" => nil,
                       "medium_id" => nil,
                     "medium_name" => nil,
                      "subnet6_id" => nil,
                    "subnet6_name" => nil,
                 "architecture_id" => nil,
               "architecture_name" => nil,
                        "realm_id" => nil,
                      "realm_name" => nil,
                      "created_at" => "2018-06-26 09:15:43 UTC",
                      "updated_at" => "2018-06-26 09:18:33 UTC",
                              "id" => 201,
                            "name" => "infra",
                           "title" => "base/backend/infra",
                     "description" => "",
                 "puppet_proxy_id" => nil,
               "puppet_proxy_name" => nil,
              "puppet_ca_proxy_id" => nil,
            "puppet_ca_proxy_name" => nil,
                    "puppet_proxy" => nil,
                 "puppet_ca_proxy" => nil
        },
        [  3] {
                       "subnet_id" => nil,
                     "subnet_name" => nil,
              "operatingsystem_id" => nil,
            "operatingsystem_name" => nil,
                       "domain_id" => nil,
                     "domain_name" => nil,
                  "environment_id" => nil,
                "environment_name" => nil,
              "compute_profile_id" => nil,
            "compute_profile_name" => nil,
                        "ancestry" => "6/200/201",
                       "parent_id" => 201,
                     "parent_name" => "base/backend/infra",
                       "ptable_id" => nil,
                     "ptable_name" => nil,
                       "medium_id" => nil,
                     "medium_name" => nil,
                      "subnet6_id" => nil,
                    "subnet6_name" => nil,
                 "architecture_id" => nil,
               "architecture_name" => nil,
                        "realm_id" => nil,
                      "realm_name" => nil,
                      "created_at" => "2018-06-26 09:15:47 UTC",
                      "updated_at" => "2018-06-26 09:15:47 UTC",
                              "id" => 202,
                            "name" => "production",
                           "title" => "base/backend/infra/production",
                     "description" => nil,
                 "puppet_proxy_id" => nil,
               "puppet_proxy_name" => nil,
              "puppet_ca_proxy_id" => nil,
            "puppet_ca_proxy_name" => nil,
                    "puppet_proxy" => nil,
                 "puppet_ca_proxy" => nil
        },
        [  4] {
                       "subnet_id" => nil,
                     "subnet_name" => nil,
              "operatingsystem_id" => nil,
            "operatingsystem_name" => nil,
                       "domain_id" => nil,
                     "domain_name" => nil,
                  "environment_id" => nil,
                "environment_name" => nil,
              "compute_profile_id" => nil,
            "compute_profile_name" => nil,
                        "ancestry" => "6/200/201/202",
                       "parent_id" => 202,
                     "parent_name" => "base/backend/infra/production",
                       "ptable_id" => nil,
                     "ptable_name" => nil,
                       "medium_id" => nil,
                     "medium_name" => nil,
                      "subnet6_id" => nil,
                    "subnet6_name" => nil,
                 "architecture_id" => nil,
               "architecture_name" => nil,
                        "realm_id" => nil,
                      "realm_name" => nil,
                      "created_at" => "2018-06-26 09:15:56 UTC",
                      "updated_at" => "2018-06-26 09:15:56 UTC",
                              "id" => 203,
                            "name" => "storage",
                           "title" => "base/backend/infra/production/storage",
                     "description" => nil,
                 "puppet_proxy_id" => nil,
               "puppet_proxy_name" => nil,
              "puppet_ca_proxy_id" => nil,
            "puppet_ca_proxy_name" => nil,
                    "puppet_proxy" => nil,
                 "puppet_ca_proxy" => nil
        },

... (shortened)

[ INFO 2018-10-30 08:03:48 API] GET /api/hostgroups/6

... (shortened, groupinfo here)

[ INFO 2018-10-30 08:03:48 API] GET /api/hostgroups/201

... (shortened, groupinfo here)

[ INFO 2018-10-30 08:03:48 API] GET /api/hostgroups/6/200

[DEBUG 2018-10-30 08:03:48 API] Params: {}
[DEBUG 2018-10-30 08:03:48 API] Headers: {
    :params => {}
}
[DEBUG 2018-10-30 08:03:48 API] Using authenticator: HammerCLIForeman::Api::SessionAuthenticatorWrapper
[ERROR 2018-10-30 08:03:48 API] 404 Not Found
[DEBUG 2018-10-30 08:03:48 API] {
    "status" => "404",
     "error" => "Not Found" 
}
[DEBUG 2018-10-30 08:03:48 Exception] Using exception handler HammerCLI::ExceptionHandler#handle_not_found
[ERROR 2018-10-30 08:03:48 Exception] 404 Not Found
404 Not Found
[ERROR 2018-10-30 08:03:48 Exception]

RestClient::NotFound (404 Not Found):
    /usr/local/share/gems/gems/rest-client-2.0.2/lib/restclient/abstract_response.rb:223:in `exception_with_response'
    /usr/local/share/gems/gems/rest-client-2.0.2/lib/restclient/abstract_response.rb:103:in `return!'
    /usr/local/share/gems/gems/apipie-bindings-0.2.2/lib/apipie_bindings/api.rb:353:in `block in rest_client_call_block'
    /usr/local/share/gems/gems/rest-client-2.0.2/lib/restclient/request.rb:807:in `call'
    /usr/local/share/gems/gems/rest-client-2.0.2/lib/restclient/request.rb:807:in `process_result'
    /usr/local/share/gems/gems/rest-client-2.0.2/lib/restclient/request.rb:725:in `block in transmit'
    /usr/share/ruby/net/http.rb:852:in `start'
    /usr/local/share/gems/gems/rest-client-2.0.2/lib/restclient/request.rb:715:in `transmit'
    /usr/local/share/gems/gems/rest-client-2.0.2/lib/restclient/request.rb:145:in `execute'
    /usr/local/share/gems/gems/rest-client-2.0.2/lib/restclient/request.rb:52:in `execute'
    /usr/local/share/gems/gems/rest-client-2.0.2/lib/restclient/resource.rb:51:in `get'
    /usr/local/share/gems/gems/apipie-bindings-0.2.2/lib/apipie_bindings/api.rb:327:in `call_client'
    /usr/local/share/gems/gems/apipie-bindings-0.2.2/lib/apipie_bindings/api.rb:240:in `http_call'
    /usr/local/share/gems/gems/apipie-bindings-0.2.2/lib/apipie_bindings/api.rb:190:in `call_action'
    /usr/local/share/gems/gems/apipie-bindings-0.2.2/lib/apipie_bindings/api.rb:185:in `call'
    /usr/local/share/gems/gems/apipie-bindings-0.2.2/lib/apipie_bindings/resource.rb:21:in `call'
    /home/in-kon.ch/adm_did/.gem/ruby/gems/hammer_cli_csv-2.3.1/lib/hammer_cli_csv/base.rb:590:in `foreman_hostgroup'
    /home/in-kon.ch/adm_did/.gem/ruby/gems/hammer_cli_csv-2.3.1/lib/hammer_cli_csv/host_groups.rb:51:in `block in export'
    /home/in-kon.ch/adm_did/.gem/ruby/gems/hammer_cli_csv-2.3.1/lib/hammer_cli_csv/host_groups.rb:32:in `each'
    /home/in-kon.ch/adm_did/.gem/ruby/gems/hammer_cli_csv-2.3.1/lib/hammer_cli_csv/host_groups.rb:32:in `export'
    /home/in-kon.ch/adm_did/.gem/ruby/gems/hammer_cli_csv-2.3.1/lib/hammer_cli_csv/base.rb:62:in `block in execute'
    /usr/share/ruby/csv.rb:1047:in `instance'
    /usr/share/ruby/csv.rb:2296:in `CSV'
    /home/in-kon.ch/adm_did/.gem/ruby/gems/hammer_cli_csv-2.3.1/lib/hammer_cli_csv/base.rb:61:in `execute'
    /usr/local/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:63:in `run'
    /usr/local/share/gems/gems/hammer_cli-0.15.0/lib/hammer_cli/abstract.rb:29:in `run'
    /usr/local/share/gems/gems/clamp-1.1.2/lib/clamp/subcommand/execution.rb:11:in `execute'
    /usr/local/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:63:in `run'
    /usr/local/share/gems/gems/hammer_cli-0.15.0/lib/hammer_cli/abstract.rb:29:in `run'
    /usr/local/share/gems/gems/clamp-1.1.2/lib/clamp/subcommand/execution.rb:11:in `execute'
    /usr/local/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:63:in `run'
    /usr/local/share/gems/gems/hammer_cli-0.15.0/lib/hammer_cli/abstract.rb:29:in `run'
    /usr/local/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:132:in `run'
    /usr/local/share/gems/gems/hammer_cli-0.15.0/bin/hammer:144:in `<top (required)>'
    /usr/local/bin/hammer:23:in `load'
    /usr/local/bin/hammer:23:in `<main>'

Or, without debug info:

 $ hammer csv host-groups --export --continue-on-error
Name,Parent Host Group,Organizations,Locations,Subnet,Domain,Operating System,Puppet Environment,Compute Profile,Partition Table,Medium,Architecture,Realm,Puppet Proxy,Puppet CA Proxy,Content Source,Password,Puppet Classes
base,,"","",,,,,,,,,,,,,,"" 
backend,base,"","",,,,,,,,,,,,,,"" 
404 Not Found

It ignores "continue-on-error" and simply breaks with a 404 for the wrong URI (URI seems to be created from Ancestors field).

#1

Updated by Andrew Kofink over 6 years ago

  • Triaged changed from No to Yes
  • Team Backlog Brad added
#2

Updated by Justin Sherrill over 6 years ago

  • Status changed from New to Rejected
Actions

Also available in: Atom PDF