Install WebVirtMgr

lowang-bh edited this page Jun 7, 2018 · 80 revisions

1. Installation

Fedora 17

Run:

$ sudo yum -y install git python-pip libvirt-python libxml2-python python-websockify supervisor nginx

CentOS/RHEL 6.x

Run:

$ sudo yum -y install http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
$ sudo yum -y install git python-pip libvirt-python libxml2-python python-websockify supervisor nginx

CentOS 7.x

Run:

$ sudo yum -y install http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
 if this doesn't work, use yum install epel-release
$ sudo yum -y install git python-pip libvirt-python libxml2-python python-websockify supervisor nginx
$ sudo yum -y install gcc python-devel
$ sudo pip install numpy

Debian 7, Ubuntu 12.04 and above

Run:

$ sudo apt-get install git python-pip python-libvirt python-libxml2 novnc supervisor nginx 

OpenSuse 13.1 and above

# libVirt+kvm   
$ sudo zypper in cyrus-sasl-digestmd5 dmidecode dnsmasq ebtables gnutls libapparmor1 libavahi-client3 libavahi-common3 libcgroup1 libdaemon0 libmnl0 \
libnetcontrol0 libnetfilter_conntrack3 libnl-config libnl3-200 libnuma1 libpcap1 libvirt libvirt-client libvirt-daemon \
libvirt-daemon-config-network libvirt-daemon-config-nwfilter libvirt-daemon-driver-interface libvirt-daemon-driver-libxl \
libvirt-daemon-driver-lxc libvirt-daemon-driver-network libvirt-daemon-driver-nodedev libvirt-daemon-driver-nwfilter \
libvirt-daemon-driver-qemu libvirt-daemon-driver-secret libvirt-daemon-driver-storage libvirt-daemon-driver-uml libvirt-daemon-driver-vbox \
libvirt-daemon-driver-xen libvirt-doc libyajl2 lzop nfs-kernel-server open-iscsi qemu-tools radvd xen-libs

#  WebVirtMgr deps
$ sudo zypper install novnc nginx\
libblas3 libgfortran3 liblapack3 libquadmath0 libvirt-python python-libxml2 python-numpy \
python-pip python-pyOpenSSL python-setuptools   python-websockify \
python-django python3-django-appconf python-gunicorn python-lockfile python-django-auth-ldap

 grab supervisor-3.0-4.3.noarch.rpm from https://build.opensuse.org/package/binaries/devel:languages:python/supervisor?repository=openSUSE_13.1, 
 grab python-meld3 from https://build.opensuse.org/package/binaries/devel:languages:python/python-meld3?repository=openSUSE_13.1

$ sudo rpm -i  supervisor-3.0-4.3.noarch.rpm python-meld3-0.6.10-2.1.noarch.rpm 
$ sudo mkdir /var/log/supervisor
$ sudo chkconfig supervisord on

Arch Linux

Use webvirtmgr-git package from AUR

yaourt -S webvirtmgr-git

Then perform what you were told to do by post_install trigger. Do skip step 2.

2. Install python requirements and setup Django environment

Run:

$ git clone git://github.com/retspen/webvirtmgr.git
$ cd webvirtmgr
$ sudo pip install -r requirements.txt # or python-pip (RedHat, Fedora, CentOS, OpenSuse)
$ ./manage.py syncdb
$ ./manage.py collectstatic

Enter the user information:

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes (Put: yes)
Username (Leave blank to use 'admin'): admin (Put: your username or login)
E-mail address: username@domain.local (Put: your email)
Password: xxxxxx (Put: your password)
Password (again): xxxxxx (Put: confirm password)
Superuser created successfully.

Adding additional superusers

Run:

$ ./manage.py createsuperuser

3. Setup Nginx

Warning: Usually WebVirtMgr is only available from localhost on port 8000. This step will make WebVirtMgr available to everybody on port 80. The webinterface is also unprotected (no https), which means that everybody in between you and the server (people on the same wifi, your local router, your provider, the servers provider, backbones etc.) can see your login credentials in clear text!

Instead you can also skip this step completely + uninstall nginx. By simply redirecting port 8000 to your local machine via SSH. This is much safer because WebVirtMgr is not available to the public any more and you can only access it over an encrypted connection.

Example:

$ ssh user@server:port -L localhost:8000:localhost:8000 -L localhost:6080:localhost:6080

You should be able to access WebVirtMgr by typing localhost:8000 in your browser after completing the install. Port 6080 is forwarded to make noVNC work.

If you really know what you are doing, feel free to ignore the warning and continue setting up the redirect with nginx:

$ cd ..
$ sudo mv webvirtmgr /var/www/         ( CentOS, RedHat, Fedora, Ubuntu )      
$ sudo mv webvirtmgr /srv/www/         ( OpenSuSe )    

Add file webvirtmgr.conf in /etc/nginx/conf.d:

server {
    listen 80 default_server;

    server_name $hostname;
    #access_log /var/log/nginx/webvirtmgr_access_log; 

    location /static/ {
        root /var/www/webvirtmgr/webvirtmgr; # or /srv instead of /var
        expires max;
    }

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-for $proxy_add_x_forwarded_for;
        proxy_set_header Host $host:$server_port;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_connect_timeout 600;
        proxy_read_timeout 600;
        proxy_send_timeout 600;
        client_max_body_size 1024M; # Set higher depending on your needs 
    }
}

Open nginx.conf out of /etc/nginx/nginx.conf (in Ubuntu 14.04 LTS the configuration is in /etc/nginx/sites-enabled/default):

$ sudo vim /etc/nginx/nginx.conf

Comment the Server Section as it is shown in the example:

#    server {
#        listen       80 default_server;
#        server_name  localhost;
#        root         /usr/share/nginx/html;
#
#        #charset koi8-r;
#
#        #access_log  /var/log/nginx/host.access.log  main;
#
#        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#
#        location / {
#        }
#
#        # redirect server error pages to the static page /40x.html
#        #
#        error_page  404              /404.html;
#        location = /40x.html {
#        }
#
#        # redirect server error pages to the static page /50x.html
#        #
#        error_page   500 502 503 504  /50x.html;
#        location = /50x.html {
#        }
#    }

Restart nginx service:

$ sudo service nginx restart

Update SELinux policy

/usr/sbin/setsebool httpd_can_network_connect true 

make it permanet service: ( OpenSusE ,CentOS, RedHat, Fedora)

$ sudo  chkconfig supervisord on

4. Setup Supervisor

CentOS, RedHat, Fedora

Run:

$ sudo chown -R nginx:nginx /var/www/webvirtmgr

Create file /etc/supervisord.d/webvirtmgr.ini with following content:

[program:webvirtmgr]
command=/usr/bin/python /var/www/webvirtmgr/manage.py run_gunicorn -c /var/www/webvirtmgr/conf/gunicorn.conf.py
directory=/var/www/webvirtmgr
autostart=true
autorestart=true
logfile=/var/log/supervisor/webvirtmgr.log
log_stderr=true
user=nginx

[program:webvirtmgr-console]
command=/usr/bin/python /var/www/webvirtmgr/console/webvirtmgr-console
directory=/var/www/webvirtmgr
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/webvirtmgr-console.log
redirect_stderr=true
user=nginx

OpenSuSE

Run:

$ sudo chown -R nginx:nginx /srv/www/webvirtmgr

Add these lines to end of file /etc/supervisord.conf:

[program:webvirtmgr]
command=/usr/bin/python /srv/www/webvirtmgr/manage.py run_gunicorn -c /srv/www/webvirtmgr/conf/gunicorn.conf.py
directory=/srv/www/webvirtmgr
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/webvirtmgr.log
redirect_stderr=true
user=nginx

[program:webvirtmgri-console]
command=/usr/bin/python /srv/www/webvirtmgr/console/webvirtmgr-console
directory=/var/www/webvirtmgr
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/webvirtmgr-console.log
redirect_stderr=true
user=nginx

Debian, Ubuntu

Run:

$ sudo service novnc stop
$ sudo insserv -r novnc
$ sudo vi /etc/insserv/overrides/novnc
#!/bin/sh
### BEGIN INIT INFO
# Provides:          nova-novncproxy
# Required-Start:    $network $local_fs $remote_fs $syslog
# Required-Stop:     $remote_fs
# Default-Start:     
# Default-Stop:      
# Short-Description: Nova NoVNC proxy
# Description:       Nova NoVNC proxy
### END INIT INFO
$ sudo chown -R www-data:www-data /var/www/webvirtmgr

Add file webvirtmgr.conf in /etc/supervisor/conf.d:

[program:webvirtmgr]
command=/usr/bin/python /var/www/webvirtmgr/manage.py run_gunicorn -c /var/www/webvirtmgr/conf/gunicorn.conf.py
directory=/var/www/webvirtmgr
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/webvirtmgr.log
redirect_stderr=true
user=www-data

[program:webvirtmgr-console]
command=/usr/bin/python /var/www/webvirtmgr/console/webvirtmgr-console
directory=/var/www/webvirtmgr
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/webvirtmgr-console.log
redirect_stderr=true
user=www-data

Restart supervisor daemon

Ubuntu, Debian

$ sudo service supervisor stop
$ sudo service supervisor start

CentOS, RedHat, Fedora

$ sudo service supervisord stop
$ sudo service supervisord start

5.1 Update - CentOS, RedHat, Fedora

Read README.md check settings (maybe something has changed) and then:

$ cd /var/www/webvirtmgr
$ sudo git pull
$ sudo ./manage.py collectstatic
$ sudo service supervisord restart

5.1 Update - Debian & Ubuntu

Read README.md check settings (maybe something has changed) and then:

$ cd /var/www/webvirtmgr
$ sudo git pull
$ sudo ./manage.py collectstatic
$ sudo service supervisor restart

5.2 Update - OpenSuSE

Read README.md check settings (maybe something has changed) and then:

$ cd /srv/www/webvirtmgr
$ sudo git pull
$ sudo ./manage.py collectstatic
$ sudo service supervisord restart

6. Debug

If you have error or not run panel (only for DEBUG or DEVELOP):

$ ./manage.py runserver 0:8000

Enter in your browser:

http://x.x.x.x:8000 (x.x.x.x - your server IP address )