Bug #14239
Updated by Ivan Necas almost 9 years ago
when running
<pre>
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'
</pre>
which causes this params to be sent to the API host controller:
<pre>
{"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"}
</pre>
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:
<pre>
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'
</pre>
Expected result:
When no primary interface is set, the first one is considered as the one (consistent with the UI)