System-network cockpit-api

Hello!

I’m trying to automate the configuration of new network interfaces added to the VM in which nethserver is installed.

I have a PHP script that connects via ssh, loops through a JSON type file that has all the information about new interfaces, using that information on the API commands.
All the commands work individually and making the loop only run one time also successfully configures the interface.
The problem is the looping, after configuring the first interface the rest fails with apparently no output like the command wasn’t run. Configuring manually via the web interface (after running the loop) causes this error message: network-update failed

Commands run in each loop
API exec: system-network/validate
API exec: system-network/update

Is there anything else I should be doing to refresh the system-network or something like that?
I tried sleep commands, system-task shows no tasks running.

Thanks,
Joel

Would you like to share your script?

You may use the config databases, in this case the network database for configuring networks instead of cockpit API.

Example:

db networks set eth0 ethernet gateway 192.168.0.1 ipaddr 192.168.0.100 netmask 255.255.255.0 role green

After configuration run the following to apply the changes:

signal-event interface-update

2 Likes