Sunday, June 22, 2008

web UI for YaST

With python-bindings we can slowly move our wishes from impossible into possible group.One of our wishes is web UI. Today before lunch I did some research, and it works!

Fist of all enable mod_python in apache2, then configure Handler for Python.

Then write index.py with this code:
def getDescription():
 import ycp
  ycp.import_module('Lan')
  ycp.import_module('LanItems')
  ycp.Lan.Read(ycp.Term('nocache'))
  interfaces=ycp.LanItems.Overview()
  descr="<table>"
  for interface in interfaces:
   descr+="<tr><td>"+interface['table_descr'][0]+"</td>"
   descr+="<td>"+interface['rich_descr']+"</td></tr>"
   descr+="</table>"
   return descr

def index():
  s = """\
<html>
<body>
"""+getDescription()+"""
</body>
</html>
"""
  return s


It needs some hack - disable check if YaST code is running as root. I commented one line in Lan::Read() function. And result is here:

PRO/Wireless 3945ABG Network ConnectionPRO/Wireless 3945ABG Network Connection (Not connected)
MAC : 00:18:de:64:b8:0d

The device is not configured. Press Edit
to configure.


82573L Gigabit Ethernet Controller82573L Gigabit Ethernet Controller
MAC : 00:16:41:aa:74:56
  • Device Name: eth0
  • Started automatically on cable connection
  • IP address assigned using DHCP


It's just summary of network devices configuration. I know it's very simple example, but as I wrote - the plan was to do it before lunch, not instead of ;-)

No comments: