Bug 1595188

Summary: `hammer host create --environment='...' ...` complains about missing lifecycle_environment
Product: Red Hat Satellite Reporter: Jan Hutař <jhutar>
Component: HammerAssignee: Rahul Bajaj <rabajaj>
Status: CLOSED DUPLICATE QA Contact: Katello QA List <katello-qa-list>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.4CC: akarsale, apatel, dhlavacd, inecas, kgaikwad, mbacovsk, mhulan, mshira, rabajaj, tstrachota
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-07-17 09:42:37 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jan Hutař 2018-06-26 10:31:46 UTC
Description of problem:
`hammer host create --environment='...' ...` complains about missing lifecycle_environment while `hammer host create --environment-id='...' ...` does not


Version-Release number of selected component (if applicable):
satellite-6.4.0-9.beta.el7sat.noarch


How reproducible:
always


Steps to Reproduce:
1. # hammer -u admin -p changeme host create --architecture-id="1" --domain-id="4" --environment-id="6" --ip="186.107.94.91" --location-id="2" --mac="4c:f7:c4:84:e2:93" --medium-id="11" --name="hur$RANDOM" --operatingsystem-id="2" --organization-id="1" --partition-table-id="94" --root-password="GKdvnWhu"
Host created.
2. # hammer -u admin -p changeme host create --architecture-id="1" --domain-id="4" --environment="KT_Ms0ovx_Library_OJLnvBxDrK_13" --ip="186.107.94.91" --location-id="2" --mac="4c:f7:c4:84:e2:93" --medium-id="11" --name="hur$RANDOM" --operatingsystem-id="2" --organization-id="1" --partition-table-id="94" --root-password="GKdvnWhu"
Could not create the host:
  Error: lifecycle_environment not found.


Actual results:
When you use "--environment=", it complains about the lifecycle_environment, it works when you use "--environment-id=".


Expected results:
Should work both ways


Additional info:
# hammer -d -u admin -p changeme host create --architecture-id="1" --domain-id="4" --environment="KT_Ms0ovx_Library_OJLnvBxDrK_13" --ip="186.107.94.91" --location-id="2" --mac="4c:f7:c4:84:e2:93" --medium-id="11" --name="hur$RANDOM" --operatingsystem-id="2" --organization-id="1" --partition-table-id="94" --root-password="GKdvnWhu" --lifecycle-environment-id 1
[ INFO 2018-06-26T06:30:18 Init] Initialization of Hammer CLI (0.13.0) has started...
[DEBUG 2018-06-26T06:30:18 Init] Running at ruby 2.4.3-p205
[ INFO 2018-06-26T06:30:18 Init] Configuration from the file /etc/hammer/cli_config.yml has been loaded
[ INFO 2018-06-26T06:30:18 Init] Configuration from the file /etc/hammer/cli.modules.d/csv.yml has been loaded
[ INFO 2018-06-26T06:30:18 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman.yml has been loaded
[ INFO 2018-06-26T06:30:18 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_admin.yml has been loaded
[ INFO 2018-06-26T06:30:18 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_admin_logging_core.yml has been loaded
[ INFO 2018-06-26T06:30:18 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_admin_logging_katello.yml has been loaded
[ INFO 2018-06-26T06:30:18 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_bootdisk.yml has been loaded
[ INFO 2018-06-26T06:30:18 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_discovery.yml has been loaded
[ INFO 2018-06-26T06:30:18 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_docker.yml has been loaded
[ INFO 2018-06-26T06:30:18 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_openscap.yml has been loaded
[ INFO 2018-06-26T06:30:18 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_remote_execution.yml has been loaded
[ INFO 2018-06-26T06:30:18 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_tasks.yml has been loaded
[ INFO 2018-06-26T06:30:18 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_templates.yml has been loaded
[ INFO 2018-06-26T06:30:18 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_virt_who_configure.yml has been loaded
[ INFO 2018-06-26T06:30:18 Init] Configuration from the file /etc/hammer/cli.modules.d/katello.yml has been loaded
[ INFO 2018-06-26T06:30:18 Init] Configuration from the file /root/.hammer/cli.modules.d/foreman.yml has been loaded
[DEBUG 2018-06-26T06:30:18 SSLoptions] SSL options: {
    :ssl_ca_file => "/etc/pki/katello/certs/katello-server-ca.crt",
     :verify_ssl => true
}
[DEBUG 2018-06-26T06:30:18 API] Global headers: {
        :content_type => "application/json",
              :accept => "application/json;version=2",
    "Accept-Language" => "en"
}
[DEBUG 2018-06-26T06:30:18 API] Follow redirects: never
[DEBUG 2018-06-26T06:30:18 Connection] Registered: foreman
[ INFO 2018-06-26T06:30:19 Modules] Extension module hammer_cli_foreman (0.13.0) loaded.
[ INFO 2018-06-26T06:30:19 Modules] Extension module hammer_cli_foreman_admin (0.0.8) loaded.
[ INFO 2018-06-26T06:30:19 Modules] Extension module hammer_cli_foreman_bootdisk (0.1.3.3) loaded.
[ INFO 2018-06-26T06:30:19 Modules] Extension module hammer_cli_foreman_discovery (1.0.0) loaded.
[ INFO 2018-06-26T06:30:19 Modules] Extension module hammer_cli_foreman_openscap (0.1.6) loaded.
[ INFO 2018-06-26T06:30:19 Modules] Extension module hammer_cli_foreman_templates (0.1.0) loaded.
[ INFO 2018-06-26T06:30:19 HammerCLI::MainCommand] subcommand organization (HammerCLIForeman::Organization) was removed.
[ INFO 2018-06-26T06:30:19 HammerCLI::MainCommand] subcommand organization (HammerCLIKatello::Organization) was created.
[ INFO 2018-06-26T06:30:19 Modules] Extension module hammer_cli_katello (0.13.1) loaded.
[DEBUG 2018-06-26T06:30:19 Init] Using locale 'en'
[DEBUG 2018-06-26T06:30:19 Init] 'mo' files for locale domain 'hammer-cli' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.13.0/locale'
[DEBUG 2018-06-26T06:30:19 Init] 'mo' files for locale domain 'hammer-cli-foreman' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.13.0/locale'
[DEBUG 2018-06-26T06:30:19 Init] 'mo' files for locale domain 'hammer-cli-csv' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_csv-2.3.1/locale'
[DEBUG 2018-06-26T06:30:19 Init] 'mo' files for locale domain 'hammer_cli_foreman_docker' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman_docker-0.0.6/locale'
[DEBUG 2018-06-26T06:30:19 Init] 'mo' files for locale domain 'hammer-cli-foreman-virt-who-configure' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman_virt_who_configure-0.0.3/locale'
[DEBUG 2018-06-26T06:30:19 Init] 'mo' files for locale domain 'hammer-cli-katello' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_katello-0.13.1/locale'
[ INFO 2018-06-26T06:30:19 HammerCLI::MainCommand] Called with options: {"option_debug"=>true, "option_username"=>"admin", "option_password"=>"***"}
[ INFO 2018-06-26T06:30:19 HammerCLIForeman::Host] Called with options: {}
[ INFO 2018-06-26T06:30:19 API] Server: https://<fqdn>
[ INFO 2018-06-26T06:30:19 API] GET /katello/api/organizations/1/environments
[DEBUG 2018-06-26T06:30:19 API] Params: {
    "name" => "KT_Ms0ovx_Library_OJLnvBxDrK_13"
}
[DEBUG 2018-06-26T06:30:19 API] Headers: {
    :params => {
        "name" => "KT_Ms0ovx_Library_OJLnvBxDrK_13"
    }
}
[DEBUG 2018-06-26T06:30:19 API] Using authenticator: HammerCLIForeman::Api::InteractiveBasicAuth
[DEBUG 2018-06-26T06:30:19 API] Response: {
       "total" => 0,
    "subtotal" => 0,
        "page" => 1,
    "per_page" => 20,
       "error" => nil,
      "search" => nil,
        "sort" => {
           "by" => "name",
        "order" => "asc"
    },
     "results" => []
}
[DEBUG 2018-06-26T06:30:19 API] Response headers: {
                                 :date => "Tue, 26 Jun 2018 10:30:19 GMT",
                               :server => "Apache/2.4.6 (Red Hat Enterprise Linux)",
                      :foreman_version => "1.18.0-RC1",
                  :foreman_api_version => "2",
                      :apipie_checksum => "852e93a6ac5deceb3d5b1fd20892055915485bbe",
                        :cache_control => "max-age=0, private, must-revalidate",
                         :x_request_id => "11344391-bd34-403b-aeb9-d29362224bea",
                            :x_runtime => "0.037017",
              :content_security_policy => "default-src 'self'; child-src 'self'; connect-src 'self' ws: wss:; img-src 'self' data: *.gravatar.com; script-src 'unsafe-eval' 'unsafe-inline' 'self'; style-src 'unsafe-inline' 'self'",
            :strict_transport_security => "max-age=631139040; includeSubdomains",
               :x_content_type_options => "nosniff",
                   :x_download_options => "noopen",
                      :x_frame_options => "sameorigin",
    :x_permitted_cross_domain_policies => "none",
                     :x_xss_protection => "1; mode=block",
                         :x_powered_by => "Phusion Passenger 4.0.18",
                           :set_cookie => [
        [0] "_session_id=126a75387ec5cd4b92243aab89fe236b; path=/; secure; HttpOnly; SameSite=Lax"
    ],
                                 :etag => "W/\"956e0fd5b832fbda8d01b01a5b7de844-gzip\"",
                               :status => "200 OK",
                                 :vary => "Accept-Encoding",
                     :content_encoding => "gzip",
                       :content_length => "112",
                         :content_type => "application/json; charset=utf-8"
}
[DEBUG 2018-06-26T06:30:19 Exception] Using exception handler HammerCLIForeman::ExceptionHandler#handle_general_exception
[ERROR 2018-06-26T06:30:19 Exception] Error: lifecycle_environment not found.
Could not create the host:
  Error: lifecycle_environment not found.
[ERROR 2018-06-26T06:30:19 Exception] 

HammerCLIForeman::ResolverError (lifecycle_environment not found.):
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.13.0/lib/hammer_cli_foreman/id_resolver.rb:241:in `pick_result'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.13.0/lib/hammer_cli_foreman/id_resolver.rb:198:in `find_resource'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.13.0/lib/hammer_cli_foreman/id_resolver.rb:146:in `get_id'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.13.0/lib/hammer_cli_foreman/id_resolver.rb:134:in `block (2 levels) in define_id_finders'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_katello-0.13.1/lib/hammer_cli_katello/id_resolver.rb:69:in `environment_id'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.13.0/lib/hammer_cli_foreman/commands.rb:131:in `get_resource_id'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.13.0/lib/hammer_cli_foreman/option_sources/id_params.rb:23:in `block in get_options'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.13.0/lib/hammer_cli_foreman/option_sources/id_params.rb:20:in `each'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.13.0/lib/hammer_cli_foreman/option_sources/id_params.rb:20:in `get_options'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.13.0/lib/hammer_cli/options/option_collector.rb:13:in `block in all_options_raw'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.13.0/lib/hammer_cli/options/option_collector.rb:12:in `each'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.13.0/lib/hammer_cli/options/option_collector.rb:12:in `inject'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.13.0/lib/hammer_cli/options/option_collector.rb:12:in `all_options_raw'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.13.0/lib/hammer_cli/options/option_collector.rb:18:in `all_options'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.13.0/lib/hammer_cli/options/option_collector.rb:22:in `options'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.13.0/lib/hammer_cli/abstract.rb:239:in `options'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.13.0/lib/hammer_cli/abstract.rb:42:in `parse'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:62:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.13.0/lib/hammer_cli/abstract.rb:29:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/subcommand/execution.rb:11:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:63:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.13.0/lib/hammer_cli/abstract.rb:29:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/subcommand/execution.rb:11:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:63:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.13.0/lib/hammer_cli/abstract.rb:29:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:132:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.13.0/bin/hammer:143:in `<top (required)>'
    /usr/bin/hammer:23:in `load'
    /usr/bin/hammer:23:in `<main>'