configured mutli-threading and fixed lxc detection for steps
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Mathieu Broillet 2023-06-22 16:15:52 +02:00
parent ea6266b433
commit a503ad16c0
No known key found for this signature in database
GPG Key ID: 7D4F25BC50A0AA32
2 changed files with 13 additions and 8 deletions

View File

@ -1,4 +1,5 @@
import logging import logging
import threading
from pathlib import Path from pathlib import Path
from .lxc.lxc_utils import load_lxc, get_all_lxcs from .lxc.lxc_utils import load_lxc, get_all_lxcs
@ -44,6 +45,10 @@ def run(args):
load_lxc(content=lxc_file_content, lxc_id=int(lxc_folder), pve=pve) load_lxc(content=lxc_file_content, lxc_id=int(lxc_folder), pve=pve)
for lxc in get_all_lxcs(): for lxc in get_all_lxcs():
threading.Thread(target=launch_lxc, args=(lxc,)).start()
def launch_lxc(lxc):
logging.info(f"Loading LXC {lxc.id}") logging.info(f"Loading LXC {lxc.id}")
lxc.create() lxc.create()
lxc.start() lxc.start()

View File

@ -11,14 +11,14 @@ from ..machine.machine import LinuxMachine
from ..utils import conditions_utils from ..utils import conditions_utils
if TYPE_CHECKING: if TYPE_CHECKING:
from ..lxc.lxc import LXC pass
def _run_script_step(linux_machine, step): def _run_script_step(linux_machine, step):
if isinstance(linux_machine, LXC): if "LXC" in str(linux_machine.__class__):
lxc_utils.run_script_step_parser(linux_machine, step) lxc_utils.run_script_step_parser(linux_machine, step)
else: else:
logging.warning(f"Script step only supported on LXCs") logging.warning("Script step only supported on LXCs")
pass pass
@ -27,7 +27,7 @@ def _run_file_create_step(linux_machine, step):
def _run_file_copy_step(linux_machine, step): def _run_file_copy_step(linux_machine, step):
if isinstance(linux_machine, LXC): if "LXC" in str(linux_machine.__class__):
linux_machine.pve.copy_file_to_lxc(linux_machine, get_path(linux_machine, step["path"]), step["destination"], linux_machine.pve.copy_file_to_lxc(linux_machine, get_path(linux_machine, step["path"]), step["destination"],
step.get("permission", 644), step.get("owner", "root")) step.get("permission", 644), step.get("owner", "root"))
else: else: