diff options
author | Christian Poessinger <christian@poessinger.com> | 2022-09-22 07:59:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-22 07:59:59 +0200 |
commit | cd1875cb15211d733630b97f1dc7f73f11061927 (patch) | |
tree | 5d71bedc1924b29d96cbae5d12064e2bf69c2287 /python | |
parent | 7ba1f6444d1b7a8d25715623daf75f81521d9667 (diff) | |
parent | a8e73794ec421ad2bb0053214504f20a1dc3b21a (diff) | |
download | vyos-1x-cd1875cb15211d733630b97f1dc7f73f11061927.tar.gz vyos-1x-cd1875cb15211d733630b97f1dc7f73f11061927.zip |
Merge pull request #1521 from sever-sever/T3476
update-check: T3476: Allow update-check for VyOS images
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/version.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/python/vyos/version.py b/python/vyos/version.py index 871bb0f1b..fb706ad44 100644 --- a/python/vyos/version.py +++ b/python/vyos/version.py @@ -31,6 +31,7 @@ Example of the version data dict:: import os import json +import requests import vyos.defaults from vyos.util import read_file @@ -105,3 +106,41 @@ def get_full_version_data(fname=version_file): version_data['hardware_uuid'] = read_file(subsystem + '/product_uuid', 'Unknown') return version_data + +def get_remote_version(url): + """ + Get remote available JSON file from remote URL + An example of the image-version.json + + [ + { + "arch":"amd64", + "flavors":[ + "generic" + ], + "image":"vyos-rolling-latest.iso", + "latest":true, + "lts":false, + "release_date":"2022-09-06", + "release_train":"sagitta", + "url":"http://xxx/rolling/current/vyos-rolling-latest.iso", + "version":"vyos-1.4-rolling-202209060217" + } + ] + """ + headers = {} + try: + remote_data = requests.get(url=url, headers=headers) + remote_data.raise_for_status() + if remote_data.status_code != 200: + return False + return remote_data.json() + except requests.exceptions.HTTPError as errh: + print ("HTTP Error:", errh) + except requests.exceptions.ConnectionError as errc: + print ("Connecting error:", errc) + except requests.exceptions.Timeout as errt: + print ("Timeout error:", errt) + except requests.exceptions.RequestException as err: + print ("Unable to get remote data", err) + return False |