diff --git a/src/lxc/lxc.py b/src/lxc/lxc.py index ec3088f..c08d6c9 100644 --- a/src/lxc/lxc.py +++ b/src/lxc/lxc.py @@ -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 diff --git a/src/utils/steps_utils.py b/src/utils/steps_utils.py index 3aca0b4..6a34723 100644 --- a/src/utils/steps_utils.py +++ b/src/utils/steps_utils.py @@ -1,13 +1,18 @@ +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: + from ..lxc.lxc import LXC + def _run_script_step(linux_machine, step): if isinstance(linux_machine, LXC):