lost and found ( for me ? )

install webvirtmgr on Ubuntu 12.10 and manage KVM hosts with webvirtmgr

webvirtmgr is web-based KVM management tool.
https://www.webvirtmgr.net/

KVM host

root@ubuntu-1:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 12.10
Release:        12.10
Codename:       quantal

root@ubuntu-1:~# uname -ri
3.5.0-18-generic x86_64

root@ubuntu-1:~# kvm --version
QEMU emulator version 1.2.0 (qemu-kvm-1.2.0+noroms-0ubuntu2, Debian), Copyright (c) 2003-2008 Fabrice Bellard

root@ubuntu-1:~# libvirtd --version
libvirtd (libvirt) 0.9.13

root@ubuntu-1:~# virt-manager --version
0.9.3


[ install webvirtmgr on the KVM ( ubuntu 12.10 ) ]

There’s a github for webvirtmgr.
https://github.com/retspen/webvirtmgr

So , I’ll install webvirtmgr with github on the KVM host.

before installing webvirtmgr , install requreid packages for webvirtmgr to run.
# apt-get install git python-django virtinst apache2 libapache2-mod-python libapache2-mod-wsgi sasl2-bin libvirt-bin -y


[ set libvirtd to run webvirtmagr ]

enable webvirmgr to access to KVM hosts.

edit /etc/default/libvirt-bin
# egrep ^libvirtd_opts /etc/default/libvirt-bin
libvirtd_opts="-d -l"


edit /etc/libvirt/libvirtd.conf
# egrep -R '(listen_tcp|listen_tls)' /etc/libvirt/libvirtd.conf | egrep -v ^#
listen_tls = 0
listen_tcp = 1

# service libvirt-bin restart
libvirt-bin stop/waiting
libvirt-bin start/running


confirm TCP 16509 is listening
# lsof -ni:16509
COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
libvirtd 20441 root   13u  IPv4  54538      0t0  TCP *:16509 (LISTEN)
libvirtd 20441 root   14u  IPv6  54539      0t0  TCP *:16509 (LISTEN)


add a user
# saslpasswd2 -a libvirt hattori
Password:
Again (for verification):


check
# sasldblistusers2 -f /etc/libvirt/passwd.db
hattori@ubuntu-1: userPassword


configure the firewall
# cat /etc/ufw/applications.d/libvirtd
[Libvirt]
title=Virtualization library
description=Open port for WebVirtMgr
ports=16509/tcp

# ufw allow from any to any app Libvirt
Rules updated
Rules updated (v6)


connect to KVM on the local host
# virsh -c qemu+tcp://127.0.0.1/system nodeinfo
Please enter your authentication name: hattori
Please enter your password:
CPU model:           x86_64


connect to the KVM from the remote host
# virsh -c qemu+tcp://x.x.x.x/system nodeinfo
Please enter your authentication name: hattori
Please enter your password:
CPU model:           x86_64


- install webvirtmgr from github
# git clone git://github.com/retspen/webvirtmgr.git


setup db. nnn error
# ./manage.py syncdb
Creating tables ...
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table django_admin_log
Creating table model_host
Creating table model_log

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
Traceback (most recent call last):
 File "./manage.py", line 11, in <module>
   execute_manager(settings)
 File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 459, in execute_manager
   utility.execute()
 File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 382, in execute
   self.fetch_command(subcommand).run_from_argv(self.argv)
 File "/usr/lib/python2.7/dist-packages/django/core/management/base.py", line 196, in run_from_argv
   self.execute(*args, **options.__dict__)
 File "/usr/lib/python2.7/dist-packages/django/core/management/base.py", line 232, in execute
   output = self.handle(*args, **options)
 File "/usr/lib/python2.7/dist-packages/django/core/management/base.py", line 371, in handle
   return self.handle_noargs(**options)
 File "/usr/lib/python2.7/dist-packages/django/core/management/commands/syncdb.py", line 110, in handle_noargs
   emit_post_sync_signal(created_models, verbosity, interactive, db)
 File "/usr/lib/python2.7/dist-packages/django/core/management/sql.py", line 189, in emit_post_sync_signal
   interactive=interactive, db=db)
 File "/usr/lib/python2.7/dist-packages/django/dispatch/dispatcher.py", line 172, in send
   response = receiver(signal=self, sender=sender, **named)
 File "/usr/lib/python2.7/dist-packages/django/contrib/auth/management/__init__.py", line 73, in create_superuser
   call_command("createsuperuser", interactive=True, database=db)
 File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 150, in call_command
   return klass.execute(*args, **defaults)
 File "/usr/lib/python2.7/dist-packages/django/core/management/base.py", line 232, in execute
   output = self.handle(*args, **options)
 File "/usr/lib/python2.7/dist-packages/django/contrib/auth/management/commands/createsuperuser.py", line 70, in handle
   default_username = get_default_username()
 File "/usr/lib/python2.7/dist-packages/django/contrib/auth/management/__init__.py", line 105, in get_default_username
   default_username = get_system_username()
 File "/usr/lib/python2.7/dist-packages/django/contrib/auth/management/__init__.py", line 85, in get_system_username
   return getpass.getuser().decode(locale.getdefaultlocale()[1])
TypeError: decode() argument 1 must be string, not None
root@ubuntu-1:/home/hattori/my_works/webvirtmgr# echo $?
1


googling “TypeError: decode() argument 1 must be string, not None
“ , we may solve this :
# export LANG="en_US.UTF-8"


try again.
# rm -rf webvirtmgr/
# git clone git://github.com/retspen/webvirtmgr.git
# ./manage.py syncdb
Creating tables ...
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
root@ubuntu-1:/home/hattori/my_works/webvirtmgr# cd ..
root@ubuntu-1:/home/hattori/my_works# rm -rf webvirtmgr/
root@ubuntu-1:/home/hattori/my_works# git clone git://github.com/retspen/webvirtmgr.git
Cloning into 'webvirtmgr'...
remote: Counting objects: 459, done.
remote: Compressing objects: 100% (196/196), done.
remote: Total 459 (delta 250), reused 451 (delta 242)
Receiving objects: 100% (459/459), 551.48 KiB | 217 KiB/s, done.
Resolving deltas: 100% (250/250), done.
root@ubuntu-1:/home/hattori/my_works# cd webvirtmgr/
root@ubuntu-1:/home/hattori/my_works/webvirtmgr# ./manage.py syncdb
Creating tables ...
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table django_admin_log
Creating table model_host
Creating table model_log

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
Username (leave blank to use 'root'): hattori
E-mail address: hattori@foo.com
Password:
Password (again):
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)


Okay.

run webvirtmgr
# ./manage.py runserver x.x.x.x:8000

when flying webvirtmgr with mnage.py , you don’t need to start apache.
just start python script.

access to the IP with web browser




add the KVM hosts you want to manage with webvirtmgr.










nice !



[ how to start webvirtmgr from apache ]

install

# apt-get install -y libapache2-mod-python


enable python module
# a2enmod python
Module python already enabled


copy webvirtmgr directory to apache’s document directory.
cp -r webvirtmgr /var/www/


add the following lines in /etc/apache2/ports.conf
NameVirtualHost *:8000
Listen 8000


make webvirtmgr file under “/etc/apache2/sites-available/” direcotry.
# cat /etc/apache2/sites-available/webvirtmgr
<VirtualHost *:8000>
   DocumentRoot /var/www/webvirtmgr
   ServerAdmin webmaster@dummy-host.example.com
   ServerName foo.example.com

   SetHandler python-program
   PythonHandler django.core.handlers.modpython
   SetEnv DJANGO_SETTINGS_MODULE webvirtmgr.settings
   PythonOption django.root /var/www/webvirtmgr
   PythonDebug On
   PythonPath "['/var/www'] + sys.path"

   ErrorLog ${APACHE_LOG_DIR}/webvirtmgr-error_log
   CustomLog ${APACHE_LOG_DIR}/webvirtmgr-access_log common
</VirtualHost>

# a2ensite webvirtmgr
Enabling site webvirtmgr.
To activate the new configuration, you need to run:
 service apache2 reload


reload apache
# service apache2 reload


access to the IP
nnn , erro

r

change an owner from root to www-data.

# chown www-data.www-data /var/www/webvirtmgr/
# chown www-data.www-data /var/www/webvirtmgr/*


try again.



2 comments:

  1. Thanks!!!
    It helped me a lot
    git instructions from the owner didnt work for me

    zaccaro86 gmail

    ReplyDelete
  2. great walkthrough, thanks a lot! However, when trying to run './manage.py syncdb', I get

    ValueError: Unable to configure filter 'require_debug_false': Cannot resolve 'django.utils.log.RequireDebugFalse': No module named RequireDebugFalse

    Do you have any idea what this could be?

    Cheers,
    Alex

    ReplyDelete

Note: Only a member of this blog may post a comment.