I am trying to configure network interfaces on remote machines using python. The surrounding context is that I have a service that provisions VM instances and is required to create appropriate network interfaces on the VM host for the instance to use. I am restricted regarding remote code execution.
My first idea was to use SSH and work with the remote /etc/network/interfaces (the remote machines are exclusively debian based).
Additionally, I stumbled upon pynetlinux and others using a python socket and fcntl to retrieve and configure local interfaces (interfaces.py using socket and fcntl). Obviously, the socket is only locally available but that got me thinking: Is it possible to use a python file-like object over SSH directly accessing remote network interfaces in the way socket.socket does?
I hope there is a way to achieve this, parsing and writing /etc/network/interfaces would work but the other solution is imho awesome.
Greetings and thanks in advance