summaryrefslogtreecommitdiff
path: root/src/op_mode
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2023-12-30 13:59:07 +0000
committerViacheslav Hletenko <v.gletenko@vyos.io>2023-12-30 13:59:07 +0000
commit87202912e871eeafe20ba24c5fcbf696ce5171ff (patch)
tree5081b0f4ac1c9a1362f388fde8370f7e982a489d /src/op_mode
parent1e46cd606d9d87226fe0400bf3a53bda360808d8 (diff)
downloadvyos-1x-87202912e871eeafe20ba24c5fcbf696ce5171ff.tar.gz
vyos-1x-87202912e871eeafe20ba24c5fcbf696ce5171ff.zip
T3476: Add option latest to add system image
Add option `latest` for op-mode command `add system image` If the update check is configured we can get the remote `latest` version from conrfgure URL ``` set system update-check url 'https://example.com/version.json' ``` This way we can use "latest" option for image update: ``` add system image latest ```
Diffstat (limited to 'src/op_mode')
-rwxr-xr-xsrc/op_mode/image_installer.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/op_mode/image_installer.py b/src/op_mode/image_installer.py
index 529b388c8..5cc5b9bdb 100755
--- a/src/op_mode/image_installer.py
+++ b/src/op_mode/image_installer.py
@@ -31,12 +31,14 @@ from passlib.hosts import linux_context
from psutil import disk_partitions
from vyos.configtree import ConfigTree
+from vyos.configquery import ConfigTreeQuery
from vyos.remote import download
from vyos.system import disk, grub, image, compat, raid, SYSTEM_CFG_VER
from vyos.template import render
from vyos.utils.io import ask_input, ask_yes_no, select_entry
from vyos.utils.file import chmod_2775
from vyos.utils.process import cmd, run
+from vyos.version import get_remote_version
# define text messages
MSG_ERR_NOT_LIVE: str = 'The system is already installed. Please use "add system image" instead.'
@@ -486,6 +488,14 @@ def image_fetch(image_path: str, vrf: str = None,
Returns:
Path: a path to a local file
"""
+ # Latest version gets url from configured "system update-check url"
+ if image_path == 'latest':
+ config = ConfigTreeQuery()
+ if config.exists('system update-check url'):
+ configured_url_version = config.value('system update-check url')
+ remote_url_list = get_remote_version(configured_url_version)
+ image_path = remote_url_list[0].get('url')
+
try:
# check a type of path
if urlparse(image_path).scheme: