fixed circular import and fix ipv4 delay

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

View File

@ -93,17 +93,11 @@ class LXC(LinuxMachine):
if self.ipv4 == "dhcp" or self.ipv4 == "auto": if self.ipv4 == "dhcp" or self.ipv4 == "auto":
if self.is_running(): if self.is_running():
if self.has_program("ip", use_ssh=use_ssh): 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( self.ipv4_netmask = self.run_command(
"""ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 """, """ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 """,
use_ssh=use_ssh) use_ssh=use_ssh)
# elif self.has_program("ifconfig", use_ssh=use_ssh): self.ipv4 = str(self.ipv4_netmask).split("/")[0]
# return self.run_command(command="ifconfig eth0 | awk '/inet addr/{print substr($2,6)}'",
# use_ssh=use_ssh)
else: else:
return self.ipv4 return self.ipv4
@ -201,6 +195,8 @@ class LXC(LinuxMachine):
# Run creation steps # Run creation steps
logging.info(f"Running creation steps for LXC {self.id}") logging.info(f"Running creation steps for LXC {self.id}")
creation_utils.run_steps(self) creation_utils.run_steps(self)
else:
logging.info(f"All creation conditions met for LXC {self.id}, skipping creation steps...")
def deploy(self): def deploy(self):
pass pass

View File

@ -1,13 +1,18 @@
from __future__ import annotations
import logging import logging
import time import time
from typing import TYPE_CHECKING
from . import git_utils from . import git_utils
from .resources_utils import get_path from .resources_utils import get_path
from ..lxc import lxc_utils from ..lxc import lxc_utils
from ..lxc.lxc import LXC
from ..machine.machine import LinuxMachine from ..machine.machine import LinuxMachine
from ..utils import conditions_utils from ..utils import conditions_utils
if TYPE_CHECKING:
from ..lxc.lxc import LXC
def _run_script_step(linux_machine, step): def _run_script_step(linux_machine, step):
if isinstance(linux_machine, LXC): if isinstance(linux_machine, LXC):