Bug #11244
closedMAC taken error when updating NIC IPMI details through API
Description
Running on Foreman 1.9RC2, Ubuntu 12.04.5
I'm trying to update the BMC user+password for a host (plan to push this into the discovery image), but I can't get update to work.
First it complains that mac is required:
# curl -k -uadmin:$PW https://localhost:443/api/hosts/hostname.com -X PUT -d '{"host": {"interfaces_attributes": [{"identifier": "ipmi", "username": "root"}]}}' -H 'Content-Type: application/json' { "error": {"id":3152,"errors":{"interfaces.mac":["can't be blank"],"interfaces":["some interfaces are invalid"]},"full_messages":["Mac can't be blank","Interfaces some interfaces are invalid"]} }
Then it complains mac already exists:
# curl -k -uadmin:$PW https://localhost:443/api/hostname.com -X PUT -d '{"host": {"interfaces_attributes": [{"identifier": "ipmi", "username": "root", "mac": "34:17:eb:e5:81:ed"}]}}' -H 'Content-Type: application/json' { "error": {"id":3152,"errors":{"interfaces.mac":["has already been taken"],"interfaces":["some interfaces are invalid"]},"full_messages":["Mac has already been taken","Interfaces some interfaces are invalid"]} }
Updated by Dominic Cleal over 9 years ago
- Subject changed from can't update network interface details to MAC taken error when updating NIC IPMI details through API
- Category changed from API to Network
Updated by Marek Hulán over 9 years ago
This seems to work for me (using nested API for a single interface)
curl -k -uadmin:changeme https://localhost:443/foreman/api/hosts/bmcipmi.example.com/interfaces/2720 -X PUT -d '{"identifier": "ipmi", "username": "root", "provider":"ipmi", "type": "bmc"}' -H 'Content-Type: application/json'
Note that you have to specify provider, otherwise error is returned (another bug I guess). Obvious disadvantage is that you have to specify interface id.
Updated by Marek Hulán over 9 years ago
- Related to Bug #11258: Can't update BMC through API without specifying provider added
Updated by Marek Hulán over 9 years ago
- Priority changed from High to Normal
thanks for letting us know, lowering the priority as there's a workaround
Updated by Marek Hulán almost 9 years ago
- Status changed from New to Resolved
- Assignee set to Marek Hulán
In you example, the API call does not try to udpate existing IPMI interface but it tries to create a new one. The -X PUT says you're updating host. Since you didn't specify interface id, it thinks you want to create new interface. When you specified a MAC it conflicted with existing BMC when it tried to create a new one. When I modify your example with interface id, it works as expected
curl -k -uadmin:changeme https://foreman.example.tst/api/hosts/bm3.example.tst -X PUT -d '{"host": {"interfaces_attributes": [{"identifier": "ipmi", "username": "ares", "id": "48", "type": "Nic::BMC"}]}}' -H 'Content-Type: application/json'
just note I have to specify id of interface and also the type. Please let me know if it doesn't work for you, I'd reopen the issue.