Skip to content

Commit

Permalink
Add RPM spec file and Upstart file. Fix novnc in console
Browse files Browse the repository at this point in the history
  • Loading branch information
edospadoni committed Jan 26, 2015
1 parent 169e0f0 commit c5d18a5
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 2 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
@@ -1,7 +1,7 @@
include *.rst

include images/README.md
include console/webvirtmgr-novnc
include console/webvirtmgr-console

recursive-include console *.pem
recursive-include create *.json
Expand Down
12 changes: 12 additions & 0 deletions conf/init/webvirtmgr-redhat.conf
@@ -0,0 +1,12 @@
description "WebVirtManager"
author "Edoardo Spadoni <edoardo.spadoni@nethesis.it>"

start on started libvirtd
stop on stopped libvirtd

script
export HOME="/usr/lib/python2.6/site-packages/webvirtmgr"
export PYTHONPATH="$PYTHONPATH:/usr/lib/python2.6/site-packages/Django-1.5.6-py2.6.egg"
export DJANGO_SETTINGS_MODULE="webvirtmgr.settings"
exec $HOME/manage.py run_gunicorn -c $HOME/conf/gunicorn.conf.py
end script
7 changes: 6 additions & 1 deletion conf/initd/webvirtmgr-novnc-redhat
Expand Up @@ -16,13 +16,18 @@

. /etc/rc.d/init.d/functions

prog="webvirtmgr-novnc"
prog="webvirtmgr-console"
exec="/var/www/webvirtmgr/console/$prog"
lockfile="/var/lock/subsys/$prog"
pidfile="/var/run/webvirtmgr/$prog.pid"
logfile="/var/log/$prog.log"
username="nginx"

# load webvirtmgr-console preferences
if [ -f /etc/sysconfig/webvirtmgr-console ]; then
. /etc/sysconfig/webvirtmgr-console
fi

if [ ! -d /var/run/webvirtmgr ]; then
mkdir /var/run/webvirtmgr
chown $username /var/run/webvirtmgr
Expand Down
66 changes: 66 additions & 0 deletions deploy/rpmbuild/README.md
@@ -0,0 +1,66 @@
Installation through RPM
========================

If you want you can install webvirtmgr through a rpm package. Under `deploy/rpmbuild/webvirtmgr.spec` you find the spec file to build the rpm.

Tested on `CentOS 6.5`.

### Build

Using `mock` and `rpmdevtools` to create the rpm (`yum install mock rpm-build rpmdevtools` from `EPEL` ).

##### User

Add new mock user:

```sh
useradd <username>
passwd <username>
usermod -aG mock <username>
```

Or editing existing users:

```sh
usermod -aG mock <username> && newgrp mock
```

##### Get sources from repository

```sh
cd deploy/rpmbuild/
spectool -g webvirtmgr.spec
```

##### Build the sources (src.rpm)

```sh
mock --resultdir=. --root epel-6-x86_64 --buildsrpm --spec webvirtmgr.spec --sources .
```

##### Build rpm

```sh
mock --resultdir=. --root=epel-6-x86_64 --rebuild webvirtmgr-4.8.8-1.el6.src.rpm
```

After this operations you have `webvirtmgr-4.8.8-1.el6.noarch.rpm`. To install it simply run:

```sh
yum localinstall webvirtmgr-4.8.8-1.el6.noarch.rpm
```

### Files

After the rpm installation, you can find the webvirtmgr files under `{python_sitelib}/webvirtmgr`.

Set the correct bind parameter in file `{python_sitelib}/webvirtmgr/conf/gunicorn.conf.py`.

In `CentOS 6.5` the path `{python_sitelib}` is usually `/usr/lib/python2.6/site-packages`.

Upstart file
============

If you want that webvirtmgr starts at boot, under `{python_sitelib}/webvirtmgr/conf/init/webvirtmgr-redhat.conf` there is the configuration file for upstart. The installation through rpm **launch** the app at boot. In fact the rpm installation copy the file `webvirtmgr-redhat.conf` in `/etc/init/`.

If you don't want to start webvirtmgr at boot simply remove the `webvirtmgr-redhat.conf` file in `/etc/init/`.
63 changes: 63 additions & 0 deletions deploy/rpmbuild/webvirtmgr.spec
@@ -0,0 +1,63 @@
%global name webvirtmgr
%global version 4.8.8
%global release 1

Name: %{name}
Version: %{version}
Release: %{release}%{?dist}
Summary: WebVirtMgr panel for manage virtual machine

License: Apache Licence, Version 2.0
URL: http://github.com/retspen/webvirtmgr
Source0: https://github.com/retspen/webvirtmgr/archive/master.tar.gz

BuildArch: noarch
BuildRequires: python-setuptools

Requires: python-setuptools libvirt-python libxml2-python python-websockify python-django15 python-gunicorn python-lockfile
Requires: libvirt qemu-kvm

%description
WebVirtMgr is a libvirt-based Web interface for managing virtual machines.
It allows you to create and configure new domains, and adjust a domain resource allocation.
A VNC viewer presents a full graphical console to the guest domain.
KVM is currently the only hypervisor supported.

%prep
%setup -n %{name}-master

%build
%{__python} setup.py build

%install
%{__python} setup.py install --skip-build --install-lib=%{python_sitelib}/%{name} --root $RPM_BUILD_ROOT
cp -r templates $RPM_BUILD_ROOT%{python_sitelib}/%{name}/
cp -r webvirtmgr/static $RPM_BUILD_ROOT%{python_sitelib}/%{name}/

mkdir -p $RPM_BUILD_ROOT%{python_sitelib}/%{name}/conf
cp conf/gunicorn.conf.py $RPM_BUILD_ROOT%{python_sitelib}/%{name}/conf/gunicorn.conf.py

mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/init
cp conf/init/webvirtmgr-redhat.conf $RPM_BUILD_ROOT%{_sysconfdir}/init/webvirtmgr.conf

mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/init.d
cp conf/initd/webvirtmgr-novnc-redhat $RPM_BUILD_ROOT%{_sysconfdir}/init.d/webvirtmgr-console

cp manage.py $RPM_BUILD_ROOT%{python_sitelib}/%{name}/
rm -rf $RPM_BUILD_ROOT%{_bindir}/manage.py

%post
/sbin/chkconfig --add webvirtmgr-console

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%{python_sitelib}/*
%{_sysconfdir}/init/*
%{_sysconfdir}/init.d/*

%changelog
* Wed Jan 26 2015 Edoardo Spadoni <edoardo.spadoni@nethesis.it> - 4.8.8
- first version

0 comments on commit c5d18a5

Please sign in to comment.