summaryrefslogtreecommitdiff
path: root/src/conf_mode/lldp.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-12-22 19:36:00 +0100
committerChristian Poessinger <christian@poessinger.com>2019-12-22 19:36:00 +0100
commit2cac6f3ce09ddb5140e364e86476feba4a8ed285 (patch)
tree57c1c165ec4e024f0605e847a5eae883f89b14e7 /src/conf_mode/lldp.py
parent7e0e0e504817ed1d6654893c457b7ebc71a3a909 (diff)
downloadvyos-1x-2cac6f3ce09ddb5140e364e86476feba4a8ed285.tar.gz
vyos-1x-2cac6f3ce09ddb5140e364e86476feba4a8ed285.zip
lldp: T393: add config options to /etc/lldpd.d
Diffstat (limited to 'src/conf_mode/lldp.py')
-rwxr-xr-xsrc/conf_mode/lldp.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/conf_mode/lldp.py b/src/conf_mode/lldp.py
index 88a4a57a4..16bb329c4 100755
--- a/src/conf_mode/lldp.py
+++ b/src/conf_mode/lldp.py
@@ -27,7 +27,16 @@ from vyos import ConfigError
config_file = "/etc/default/lldpd"
lldp_tmpl = """
### Autogenerated by lldp.py ###
-DAEMON_ARGS="{% if snmp %}-x {% endif %}{% if addr %}-m {{ addr }} {% endif %}{% if cdp %}-c {% endif %}{% if edp %}-e {% endif %}{% if fdp %}-f {% endif %}{% if sonmp %}-s{% endif %}"
+DAEMON_ARGS="-M4{% if snmp %} -x{% endif %}{% if addr %} -m {{ addr }}{% endif %}{% if cdp %} -c{% endif %}{% if edp %} -e{% endif %}{% if fdp %} -f{% endif %}{% if sonmp %} -s{% endif %}"
+
+"""
+
+vyos_config_file = "/etc/lldpd.d/01-vyos.conf"
+vyos_tmpl = """
+### Autogenerated by lldp.py ###
+
+configure system platform VyOS
+configure system description "VyOS {{ description }}"
"""
@@ -234,11 +243,23 @@ def generate(lldp):
if lldp is None:
return
+ version = 'unknown'
+ with open('/opt/vyatta/etc/version', 'r') as f:
+ tmp = f.read()
+ version = tmp.split()[1]
+
+ lldp['options']['description'] = version
+
tmpl = jinja2.Template(lldp_tmpl)
config_text = tmpl.render(lldp['options'])
with open(config_file, 'w') as f:
f.write(config_text)
+ tmpl = jinja2.Template(vyos_tmpl)
+ config_text = tmpl.render(lldp['options'])
+ with open(vyos_config_file, 'w') as f:
+ f.write(config_text)
+
def apply(lldp):
if lldp: