Verified Commit e3eaf7ad authored by Karel Koci's avatar Karel Koci 🤘 Committed by Jan Miksik
Browse files

nsfarm/lxd: detect host architecture for container

Instead of having hardcoded amd64 in image files we now try to detect
architecture instead.
parent e9df941e
#!/bin/sh
# images:alpine/3.14/amd64
# images:alpine/3.14
##################################################################################
# Common base for most of the containers with minimal extension.
# This mostly just adds bash as this is suppose to be only script written in plain
......
#!/bin/sh
# images:openwrt/19.07/amd64
# images:openwrt/19.07
##################################################################################
# OpenWrt container we can use to test nsfarm as well as cooperation with Turris.
##################################################################################
......
......@@ -7,6 +7,7 @@ import logging
import pathlib
import hashlib
import functools
import platform
import pylxd
from .connection import LXDConnection
from .exceptions import LXDImageUndefinedError, LXDImageParentError, LXDImageParameterError
......@@ -45,7 +46,7 @@ class Image:
self._parent = Image(lxd_connection, image_alias)
elif image_type == "images":
self._parent = self._lxd.local.images.create_from_simplestreams(
self._lxd.IMAGES_SOURCE, image_alias, auto_update=True)
self._lxd.IMAGES_SOURCE, image_alias + "/" + self.architecture(), auto_update=True)
else:
raise LXDImageParentError(self.name, parent)
......@@ -210,3 +211,13 @@ class Image:
container.files.delete(self.IMAGE_INIT_PATH) # Remove init script
finally:
container.stop(wait=True)
@staticmethod
def architecture():
arch = platform.machine()
archmap = {
"x86_64": "amd64",
}
if arch in archmap:
arch = archmap[arch]
return arch
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment