Skip to content

Commit

Permalink
frr: T6746: do not use FRRender apply() method when vyos-configd is r…
Browse files Browse the repository at this point in the history
…unning
  • Loading branch information
c-po committed Dec 12, 2024
1 parent 276a016 commit 74bc43d
Show file tree
Hide file tree
Showing 22 changed files with 66 additions and 46 deletions.
8 changes: 5 additions & 3 deletions src/conf_mode/interfaces_bonding.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@
from vyos.utils.dict import dict_search
from vyos.utils.dict import dict_to_paths_values
from vyos.utils.network import interface_exists
from vyos.utils.process import is_systemd_service_running
from vyos.configdict import has_address_configured
from vyos.configdict import has_vrf_configured
from vyos.configdep import set_dependents, call_dependents
from vyos.configdep import set_dependents
from vyos.configdep import call_dependents
from vyos import ConfigError
from vyos import airbag
airbag.enable()
Expand Down Expand Up @@ -263,12 +265,12 @@ def verify(bond):
return None

def generate(bond):
if 'frr_dict' in bond and 'frrender_cls' not in bond['frr_dict']:
if 'frr_dict' in bond and not is_systemd_service_running('vyos-configd.service'):
FRRender().generate(bond['frr_dict'])
return None

def apply(bond):
if 'frr_dict' in bond and 'frrender_cls' not in bond['frr_dict']:
if 'frr_dict' in bond and not is_systemd_service_running('vyos-configd.service'):
FRRender().apply()

b = BondIf(bond['ifname'])
Expand Down
7 changes: 3 additions & 4 deletions src/conf_mode/interfaces_ethernet.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from vyos.utils.dict import dict_to_paths_values
from vyos.utils.dict import dict_set
from vyos.utils.dict import dict_delete
from vyos.utils.process import is_systemd_service_running
from vyos import ConfigError
from vyos import airbag
airbag.enable()
Expand Down Expand Up @@ -321,14 +322,13 @@ def verify_ethernet(ethernet):
return None

def generate(ethernet):
if 'frr_dict' in ethernet and 'frrender_cls' not in ethernet['frr_dict']:
if 'frr_dict' in ethernet and not is_systemd_service_running('vyos-configd.service'):
FRRender().generate(ethernet['frr_dict'])
return None

def apply(ethernet):
if 'frr_dict' in ethernet and 'frrender_cls' not in ethernet['frr_dict']:
if 'frr_dict' in ethernet and not is_systemd_service_running('vyos-configd.service'):
FRRender().apply()

e = EthernetIf(ethernet['ifname'])
if 'deleted' in ethernet:
e.remove()
Expand All @@ -341,7 +341,6 @@ def apply(ethernet):
c = get_config()
verify(c)
generate(c)

apply(c)
except ConfigError as e:
print(e)
Expand Down
5 changes: 3 additions & 2 deletions src/conf_mode/policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from vyos.frrender import FRRender
from vyos.frrender import frr_protocols
from vyos.utils.dict import dict_search
from vyos.utils.process import is_systemd_service_running
from vyos import ConfigError
from vyos import airbag
airbag.enable()
Expand Down Expand Up @@ -262,12 +263,12 @@ def verify(config_dict):


def generate(config_dict):
if config_dict and 'frrender_cls' not in config_dict:
if config_dict and not is_systemd_service_running('vyos-configd.service'):
FRRender().generate(config_dict)
return None

def apply(config_dict):
if config_dict and 'frrender_cls' not in config_dict:
if config_dict and not is_systemd_service_running('vyos-configd.service'):
FRRender().apply()
return None

Expand Down
5 changes: 3 additions & 2 deletions src/conf_mode/protocols_babel.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from vyos.configverify import verify_prefix_list
from vyos.frrender import FRRender
from vyos.utils.dict import dict_search
from vyos.utils.process import is_systemd_service_running
from vyos import ConfigError
from vyos import airbag
airbag.enable()
Expand Down Expand Up @@ -89,12 +90,12 @@ def verify(config_dict):


def generate(config_dict):
if config_dict and 'frrender_cls' not in config_dict:
if config_dict and not is_systemd_service_running('vyos-configd.service'):
FRRender().generate(config_dict)
return None

def apply(config_dict):
if config_dict and 'frrender_cls' not in config_dict:
if config_dict and not is_systemd_service_running('vyos-configd.service'):
FRRender().apply()
return None

Expand Down
5 changes: 3 additions & 2 deletions src/conf_mode/protocols_bfd.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from vyos.frrender import FRRender
from vyos.template import is_ipv6
from vyos.utils.network import is_ipv6_link_local
from vyos.utils.process import is_systemd_service_running
from vyos import ConfigError
from vyos import airbag
airbag.enable()
Expand Down Expand Up @@ -77,11 +78,11 @@ def verify(config_dict):
return None

def generate(config_dict):
if config_dict and 'frrender_cls' not in config_dict:
if config_dict and not is_systemd_service_running('vyos-configd.service'):
FRRender().generate(config_dict)

def apply(config_dict):
if config_dict and 'frrender_cls' not in config_dict:
if config_dict and not is_systemd_service_running('vyos-configd.service'):
FRRender().apply()
return None

Expand Down
5 changes: 3 additions & 2 deletions src/conf_mode/protocols_bgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from vyos.utils.dict import dict_search
from vyos.utils.network import get_interface_vrf
from vyos.utils.network import is_addr_assigned
from vyos.utils.process import is_systemd_service_running
from vyos.utils.process import process_named_running
from vyos import ConfigError
from vyos import airbag
Expand Down Expand Up @@ -554,12 +555,12 @@ def verify(config_dict):
return None

def generate(config_dict):
if config_dict and 'frrender_cls' not in config_dict:
if config_dict and not is_systemd_service_running('vyos-configd.service'):
FRRender().generate(config_dict)
return None

def apply(config_dict):
if config_dict and 'frrender_cls' not in config_dict:
if config_dict and not is_systemd_service_running('vyos-configd.service'):
FRRender().apply()
return None

Expand Down
5 changes: 3 additions & 2 deletions src/conf_mode/protocols_eigrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from vyos.configdict import get_frrender_dict
from vyos.configverify import has_frr_protocol_in_dict
from vyos.configverify import verify_vrf
from vyos.utils.process import is_systemd_service_running
from vyos.frrender import FRRender
from vyos import ConfigError
from vyos import airbag
Expand Down Expand Up @@ -53,12 +54,12 @@ def verify(config_dict):
verify_vrf({'vrf': vrf})

def generate(config_dict):
if config_dict and 'frrender_cls' not in config_dict:
if config_dict and not is_systemd_service_running('vyos-configd.service'):
FRRender().generate(config_dict)
return None

def apply(config_dict):
if config_dict and 'frrender_cls' not in config_dict:
if config_dict and not is_systemd_service_running('vyos-configd.service'):
FRRender().apply()
return None

Expand Down
5 changes: 3 additions & 2 deletions src/conf_mode/protocols_isis.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from vyos.ifconfig import Interface
from vyos.utils.dict import dict_search
from vyos.utils.network import get_interface_config
from vyos.utils.process import is_systemd_service_running
from vyos import ConfigError
from vyos import airbag
airbag.enable()
Expand Down Expand Up @@ -232,12 +233,12 @@ def verify(config_dict):
return None

def generate(config_dict):
if config_dict and 'frrender_cls' not in config_dict:
if config_dict and not is_systemd_service_running('vyos-configd.service'):
FRRender().generate(config_dict)
return None

def apply(config_dict):
if config_dict and 'frrender_cls' not in config_dict:
if config_dict and not is_systemd_service_running('vyos-configd.service'):
FRRender().apply()
return None

Expand Down
5 changes: 3 additions & 2 deletions src/conf_mode/protocols_mpls.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from vyos.frrender import FRRender
from vyos.utils.dict import dict_search
from vyos.utils.file import read_file
from vyos.utils.process import is_systemd_service_running
from vyos.utils.system import sysctl_write
from vyos.configverify import verify_interface_exists
from vyos import ConfigError
Expand Down Expand Up @@ -67,12 +68,12 @@ def verify(config_dict):
return None

def generate(config_dict):
if config_dict and 'frrender_cls' not in config_dict:
if config_dict and not is_systemd_service_running('vyos-configd.service'):
FRRender().generate(config_dict)
return None

def apply(config_dict):
if config_dict and 'frrender_cls' not in config_dict:
if config_dict and not is_systemd_service_running('vyos-configd.service'):
FRRender().apply()

if not has_frr_protocol_in_dict(config_dict, 'mpls'):
Expand Down
5 changes: 3 additions & 2 deletions src/conf_mode/protocols_openfabric.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from vyos.configdict import get_frrender_dict
from vyos.configverify import verify_interface_exists
from vyos.configverify import has_frr_protocol_in_dict
from vyos.utils.process import is_systemd_service_running
from vyos.frrender import FRRender
from vyos import ConfigError
from vyos import airbag
Expand Down Expand Up @@ -89,12 +90,12 @@ def verify(config_dict):
return None

def generate(config_dict):
if config_dict and 'frrender_cls' not in config_dict:
if config_dict and not is_systemd_service_running('vyos-configd.service'):
FRRender().generate(config_dict)
return None

def apply(config_dict):
if config_dict and 'frrender_cls' not in config_dict:
if config_dict and not is_systemd_service_running('vyos-configd.service'):
FRRender().apply()
return None

Expand Down
5 changes: 3 additions & 2 deletions src/conf_mode/protocols_ospf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from vyos.frrender import FRRender
from vyos.utils.dict import dict_search
from vyos.utils.network import get_interface_config
from vyos.utils.process import is_systemd_service_running
from vyos import ConfigError
from vyos import airbag
airbag.enable()
Expand Down Expand Up @@ -176,12 +177,12 @@ def verify(config_dict):
return None

def generate(config_dict):
if config_dict and 'frrender_cls' not in config_dict:
if config_dict and not is_systemd_service_running('vyos-configd.service'):
FRRender().generate(config_dict)
return None

def apply(config_dict):
if config_dict and 'frrender_cls' not in config_dict:
if config_dict and not is_systemd_service_running('vyos-configd.service'):
FRRender().apply()
return None

Expand Down
5 changes: 3 additions & 2 deletions src/conf_mode/protocols_ospfv3.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from vyos.ifconfig import Interface
from vyos.utils.dict import dict_search
from vyos.utils.network import get_interface_config
from vyos.utils.process import is_systemd_service_running
from vyos import ConfigError
from vyos import airbag
airbag.enable()
Expand Down Expand Up @@ -87,12 +88,12 @@ def verify(config_dict):
return None

def generate(config_dict):
if config_dict and 'frrender_cls' not in config_dict:
if config_dict and not is_systemd_service_running('vyos-configd.service'):
FRRender().generate(config_dict)
return None

def apply(config_dict):
if config_dict and 'frrender_cls' not in config_dict:
if config_dict and not is_systemd_service_running('vyos-configd.service'):
FRRender().apply()
return None

Expand Down
5 changes: 3 additions & 2 deletions src/conf_mode/protocols_pim.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from vyos.configverify import has_frr_protocol_in_dict
from vyos.frrender import FRRender
from vyos.frrender import pim_daemon
from vyos.utils.process import is_systemd_service_running
from vyos.utils.process import process_named_running
from vyos.utils.process import call
from vyos import ConfigError
Expand Down Expand Up @@ -86,7 +87,7 @@ def verify(config_dict):
unique.append(gr_addr)

def generate(config_dict):
if config_dict and 'frrender_cls' not in config_dict:
if config_dict and not is_systemd_service_running('vyos-configd.service'):
FRRender().generate(config_dict)
return None

Expand All @@ -103,7 +104,7 @@ def apply(config_dict):
if not pim_pid:
call('/usr/lib/frr/pimd -d -F traditional --daemon -A 127.0.0.1')

if config_dict and 'frrender_cls' not in config_dict:
if config_dict and not is_systemd_service_running('vyos-configd.service'):
FRRender().apply()
return None

Expand Down
5 changes: 3 additions & 2 deletions src/conf_mode/protocols_pim6.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from vyos.configdict import get_frrender_dict
from vyos.configverify import has_frr_protocol_in_dict
from vyos.configverify import verify_interface_exists
from vyos.utils.process import is_systemd_service_running
from vyos.frrender import FRRender
from vyos import ConfigError
from vyos import airbag
Expand Down Expand Up @@ -75,12 +76,12 @@ def verify(config_dict):
unique.append(gr_addr)

def generate(config_dict):
if config_dict and 'frrender_cls' not in config_dict:
if config_dict and not is_systemd_service_running('vyos-configd.service'):
FRRender().generate(config_dict)
return None

def apply(config_dict):
if config_dict and 'frrender_cls' not in config_dict:
if config_dict and not is_systemd_service_running('vyos-configd.service'):
FRRender().apply()
return None

Expand Down
5 changes: 3 additions & 2 deletions src/conf_mode/protocols_rip.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from vyos.configverify import verify_prefix_list
from vyos.frrender import FRRender
from vyos.utils.dict import dict_search
from vyos.utils.process import is_systemd_service_running
from vyos import ConfigError
from vyos import airbag
airbag.enable()
Expand Down Expand Up @@ -68,12 +69,12 @@ def verify(config_dict):
f'with "split-horizon disable" for "{interface}"!')

def generate(config_dict):
if config_dict and 'frrender_cls' not in config_dict:
if config_dict and not is_systemd_service_running('vyos-configd.service'):
FRRender().generate(config_dict)
return None

def apply(config_dict):
if config_dict and 'frrender_cls' not in config_dict:
if config_dict and not is_systemd_service_running('vyos-configd.service'):
FRRender().apply()
return None

Expand Down
5 changes: 3 additions & 2 deletions src/conf_mode/protocols_ripng.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from vyos.configverify import verify_prefix_list
from vyos.frrender import FRRender
from vyos.utils.dict import dict_search
from vyos.utils.process import is_systemd_service_running
from vyos import ConfigError
from vyos import airbag
airbag.enable()
Expand Down Expand Up @@ -68,12 +69,12 @@ def verify(config_dict):
f'with "split-horizon disable" for "{interface}"!')

def generate(config_dict):
if config_dict and 'frrender_cls' not in config_dict:
if config_dict and not is_systemd_service_running('vyos-configd.service'):
FRRender().generate(config_dict)
return None

def apply(config_dict):
if config_dict and 'frrender_cls' not in config_dict:
if config_dict and not is_systemd_service_running('vyos-configd.service'):
FRRender().apply()
return None

Expand Down
2 changes: 1 addition & 1 deletion src/conf_mode/protocols_rpki.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
from vyos.pki import wrap_openssh_public_key
from vyos.pki import wrap_openssh_private_key
from vyos.utils.dict import dict_search_args
from vyos.utils.process import is_systemd_service_running
from vyos.utils.file import write_file
from vyos.utils.process import is_systemd_service_running
from vyos import ConfigError
from vyos import airbag
airbag.enable()
Expand Down
Loading

0 comments on commit 74bc43d

Please sign in to comment.