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

Also available in: Atom PDF