Bug 1202251 - [hammer] Auto-provisioning a host, when no rule is defined, should raise proper error
Summary: [hammer] Auto-provisioning a host, when no rule is defined, should raise prop...
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:
Blocks: 1193977
TreeView+ depends on / blocked
 
Reported: 2015-03-16 08:39 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 16:02:24 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 9870 0 None None None 2016-04-22 15:37:08 UTC

Description Sachin Ghai 2015-03-16 08:39:36 UTC
Description of problem:
In hammer, we have auto-provision cmd under discovery.

---
]# hammer --username admin --password changeme discovery auto-provision --help

Usage:
    hammer discovery auto-provision [OPTIONS]

Options:
 --id ID                        
 --name NAME                   Name to search by
 -h, --help                    print help
--


I tried auto-provision via hammer and neither discovery rule was defined nor any rule was defined. But hammer says 'host created'

Its seems to be misleading. Hammer should throw an error like:

no discovery rule match with discovered host

here is the output:
----
 
# hammer --username admin --password changeme discovery auto-provision --name mac5254003ea9d9

Host created

----

production.log:

2015-03-16 08:38:18 [I] Processing by Api::V2::DiscoveredHostsController#auto_provision as JSON
2015-03-16 08:38:18 [I]   Parameters: {"apiv"=>"v2", "id"=>"7", "discovered_host"=>{}}
2015-03-16 08:38:18 [I] Authorized user admin(Admin User)
2015-03-16 08:38:18 [I]   Rendered /opt/rh/ruby193/root/usr/share/gems/gems/foreman_discovery-2.0.0.6/app/views/api/v2/discovered_hosts/auto_provision.json.rabl (9.5ms)
2015-03-16 08:38:18 [I] Completed 200 OK in 49ms (Views: 9.2ms | ActiveRecord: 16.8ms)



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:
on executing auto-provision via hammer, hammer throws "host created" and nothing happens.. It looks misleading.. 




Expected results:
auto-provisioning via hammer should throw proper error when no discovery rule defined for discovered host

Hammer should throw error like: no matching rule found for discovered host?

Additional info:

Comment 1 Sachin Ghai 2015-03-16 08:43:53 UTC
Please note that auto-provisioning via hammer works if user define a matching discovery rule.  

I think we should throw an error when no rule is defined or no matching rule available for discovered host

Comment 3 Lukas Zapletal 2015-03-17 14:10:56 UTC
Valid bug, Ori can you squeeze this in 0.0.2?

Comment 4 orabin 2015-03-23 15:29:03 UTC
Created redmine issue http://projects.theforeman.org/issues/9870 from this bug

Comment 5 Bryan Kearney 2015-03-25 16:05:18 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/9870 has been closed
-------------
Ori Rabin
Applied in changeset commit:foreman_discovery|5188cf125376dd783653a82040e24a4b3e294cb5.

Comment 7 Sachin Ghai 2015-04-28 11:42:40 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 list
---|-----------------|-------------------|---------------------|------|--------|------------|------------|---------|--------------------
ID | NAME            | MAC               | LAST REPORT         | CPUS | MEMORY | DISK COUNT | DISKS SIZE | SUBNET  | LAST REPORT        
---|-----------------|-------------------|---------------------|------|--------|------------|------------|---------|--------------------
3  | mac525400c6b527 | 52:54:00:c6:b5:27 | 2015/04/27 12:24:38 | 1    | 995    | 1          | 8192       | libvirt | 2015/04/27 12:24:38
---|-----------------|-------------------|---------------------|------|--------|------------|------------|---------|--------------------
[root@cloud-qe-9 ~]# hammer --username admin --password changeme discovery auto-provision --name mac525400c6b527
Host created
[root@cloud-qe-9 ~]#

Comment 8 orabin 2015-04-28 12:30:27 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 10 Sachin Ghai 2015-05-05 13:18:19 UTC
Issue is still reproducible with sat6.1 GA Snap2 (Satellite-6.1.0-RHEL-7-20150429.2)

when no rule is defined, hammer still throwing 'Host created'.

# hammer --username admin --password changeme discovery auto-provision --name  mac525400c75a5e
Host created

Comment 11 orabin 2015-05-26 14:47:24 UTC
upstream bug is closed

Comment 14 Sachin Ghai 2015-06-05 11:28:07 UTC
verified with sat6.1 GA snap7.

now I get this error on auto-provisioning a discovered host when no rule is defined:

 ~]# hammer --username admin --password changeme discovery auto-provision --name mac52540038a98e
Could not create the host


2015-06-05 07:16:16 [I] Processing by Api::V2::DiscoveredHostsController#auto_provision as JSON
2015-06-05 07:16:16 [I]   Parameters: {"apiv"=>"v2", "id"=>"3", "discovered_host"=>{}}
2015-06-05 07:16:16 [I] Authorized user admin(Admin User)
2015-06-05 07:16:16 [I]   Rendered api/v2/errors/custom_error.json.rabl within api/v2/layouts/error_layout (0.3ms)
2015-06-05 07:16:16 [I] Completed 422 Unprocessable Entity in 29ms (Views: 0.9ms | ActiveRecord: 14.2ms)


"Could not create the host" is very generalized error message. Error message should be friendly enough for user to know what's going wrong.

I think as per bug description, if we can change the error like below would be more appropriate.

"No matching rule found for discovered host"

Comment 16 Sachin Ghai 2015-06-08 12:04:28 UTC
Thanks Orabin. Assigning back.

Comment 17 orabin 2015-07-07 14:22:08 UTC
Moving to POST since this was merged upstream

Comment 20 Bryan Kearney 2015-07-10 20:26:39 UTC
Delivered with Snap12.

Comment 21 Sachin Ghai 2015-07-14 07:26:27 UTC
Verified with sat6.1.1 GA snap12. Now I'm getting proper error message. Thanks Orabin for fixing it.

[root@cloud-qe-17 ~]# hammer --username admin --password changeme discovery auto-provision --name mac52540063d7a2
Could not create the host:
  No rule found for host mac52540063d7a2
[root@cloud-qe-17 ~]#

Comment 22 Bryan Kearney 2015-08-12 16:02:24 UTC
This bug was fixed in Satellite 6.1.1 which was delivered on 12 August, 2015.


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