Skip to content

Commit

Permalink
Merge pull request #4243 from c-po/frr-10
Browse files Browse the repository at this point in the history
frrender: T6746: runtime improvements
  • Loading branch information
c-po authored Dec 19, 2024
2 parents fdb9ce3 + d2a7584 commit ccb260c
Show file tree
Hide file tree
Showing 27 changed files with 534 additions and 544 deletions.
495 changes: 0 additions & 495 deletions python/vyos/configdict.py

Large diffs are not rendered by default.

520 changes: 502 additions & 18 deletions python/vyos/frrender.py

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions python/vyos/ifconfig/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
# this is not the same as socket.AF_INET/INET6
from netifaces import AF_INET
from netifaces import AF_INET6
from netaddr import EUI
from netaddr import mac_unix_expanded

from vyos import ConfigError
from vyos.configdict import list_diff
from vyos.configdict import dict_merge
from vyos.configdict import get_vlan_ids
Expand Down Expand Up @@ -61,9 +62,7 @@
from vyos.ifconfig.vrrp import VRRP
from vyos.ifconfig.operational import Operational
from vyos.ifconfig import Section

from netaddr import EUI
from netaddr import mac_unix_expanded
from vyos import ConfigError

link_local_prefix = 'fe80::/64'

Expand Down Expand Up @@ -339,8 +338,8 @@ def __init__(self, ifname, **kargs):
# Any instance of Interface, such as Interface('eth0') can be used
# safely to access the generic function in this class as 'type' is
# unset, the class can not be created
if not self.iftype:
raise Exception(f'interface "{ifname}" not found')
if not hasattr(self, 'iftype'):
raise ConfigError(f'Interface "{ifname}" has no "iftype" attribute defined!')
self.config['type'] = self.iftype

# Should an Instance of a child class (EthernetIf, DummyIf, ..)
Expand Down
5 changes: 2 additions & 3 deletions python/vyos/ifconfig/macvlan.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2022 VyOS maintainers and contributors <[email protected]>
# Copyright 2019-2024 VyOS maintainers and contributors <[email protected]>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -42,6 +42,5 @@ def _create(self):
self.set_admin_state('down')

def set_mode(self, mode):
ifname = self.config['ifname']
cmd = f'ip link set dev {ifname} type macvlan mode {mode}'
cmd = f'ip link set dev {self.ifname} type {self.iftype} mode {mode}'
return self._cmd(cmd)
2 changes: 1 addition & 1 deletion src/conf_mode/interfaces_bonding.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from sys import exit

from vyos.config import Config
from vyos.configdict import get_frrender_dict
from vyos.configdict import get_interface_dict
from vyos.configdict import is_node_changed
from vyos.configdict import leaf_node_changed
Expand All @@ -32,6 +31,7 @@
from vyos.configverify import verify_vlan_config
from vyos.configverify import verify_vrf
from vyos.frrender import FRRender
from vyos.frrender import get_frrender_dict
from vyos.ifconfig import BondIf
from vyos.ifconfig.ethernet import EthernetIf
from vyos.ifconfig import Section
Expand Down
2 changes: 1 addition & 1 deletion src/conf_mode/interfaces_ethernet.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

from vyos.base import Warning
from vyos.config import Config
from vyos.configdict import get_frrender_dict
from vyos.configdict import get_interface_dict
from vyos.configdict import is_node_changed
from vyos.configverify import verify_address
Expand All @@ -35,6 +34,7 @@
from vyos.configverify import verify_eapol
from vyos.ethtool import Ethtool
from vyos.frrender import FRRender
from vyos.frrender import get_frrender_dict
from vyos.ifconfig import EthernetIf
from vyos.ifconfig import BondIf
from vyos.utils.dict import dict_search
Expand Down
2 changes: 1 addition & 1 deletion src/conf_mode/policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
from sys import exit

from vyos.config import Config
from vyos.configdict import get_frrender_dict
from vyos.configverify import has_frr_protocol_in_dict
from vyos.frrender import FRRender
from vyos.frrender import frr_protocols
from vyos.frrender import get_frrender_dict
from vyos.utils.dict import dict_search
from vyos.utils.process import is_systemd_service_running
from vyos import ConfigError
Expand Down
2 changes: 1 addition & 1 deletion src/conf_mode/protocols_babel.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
from sys import exit

from vyos.config import Config
from vyos.configdict import get_frrender_dict
from vyos.configverify import has_frr_protocol_in_dict
from vyos.configverify import verify_access_list
from vyos.configverify import verify_prefix_list
from vyos.frrender import FRRender
from vyos.frrender import get_frrender_dict
from vyos.utils.dict import dict_search
from vyos.utils.process import is_systemd_service_running
from vyos import ConfigError
Expand Down
2 changes: 1 addition & 1 deletion src/conf_mode/protocols_bfd.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from vyos.config import Config
from vyos.configdict import get_frrender_dict
from vyos.configverify import verify_vrf
from vyos.configverify import has_frr_protocol_in_dict
from vyos.frrender import FRRender
from vyos.frrender import get_frrender_dict
from vyos.template import is_ipv6
from vyos.utils.network import is_ipv6_link_local
from vyos.utils.process import is_systemd_service_running
Expand Down
2 changes: 1 addition & 1 deletion src/conf_mode/protocols_bgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

from vyos.base import Warning
from vyos.config import Config
from vyos.configdict import get_frrender_dict
from vyos.configverify import has_frr_protocol_in_dict
from vyos.configverify import verify_prefix_list
from vyos.configverify import verify_route_map
from vyos.configverify import verify_vrf
from vyos.frrender import FRRender
from vyos.frrender import get_frrender_dict
from vyos.template import is_ip
from vyos.template import is_interface
from vyos.utils.dict import dict_search
Expand Down
2 changes: 1 addition & 1 deletion src/conf_mode/protocols_eigrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
from sys import argv

from vyos.config import Config
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.frrender import get_frrender_dict
from vyos import ConfigError
from vyos import airbag
airbag.enable()
Expand Down
2 changes: 1 addition & 1 deletion src/conf_mode/protocols_isis.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
from sys import argv

from vyos.config import Config
from vyos.configdict import get_frrender_dict
from vyos.configverify import has_frr_protocol_in_dict
from vyos.configverify import verify_common_route_maps
from vyos.configverify import verify_interface_exists
from vyos.frrender import FRRender
from vyos.frrender import get_frrender_dict
from vyos.ifconfig import Interface
from vyos.utils.dict import dict_search
from vyos.utils.network import get_interface_config
Expand Down
2 changes: 1 addition & 1 deletion src/conf_mode/protocols_mpls.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

from glob import glob
from vyos.config import Config
from vyos.configdict import get_frrender_dict
from vyos.configverify import has_frr_protocol_in_dict
from vyos.frrender import FRRender
from vyos.frrender import get_frrender_dict
from vyos.utils.dict import dict_search
from vyos.utils.file import read_file
from vyos.utils.process import is_systemd_service_running
Expand Down
2 changes: 1 addition & 1 deletion src/conf_mode/protocols_openfabric.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

from vyos.base import Warning
from vyos.config import Config
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.frrender import get_frrender_dict
from vyos import ConfigError
from vyos import airbag
airbag.enable()
Expand Down
2 changes: 1 addition & 1 deletion src/conf_mode/protocols_ospf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
from sys import argv

from vyos.config import Config
from vyos.configdict import get_frrender_dict
from vyos.configverify import verify_common_route_maps
from vyos.configverify import verify_route_map
from vyos.configverify import verify_interface_exists
from vyos.configverify import verify_access_list
from vyos.configverify import has_frr_protocol_in_dict
from vyos.frrender import FRRender
from vyos.frrender import get_frrender_dict
from vyos.utils.dict import dict_search
from vyos.utils.network import get_interface_config
from vyos.utils.process import is_systemd_service_running
Expand Down
2 changes: 1 addition & 1 deletion src/conf_mode/protocols_ospfv3.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
from sys import argv

from vyos.config import Config
from vyos.configdict import get_frrender_dict
from vyos.configverify import verify_common_route_maps
from vyos.configverify import verify_route_map
from vyos.configverify import verify_interface_exists
from vyos.configverify import has_frr_protocol_in_dict
from vyos.frrender import FRRender
from vyos.frrender import get_frrender_dict
from vyos.ifconfig import Interface
from vyos.utils.dict import dict_search
from vyos.utils.network import get_interface_config
Expand Down
2 changes: 1 addition & 1 deletion src/conf_mode/protocols_pim.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
from sys import exit

from vyos.config import Config
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.frrender import FRRender
from vyos.frrender import get_frrender_dict
from vyos.frrender import pim_daemon
from vyos.utils.process import is_systemd_service_running
from vyos.utils.process import process_named_running
Expand Down
2 changes: 1 addition & 1 deletion src/conf_mode/protocols_pim6.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
from sys import exit

from vyos.config import Config
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.frrender import get_frrender_dict
from vyos import ConfigError
from vyos import airbag
airbag.enable()
Expand Down
2 changes: 1 addition & 1 deletion src/conf_mode/protocols_rip.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
from sys import exit

from vyos.config import Config
from vyos.configdict import get_frrender_dict
from vyos.configverify import has_frr_protocol_in_dict
from vyos.configverify import verify_common_route_maps
from vyos.configverify import verify_access_list
from vyos.configverify import verify_prefix_list
from vyos.frrender import FRRender
from vyos.frrender import get_frrender_dict
from vyos.utils.dict import dict_search
from vyos.utils.process import is_systemd_service_running
from vyos import ConfigError
Expand Down
2 changes: 1 addition & 1 deletion src/conf_mode/protocols_ripng.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
from sys import exit

from vyos.config import Config
from vyos.configdict import get_frrender_dict
from vyos.configverify import has_frr_protocol_in_dict
from vyos.configverify import verify_common_route_maps
from vyos.configverify import verify_access_list
from vyos.configverify import verify_prefix_list
from vyos.frrender import FRRender
from vyos.frrender import get_frrender_dict
from vyos.utils.dict import dict_search
from vyos.utils.process import is_systemd_service_running
from vyos import ConfigError
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 @@ -20,9 +20,9 @@
from sys import exit

from vyos.config import Config
from vyos.configdict import get_frrender_dict
from vyos.configverify import has_frr_protocol_in_dict
from vyos.frrender import FRRender
from vyos.frrender import get_frrender_dict
from vyos.pki import wrap_openssh_public_key
from vyos.pki import wrap_openssh_private_key
from vyos.utils.dict import dict_search_args
Expand Down
2 changes: 1 addition & 1 deletion src/conf_mode/protocols_segment-routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
from sys import exit

from vyos.config import Config
from vyos.configdict import get_frrender_dict
from vyos.configdict import list_diff
from vyos.configverify import has_frr_protocol_in_dict
from vyos.frrender import FRRender
from vyos.frrender import get_frrender_dict
from vyos.ifconfig import Section
from vyos.utils.dict import dict_search
from vyos.utils.process import is_systemd_service_running
Expand Down
2 changes: 1 addition & 1 deletion src/conf_mode/protocols_static.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
from sys import argv

from vyos.config import Config
from vyos.configdict import get_frrender_dict
from vyos.configverify import has_frr_protocol_in_dict
from vyos.configverify import verify_common_route_maps
from vyos.configverify import verify_vrf
from vyos.frrender import FRRender
from vyos.frrender import get_frrender_dict
from vyos.utils.process import is_systemd_service_running
from vyos.template import render
from vyos import ConfigError
Expand Down
2 changes: 1 addition & 1 deletion src/conf_mode/system_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
from vyos.config import Config
from vyos.configdep import set_dependents
from vyos.configdep import call_dependents
from vyos.configdict import get_frrender_dict
from vyos.configverify import has_frr_protocol_in_dict
from vyos.configverify import verify_route_map
from vyos.frrender import FRRender
from vyos.frrender import get_frrender_dict
from vyos.utils.dict import dict_search
from vyos.utils.process import is_systemd_service_active
from vyos.utils.process import is_systemd_service_running
Expand Down
2 changes: 1 addition & 1 deletion src/conf_mode/system_ipv6.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
from vyos.config import Config
from vyos.configdep import set_dependents
from vyos.configdep import call_dependents
from vyos.configdict import get_frrender_dict
from vyos.configverify import has_frr_protocol_in_dict
from vyos.configverify import verify_route_map
from vyos.frrender import FRRender
from vyos.frrender import get_frrender_dict
from vyos.utils.dict import dict_search
from vyos.utils.file import write_file
from vyos.utils.process import is_systemd_service_active
Expand Down
2 changes: 1 addition & 1 deletion src/conf_mode/vrf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
from json import loads

from vyos.config import Config
from vyos.configdict import get_frrender_dict
from vyos.configdict import node_changed
from vyos.configverify import verify_route_map
from vyos.firewall import conntrack_required
from vyos.frrender import FRRender
from vyos.frrender import get_frrender_dict
from vyos.ifconfig import Interface
from vyos.template import render
from vyos.utils.dict import dict_search
Expand Down
3 changes: 3 additions & 0 deletions src/services/vyos-configd
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ from vyos.configsource import ConfigSourceError
from vyos.configdiff import get_commit_scripts
from vyos.config import Config
from vyos.frrender import FRRender
from vyos.frrender import get_frrender_dict
from vyos import ConfigError

CFG_GROUP = 'vyattacfg'
Expand Down Expand Up @@ -333,6 +334,8 @@ if __name__ == '__main__':

if hasattr(config, 'frrender_cls') and res == R_SUCCESS:
frrender_cls = getattr(config, 'frrender_cls')
tmp = get_frrender_dict(config)
frrender_cls.generate(tmp)
frrender_cls.apply()
else:
logger.critical(f'Unexpected message: {message}')

0 comments on commit ccb260c

Please sign in to comment.