Actions
Bug #10726
closedUpdating an interface via API changes its type
Difficulty:
Triaged:
Bugzilla link:
Pull request:
Description
Start with a BMC interface:
# curl -sku admin:$FOREMAN_PASSWORD https://1.2.3.4/api/v2/hosts/15/interfaces/106|json_pp { "name" : "", "provider" : "IPMI", "username" : "root", "subnet_id" : null, "virtual" : false, "identifier" : "", "created_at" : "2015-06-06T22:03:50Z", "mac" : "aa:aa:aa:aa:aa:aa", "provision" : false, "type" : "bmc", "managed" : true, "ip" : "1.2.3.4", "primary" : false, "id" : 106, "updated_at" : "2015-06-06T22:03:50Z", "domain_id" : null, "password" : "redacted", "domain_name" : null, "subnet_name" : null }
update the subnet_id via the API:
#curl -ku admin:$FOREMAN_PASSWORD -X PUT -H "Content-type: application/json" -d '{"interface":{"managed":true,"subnet_id":77}}' https://1.2.3.4/api/v2/hosts/15/interfaces/106|json_pp { "managed" : true, "created_at" : "2015-06-06T22:03:50Z", "subnet_name" : "blah [12261]", "domain_id" : null, "virtual" : false, "subnet_id" : 77, "updated_at" : "2015-06-06T22:06:42Z", "mac" : "aa:aa:aa:aa:aa:aa", "domain_name" : null, "provision" : false, "identifier" : "", "id" : 106, "name" : "", "type" : "bmc", "primary" : false, "ip" : "1.2.3.4" }
The result looks mostly correct, type is still bmc but username and password are missing.
Validate the actual result:
# curl -ku admin:$FOREMAN_PASSWORD https://1.2.3.4/api/v2/hosts/15/interfaces/106|json_pp { "identifier" : "", "mac" : "aa:aa:aa:aa:aa:aa", "subnet_name" : "blah", "primary" : false, "managed" : true, "domain_name" : null, "ip" : "1.2.3.4", "id" : 106, "provision" : false, "subnet_id" : 77, "virtual" : false, "updated_at" : "2015-06-06T22:06:42Z", "type" : "interface", "name" : "", "domain_id" : null, "created_at" : "2015-06-06T22:03:50Z" }
Interface type has been reset to "interface"
Updated by Dominic Cleal over 9 years ago
- Description updated (diff)
- Category set to API
Updated by Tomáš Strachota over 7 years ago
- Subject changed from setting subnet via API changes interface type to Updating an interface via API changes its type
- Category changed from API to Network
- Target version set to 115
- Bugzilla link set to 1484003
Its not only subent_id that makes the NIC type to change. In fact any update call that doesn't specifically send "type" parameter changes it to default interface.
Interface mapper maps nil to default interface and it's used also before the update action:
https://github.com/theforeman/foreman/blob/develop/app/controllers/api/v2/interfaces_controller.rb#L107
Updated by The Foreman Bot over 7 years ago
- Status changed from New to Ready For Testing
- Assignee set to Tomáš Strachota
- Pull request https://github.com/theforeman/foreman/pull/4833 added
Updated by Ivan Necas over 7 years ago
- Status changed from Ready For Testing to Closed
- Translation missing: en.field_release set to 296
Actions