Bug #9970
closedCreating hosts with NICs on vmWare fails with "Unknown Network ID:"
Description
hammer -d host create --name dn101 --hostgroup-id 7 --compute-resource-id 2 --provision-method image --image-id 5 --enabled true --managed true --environment-id 1 --domain-id 2 --interface "compute_network=SDC1_111" --subnet-id 2 --compute-attributes "cluster=BD_LAB,memory_mb=16384,cpus=4,start=1" --volume "datastore=BDH04_DISK3,name=HDD,size_gb=100"
Fails with:
Could not create the host: Failed to create a compute VC02_BIGD (VMware) instance dn101.pldc1.example.com: Unknown Network ID:
It seems that parameters being sent in the log are correct.
There is suspicious part of the code that raises the exception. The data structures changed a bit since the primary NIC extraction has been merged and it tries to compare missing data. Compute related data has been moved under a key "compute_attributes" in the interface structure. The fix is most likely just adding the "compute_attributes" key.
https://github.com/theforeman/foreman/blob/develop/app/models/compute_resources/foreman/model/vmware.rb#L305
Files
Updated by Tomáš Strachota over 9 years ago
- Related to Bug #9871: Provisioning a new vmware hosts fails with 'Invalid MAC ' added
Updated by Dominic Cleal over 9 years ago
- Translation missing: en.field_release set to 28
Updated by Dominic Cleal over 9 years ago
I think this is slightly different. The code for searching for networks is OK because the add_interfaces_to_compute_attrs method in orchestration/compute.rb copies the interfaces_attributes into the compute_attributes into the right place, this all seems to be working correctly.
It appears that if you just pass:
"interfaces_attributes": { "0": { "compute_attributes": { "network": "SDC1_111" } } }
into a host creation, then Host::Base creates a second, primary interface as it doesn't think there is a primary supplied. This second interface doesn't have any compute_attributes and so you get the blank network ID error.
In my test it was generating these two NICs when I passed the interfaces_attributes above:
=> [#<Nic::Managed id: nil, mac: nil, ip: nil, type: "Nic::Managed", name: nil, host_id: nil, subnet_id: nil, domain_id: nil, attrs: {}, created_at: nil, updated_at: nil, provider: nil, username: nil, password: nil, virtual: false, link: true, identifier: nil, tag: "", at tached_to: "", managed: true, mode: "balance-rr", attached_devices: "", bond_options: "", primary: false, provision: false, compute_attributes: {"network"=>"SDC1_111"}>, #<Nic::Managed id: nil, mac: nil, ip: "192.168.122.118", type: "Nic::Managed", name: "dcleal-test2.example.com", host_id: nil, subnet_id: 4, domain_id: 6, attrs: {}, created_at: nil, updated_at: nil, provider: nil, username: nil, password: nil, virtual: false, link: true , identifier: nil, tag: "", attached_to: "", managed: true, mode: "balance-rr", attached_devices: "", bond_options: "", primary: true, provision: true, compute_attributes: {}>]
When I send this, it generates only one NIC and works better:
{ "interfaces_attributes": { "0": { "primary": 1, "compute_attributes": { "network": "SDC1_111" } } } }
Can we specify primary with Hammer, or should we improve the logic for primary NIC creation in Host::Base to merge interface_attributes into the new primary NIC if there's only one supplied?
Updated by Dominic Cleal over 9 years ago
- Related to Feature #3849: Add commands for managing interfaces added
Updated by Dominic Cleal over 9 years ago
- Status changed from New to Resolved
Tomas confirmed on IRC that setting the primary interface details should be something that Hammer, via #3849 should be handling.
Updated by Dominic Cleal over 9 years ago
- Translation missing: en.field_release deleted (
28)