summaryrefslogtreecommitdiffstats
path: root/src/utils/cache.py
diff options
context:
space:
mode:
authorAlejandro Sirgo Rica <asirgo@soleta.eu>2024-10-01 10:14:48 +0200
committerAlejandro Sirgo Rica <asirgo@soleta.eu>2024-10-01 15:32:54 +0200
commite30e934272f16e3fa60454c37692034064a33a5c (patch)
tree1ce5a32c25581a201d2129a1aa55f4cf53acd1bc /src/utils/cache.py
parent8f437bb954266d1da31c7044edcdc2d9f4cef540 (diff)
src: replace DEVICE env variable with get_ethernet_interface()
Use a python function to obtain the main net interface. Detect the first ethernet inferface in use. Stop using the DEVICE environment variable.
Diffstat (limited to 'src/utils/cache.py')
-rw-r--r--src/utils/cache.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/utils/cache.py b/src/utils/cache.py
index 374f8e0..6358c6a 100644
--- a/src/utils/cache.py
+++ b/src/utils/cache.py
@@ -10,7 +10,7 @@ import logging
import os
from src.utils.fs import mount_mkdir, umount
-from src.utils.net import getifaddr
+from src.utils.net import *
from src.utils.probe import get_cache_dev_path
OG_IMAGE_PATH = '/opt/opengnsys/images/'
@@ -45,7 +45,7 @@ def write_cache_txt(content):
"""
Dumps content to /opt/opengnsys/log/{ip}.cache.txt
"""
- client_ip = getifaddr(os.getenv('DEVICE'))
+ client_ip = getifaddr(get_ethernet_interface())
with open(OGCLIENT_LOG_CACHE.format(ip=client_ip), 'w') as f:
logging.debug('Writing cache contents to %s.cache.txt', client_ip)
f.write(content)