summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/vyos/configdict.py2
-rw-r--r--python/vyos/firewall.py6
-rw-r--r--python/vyos/ifconfig/vxlan.py7
-rw-r--r--python/vyos/system/grub.py2
-rw-r--r--python/vyos/template.py13
-rw-r--r--python/vyos/utils/__init__.py3
-rw-r--r--python/vyos/utils/cpu.py (renamed from python/vyos/cpu.py)1
7 files changed, 23 insertions, 11 deletions
diff --git a/python/vyos/configdict.py b/python/vyos/configdict.py
index 870d7cfda..5a353b110 100644
--- a/python/vyos/configdict.py
+++ b/python/vyos/configdict.py
@@ -631,7 +631,7 @@ def get_accel_dict(config, base, chap_secrets, with_pki=False):
Return a dictionary with the necessary interface config keys.
"""
- from vyos.cpu import get_core_count
+ from vyos.utils.cpu import get_core_count
from vyos.template import is_ipv4
dict = config.get_config_dict(base, key_mangling=('-', '_'),
diff --git a/python/vyos/firewall.py b/python/vyos/firewall.py
index d7b7b80a8..664df28cc 100644
--- a/python/vyos/firewall.py
+++ b/python/vyos/firewall.py
@@ -178,6 +178,8 @@ def parse_rule(rule_conf, hook, fw_name, rule_id, ip_name):
hook_name = 'input'
if hook == 'OUT':
hook_name = 'output'
+ if hook == 'PRE':
+ hook_name = 'prerouting'
if hook == 'NAM':
hook_name = f'name{def_suffix}'
output.append(f'{ip_name} {prefix}addr {operator} @FQDN_{hook_name}_{fw_name}_{rule_id}_{prefix}')
@@ -193,6 +195,8 @@ def parse_rule(rule_conf, hook, fw_name, rule_id, ip_name):
hook_name = 'input'
if hook == 'OUT':
hook_name = 'output'
+ if hook == 'PRE':
+ hook_name = 'prerouting'
if hook == 'NAM':
hook_name = f'name'
output.append(f'{ip_name} {prefix}addr {operator} @GEOIP_CC{def_suffix}_{hook_name}_{fw_name}_{rule_id}')
@@ -477,8 +481,6 @@ def parse_rule(rule_conf, hook, fw_name, rule_id, ip_name):
output.append(f'tcp option maxseg size set {mss}')
if 'action' in rule_conf:
- # Change action=return to action=action
- # #output.append(nft_action(rule_conf['action']))
if rule_conf['action'] == 'offload':
offload_target = rule_conf['offload_target']
output.append(f'flow add @VYOS_FLOWTABLE_{offload_target}')
diff --git a/python/vyos/ifconfig/vxlan.py b/python/vyos/ifconfig/vxlan.py
index bdb48e303..918aea202 100644
--- a/python/vyos/ifconfig/vxlan.py
+++ b/python/vyos/ifconfig/vxlan.py
@@ -138,10 +138,13 @@ class VXLANIf(Interface):
raise ValueError('Value out of range')
if 'vlan_to_vni_removed' in self.config:
- cur_vni_filter = get_vxlan_vni_filter(self.ifname)
+ cur_vni_filter = None
+ if dict_search('parameters.vni_filter', self.config) != None:
+ cur_vni_filter = get_vxlan_vni_filter(self.ifname)
+
for vlan, vlan_config in self.config['vlan_to_vni_removed'].items():
# If VNI filtering is enabled, remove matching VNI filter
- if dict_search('parameters.vni_filter', self.config) != None:
+ if cur_vni_filter != None:
vni = vlan_config['vni']
if vni in cur_vni_filter:
self._cmd(f'bridge vni delete dev {self.ifname} vni {vni}')
diff --git a/python/vyos/system/grub.py b/python/vyos/system/grub.py
index faf68c2d1..daddb799a 100644
--- a/python/vyos/system/grub.py
+++ b/python/vyos/system/grub.py
@@ -49,7 +49,7 @@ TMPL_GRUB_COMMON: str = 'grub/grub_common.j2'
BOOT_OPTS_STEM: str = 'boot=live rootdelay=5 noautologin net.ifnames=0 biosdevname=0 vyos-union=/boot/'
# prepare regexes
-REGEX_GRUB_VARS: str = r'^set (?P<variable_name>.+)=[\'"]?(?P<variable_value>.*)(?<![\'"])[\'"]?$'
+REGEX_GRUB_VARS: str = r'^set (?P<variable_name>\w+)=[\'"]?(?P<variable_value>.*)(?<![\'"])[\'"]?$'
REGEX_GRUB_MODULES: str = r'^insmod (?P<module_name>.+)$'
REGEX_KERNEL_CMDLINE: str = r'^BOOT_IMAGE=/(?P<boot_type>boot|live)/((?P<image_version>.+)/)?vmlinuz.*$'
REGEX_GRUB_BOOT_OPTS: str = r'^\s*set boot_opts="(?P<boot_opts>[^$]+)"$'
diff --git a/python/vyos/template.py b/python/vyos/template.py
index fbc5f1456..e8d7ba669 100644
--- a/python/vyos/template.py
+++ b/python/vyos/template.py
@@ -525,10 +525,17 @@ def get_esp_ike_cipher(group_config, ike_group=None):
return ciphers
@register_filter('get_uuid')
-def get_uuid(interface):
+def get_uuid(seed):
""" Get interface IP addresses"""
- from uuid import uuid1
- return uuid1()
+ if seed:
+ from hashlib import md5
+ from uuid import UUID
+ tmp = md5()
+ tmp.update(seed.encode('utf-8'))
+ return str(UUID(tmp.hexdigest()))
+ else:
+ from uuid import uuid1
+ return uuid1()
openvpn_translate = {
'des': 'des-cbc',
diff --git a/python/vyos/utils/__init__.py b/python/vyos/utils/__init__.py
index 12ef2d3b8..1cd062a11 100644
--- a/python/vyos/utils/__init__.py
+++ b/python/vyos/utils/__init__.py
@@ -1,4 +1,4 @@
-# Copyright 2023 VyOS maintainers and contributors <maintainers@vyos.io>
+# Copyright 2024 VyOS maintainers and contributors <maintainers@vyos.io>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -18,6 +18,7 @@ from vyos.utils import auth
from vyos.utils import boot
from vyos.utils import commit
from vyos.utils import convert
+from vyos.utils import cpu
from vyos.utils import dict
from vyos.utils import file
from vyos.utils import io
diff --git a/python/vyos/cpu.py b/python/vyos/utils/cpu.py
index cae5f5f4d..3bea5ac12 100644
--- a/python/vyos/cpu.py
+++ b/python/vyos/utils/cpu.py
@@ -28,7 +28,6 @@ but nothing is certain.
import re
-
def _read_cpuinfo():
with open('/proc/cpuinfo', 'r') as f:
lines = f.read().strip()