summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2024-01-01 08:33:18 +0100
committerGitHub <noreply@github.com>2024-01-01 08:33:18 +0100
commit95de314ad99298f7420c657bc0cfdc8624af27ed (patch)
tree09ab473b247ed373b5d7c47e9614d4839c0fb452
parent22d5b2bab254668dd0fe8c543fb1bd0edcbead18 (diff)
parent87202912e871eeafe20ba24c5fcbf696ce5171ff (diff)
downloadvyos-1x-95de314ad99298f7420c657bc0cfdc8624af27ed.tar.gz
vyos-1x-95de314ad99298f7420c657bc0cfdc8624af27ed.zip
Merge pull request #2724 from sever-sever/T3476
T3476: Add option latest to add system image
-rw-r--r--op-mode-definitions/system-image.xml.in2
-rwxr-xr-xsrc/op_mode/image_installer.py10
2 files changed, 11 insertions, 1 deletions
diff --git a/op-mode-definitions/system-image.xml.in b/op-mode-definitions/system-image.xml.in
index c131087be..7b5260b4e 100644
--- a/op-mode-definitions/system-image.xml.in
+++ b/op-mode-definitions/system-image.xml.in
@@ -14,7 +14,7 @@
<properties>
<help>Add a new image to the system</help>
<completionHelp>
- <list>/path/to/vyos-image.iso "http://example.com/vyos-image.iso"</list>
+ <list>/path/to/vyos-image.iso "http://example.com/vyos-image.iso" latest</list>
</completionHelp>
</properties>
<command>sudo ${vyos_op_scripts_dir}/image_installer.py --action add --image-path "${4}"</command>
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: