summaryrefslogtreecommitdiff
path: root/src/helpers
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2026-02-03 13:56:54 +0200
committerGitHub <noreply@github.com>2026-02-03 13:56:54 +0200
commit810d1048c0c95e0037b4356877dd75b9b1cc02ee (patch)
treeb0d5c314d7c614fc188145873478e6fa122cb5fd /src/helpers
parente31c302a024720da060889ea98eaf8d4069613fd (diff)
parent7fd4b50494d3b8865a7300e97c72df2a4fe11f14 (diff)
downloadvyos-1x-810d1048c0c95e0037b4356877dd75b9b1cc02ee.tar.gz
vyos-1x-810d1048c0c95e0037b4356877dd75b9b1cc02ee.zip
Merge pull request #4953 from alexandr-san4ez/T7090-current
http-api: T7090: Implement background configure operations for REST API
Diffstat (limited to 'src/helpers')
-rwxr-xr-xsrc/helpers/vyos_config_sync.py28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/helpers/vyos_config_sync.py b/src/helpers/vyos_config_sync.py
index 80bfb6d17..f0650c5fc 100755
--- a/src/helpers/vyos_config_sync.py
+++ b/src/helpers/vyos_config_sync.py
@@ -40,9 +40,12 @@ logger.name = os.path.basename(__file__)
API_HEADERS = {'Content-Type': 'application/json'}
-def post_request(url: str,
- data: str,
- headers: Dict[str, str]) -> requests.Response:
+def post_request(
+ url: str,
+ data: str,
+ params: Dict[str, Any],
+ headers: Dict[str, str],
+) -> requests.Response:
"""Sends a POST request to the specified URL
Args:
@@ -54,11 +57,14 @@ def post_request(url: str,
requests.Response: The response object representing the server's response to the request
"""
- response = requests.post(url,
- data=data,
- headers=headers,
- verify=False,
- timeout=timeout)
+ response = requests.post(
+ url,
+ data=data,
+ params=params,
+ headers=headers,
+ verify=False,
+ timeout=timeout,
+ )
return response
@@ -116,6 +122,10 @@ def set_remote_config(
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
url = f'https://{address}:{port}/configure-section'
+ params = {
+ # Ask the remote API to perform the configure and commit workflow asynchronously
+ 'in_background': True,
+ }
data = json.dumps({
'op': op,
'mask': mask,
@@ -124,7 +134,7 @@ def set_remote_config(
})
try:
- config = post_request(url, data, headers)
+ config = post_request(url, data, params, headers)
return config.json()
except requests.exceptions.RequestException as e:
print(f"An error occurred: {e}")