Right now there is no generic way in configuring an interface IP address from within a Python script.
The only occurance right now is in https://github.com/vyos/vyos-1x/blob/current/src/conf_mode/wireguard.py
def add_addr(intf, addr): # see https://phabricator.vyos.net/T949 ret = subprocess.call(['ip a a dev ' + intf + ' ' + addr + ' &>/dev/null'], shell=True) sl.syslog(sl.LOG_NOTICE, "ip a a dev " + intf + " " + addr) def del_addr(intf, addr): ret = subprocess.call(['ip a d dev ' + intf + ' ' + addr + ' &>/dev/null'], shell=True) sl.syslog(sl.LOG_NOTICE, "ip a d dev " + intf + " " + addr)
We need to make this available in the generic vyos python library or a proper 3rd party library to be reusable from within multiple scripts.
Requirements:
- add IPv4/IPv6 interface address
- remove IPv4/IPv6 interface address
- add DHCP/DHCPv6 interface address
- remove DHCP/DHCPv6 interface address
- add interface description /sys/class/net/eth0/ifalias