Project

General

Profile

Bug #14239

Creating a host via API fails with cryptic error when no primary interface is set explicitly

Added by Ivan Necas about 3 years ago. Updated 11 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Compute resources
Target version:
Difficulty:
Triaged:
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

when running

bundle exec bin/hammer host create --hostgroup=abcde --compute-resource='abcde ovirt' --name inecas-test-1 --location Default_Location \
                                   --organization Default_Organization1 --interface='compute_name=eth0,compute_network=d3e5f222-1ece-4d77-bc18-98b0937e72bf'

which causes this params to be sent to the API host controller:

{"host"=>{"name"=>"inecas-test-1", "location_id"=>2, "organization_id"=>1, "compute_resource_id"=>3, "hostgroup_id"=>3, "build"=>true, "enabled"=>true, "managed"=>true, "compute_attributes"=>{"volumes_attributes"=>{}}, "overwrite"=>true, "host_parameters_attributes"=>{}, "interfaces_attributes"=>[{"compute_attributes"=>{"name"=>"eth0", "network"=>"d3e5f222-1ece-4d77-bc18-98b0937e72bf"}}]}, "apiv"=>"v2"}

Ends up with error `Failed to create a compute abcde ovirt (oVirt) instance inecas-test-1.inecas.ovirt.test: Network not found in cluster`

After debugging, it turns out the host is created with two interfaces, one corresponding to the params from the UI, while another one is build
by default https://github.com/theforeman/foreman/blob/1.11.0-RC2/app/models/host/base.rb#L104

A workaround is to set `primary=true` as interface like this:

bundle exec bin/hammer host create --hostgroup=abcde --compute-resource='abcde ovirt' --name inecas-test-1 --location Default_Location \
                                   --organization Default_Organization1 --interface='compute_name=eth0,compute_network=d3e5f222-1ece-4d77-bc18-98b0937e72bf,primary=true'

Expected result:

When no primary interface is set, the first one is considered as the one (consistent with the UI)


Related issues

Related to Foreman - Bug #14264: Getting 500 when creating host through API and not specifying any interface attributesClosed2016-03-18
Related to Hammer CLI - Bug #13927: Specifying provision and primary flags should not be mandatoryClosed2016-02-27
Has duplicate Foreman - Bug #13982: API description for creating hosts incorrectly lists "interfaces_attributes"'s "primary" as optionalDuplicate2016-03-01

Associated revisions

Revision 38d9333f (diff)
Added by Tom Caspy about 3 years ago

fixes #14239 - when creating host from API, set first interface as primary if none set

Revision e83f4d7f (diff)
Added by Tom Caspy about 3 years ago

fixes #14239 - when creating host from API, set first interface as primary if none set

(cherry picked from commit 38d9333f8e82e45fc6771ea7740e6ea625b97d3f)

History

#1 Updated by Ivan Necas about 3 years ago

  • Description updated (diff)

#2 Updated by The Foreman Bot about 3 years ago

  • Status changed from New to Ready For Testing
  • Assignee set to Tom Caspy
  • Pull request https://github.com/theforeman/foreman/pull/3339 added

#3 Updated by Dominic Cleal about 3 years ago

  • Has duplicate Bug #13982: API description for creating hosts incorrectly lists "interfaces_attributes"'s "primary" as optional added

#4 Updated by Tom Caspy about 3 years ago

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

#5 Updated by Dominic Cleal about 3 years ago

  • Legacy Backlogs Release (now unused) set to 141

#6 Updated by Dominic Cleal about 3 years ago

  • Related to Bug #14264: Getting 500 when creating host through API and not specifying any interface attributes added

#7 Updated by Dominic Cleal about 3 years ago

  • Related to Bug #13927: Specifying provision and primary flags should not be mandatory added

Also available in: Atom PDF