WebVirtMgr@CentOS 6 KVM libvirtd

Install WebVirtMgr @ Centos 6:

# yum -y install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# yum -y install git python-pip libvirt-python libxml2-python python-websockify supervisor nginx
# git clone git://github.com/retspen/webvirtmgr.git
# cd webvirtmgr
# pip install -r requirements.txt
# ./manage.py syncdb
# ./manage.py collectstatic


##########Adding additional superusers

# ./manage.py createsuperuser

######
# cd ..
# mv webvirtmgr /var/www/
####NGINX VIRTULKA HOST:

# cat /etc/nginx/conf.d/webvirtmgr.conf 
server {
    listen       6699;
    server_name  kvm.belomor.nl:6699;
    

    location /static/ {
root /var/www/webvirtmgr/webvirtmgr;        
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 
    }
}

###Update SELinux policy

# setsebool httpd_can_network_connect true 

####SET OWNER nginx
# chown -R nginx:nginx /var/www/webvirtmgr


#####################

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

[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


#########

vi /var/www/webvirtmgr/conf/gunicorn.conf.py

#bind = '127.0.0.1:8000'
bind = '192.168.200.70:8000'
####U can change it to desired port...

#############

# service supervisord restart

###ACCESS

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

##############DEBUG

# ./manage.py runserver 0:8000

####SSH CONNECTION:
####on KVM host create file:
# vi /etc/polkit-1/localauthority/50-local.d/50-libvirt-remote-access.pkla

[Remote libvirt SSH access]
Identity=unix-user:nginx
Action=org.libvirt.unix.manage
ResultAny=yes
ResultInactive=yes
ResultActive=yes

#####
# su - nginx -s /bin/bash

-bash-4.1$ ssh-keygen
-bash-4.1$ touch ~/.ssh/config
-bash-4.1$ echo -e "StrictHostKeyChecking=no\nUserKnownHostsFile=/dev/null" >> ~/.ssh/config
-bash-4.1$ chmod 0600 ~/.ssh/config
-bash-4.1$ ssh-copy-id [email protected]
-bash-4.1$ ssh [email protected]
-bash-4.1$ virsh -c qemu+ssh://[email protected]/system list --all
 Id    Name                           State
----------------------------------------------------
 2     CactiEZ                        running
 3     Debian8                        running
 -     1pc0p                          shut off
 -     V01c3                          shut off
 -     Z3nty4l                        shut off
###

My KVM Hypervizor is behind NAT so therefore I have port forward rules on Cisco router:

#sh run | in 192.168.200.70
ip nat inside source static tcp 192.168.200.70 6080 ext_ip 6080 extendable
ip nat inside source static tcp 192.168.200.70 8000 ext_ip 8000 extendable

#####
screens:

<a href="http://www.anit.az/wp-content/uploads/2016/04/kvm-stats.jpg"><img class="aligncenter size-medium wp-image-928" src="http://www.anit.az/wp-content/uploads/2016/04/kvm-stats-300x281.jpg" alt="kvm-stats" width="300" height="281" /></a> <a href="http://www.anit.az/wp-content/uploads/2016/04/kvm_console.jpg"><img class="aligncenter size-medium wp-image-929" src="http://www.anit.az/wp-content/uploads/2016/04/kvm_console-300x205.jpg" alt="kvm_console" width="300" height="205" /></a> <a href="http://www.anit.az/wp-content/uploads/2016/04/kvm1.jpg"><img class="aligncenter size-medium wp-image-930" src="http://www.anit.az/wp-content/uploads/2016/04/kvm1-300x114.jpg" alt="kvm1" width="300" height="114" /></a>
<strong>BUG_SHIT:</strong>

Server disconnected (code: 1006) after 20 seconds
# vi /usr/lib/python2.6/site-packages/websockify/websocket.py
search and comment this lines:
if not multiprocessing:
# os.fork() (python 2.4) child reaper
signal.signal(signal.SIGCHLD, self.fallback_SIGCHLD)
else:
# make sure that _cleanup is called when children die
# by calling active_children on SIGCHLD
signal.signal(signal.SIGCHLD, self.multiprocessing_SIGCHLD)

# /etc/init.d/supervisord restart

####TROUBLESHOOTING:
# tail -f /var/log/libvirt/libvirtd.log
2016-04-11 10:23:49.672+0000: 5623: error : virNetServerAddClient:270 : Too many active clients (20), dropping connection from 127.0.0.1;0

SOLUTION ADD TO THE END OF
# vi /etc/libvirt/libvirtd.conf
####GUS
max_clients = 1024
min_workers = 50
max_workers = 200
max_requests = 1000
max_client_requests = 200

# /etc/init.d/libvirtd restart

#########

Done

# date

Mon Apr 11 12:18:30 AZT 2016