Project

General

Profile

Bug #10726

Updating an interface via API changes its type

Added by Adam Jacob Muller over 5 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Category:
Network
Target version:
Difficulty:
Triaged:
Bugzilla link:
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"

Associated revisions

Revision 9a41f58f (diff)
Added by Tomáš Strachota about 3 years ago

Fixes #10726 - NIC types are immutable

History

#1 Updated by Dominic Cleal over 5 years ago

  • Description updated (diff)
  • Category set to API

#2 Updated by Tomáš Strachota about 3 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

#3 Updated by The Foreman Bot about 3 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

#4 Updated by Ivan Necas about 3 years ago

  • Status changed from Ready For Testing to Closed
  • Legacy Backlogs Release (now unused) set to 296

Also available in: Atom PDF