Docker container for managing HP servers through ILO
- Tutorial
You might be wondering - why is Docker here? What is the problem of going to the ILO web interface and setting up your server as it should?
So I thought when they gave me a couple of old unnecessary servers that I had to reinstall (what is called reprovision). The server itself is located across the ocean, the only thing that is available is the web interface. Well, accordingly, I had to go into the Virtual Console to execute some commands. This is where it started.
As you know, for various kinds of virtual consoles, Java is usually used, which is at HP, that at Dell. In any case, it used to be so accurate (and the systems are very old). But Firefox and Chrome have long ceased to support these applets, and the new IcedTea does not work with these systems. Therefore, several options were identified:
(Actually, I reached point 3 only after I made point 2)
We will do point 3 today.
I was inspired mainly by two projects:
In principle, the first docker-baseimage-gui project already contains utilities and configurations for launching desktop applications in docker. Usually you need to define standard variables and your application will be accessible through a browser (websocket) or VNC. In our case, we will run through Firefox and VNC, through websocket it did not work.
First, install the necessary packages - Java 6 and IcedTea:
Now it remains to go to the ILO interface page and drive in your username and password. We start Firefox in autostart:
The HILO_HOST environment variable contains the web address of our ILO interface, for example myhp.example.com .
To automate the entry, let's screw the authorization. Login to ILO is performed by a regular POST request, as a result of which you get a JSON session_key, which you then pass in a GET request.
Compute session_key via curl if the environment variables HILO_USER and HILO_PASS are defined:
After we recorded session_key in the docker, we can start VNC:
Now just connect via VNC to port 5900 (or any other of your choice) on localhost and go to the virtual console.
All code is in the docker-ilo-client repository .
Full command to connect to ILO:
where ADDRESS_OF_YOUR_HOST is the ILO host name, SOME_USERNAME is the username and, accordingly, SOME_PASSWORD is the ILO password.
After that, simply launch any VNC client to the address:
Additions and pull requests are, of course, welcome.
A similar project exists for connecting to IDRAC interfaces of DELL machines: docker-idrac6 .
So I thought when they gave me a couple of old unnecessary servers that I had to reinstall (what is called reprovision). The server itself is located across the ocean, the only thing that is available is the web interface. Well, accordingly, I had to go into the Virtual Console to execute some commands. This is where it started.
As you know, for various kinds of virtual consoles, Java is usually used, which is at HP, that at Dell. In any case, it used to be so accurate (and the systems are very old). But Firefox and Chrome have long ceased to support these applets, and the new IcedTea does not work with these systems. Therefore, several options were identified:
- To start building a zoo from browsers and Java versions on your machine, this option disappeared immediately. There is no desire to mock the system for a couple of teams.
- Run something pretty old on the virtual machine (it was experimentally found out that Java 6 is needed) and configure everything you need through it.
- The same thing as point 2, only in the container, as several colleagues encountered the same problem and it is much easier to pass them a link to the container on dockerhub than an image of a virtual machine, with all passwords, etc.
(Actually, I reached point 3 only after I made point 2)
We will do point 3 today.
I was inspired mainly by two projects:
In principle, the first docker-baseimage-gui project already contains utilities and configurations for launching desktop applications in docker. Usually you need to define standard variables and your application will be accessible through a browser (websocket) or VNC. In our case, we will run through Firefox and VNC, through websocket it did not work.
First, install the necessary packages - Java 6 and IcedTea:
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list && \
apt-get update && \
apt-get -y upgrade && \
apt-get -y install firefox \
nano curl \
icedtea-6-plugin \
icedtea-netx \
openjdk-6-jre \
openjdk-6-jre-headless \
tzdata-java
Now it remains to go to the ILO interface page and drive in your username and password. We start Firefox in autostart:
RUN bash -c 'echo "exec openbox-session &" >> ~/.xinitrc' && \
bash -c 'echo "firefox \${HILO_HOST}">> ~/.xinitrc' && \
bash -c 'chmod 755 ~/.xinitrc'
The HILO_HOST environment variable contains the web address of our ILO interface, for example myhp.example.com .
To automate the entry, let's screw the authorization. Login to ILO is performed by a regular POST request, as a result of which you get a JSON session_key, which you then pass in a GET request.
Compute session_key via curl if the environment variables HILO_USER and HILO_PASS are defined:
export HOME=/config
export HILO_HOST=${HILO_HOST%%/}
SESSION_KEY=""
data="{\"method\":\"login\",\"user_login\":\"${HILO_USER}\",\"password\":\"${HILO_PASS}\"}"
if [[ -n "${HILO_USER}" && -n "${HILO_PASS}" ]]; then
SESSION_KEY=$(curl -k -X POST "${HILO_HOST}/json/login_session" -d "$data" 2>/dev/null | grep -Eo '"session_key":"[^"]+' | sed 's/"session_key":"//')
fi
echo "SESSION_KEY=$SESSION_KEY"
echo $SESSION_KEY > /session_key
After we recorded session_key in the docker, we can start VNC:
exec x11vnc -forever -create
Now just connect via VNC to port 5900 (or any other of your choice) on localhost and go to the virtual console.
All code is in the docker-ilo-client repository .
Full command to connect to ILO:
docker run -d --rm --name ilo-client -p 5900:5900 -e HILO_HOST=https://ADDRESS_OF_YOUR_HOST -e HILO_USER=SOME_USERNAME -e HILO_PASS=SOME_PASSWORD sshnaidm/docker-ilo-client
where ADDRESS_OF_YOUR_HOST is the ILO host name, SOME_USERNAME is the username and, accordingly, SOME_PASSWORD is the ILO password.
After that, simply launch any VNC client to the address:
vnc://localhost:5900
Additions and pull requests are, of course, welcome.
A similar project exists for connecting to IDRAC interfaces of DELL machines: docker-idrac6 .