diff options
-rw-r--r-- | python/vyos/configdep.py | 7 | ||||
-rw-r--r-- | python/vyos/system/grub.py | 16 | ||||
-rwxr-xr-x | smoketest/scripts/cli/test_protocols_bgp.py | 18 |
3 files changed, 29 insertions, 12 deletions
diff --git a/python/vyos/configdep.py b/python/vyos/configdep.py index 8a28811eb..64727d355 100644 --- a/python/vyos/configdep.py +++ b/python/vyos/configdep.py @@ -107,6 +107,13 @@ def call_dependents(): f = l.pop(0) f() +def called_as_dependent() -> bool: + st = stack()[1:] + for f in st: + if f.filename == __file__: + return True + return False + def graph_from_dependency_dict(d: dict) -> dict: g = {} for k in list(d): diff --git a/python/vyos/system/grub.py b/python/vyos/system/grub.py index 763ccf983..a94729964 100644 --- a/python/vyos/system/grub.py +++ b/python/vyos/system/grub.py @@ -21,7 +21,7 @@ from typing import Union from uuid import uuid5, NAMESPACE_URL, UUID from vyos.template import render -from vyos.utils.process import cmd +from vyos.utils.process import cmd, rc_cmd from vyos.system import disk # Define variables @@ -139,14 +139,22 @@ def version_list(root_dir: str = '') -> list[str]: Returns: list: A list with versions names + + N.B. coreutils stat reports st_birthtime, but not available in + Path.stat()/os.stat() """ if not root_dir: root_dir = disk.find_persistence() versions_files = Path(f'{root_dir}/{GRUB_DIR_VYOS_VERS}').glob('*.cfg') - versions_list: list[str] = [] + versions_order: dict[str, int] = {} for file in versions_files: - versions_list.append(file.stem) - versions_list.sort(reverse=True) + p = Path(root_dir).joinpath('boot').joinpath(file.stem) + command = f'stat -c %W {p.as_posix()}' + rc, out = rc_cmd(command) + if rc == 0: + versions_order[file.stem] = int(out) + versions_order = sorted(versions_order, key=versions_order.get, reverse=True) + versions_list: list[str] = list(versions_order) return versions_list diff --git a/smoketest/scripts/cli/test_protocols_bgp.py b/smoketest/scripts/cli/test_protocols_bgp.py index d8214db41..ebc9eeaaa 100755 --- a/smoketest/scripts/cli/test_protocols_bgp.py +++ b/smoketest/scripts/cli/test_protocols_bgp.py @@ -15,7 +15,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import unittest -from subprocess import run + +from time import sleep from base_vyostest_shim import VyOSUnitTestSHIM @@ -23,6 +24,7 @@ from vyos.ifconfig import Section from vyos.configsession import ConfigSessionError from vyos.template import is_ipv6 from vyos.utils.process import process_named_running +from vyos.utils.process import cmd PROCESS_NAME = 'bgpd' ASN = '64512' @@ -1150,7 +1152,6 @@ class TestProtocolsBGP(VyOSUnitTestSHIM.TestCase): self.assertIn(f' sid vpn per-vrf export {sid}', frrconfig) def test_bgp_25_bmp(self): - self.skipTest('Skipping for now - until GitHub builds work again - just a test') target_name = 'instance-bmp' target_address = '127.0.0.1' target_port = '5000' @@ -1161,13 +1162,10 @@ class TestProtocolsBGP(VyOSUnitTestSHIM.TestCase): mirror_buffer = '32000000' bmp_path = base_path + ['bmp'] target_path = bmp_path + ['target', target_name] - bgpd_bmp_pid = process_named_running('bgpd', 'bmp') - command = ['/opt/vyatta/bin/vyatta-op-cmd-wrapper', 'restart', 'bgp'] + # by default the 'bmp' module not loaded for the bgpd expect Error self.cli_set(bmp_path) - # by default the 'bmp' module not loaded for the bgpd - # expect Error - if not bgpd_bmp_pid: + if not process_named_running('bgpd', 'bmp'): with self.assertRaises(ConfigSessionError): self.cli_commit() @@ -1175,8 +1173,12 @@ class TestProtocolsBGP(VyOSUnitTestSHIM.TestCase): self.cli_delete(bmp_path) self.cli_set(['system', 'frr', 'bmp']) self.cli_commit() + # restart bgpd to apply "-M bmp" and update PID - run(command, input='Y', text=True) + cmd(f'sudo kill -9 {self.daemon_pid}') + # let the bgpd process recover + sleep(10) + # update daemon PID - this was a planned daemon restart self.daemon_pid = process_named_running(PROCESS_NAME) # set bmp config but not set address |