Merge pull request 'refs #1916 move ogGetIpAddress to NetLib' (#28) from move-ogGetIpAddress into main
Reviewed-on: opengnsys/ogclone-engine#28fix-restaurar-imagen 0.6.0
commit
f785143b73
|
@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [0.6.0] - 2025-04-15
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- ogGetIpAddress() is no longer required in ogGlobals--move it back into NetLib
|
||||||
|
|
||||||
## [0.5.0] - 2025-04-15
|
## [0.5.0] - 2025-04-15
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
|
@ -142,7 +142,29 @@ def ogGetHostname():
|
||||||
#@note Usa las variables utilizadas por el initrd "/etc/net-ethX.conf
|
#@note Usa las variables utilizadas por el initrd "/etc/net-ethX.conf
|
||||||
#*/ ##
|
#*/ ##
|
||||||
def ogGetIpAddress():
|
def ogGetIpAddress():
|
||||||
return ogGlobals.ogGetIpAddress()
|
if "IPV4ADDR" in os.environ:
|
||||||
|
ip = os.environ["IPV4ADDR"]
|
||||||
|
if '/' in ip: ip = ip.split ('/')[0]
|
||||||
|
return ip
|
||||||
|
|
||||||
|
extra_args = []
|
||||||
|
if "DEVICE" in os.environ:
|
||||||
|
extra_args = [ "dev", os.environ["DEVICE"] ]
|
||||||
|
ipas = subprocess.run (['ip', '-json', 'address', 'show', 'up'] + extra_args, capture_output=True, text=True).stdout
|
||||||
|
|
||||||
|
ipasj = json.loads (ipas)
|
||||||
|
addresses = []
|
||||||
|
for e in ipasj:
|
||||||
|
if 'lo' == e['ifname']: continue
|
||||||
|
if 'addr_info' not in e: continue
|
||||||
|
addrs = e['addr_info']
|
||||||
|
for a in addrs:
|
||||||
|
if 'inet' != a['family']: continue
|
||||||
|
addresses.append ({ 'local': a['local'], 'prefixlen': a['prefixlen'] })
|
||||||
|
|
||||||
|
if 1 != len (addresses):
|
||||||
|
raise Exception ('more than one local IP address found')
|
||||||
|
return addresses[0]
|
||||||
|
|
||||||
|
|
||||||
#/**
|
#/**
|
||||||
|
|
|
@ -6,33 +6,6 @@ import os.path
|
||||||
import locale
|
import locale
|
||||||
import importlib.util
|
import importlib.util
|
||||||
|
|
||||||
## required for defining OGLOGFILE
|
|
||||||
def ogGetIpAddress():
|
|
||||||
if "IPV4ADDR" in os.environ:
|
|
||||||
ip = os.environ["IPV4ADDR"]
|
|
||||||
if '/' in ip: ip = ip.split ('/')[0]
|
|
||||||
return ip
|
|
||||||
|
|
||||||
extra_args = []
|
|
||||||
if "DEVICE" in os.environ:
|
|
||||||
extra_args = [ "dev", os.environ["DEVICE"] ]
|
|
||||||
ipas = subprocess.run (['ip', '-json', 'address', 'show', 'up'] + extra_args, capture_output=True, text=True).stdout
|
|
||||||
|
|
||||||
ipasj = json.loads (ipas)
|
|
||||||
addresses = []
|
|
||||||
for e in ipasj:
|
|
||||||
if 'lo' == e['ifname']: continue
|
|
||||||
if 'addr_info' not in e: continue
|
|
||||||
addrs = e['addr_info']
|
|
||||||
for a in addrs:
|
|
||||||
if 'inet' != a['family']: continue
|
|
||||||
addresses.append ({ 'local': a['local'], 'prefixlen': a['prefixlen'] })
|
|
||||||
|
|
||||||
if 1 != len (addresses):
|
|
||||||
raise Exception ('more than one local IP address found')
|
|
||||||
return addresses[0]
|
|
||||||
ip = ogGetIpAddress()
|
|
||||||
|
|
||||||
def load_lang (name):
|
def load_lang (name):
|
||||||
global lang
|
global lang
|
||||||
if name in sys.modules:
|
if name in sys.modules:
|
||||||
|
|
Loading…
Reference in New Issue