diff options
| author | Christian Breunig <christian@breunig.cc> | 2023-01-17 15:23:00 +0100 | 
|---|---|---|
| committer | Christian Breunig <christian@breunig.cc> | 2023-01-17 15:23:12 +0100 | 
| commit | 328dba073dc72fd2d87ba85e4e8eb93e50358f31 (patch) | |
| tree | 2e5f1686a41f0cab6bb53fc37b72704df78fba45 /src | |
| parent | 324b74f7420bed3e9f7b5aee4a7caf926fd8eb91 (diff) | |
| download | vyos-1x-328dba073dc72fd2d87ba85e4e8eb93e50358f31.tar.gz vyos-1x-328dba073dc72fd2d87ba85e4e8eb93e50358f31.zip  | |
ifb: T4938: add Python implementation for input function block interfaces
Diffstat (limited to 'src')
| -rwxr-xr-x | src/conf_mode/interfaces-input.py | 70 | ||||
| -rw-r--r-- | src/etc/modprobe.d/ifb.conf | 1 | 
2 files changed, 71 insertions, 0 deletions
diff --git a/src/conf_mode/interfaces-input.py b/src/conf_mode/interfaces-input.py new file mode 100755 index 000000000..ad248843d --- /dev/null +++ b/src/conf_mode/interfaces-input.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2023 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program.  If not, see <http://www.gnu.org/licenses/>. + +from sys import exit + +from vyos.config import Config +from vyos.configdict import get_interface_dict +from vyos.configverify import verify_mirror_redirect +from vyos.ifconfig import InputIf +from vyos import ConfigError +from vyos import airbag +airbag.enable() + +def get_config(config=None): +    """ +    Retrive CLI config as dictionary. Dictionary can never be empty, as at +    least the interface name will be added or a deleted flag +    """ +    if config: +        conf = config +    else: +        conf = Config() +    base = ['interfaces', 'input'] +    _, ifb = get_interface_dict(conf, base) + +    return ifb + +def verify(ifb): +    if 'deleted' in ifb: +        return None + +    verify_mirror_redirect(ifb) +    return None + +def generate(ifb): +    return None + +def apply(ifb): +    d = InputIf(ifb['ifname']) + +    # Remove input interface +    if 'deleted' in ifb: +        d.remove() +    else: +        d.update(ifb) + +    return None + +if __name__ == '__main__': +    try: +        c = get_config() +        verify(c) +        generate(c) +        apply(c) +    except ConfigError as e: +        print(e) +        exit(1) diff --git a/src/etc/modprobe.d/ifb.conf b/src/etc/modprobe.d/ifb.conf new file mode 100644 index 000000000..2dcfb6af4 --- /dev/null +++ b/src/etc/modprobe.d/ifb.conf @@ -0,0 +1 @@ +options ifb numifbs=0  | 
