Project

General

Profile

Actions

Bug #10726

closed

Updating an interface via API changes its type

Added by Adam Jacob Muller almost 9 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Category:
Network
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

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"

Actions

Also available in: Atom PDF