summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--python/vyos/util.py14
-rwxr-xr-xsrc/conf_mode/protocols_mpls.py2
-rwxr-xr-xsrc/conf_mode/system-ip.py2
-rwxr-xr-xsrc/conf_mode/system-ipv6.py2
-rwxr-xr-xsrc/conf_mode/vrf.py2
-rw-r--r--src/tests/test_util.py3
6 files changed, 6 insertions, 19 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py
index bd47940bb..fac3a920b 100644
--- a/python/vyos/util.py
+++ b/python/vyos/util.py
@@ -1130,20 +1130,6 @@ def is_wwan_connected(interface):
# return True/False if interface is in connected state
return dict_search('modem.generic.state', tmp) == 'connected'
-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
-
def load_as_module(name: str, path: str):
import importlib.util
diff --git a/src/conf_mode/protocols_mpls.py b/src/conf_mode/protocols_mpls.py
index 73af6595b..bb982c5fc 100755
--- a/src/conf_mode/protocols_mpls.py
+++ b/src/conf_mode/protocols_mpls.py
@@ -23,7 +23,7 @@ from vyos.config import Config
from vyos.template import render_to_string
from vyos.util import dict_search
from vyos.util import read_file
-from vyos.util import sysctl_write
+from vyos.utils.system import sysctl_write
from vyos.configverify import verify_interface_exists
from vyos import ConfigError
from vyos import frr
diff --git a/src/conf_mode/system-ip.py b/src/conf_mode/system-ip.py
index 95865c690..b2225d665 100755
--- a/src/conf_mode/system-ip.py
+++ b/src/conf_mode/system-ip.py
@@ -22,8 +22,8 @@ from vyos.configverify import verify_route_map
from vyos.template import render_to_string
from vyos.util import call
from vyos.util import dict_search
-from vyos.util import sysctl_write
from vyos.util import write_file
+from vyos.utils.system import sysctl_write
from vyos.xml import defaults
from vyos import ConfigError
from vyos import frr
diff --git a/src/conf_mode/system-ipv6.py b/src/conf_mode/system-ipv6.py
index b6d3a79c3..60ebc8006 100755
--- a/src/conf_mode/system-ipv6.py
+++ b/src/conf_mode/system-ipv6.py
@@ -22,7 +22,7 @@ from vyos.configdict import dict_merge
from vyos.configverify import verify_route_map
from vyos.template import render_to_string
from vyos.util import dict_search
-from vyos.util import sysctl_write
+from vyos.utils.system import sysctl_write
from vyos.util import write_file
from vyos.xml import defaults
from vyos import ConfigError
diff --git a/src/conf_mode/vrf.py b/src/conf_mode/vrf.py
index 0b983293e..2871f8527 100755
--- a/src/conf_mode/vrf.py
+++ b/src/conf_mode/vrf.py
@@ -32,7 +32,7 @@ from vyos.util import dict_search
from vyos.util import get_interface_config
from vyos.util import popen
from vyos.util import run
-from vyos.util import sysctl_write
+from vyos.utils.system import sysctl_write
from vyos import ConfigError
from vyos import frr
from vyos import airbag
diff --git a/src/tests/test_util.py b/src/tests/test_util.py
index 473052bef..2e8f1b6cc 100644
--- a/src/tests/test_util.py
+++ b/src/tests/test_util.py
@@ -15,14 +15,15 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from unittest import TestCase
-from vyos.util import *
class TestVyOSUtil(TestCase):
def test_key_mangline(self):
+ from vyos.util import mangle_dict_keys
data = {"foo-bar": {"baz-quux": None}}
expected_data = {"foo_bar": {"baz_quux": None}}
new_data = mangle_dict_keys(data, '-', '_')
self.assertEqual(new_data, expected_data)
def test_sysctl_read(self):
+ from vyos.utils.system import sysctl_read
self.assertEqual(sysctl_read('net.ipv4.conf.lo.forwarding'), '1')