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 ;-)

Wednesday, June 18, 2008

IPv6, prefixlen

This story started when I discussed with our openSUSE member Marek Stopka and he told me that he is running IPv6 network but because of really bad support in YaST2 he needs to configure that manually.
Oh, what a shame! So we made a deal that he'll test my patches and I'll try to implement initial support.
So now we have initial support for IPv6 in YaST. Initial means that you're able to configure "primary" address IPv6 type. Nothing more, nothing less.
Because of this I add new parameter to configure prefixlen (in v6 there is no netmask as we know from v4). In UI you can configure prefix with a little trick - instead of 255.255.255.0 you can write "/24".

Ok, example of CLI:


linux-1pi7:~ # yast lan list
0 79c970 [PCnet32 LANCE], Not configured

1 79c970 [PCnet32 LANCE], Not configured

linux-1pi7:~ # yast lan edit id=0 ip=2001:15c0:668e::5 prefix=48
Ethernet Network Card
MAC : 08:00:27:80:b5:07
Device Name: eth1
Started automatically at boot
IP address: 2001:15c0:668e::5/48


linux-1pi7:~ # yast lan list
0 Ethernet Network Card, 2001:15c0:668e::5

1 79c970 [PCnet32 LANCE], Not configured

linux-1pi7:~ #


And some screenshots from ncurses UI:






Of course there's still much work to implement full support, routing, network services support, test all possible cases, AutoYaST, etc.
Implemented in yast2-network-2.17.1

Saturday, June 14, 2008

running YaST in debugger

First of all - I like Python.
Second - we have some prototype for mysql-server configuration written in Python I never tried before.

So I check-in code from subversion and try to run. Unfortunately it exits with some errors like "couldn't initialize UI". So I open the code in Eric - great Python debugger.

With breakpoints, globals and locals variables dispatcher it was really easy to find problematic places in code. Also possibility to write code interactively into interpreter is very helpful.
And finally module runs ;-)

video
Sorry, video is pretty slow - probably ati driver problem ;-(

Monday, June 9, 2008

http-server, dns-server integration

Actually this is not new feature, but because I re-tested that functionality today, I found it's good time to describe it in a few words.
Integration in this case means that you can configure DNS server records while adding new virtual hosts for apache HTTP server (with YaST, both on the same machine)

yast2-dns-server

First - DNS server must be installed, enabled and running:



Then add new zone (it must be type "Master"):



yast2-http-server

Then in yast2-http-server module add new virtual host. Server name belongs into dns zone "example.com" we configured in yast2-dns-server:

Virtual Host ID must be valid IP address


And here we can see there is button "Add to Zone" which in this case will add record www.example.com with IP address 10.20.30.40 into example.com zone



yast2-dns-server

When you open YaST DNS server again, you can see that new record for "example.com" zone was correctly added.

Thursday, June 5, 2008

Command Line Interface

This is probably nothing new but for those who don't know yet ...

You can run every YaST2 module in Qt, GTK or Ncurses UI. Some of that modules has implemented also command line interface. Just type: yast module_name help and you will see something like this:


linux:/home/mzugec # yast lan help

YaST Configuration Module lan
------------------------------

Network Card Configuration

Basic Syntax:
yast2 lan interactive
yast2 lan [verbose] [options]
yast2 lan help
yast2 lan longhelp
yast2 lan xmlhelp
yast2 lan help

Commands:
add Add a network card
delete Delete a network card
edit Change existing configuration
list Display configuration summary
show Display configuration summary

Run 'yast2 lan help' for a list of available options.


In case module doesn't support CLI, output is like:

linux:/home/mzugec # yast dsl help
There is no user interface available for this module.



Option interactive is useful when you want to do several actions, because read and write are done only one. Difference between using ip or ifconfig commands and yast lan is that yast lan works with configurations, not only current status.

Ok, so let's start with example. List all network cards:

linux:/home/mzugec # yast lan list
0 Ethernet Network Card, DHCP

1 79c970 [PCnet32 LANCE], Not configured

2 79c970 [PCnet32 LANCE], DHCP

3 Ethernet Network Card, 10.20.30.40


See configuration of last device:

linux:/home/mzugec # yast lan show id=3
Ethernet Network Card
MAC : 08:00:27:d9:db:b7
Device Name: eth0
Started automatically at boot
IP address: 10.20.30.40, subnet mask 255.255.255.0


Change configuration to DHCP :

linux:/home/mzugec # yast lan edit id=3 bootproto=dhcp
Device Type : eth
Bootproto : dhcp
IP Address :
Mask :


Done, that was easy ;-)

Bye,
Michal