diff options
| author | goodNETnick <33053932+goodNETnick@users.noreply.github.com> | 2022-03-31 13:48:47 +1000 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-31 13:48:47 +1000 | 
| commit | aa5b35b68c1170bfd0b9661bafa72bb10fe6ca95 (patch) | |
| tree | 46f3ffc41c29666c3251f25f2f93cb1f1b9a6c60 /python/vyos/util.py | |
| parent | b776003cf55e1035ac83186e44f72764e52e9e0d (diff) | |
| parent | bafb1973d906707cb571385e994a949d0d90b645 (diff) | |
| download | vyos-1x-aa5b35b68c1170bfd0b9661bafa72bb10fe6ca95.tar.gz vyos-1x-aa5b35b68c1170bfd0b9661bafa72bb10fe6ca95.zip | |
Merge branch 'vyos:current' into ocserv_local_otp
Diffstat (limited to 'python/vyos/util.py')
| -rw-r--r-- | python/vyos/util.py | 22 | 
1 files changed, 22 insertions, 0 deletions
| diff --git a/python/vyos/util.py b/python/vyos/util.py index 571d43754..f46775490 100644 --- a/python/vyos/util.py +++ b/python/vyos/util.py @@ -774,6 +774,14 @@ def dict_search_recursive(dict_object, key):              for x in dict_search_recursive(j, key):                  yield x +def get_bridge_fdb(interface): +    """ Returns the forwarding database entries for a given interface """ +    if not os.path.exists(f'/sys/class/net/{interface}'): +        return None +    from json import loads +    tmp = loads(cmd(f'bridge -j fdb show dev {interface}')) +    return tmp +  def get_interface_config(interface):      """ Returns the used encapsulation protocol for given interface.          If interface does not exist, None is returned. @@ -997,3 +1005,17 @@ def boot_configuration_complete() -> bool:      if os.path.isfile(config_status):          return True      return False + +def sysctl_read(name): +    """ Read and return current value of sysctl() option """ +    tmp = cmd(f'sysctl {name}') +    return tmp.split()[-1] + +def sysctl_write(name, value): +    """ Change value via sysctl() - return True if changed, False otherwise """ +    tmp = cmd(f'sysctl {name}') +    # last list index contains the actual value - only write if value differs +    if sysctl_read(name) != str(value): +        call(f'sysctl -wq {name}={value}') +        return True +    return False | 
