Compare commits
2 Commits
099638570f
...
a503ad16c0
Author | SHA1 | Date | |
---|---|---|---|
a503ad16c0 | |||
ea6266b433 |
@ -93,17 +93,11 @@ class LXC(LinuxMachine):
|
||||
if self.ipv4 == "dhcp" or self.ipv4 == "auto":
|
||||
if self.is_running():
|
||||
if self.has_program("ip", use_ssh=use_ssh):
|
||||
self.ipv4 = self.run_command(
|
||||
"""ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/'""",
|
||||
use_ssh=use_ssh)
|
||||
|
||||
self.ipv4_netmask = self.run_command(
|
||||
"""ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 """,
|
||||
use_ssh=use_ssh)
|
||||
|
||||
# elif self.has_program("ifconfig", use_ssh=use_ssh):
|
||||
# return self.run_command(command="ifconfig eth0 | awk '/inet addr/{print substr($2,6)}'",
|
||||
# use_ssh=use_ssh)
|
||||
self.ipv4 = str(self.ipv4_netmask).split("/")[0]
|
||||
else:
|
||||
return self.ipv4
|
||||
|
||||
@ -201,6 +195,8 @@ class LXC(LinuxMachine):
|
||||
# Run creation steps
|
||||
logging.info(f"Running creation steps for LXC {self.id}")
|
||||
creation_utils.run_steps(self)
|
||||
else:
|
||||
logging.info(f"All creation conditions met for LXC {self.id}, skipping creation steps...")
|
||||
|
||||
def deploy(self):
|
||||
pass
|
||||
|
@ -1,4 +1,5 @@
|
||||
import logging
|
||||
import threading
|
||||
from pathlib import Path
|
||||
|
||||
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)
|
||||
|
||||
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}")
|
||||
lxc.create()
|
||||
lxc.start()
|
||||
|
@ -1,19 +1,24 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import time
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from . import git_utils
|
||||
from .resources_utils import get_path
|
||||
from ..lxc import lxc_utils
|
||||
from ..lxc.lxc import LXC
|
||||
from ..machine.machine import LinuxMachine
|
||||
from ..utils import conditions_utils
|
||||
|
||||
if TYPE_CHECKING:
|
||||
pass
|
||||
|
||||
|
||||
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)
|
||||
else:
|
||||
logging.warning(f"Script step only supported on LXCs")
|
||||
logging.warning("Script step only supported on LXCs")
|
||||
pass
|
||||
|
||||
|
||||
@ -22,7 +27,7 @@ def _run_file_create_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"],
|
||||
step.get("permission", 644), step.get("owner", "root"))
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user