Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1202240 - provisioning a discovered host via hammer should show all mandatory options, otherwise user gets 500 ISE
Summary: provisioning a discovered host via hammer should show all mandatory options, ...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Hammer
Version: 6.1.0
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: Unspecified
Assignee: orabin
QA Contact: Sachin Ghai
URL: http://projects.theforeman.org/issues...
Whiteboard:
Depends On: 1197975
Blocks: 1193977
TreeView+ depends on / blocked
 
Reported: 2015-03-16 08:01 UTC by Sachin Ghai
Modified: 2017-02-23 20:18 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-08-12 13:55:55 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 9634 0 None None None 2016-04-22 16:00:34 UTC

Description Sachin Ghai 2015-03-16 08:01:45 UTC
Description of problem:
I was trying to provision a discovered host via hammer cli but wasn't sure about the mandatory options..

so I tried: 
# hammer --username admin --password changeme discovery provision
Could not create the host:
  Error: Could not find discovered_host, please set one of options --name, --id.

Here error says please set discovered_host name or ID.

fetch id:
==========

]# hammer --username admin --password changeme discovery list

---|-----------------|-------------------|---------------------|------|--------|------------|------------|---------|--------------------
ID | NAME            | MAC               | LAST REPORT         | CPUS | MEMORY | DISK COUNT | DISKS SIZE | SUBNET  | LAST REPORT        
---|-----------------|-------------------|---------------------|------|--------|------------|------------|---------|--------------------
6  | mac525400167941 | 52:54:00:16:79:41 | 2015/03/16 01:48:12 | 1    | 995    | 1          | 8192       | libvirt | 2015/03/16 01:48:12
---|-----------------|-------------------|---------------------|------|--------|------------|------------|---------|--------------------


]# hammer --username admin --password changeme discovery provision --id 6

Could not create the host:
  Error: 500 Internal Server Error


production.log says:
===================

2015-03-16 07:47:24 [I] Processing by Api::V2::DiscoveredHostsController#update as JSON
2015-03-16 07:47:24 [I]   Parameters: {"discovered_host"=>{}, "apiv"=>"v2", "id"=>"6"}
2015-03-16 07:47:24 [I] Authorized user admin(Admin User)
2015-03-16 07:47:24 [E] undefined method `boot_filename' for nil:NilClass (NoMethodError)
/usr/share/foreman/app/models/concerns/orchestration/dhcp.rb:60:in `dhcp_attrs'
/usr/share/foreman/app/models/concerns/orchestration/dhcp.rb:16:in `dhcp_record'
/usr/share/foreman/app/models/concerns/orchestration/dhcp.rb:140:in `dhcp_conflict_detected?'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:504:in `_run__368707488151697265__validation__15510762665



Version-Release number of selected component (if applicable):

sat6.1 beta snap6 compose2 (Satellite-6.1.0-RHEL-6-20150311.1).

How reproducible:
always

Steps to Reproduce:
1.
2.
3.

Actual results:
As per hammer error message, I provided the discovered host id, but got 500 ISE

Expected results:
if user didn't specify any option to "hammer discovery provision" then hammer should throw message with all mandatory options like:

Could not create the host:
  Error: Could not find discovered_host, please set one of options --name, --id along with <other_options>

OR

 when user provides "hammer discovery provision --id 6" then it should throw the proper error instead of 500 internal server error.



Additional info:
similar bz (https://bugzilla.redhat.com/show_bug.cgi?id=1197975) is already filed for the error but that's for rest API. This bz is for improving the error and required mandatory options for provisioning via CLI.

Comment 1 Sachin Ghai 2015-03-16 08:06:17 UTC
Please note that provisioning started when I tried provisioning by providing hostgroup id.
~]# hammer --username admin --password changeme discovery provision --id 6 --hostgroup-id 1
/usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.4/lib/hammer_cli/./apipie/../abstract.rb:68: warning: already initialized constant DEFAULT_LABEL_INDENT
Host created

Comment 3 Lukas Zapletal 2015-03-17 14:09:21 UTC
We are rebasing to discovery CLI 0.0.2 this week, if this is not fixed Ori will add required fields. But I think this was alrady fixed.

Comment 4 orabin 2015-03-23 15:02:11 UTC
this is related to: https://bugzilla.redhat.com/show_bug.cgi?id=1197975 so they should be resolved together

Comment 6 Sachin Ghai 2015-04-28 11:50:22 UTC
Reported issue is still reproducible with:

sat6.1 GA snap1 compose 2 (Satellite-6.1.0-RHEL-7-20150424.0)


[root@cloud-qe-9 ~]# hammer --username admin --password changeme discovery provision --id 3
Could not create the host:
  Error: 500 Internal Server Error
[


production.log:
===============

2015-04-28 07:48:02 [I] Processing by Api::V2::DiscoveredHostsController#update as JSON
2015-04-28 07:48:02 [I]   Parameters: {"discovered_host"=>{}, "apiv"=>"v2", "id"=>"3"}
2015-04-28 07:48:02 [I] Expire fragment views/tabs_and_title_records-3 (0.1ms)
2015-04-28 07:48:02 [I] Authorized user admin(Admin User)
2015-04-28 07:48:02 [E] undefined method `boot_filename' for nil:NilClass (NoMethodError)
/usr/share/foreman/app/models/concerns/orchestration/dhcp.rb:60:in `dhcp_attrs'
/usr/share/foreman/app/models/concerns/orchestration/dhcp.rb:16:in `dhcp_record'
/usr/share/foreman/app/models/concerns/orchestration/dhcp.rb:140:in `dhcp_conflict_detected?'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:504:in `_run__3475909079161435654__validation__3659363730053100342__callbacks'

Comment 7 orabin 2015-04-28 12:30:13 UTC
The compose is using a version of discovery prior to Bryan's merge.
The package needs to be rebuilt with the changes and then tested.
Moving to post until there is a new package.

Comment 9 Sachin Ghai 2015-05-05 13:38:51 UTC
Reproducible with snap2:

--
# hammer --username admin --password changeme discovery provision --id 6
Could not create the host:
  Error: 500 Internal Server Error
--

Comment 10 Sachin Ghai 2015-05-05 13:39:35 UTC
[root@dhcp201-172 ~]#  hammer -u admin -p changeme discovery info --name mac525400c75a5eID:           6
Name:         mac525400c75a5e
MAC:          52:54:00:c7:5a:5e
Last report:  2015/05/05 06:39:30
CPUs:         1
Memory:       995
Disk count:   1
Disks size:   8192
Subnet:       libvirt
Last Report:  2015/05/05 06:39:30
IP:           192.168.100.17
Model:        
Organization: Default Organization
Location:     Default Location

Comment 11 orabin 2015-05-06 09:52:38 UTC
The error is a result of 1197975.

Comment 12 Sachin Ghai 2015-05-06 09:56:29 UTC
Installed packages where the issue is reproducible:

ruby193-rubygem-foreman_discovery-2.0.0.12-1.el7sat.noarch
rubygem-smart_proxy_discovery-1.0.2.1-1.el7sat.noarch
rubygem-hammer_cli_foreman_discovery-0.0.1.8-1.el7sat.noarch
foreman-discovery-image-2.1.0-20.el7sat.noarch

foreman-1.7.2.18-1.el7sat.noarch

Comment 15 Sachin Ghai 2015-05-14 12:59:32 UTC
Reproducible with snap4 c2.

--
]# hammer --username admin --password changeme discovery provision --id 3
Could not create the host:
  undefined method `boot_filename' for nil:NilClass
--

Comment 16 orabin 2015-05-14 13:24:23 UTC
Moving to post since this was merged into upstream today

Comment 21 Sachin Ghai 2015-05-21 12:36:49 UTC
Verified sat6.1 GA snap5

The reported issue has been fixed. Now I didn't get 500 ISE on provisioning a discovered host via hammer.

Now hammer throws:

#  hammer --username admin --password changeme discovery provision --id 2
Could not create the host:
  Environment can't be blank
  Architecture can't be blank
  Operatingsystem can't be blank
  Domain can't be blank
  Root password should be 8 characters or more
  Root password should not be blank - consider setting a global or host group default
  Partition Table can't be blank unless a custom partition has been defined
  Medium can't be blank



I think this can be improved if we throw the options to user like other cases. For example:

[root@i]# hammer --username admin --password changeme  host create
Could not create the host:
  Error: Options --environment-id, --architecture-id, --domain-id, --puppet-proxy-id, --operatingsystem-id, --partition-table-id are required
  
I'll file another bz for this.  

Also as soon as I pass the hostgroup-id to discovered host, provisioning starts perfectly:

[root]# hammer --username admin --password changeme  discovery provision --id 2 --hostgroup-id 1
Host created

And discovered host removed from the list:

]# hammer --username admin --password changeme discovery list
---|------|-----|-------------|------|--------|------------|------------|--------|------------
ID | NAME | MAC | LAST REPORT | CPUS | MEMORY | DISK COUNT | DISKS SIZE | SUBNET | LAST REPORT
---|------|-----|-------------|------|--------|------------|------------|--------|------------

Comment 22 Bryan Kearney 2015-08-11 13:19:29 UTC
This bug is slated to be released with Satellite 6.1.

Comment 23 Bryan Kearney 2015-08-12 13:55:55 UTC
This bug was fixed in version 6.1.1 of Satellite which was released on 12 August, 2015.


Note You need to log in before you can comment on or make changes to this bug.