From 54b9b8f80ce1a16362c4ef6e89efc70ef29ae59e Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 23 Feb 2020 19:18:40 +0100 Subject: pppoe: T1318: set interface description --- src/conf_mode/interfaces-pppoe.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/conf_mode') diff --git a/src/conf_mode/interfaces-pppoe.py b/src/conf_mode/interfaces-pppoe.py index 245f5a4b0..cb09b6f29 100755 --- a/src/conf_mode/interfaces-pppoe.py +++ b/src/conf_mode/interfaces-pppoe.py @@ -20,8 +20,10 @@ from sys import exit from copy import deepcopy from jinja2 import Template from subprocess import Popen, PIPE +from time import sleep from vyos.config import Config +from vyos.ifconfig import Interface from vyos import ConfigError from netifaces import interfaces @@ -240,6 +242,24 @@ def apply(pppoe): cmd = 'systemctl start ppp@{}.service'.format(pppoe['intf']) subprocess_cmd(cmd) + # better late then sorry ... but we can only set interface alias after + # pppd has been launched and created the interface + cnt = 0 + while pppoe['intf'] not in interfaces(): + cnt += 1 + if cnt == 50: + break + + # sleep 250ms + sleep(0.250) + + try: + # we need to catch the exception if the interface is not up due to + # reason stated above + Interface(pppoe['intf']).set_alias(pppoe['description']) + except: + pass + return None if __name__ == '__main__': -- cgit v1.2.3