While trying to set up Wireguard interface and its peers, I had a question in my mind that can we remove peers, other than just disabling it? After executing delete interfaces wireguard wg0 peer Example, everything seemed fine until commiting and saving which returned error.
The error contained these: cmd 'wg set wg0 peer ['ebFx/1G0ti8tvuZd94sEIosAZZIznX+dBAKG/8DFm0I='] remove' and Key is not the correct length or format: '[ebFx/1G0ti8tvuZd94sEIosAZZIznX+dBAKG/8DFm0I=]'. There is also a stack trace corresponding to this:
File "/usr/libexec/vyos/conf_mode/interfaces-wireguard.py", line 117, in <module> apply(c) File "/usr/libexec/vyos/conf_mode/interfaces-wireguard.py", line 109, in apply w.update(wireguard) File "/usr/lib/python3/dist-packages/vyos/ifconfig/wireguard.py", line 185, in update self._cmd(cmd.format(**peer)) File "/usr/lib/python3/dist-packages/vyos/ifconfig/control.py", line 51, in _cmd return cmd(command, self.debug) File "/usr/lib/python3/dist-packages/vyos/util.py", line 179, in cmd raise OSError(code, feedback) PermissionError: [Errno 1] failed to run command: wg set wg0 peer ['ebFx/1G0ti8tvuZd94sEIosAZZIznX+dBAKG/8DFm0I='] remove
As a person who is also interested in coding, I have checked out here and seen that peer_config variable is a list type. Hence, during command formatting process, it is formatted in a wrong way. One easy solution can be taking first and only element of the array (since one peer can only have one pubkey) at this line.