diff options
author | Daniil Baturin <daniil@vyos.io> | 2025-03-18 15:48:30 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-18 15:48:30 +0000 |
commit | 78a3ba7039e8ad9be8ca1960ecc5dac9a985fb0e (patch) | |
tree | 2fdef8540f26e4e03dbea232a09a26360fd7ada7 /src/helpers/show_commit_data.py | |
parent | 62ebdb827b1b3097b345aae0cf13b636ca055537 (diff) | |
parent | d8a6295a13a6eb8faf127639ae15fa76608e7351 (diff) | |
download | vyos-1x-78a3ba7039e8ad9be8ca1960ecc5dac9a985fb0e.tar.gz vyos-1x-78a3ba7039e8ad9be8ca1960ecc5dac9a985fb0e.zip |
Merge pull request #4398 from jestabro/commitd
T7121: Set up communication vyconfd to vyos-commitd
Diffstat (limited to 'src/helpers/show_commit_data.py')
-rwxr-xr-x | src/helpers/show_commit_data.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/helpers/show_commit_data.py b/src/helpers/show_commit_data.py new file mode 100755 index 000000000..d507ed9a4 --- /dev/null +++ b/src/helpers/show_commit_data.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2025 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/>. +# +# +# This script is used to show the commit data of the configuration + +import sys +from pathlib import Path +from argparse import ArgumentParser + +from vyos.config_mgmt import ConfigMgmt +from vyos.configtree import ConfigTree +from vyos.configtree import show_commit_data + +cm = ConfigMgmt() + +parser = ArgumentParser( + description='Show commit priority queue; no options compares the last two commits' +) +parser.add_argument('--active-config', help='Path to the active configuration file') +parser.add_argument('--proposed-config', help='Path to the proposed configuration file') +args = parser.parse_args() + +active_arg = args.active_config +proposed_arg = args.proposed_config + +if active_arg and not proposed_arg: + print('--proposed-config is required when --active-config is specified') + sys.exit(1) + +if not active_arg and not proposed_arg: + active = cm.get_config_tree_revision(1) + proposed = cm.get_config_tree_revision(0) +else: + if active_arg: + active = ConfigTree(Path(active_arg).read_text()) + else: + active = cm.get_config_tree_revision(0) + + proposed = ConfigTree(Path(proposed_arg).read_text()) + +ret = show_commit_data(active, proposed) +print(ret) |