Project

General

Profile

Actions

Bug #14239

closed

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

Added by Ivan Necas almost 9 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Compute resources
Target version:
Difficulty:
Triaged:
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 3 (0 open3 closed)

Related to Foreman - Bug #14264: Getting 500 when creating host through API and not specifying any interface attributesClosedMarek Hulán03/18/2016Actions
Related to Hammer CLI - Bug #13927: Specifying provision and primary flags should not be mandatoryClosedMarek Hulán02/27/2016Actions
Has duplicate Foreman - Bug #13982: API description for creating hosts incorrectly lists "interfaces_attributes"'s "primary" as optionalDuplicate03/01/2016Actions
Actions #1

Updated by Ivan Necas almost 9 years ago

  • Description updated (diff)
Actions #2

Updated by The Foreman Bot almost 9 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
Actions #3

Updated by Dominic Cleal almost 9 years ago

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

Updated by Tom Caspy almost 9 years ago

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

Updated by Dominic Cleal almost 9 years ago

  • Translation missing: en.field_release set to 141
Actions #6

Updated by Dominic Cleal almost 9 years ago

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

Updated by Dominic Cleal almost 9 years ago

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

Also available in: Atom PDF