[prev in list] [next in list] [prev in thread] [next in thread] 

List:       rdesktop-users
Subject:    [rdesktop-users] Unattended OS installations using rdesktop and gocr
From:       Tommy Lindgren <tommy.lindgren () gmail ! com>
Date:       2011-06-26 20:06:53
Message-ID: 87tybcfjc2.fsf () gmail ! com
[Download RAW message or body]

Hi,

I thought I should share a little rdesktop hack I did.

At work we build a product on top of SuSE Linux. We make nightly iso
builds and we wanted to do fully automatic testing of these,
e.g. automatically install the OS + our software and execute a test
suite. It's trivial to boot a fresh build under VirtualBox in headless
mode, but the installation will of course get stuck, waiting for someone
to enter hostname, IP address, and so on. At first we built a special
version of the iso with an autoyast profile with hard-coded hostname
etc, but it didn't feel like a very elegant solution so I did the
following hack...

In headless mode, the guest OS is accessible via VirtualBox's built-in
RDP server. I figured it wouldn't be too hard to combine an RDP client
with some optical character recognition software to detected the
installation dialogs, and then make the RDP client send fake key
presses.

I had a look at the rdesktop source code and found it to be quite
nice. So I added a -G switch, making it possible to control rdesktop
from an "agent" script. My script in question would run import(1) on the
X11 window, feed the image to gocr(1), then look for strings like "Enter
hostname" in the text dump and finally ask rdesktop to send back an
appropriate key sequence.

To achieve that last bit I snarfed the code at

  https://sites.google.com/site/dannychouinard/Home/unix-linux-trinkets/little-utilities/xkeyin-send-x11-keyboard-events-to-an-x-window


and basically just replaced the X11 calls with xkeymap_send_keys()...

So, each night our Hudson server will

1. build the iso and and boot it under VirtualBox

2. launch Xvnc with rdesktop -G agentscript

3. wait until rdesktop exists (the agent script will ask rdesktop to
exit after the last dialog), wait until sshd comes up, and then execute
the test suite

The whole setup is pretty ridiculous but works surprisingly well. The
only problem I've noticed is that different versions of gocr can return
slightly different output. Also, too small window size may give poor
results (increasing the video memory size in VirtualBox helps here).

I have uploaded the stuff to

  https://github.com/tomyl/rdesktop-agent 

The major changes are the new agent.c (code for communicating with the
agent script) and xkeymap_send_string() in xkeymap.c. I've also
included an example agent script (test.xexpect).

The purpose of this mail is mainly to share my experiences, but if there
is any interest to merge the agent code I would be delighted.

Regards,
Tommy

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
rdesktop-users mailing list
rdesktop-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdesktop-users


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic