Project

General

Profile

Bug #9634

Creating a host via API without OS set gives undefined method `boot_filename' exception

Added by Lukas Zapletal over 6 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
DHCP
Target version:
Difficulty:
Triaged:
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

We already fixed this for Discovery UI, but the error remains for Foreman core when you try to create a host without OS set via API.


Related issues

Related to Foreman - Bug #5701: Creating a host without OS set gives undefined method `boot_filename' exceptionClosed2014-05-13

Associated revisions

Revision 93dbb7e7 (diff)
Added by Ori Rabin over 6 years ago

Fixes #9634 - creating a host with an interface and without os returns a validation message

Revision 61251e24 (diff)
Added by Ori Rabin over 6 years ago

Fixes #9634 - creating a host with an interface and without os returns a validation message

(cherry picked from commit 93dbb7e77dc3502a5cfa6888a13212bed7e178f6)

History

#1 Updated by Lukas Zapletal over 6 years ago

  • Project changed from Foreman to Discovery
  • Category changed from API to Discovery plugin
  • Bugzilla link set to 1197975

Moving to discovery as I am not sure if we can reproduce this in core foreman.

#2 Updated by Lukas Zapletal over 6 years ago

Reproducer:

[root@dhcp207-190 fdi-image]# curl -i -k -u admin:changeme -H "Accept: application/json" -X GET 'https://dhcp207-190.lab.eng.pnq.redhat.com/api/v2/discovered_hosts/'
HTTP/1.1 200 OK

Status: 200 OK
Connection: close
Transfer-Encoding: chunked
Content-Type: application/json; charset=utf-8

{
"total": 1,
"subtotal": 1,
"page": 1,
"per_page": 20,
"search": null,
"sort": {
"by": null,
"order": null
},
"results": [{"name":"mac52540054c6e2","id":4,"ip":"192.168.100.11","mac":"52:54:00:54:c6:e2","last_report":"2015-03-03T05:55:53Z","subnet_id":1,"subnet_name":"libvirt","memory":995,"disk_count":1,"disks_size":8192,"cpus":1,"organization_id":1,"organization_name":"Default Organization","location_id":2,"location_name":"Default Location"}]
}
---

Next, I tried to provision it:

[root@dhcp207-190 fdi-image]# curl -i -k -u admin:changeme -H "Content-Type: application/json" -X PUT 'https://dhcp207-190.lab.eng.pnq.redhat.com/api/v2/discovered_hosts/4'
HTTP/1.1 500 Internal Server Error

Status: 500 Internal Server Error
Connection: close
Transfer-Encoding: chunked
Content-Type: application/json; charset=utf-8

{
"error": {"message":"undefined method `boot_filename' for nil:NilClass"}
}

We should give a nice error.

For the record: this patch (which was NOT merged) fixes this, but it is not clean. We should somehow detect earlier that OS was not set and raise a nicer error instead.

#3 Updated by Lukas Zapletal over 6 years ago

  • Target version set to Discovery Plugin 4.0.0

#4 Updated by Lukas Zapletal over 6 years ago

  • Related to Bug #5701: Creating a host without OS set gives undefined method `boot_filename' exception added

#5 Updated by Lukas Zapletal over 6 years ago

  • Target version changed from Discovery Plugin 4.0.0 to Discovery Plugin 2.0.1

#6 Updated by Lukas Zapletal over 6 years ago

For the record there was a solution filed https://github.com/theforeman/foreman/pull/2026 but it was replaced by https://github.com/theforeman/foreman/pull/2120 (UI fix only). Not API/CLI.

#7 Updated by Ori Rabin over 6 years ago

  • Project changed from Discovery to Foreman
  • Category deleted (Discovery plugin)
  • Status changed from New to Assigned
  • Assignee set to Ori Rabin
  • Target version deleted (Discovery Plugin 2.0.1)

This is also reproducible through the UI with a new host: create a host, fill in the interface but not the os and try to save

#8 Updated by The Foreman Bot over 6 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/2378 added
  • Pull request deleted ()

#9 Updated by Dominic Cleal over 6 years ago

  • Category set to DHCP
  • Legacy Backlogs Release (now unused) set to 50

#10 Updated by Ori Rabin over 6 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF