Skip to content

T7499: update config merge tools #4574

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

Draft
wants to merge 7 commits into
base: current
Choose a base branch
from
Draft

Conversation

jestabro
Copy link
Contributor

@jestabro jestabro commented Jun 24, 2025

Change summary

Before merge of the current PR, the following will need to be merged:
vyos/vyos1x-config#45
vyos/vyconf#24
vyos/libvyosconfig#42

This updates the vyos-config-merge.py script to use current tools; adds option destructive to merge; and exposes in the http-api. A unittest is added in src/tests/test_config_merge.py, analogous to test_config_diff.py.

Default non-destructive merge:

└──> ./api-merge-test.py
before: {'success': True, 'data': {'address': '10.23.2.17/24', 'hw-id': '52:54:00:20:0c:7e'}, 'error': None}
{'success': True, 'data': '', 'error': None}
after: {'success': True, 'data': {'address': '10.23.2.17/24', 'hw-id': '52:54:00:20:0c:7e'}, 'error': None}

Destructive merge:

└──> ./api-merge-test.py
before: {'success': True, 'data': {'address': '10.23.2.17/24', 'hw-id': '52:54:00:20:0c:7e'}, 'error': None}
{'success': True, 'data': '', 'error': None}
after: {'success': True, 'data': {'address': '192.168.2.137/24', 'hw-id': '52:54:00:20:0c:7e'}, 'error': None}

└──> cat api-merge-test.py 
#!/usr/bin/env python3

import json
import urllib3
from requests import request

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)


address = '192.168.122.212'
key = 'baz'
headers = {}
url_config_file = f'https://{address}/config-file'
url_retrieve = f'https://{address}/retrieve'

merge_string = 'interfaces {\nethernet eth1 {\naddress "192.168.2.137/24"\n}\n}\n'

path = ['interfaces', 'ethernet', 'eth1']

payload = {'data': json.dumps({'op': 'showConfig', 'path': path}), 'key': f'{key}'}
r = request('POST', url_retrieve, verify=False, headers=headers, data=payload)

print(f'before: {r.json()}')

payload = {'data': json.dumps({'op': 'merge', 'string': merge_string, 'destructive': True}), 'key': f'{key}'}

r = request('POST', url_config_file, verify=False, headers=headers, data=payload)

print(r.json())

payload = {'data': json.dumps({'op': 'showConfig', 'path': path}), 'key': f'{key}'}
r = request('POST', url_retrieve, verify=False, headers=headers, data=payload)

print(f'after: {r.json()}')

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes)
  • Migration from an old Vyatta component to vyos-1x, please link to related PR inside obsoleted component
  • Other (please describe):

Related Task(s)

Related PR(s)

vyos/vyos1x-config#45
vyos/vyconf#24
vyos/libvyosconfig#42

How to test / Smoketest result

Checklist:

  • I have read the CONTRIBUTING document
  • I have linked this PR to one or more Phabricator Task(s)
  • I have run the components SMOKETESTS if applicable
  • My commit headlines contain a valid Task id
  • My change requires a change to the documentation
  • I have updated the documentation accordingly

@jestabro jestabro self-assigned this Jun 24, 2025
Copy link

github-actions bot commented Jun 24, 2025

👍
No issues in PR Title / Commit Title

Copy link

CI integration ❌ failed!

Details

CI logs

  • CLI Smoketests (no interfaces) ❌ failed
  • CLI Smoketests (interfaces only) ❌ failed
  • Config tests ❌ failed
  • RAID1 tests ❌ failed
  • TPM tests ❌ failed

@jestabro jestabro marked this pull request as draft June 24, 2025 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

1 participant