Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T5812: report actual number of revisions instead of max #2613

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions python/vyos/config_mgmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def __init__(self, session_env=None, config=None):
get_first_key=True)

self.max_revisions = int(d.get('commit_revisions', 0))
self.num_revisions = 0
self.locations = d.get('commit_archive', {}).get('location', [])
self.source_address = d.get('commit_archive',
{}).get('source_address', '')
Expand Down Expand Up @@ -233,7 +234,7 @@ def rollback(self, rev: int, no_prompt: bool=False) -> Tuple[str,int]:
msg = ''

if not self._check_revision_number(rev):
msg = f'Invalid revision number {rev}: must be 0 < rev < {self.max_revisions}'
msg = f'Invalid revision number {rev}: must be 0 < rev < {self.num_revisions}'
return msg, 1

prompt_str = 'Proceed with reboot ?'
Expand Down Expand Up @@ -560,8 +561,8 @@ def _get_number_of_revisions(self) -> int:
return len(l)

def _check_revision_number(self, rev: int) -> bool:
maxrev = self._get_number_of_revisions()
if not 0 <= rev < maxrev:
self.num_revisions = self._get_number_of_revisions()
if not 0 <= rev < self.num_revisions:
return False
return True

Expand Down