summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-12-03 13:22:38 +0100
committerGitHub <noreply@github.com>2020-12-03 13:22:38 +0100
commit4e4746f50a9eef25bd06f1dbeb0f0393ca8ec99c (patch)
treeb39ca48359a5b14774f9a3f7ef065765d6c2e63d
parent372ee96d5721bf9b315d1fb9180b553a9f859c4c (diff)
parent8b2285b9f3cee2a8e0be0ed83a7b59ae75679f0f (diff)
downloadvyos-1x-4e4746f50a9eef25bd06f1dbeb0f0393ca8ec99c.tar.gz
vyos-1x-4e4746f50a9eef25bd06f1dbeb0f0393ca8ec99c.zip
Merge pull request #630 from sever-sever/T1316
isis: T1316: Fix isis delete section. Use an updated frr framework
-rw-r--r--data/templates/frr/isis.frr.tmpl7
-rwxr-xr-xsrc/conf_mode/protocols_isis.py34
2 files changed, 12 insertions, 29 deletions
diff --git a/data/templates/frr/isis.frr.tmpl b/data/templates/frr/isis.frr.tmpl
index 929f5bdb2..a1dae0c7c 100644
--- a/data/templates/frr/isis.frr.tmpl
+++ b/data/templates/frr/isis.frr.tmpl
@@ -70,13 +70,6 @@ router isis {{ process }}
{% endif %}
{% endif %}
!
-{% if interface_remove is defined and interface_remove is not none %}
-{% for iface in interface_remove %}
-interface {{ iface }}
- no ip router isis
-{% endfor %}
-{% endif %}
-!
{% if interface is defined and interface is not none %}
{% for iface, iface_config in interface.items() %}
interface {{ iface }}
diff --git a/src/conf_mode/protocols_isis.py b/src/conf_mode/protocols_isis.py
index bd372a7b3..97ab79583 100755
--- a/src/conf_mode/protocols_isis.py
+++ b/src/conf_mode/protocols_isis.py
@@ -28,8 +28,6 @@ from vyos import frr
from vyos import airbag
airbag.enable()
-config_file = r'/tmp/isis.frr'
-
def get_config(config=None):
if config:
conf = config
@@ -39,13 +37,6 @@ def get_config(config=None):
isis = conf.get_config_dict(base, key_mangling=('-', '_'), get_first_key=True)
- # determine which members have been removed
- for instance in isis:
- conf.set_level(base + [instance])
- tmp = node_changed(conf, ['interface'])
- if tmp:
- isis[instance].update({'interface_remove': tmp})
-
return isis
def verify(isis):
@@ -106,9 +97,6 @@ def generate(isis):
process = list(isis.keys())[0]
isis[process]['process'] = process
- # render(config) not needed, its only for debug
- render(config_file, 'frr/isis.frr.tmpl', isis[process])
-
isis['new_frr_config'] = render_to_string('frr/isis.frr.tmpl',
isis[process])
@@ -116,9 +104,18 @@ def generate(isis):
def apply(isis):
# Save original configuration prior to starting any commit actions
- frr_cfg = {}
- frr_cfg['original_config'] = frr.get_configuration(daemon='isisd')
- frr_cfg['modified_config'] = frr.replace_section(frr_cfg['original_config'], isis['new_frr_config'], from_re='interface .*')
+ frr_cfg = frr.FRRConfig()
+ frr_cfg.load_configuration(daemon='isisd')
+ frr_cfg.modify_section(r'interface \S+', '')
+ frr_cfg.modify_section(f'router isis \S+', '')
+ frr_cfg.add_before(r'(ip prefix-list .*|route-map .*|line vty)', isis['new_frr_config'])
+ frr_cfg.commit_configuration(daemon='isisd')
+
+ # If FRR config is blank, rerun the blank commit x times due to frr-reload
+ # behavior/bug not properly clearing out on one commit.
+ if isis['new_frr_config'] == '':
+ for a in range(5):
+ frr_cfg.commit_configuration(daemon='isisd')
# Debugging
'''
@@ -128,13 +125,6 @@ def apply(isis):
print(f'Replacement config:\n{isis["new_frr_config"]}\n\n')
print(f'Modified config:\n{frr_cfg["modified_config"]}\n\n')
'''
- # FRR mark configuration will test for syntax errors and throws an
- # exception if any syntax errors is detected
- frr.mark_configuration(frr_cfg['modified_config'])
-
- # Commit resulting configuration to FRR, this will throw CommitError
- # on failure
- frr.reload_configuration(frr_cfg['modified_config'], daemon='isisd')
return None