Thursday, January 17, 2013

oVirt WebAdmin + ShellInABox UI Plugin

Inspired by a recent post on Oved's blog regarding the new UI-plugins infrastructure
introduced by oVirt,  I've decided to take my chances and create one myself.

The Challenge

Using oVirt WebAdmin, make SSH connection to a host and emulate a terminal.
  • Hosts main-tab -> create a 'Shell Box' action button
  • Hosts main-tab -> create a 'Shell Box' sub-tab

The Means

Shell In A Box: http://code.google.com/p/shellinabox/

The Implementation

oVirt Engine side

  • Create 'shellbox.json' file under '/usr/share/ovirt-engine/ui-plugins'
    (a plugin configuration file):
  • Create 'start.html' file under '/usr/share/ovirt-engine/shellbox-files'
    (the iframe content HTML file):

Host side

  • Download and Install 'shellinabox': http://rpmfind.net/linux/rpm2html/search.php?query=shellinabox
  • Edit configuration file '/etc/sysconfig/shellinaboxd':
    Replace 'OPTS="-s /:LOGIN"' with 'OPTS="--disable-ssl --service /:SSH"'
  • Start 'shellinabox' service

The Results

Shell Box sub-tab:


Shell Box action button (+ context menu):


Shell Box on a new browser tab:


The Source Code on oVirt


Thanks!

  • For UI-plugins infrastructure: Vojtech Szocs
  • For oVirt-Foreman UI Plugin: Oved Ourfali

5 comments:

  1. Can it be enhanced to also show up at the VM's tab?

    ReplyDelete
  2. Joop - Adding the sub-tab and action button shouldn't be difficult.
    The problem is understanding the FQDN or ip address of the VM.
    If the assumption is that the VM name is the FQDN, then it should be easy.

    It would require adding a section (next to the one already available)
    api.addMainTabActionButton('VirtualMachine', 'Shell Box', {
    onClick : function() {
    window.open(getShellBoxUrl(arguments), '_blank');
    },
    isEnabled : function() {
    // The button is enabled only when a
    // single VM is selected
    return arguments.length == 1;
    },
    isAccessible : function() {
    // The button is always visible
    return true;
    }
    });

    // Add 'Shell Box' sub-tab under 'Hosts' main-tab
    api.addSubTab('VirtualMachine', 'Shell Box', 'vm-shell-box', '');

    VirtualMachineSelectionChange : function() {
    if (arguments.length == 1) {
    // Update iframe URL on host selection
    api.setTabContentUrl(
    'vm-shell-box', getShellBoxUrl(arguments));
    }
    },

    ReplyDelete
  3. This looks cool although I've not been able to make it work.

    Should "Create 'start.html' file under '/usr/share/ovirt-engine/shellbox-files'" actually be "Create 'start.html' file under '/usr/share/ovirt-engine/ui-plugins/shellbox-files'"?

    I see the 'Shell Box' tab but it is always empty. When I do a 'tcpdump -i eth0 port 4200' on the RHEV-M node I see no traffic. When I do the equivalent on the fat RHEL hypervisors, I see nothing.

    Note that I'm not runing oVirt but RHEV-M 3.3.

    Thanks

    ReplyDelete