bsdci / libioc

A Python library to manage jails with ioc{age,ell}
https://bsd.ci/libioc
Other
38 stars 11 forks source link

Setting custom MAC address fails on the first time #688

Closed gronke closed 5 years ago

gronke commented 5 years ago

The first time a dynamic _mac property is set, an UnknownConfigProperty exception is raised. When the value already exists, the MAC address can be set without this message.

$ ioc set vnet0_mac=63ECAC12D0F1 testmac         
The config property 'vnet0_mac' is unknown
Jail 'foobar2' updated: vnet0_mac
$ ioc set vnet0_mac=63ECAC12D0F2 testmac
Jail 'foobar2' updated: vnet0_mac

One problem is that an error should interrupt the execution (so the value should not be updated after the message), another is that on set any _mac config property is valid. It would be possible to enforce the according interface to exist, but this would impact the order of setting them:

ioc create testmac1 vnet=on interfaces="vnet0:bridge0" vnet0_mac=63ECAC12D0F1
ioc create testmac1 vnet=on vnet0_mac=63ECAC12D0F1 interfaces="vnet0:bridge0"

A solution to work around this issue is to apply config properties in order of priority.

Thanks to @leonbayer for reporting this issue.