Unable to provision discovered BM with bond interface set using api call

I am trying to provision a discovered server using foreman api command.
When I try to add a bond interface the command fails.

Expected outcome:
Using GUI I am able to create a bond0 interface.
The expected output is to have have a server with:
bond0 interface with mode 802.3ad
The bond0 will have the server ip
with bond-slave interfaces em3,em4

Foreman and Proxy versions:
Foreman Version: 3.6.1

Foreman and Proxy plugin versions:
3.6.1
Distribution and version:
cent OS stream 8

Other relevant data:

I use the PUT /api/v2/discovered_hosts/:id api call
The hostdata that is sent in the put command is:
hostdata={
“location_id”: location_id,
“organization_id”: organization_id,
“id”: discovery_id,
“discovered_host”: {
“name”: ‘kvm422’,
“ip”: discovered_host_ip,
“mac”: args.mac,
“architecture_id”: 1,
“domain_id”: domain_id,
“environment_id”: environment_id,
“operatingsystem_id”: operatingsystem_id,
“ptable_id”: ptable_id,
“subnet_id”: subnet_id ,
“hostgroup_id”: hostgroup_id,
“enabled”: “true”,
“build”: “true”,
“managed”: “true”,
“provision_method”: “build”,
“host_parameters_attributes”: {},
“interfaces_attributes”: [
{
“subnet_id”:30,
#“domain_id”: 20,
#“identifier”:“ipmi”,
“name”:“”,
“ip”:“x.x.x.x”,
“mac”:“x:x:x:x:x:x”,
“primary”:“false”,
“provision”:“false”,
#“type”:“BMC”,
“virtual”:“false”,
},
#I am trying to make the existing primary interface not be primary, provision and managed
{
“subnet_id”:15,
“domain_id”:21,
“managed”:“false”,
“name”:“”,
“ip”:“”,
“mac”:“x.x”,
“fqdn”:“idle”,
“primary”:“false”,
“provision”:“false”,
# when is set type to interface I get error “wrong constant name interface”
#“type”:“interface”,
“execution”:“false”,
“virtual”:“false”,
},
{
“provision”: “true”,
“virtual”: “false”,
“managed”:“true”,
“primary”: “true”,
“subnet_id”:15,
# when is set type to bond I get error “wrong constant name bond”
#“type”: “bond”,
“identifier”:“bond0”,
“name”: “kvm422”,
“ip”: ‘x.x.x.x’,
“mac”:‘x:x:x:x:x:x’,
“domain_id”: 21 ,
“mode”:“802.3ad”,
“attached_devices”:“em3,em4”,
“bond_options”:“miimon=100”,
},

The error that i get is:
2023-08-16T01:15:23 [W|app|55113d8e] Not queueing Nic::Managed: [“Primary interface is already set on the host”, “Provision interface is already set on the host”]
2023-08-16T01:15:23 [W|app|55113d8e] Not queueing Nic::Managed: [“Primary interface is already set on the host”, “Provision interface is already set on the host”]
2023-08-16T01:15:23 [W|app|55113d8e] Not queueing Nic::Managed: [“Primary interface is already set on the host”, “Provision interface is already set on the host”]
2023-08-16T01:15:23 [W|app|55113d8e] Not queueing Host::Managed: [“Primary interface is already set on the host”, “Provision interface is already set on the host”, “Mac has already been taken”, “Primary interface is already set on the host”, “Provision interface is already set on the host”]
2023-08-16T01:15:23 [W|app|55113d8e] Not queueing Host::Managed: [“Primary interface is already set on the host”, “Provision interface is already set on the host”, “Mac has already been taken”, “Primary interface is already set on the host”, “Provision interface is already set on the host”]
2023-08-16T01:15:23 [W|app|55113d8e] Not queueing Host::Managed: [“Primary interface is already set on the host”, “Provision interface is already set on the host”, “Mac has already been taken”, “Primary interface is already set on the host”, “Provision interface is already set on the host”]
2023-08-16T01:15:23 [W|app|55113d8e] Not queueing Discovery reboot: Primary interface is already set on the host, Provision interface is already set on the host, Mac has already been taken, Primary interface is already set on the host, and Provision interface is already set on the host
2023-08-16T01:15:23 [W|app|55113d8e] Action failed
2023-08-16T01:15:23 [I|app|55113d8e] Backtrace for ‘Action failed’ error (RuntimeError): resource have no errors

When I edit the interfaces in gui I am able to edit the existing interfaces, in this case the primary interface.
I remove the mac and ip address of the primary and use it for the bond0 interface.
I also select the bond0 interface to be primary, provisioned and managed. Is it possible to do the same with api.
How do I make the bond0 interface the primary, is there an interface id for the existing interface(so that I can edit the existing primary interface)?
I am unable to use " [PUT /api/hosts/:host_id/interfaces/:id] " for discovered host

How can this same step be done using api call?

Thank you, I look forward to your reply.

1 Like