Add os_net_interfaces_info

master3.3
Самоукин Алексей 15 years ago
parent 4a87c151d5
commit a4ab35e473

@ -19,5 +19,36 @@ import re
from cl_datavars import glob_attr
class fillVars(object, glob_attr):
pass
def get_os_net_interfaces_info(self):
"""Информация о существующих сетевых интерфейсах"""
netInterfaces=self.Get("os_net_interfaces")
listInterfacesInfo = []
# Получена ли сеть по DHCP если нет to ip или off
for interfaces in netInterfaces:
fdhcpLeases = "/var/lib/dhcp/dhclient.leases"
if os.access(fdhcpLeases, os.R_OK) and\
interfaces in open(fdhcpLeases).read():
listInterfacesInfo.append((interfaces, "DHCP"))
continue
fdhcpInfo = "/var/lib/dhcpcd/dhcpcd-%s.info"%interfaces
fdhcpLease = "/var/lib/dhcpcd/dhcpcd-%s.lease"%interfaces
if os.path.exists(fdhcpInfo) or os.path.exists(fdhcpLease):
listInterfacesInfo.append((interfaces, "DHCP"))
# Если интерфейс без DHCP
if not (interfaces, "DHCP") in listInterfacesInfo:
# Находим ip
res = self._runos("/sbin/ifconfig %s"%interfaces)
ip = ""
for j in res:
sIP=re.search('addr:([0-9\.]+).+',j)
if sIP:
ip = sIP.group(1)
listInterfacesInfo.append((interfaces, ip))
break
if not ip:
listInterfacesInfo.append((interfaces, "Off"))
return ", ".join(map(lambda x:"%s (%s)"%(x[0],x[1]),listInterfacesInfo))

@ -104,7 +104,7 @@ class cl_install(color_print):
self.printSUCCESS(_("Domain name")+": %s"%
self.clVars.Get('os_net_domain'))
self.printSUCCESS(_("Network devices")+": %s"%
"<needed>")
self.clVars.Get("os_net_interfaces_info"))
self.printSUCCESS(_("Installed system")+": %s %s"%
(self.clVars.Get('os_linux_name'),
self.clVars.Get('os_linux_ver')))

@ -32,3 +32,6 @@ class Data:
cl_ver = {'value':'2.2.0'}
os_arch_machine = {'mode':'w'}
os_net_interfaces_info = {}

@ -18,7 +18,8 @@
import sys
import os
sys.path.insert(0,os.path.abspath('/usr/lib/calculate-2.2/calculate-lib/pym'))
sys.path.insert(0,os.path.abspath('/usr/lib/calculate-2.2/calculate-install/pym'))
sys.path.insert(0,
os.path.abspath('/usr/lib/calculate-2.2/calculate-install/pym'))
from cl_install_cmd import install_cmd
@ -38,7 +39,7 @@ if __name__ == "__main__":
# init variables
install.initVars()
# set lang
if not options.l is None:
if options.l:
if not install.processSetLang(options.l):
sys.exit(1)
# set values to variables
@ -46,11 +47,11 @@ if __name__ == "__main__":
if not install.processSetVars(options.set):
sys.exit(1)
# print variables
if not options.vars is None:
if options.vars:
install.processDisplayVars(options.vars)
sys.exit(0)
# apply template to current system
elif not options.T is None:
elif options.T:
if not install.applyTemplatesForSystem():
sys.exit(1)
else:

Loading…
Cancel
Save