Hello Juan Hernandez,

I'd like you to do a code review.  Please visit

    http://gerrit.ovirt.org/17955

to review the following change.

Change subject: Initial packaging
......................................................................

Initial packaging

This patch introduces the initial version of the packaging stuff.

Change-Id: I8aa86f5ee80f40eb25a719fd72e75f7b275f38a0
Signed-off-by: Juan Hernandez <juan.hernan...@redhat.com>
---
M .gitignore
M Makefile
A ovirt-scheduler-proxy.spec
A packaging/ovirt-scheduler-proxy.systemd
A packaging/ovirt-scheduler-proxy.sysv
A setup.py
R src/ovirtscheduler/API.py
R src/ovirtscheduler/__init__.py
R src/ovirtscheduler/loader.py
R src/ovirtscheduler/oschedproxyd.py
R src/ovirtscheduler/request_handler.py
R src/ovirtscheduler/request_handler_test.py
R src/ovirtscheduler/runner.py
R src/ovirtscheduler/runner_test.py
R src/ovirtscheduler/utils.py
15 files changed, 331 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-scheduler-proxy 
refs/changes/55/17955/1

diff --git a/.gitignore b/.gitignore
index 5da7ef5..c73edf0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,6 @@
+# Ignore python generated files:
 *.pyc
 *.pyo
 
+# Ignore the tarballs:
+*.tar.gz
diff --git a/Makefile b/Makefile
index 96b1d1f..87e261b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,36 @@
+#
+# Copyright 2013 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+NAME=ovirt-scheduler-proxy
+VERSION=0.1
+TARBALL=$(NAME)-$(VERSION).tar.gz
+
+tarball:
+       tar --xform='s,^,$(NAME)-$(VERSION)/,' -c -z -f $(TARBALL) `git 
ls-files`
+
+srpm: tarball
+       rpmbuild -ts $(TARBALL)
+
+rpm: srpm
+       rpmbuild -tb $(TARBALL)
+
 all: test pep8
 
 PYTHONPATH=src
@@ -12,10 +45,10 @@
        pep8 src
 
 start:
-       python src/oschedproxyd.py &
+       python src/ovirtscheduler/oschedproxyd.py &
 
 stop:
-       pkill -f "python src/oschedproxyd.py"
+       pkill -f "python src/ovirtscheduler/oschedproxyd.py"
 
 clean:
        find -name "*.pyc" -exec rm {} \;
diff --git a/ovirt-scheduler-proxy.spec b/ovirt-scheduler-proxy.spec
new file mode 100644
index 0000000..cef0f12
--- /dev/null
+++ b/ovirt-scheduler-proxy.spec
@@ -0,0 +1,187 @@
+#
+# Copyright 2013 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+# Enable/disable features according to the type of distribution:
+%if 0%{?fedora}
+%global install_systemd 1
+%global install_systemv 0
+%endif
+
+%if 0%{?rhel}
+%global install_systemd 0
+%global install_systemv 1
+%endif
+
+Name: ovirt-scheduler-proxy
+Version: 0.1
+Release: 1%{?dist}
+Summary: Scheduling Proxy for Open Virtualization
+Group: Virtualization/Management
+License: ASL 2.0
+URL: http://www.ovirt.org
+Source: http://ovirt.org/releases/stable/src/%{name}-%{version}.tar.gz
+BuildArch: noarch
+
+%if %{install_systemd}
+BuildRequires: systemd
+%endif
+
+Requires: python
+
+
+%description
+The scheduler proxy runs user defined scripts to filter and fine-tune
+load-balancing of their oVirt system.
+
+
+%prep
+%setup -q
+
+
+%build
+%{__python} setup.py \
+    build
+
+
+%install
+
+# Install the python files:
+%{__python} setup.py \
+    install \
+    -O1 \
+    --skip-build \
+    --root %{buildroot}
+
+# Install the systemd service file:
+%if %{install_systemd}
+install \
+    -dm 755 \
+    %{buildroot}%{_unitdir}
+install \
+    -m 644 \
+    packaging/ovirt-scheduler-proxy.systemd \
+     %{buildroot}%{_unitdir}/ovirt-scheduler-proxy.service
+%endif
+
+# Install the System V init script:
+%if %{install_systemv}
+install \
+    -dm 755 \
+    %{buildroot}%{_initddir}
+install \
+    -m 755 \
+    packaging/ovirt-scheduler-proxy.sysv \
+     %{buildroot}%{_initddir}/ovirt-scheduler-proxy
+%endif
+
+# Install the data directory:
+install \
+    -dm 755 \
+    %{buildroot}%{_datadir}/ovirt-scheduler-proxy
+
+# Install the directory for plugins:
+install \
+    -dm 755 \
+    %{buildroot}%{_datadir}/ovirt-scheduler-proxy/plugins
+
+# Install the directory for logs:
+install \
+    -dm 755 \
+    %{buildroot}%{_localstatedir}/log/ovirt-scheduler-proxy
+
+
+%pre
+
+# Create the user if it doesn't exist:
+getent group ovirt &>/dev/null || \
+    groupadd \
+        -g 108 \
+        ovirt
+
+# Create the group if it doesn't exist:
+getent passwd ovirt &>/dev/null || \
+    useradd \
+        -u 108 \
+        -g ovirt \
+        -c "oVirt Manager" \
+        -s /sbin/nologin \
+        -d %{_datadir}/ovirt-scheduler-proxy \
+        ovirt
+
+
+%post
+
+# Make sure that systemd reloads its configuration once the package is
+# installed, otherwise it won't recognize the new service name:
+%if %{install_systemd}
+%systemd_post ovirt-scheduler-proxy.service
+%endif
+
+# Register the service:
+chkconfig --add ovirt-scheduler-proxy
+
+
+%postun
+
+# Make sure that the service is stoped and removed from the systemd
+# configuration:
+%if %{install_systemd}
+%systemd_postun ovirt-scheduler-proxy.service
+%endif
+
+# Stop the SysV service only if the package is being completely
+# uninstalled:
+%if %{install_systemv}
+if [ $1 -eq 0 ]
+then
+    service ovirt-scheduler-proxy stop &>/dev/null
+    chkconfig --del ovirt-scheduler-proxy
+fi
+%endif
+
+
+%files
+
+# Python files (included the generated egg):
+%{python_sitelib}/ovirtscheduler
+%{python_sitelib}/ovirt_scheduler_proxy-*.egg-info
+
+# Systemd and SysV files:
+%if %{install_systemd}
+%{_unitdir}/ovirt-scheduler-proxy.service
+%endif
+%if %{install_systemv}
+%{_initddir}/ovirt-scheduler-proxy
+%endif
+
+# Data directory:
+%{_datadir}/ovirt-scheduler-proxy/plugins
+
+# Logs directory needs to be owned by the user that runs the service because it
+# needs to create files inside:
+%attr(-, ovirt, ovirt) %{_localstatedir}/log/ovirt-scheduler-proxy
+
+# Documentation files:
+%doc README
+
+
+%changelog
+* Fri Aug 09 2013 Juan Hernandez <juan.hernan...@redhat.com> - 0.1-1
+- Initial packaging
diff --git a/packaging/ovirt-scheduler-proxy.systemd 
b/packaging/ovirt-scheduler-proxy.systemd
new file mode 100644
index 0000000..a68856b
--- /dev/null
+++ b/packaging/ovirt-scheduler-proxy.systemd
@@ -0,0 +1,14 @@
+[Unit]
+Description=oVirt Scheduler Proxy
+After=network.service
+
+[Service]
+Type=simple
+User=ovirt
+Group=ovirt
+WorkingDirectory=/usr/share/ovirt-scheduler-proxy
+ExecStart=/usr/bin/python -m ovirtscheduler.oschedproxyd
+EnvironmentFile=-/etc/sysconfig/ovirt-scheduler-proxy
+
+[Install]
+WantedBy=multi-user.target
diff --git a/packaging/ovirt-scheduler-proxy.sysv 
b/packaging/ovirt-scheduler-proxy.sysv
new file mode 100644
index 0000000..ee9ec6f
--- /dev/null
+++ b/packaging/ovirt-scheduler-proxy.sysv
@@ -0,0 +1,76 @@
+#!/bin/sh
+#
+# ovirt-scheduler-proxy Startup script for the oVirt Scheduler Proxy
+#
+# chkconfig: - 66 33
+# description: oVirt Scheduler Proxy
+# pidfile: /var/run/ovirt-scheduler-proxy.pid
+
+# Source function library:
+. /etc/rc.d/init.d/functions
+
+name="ovirt-scheduler-proxy"
+prog="oVirt Scheduler Proxy"
+pidfile="/var/run/${name}.pid"
+lockfile="/var/lock/subsys/${name}"
+retval=0
+
+if [ -f "/etc/sysconfig/${name}" ]
+then
+    . "/etc/sysconfig/${name}"
+fi
+
+case "$1" in
+
+start)
+    echo -n $"Starting $prog: "
+    touch "${pidfile}"
+    chown ovirt "${pidfile}"
+    pushd "/usr/share/${name}" &>/dev/null
+        daemon \
+            --user=ovirt \
+            "python -m ovirtscheduler.oschedproxyd 
&>/var/log/${name}/console.log & echo \$! >${pidfile}"
+    popd &>/dev/null
+    retval=$?
+    echo
+    if [ "${retval}" -eq 0 ]
+    then
+        touch "${lockfile}"
+    else
+        if [ -f "${lockfile}" ]
+        then
+            retval=0
+        fi
+    fi
+;;
+
+stop)
+    echo -n $"Stopping $prog: "
+    killproc -p "${pidfile}" -d 10
+    retval=$?
+    echo
+    if [ "${retval}" -eq 0 ]
+    then
+        rm -f "${lockfile}"
+    fi
+;;
+
+status)
+    status -p "${pidfile}" "${name}"
+    retval=$?
+;;
+
+restart)
+    $0 stop
+    $0 start
+    retval=$?
+    ;;
+
+*)
+    echo $"Usage: $0 {start|stop|status|restart}"
+    exit 2
+    ;;
+
+esac
+
+exit ${retval}
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..86cba98
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,15 @@
+from distutils.core import setup
+
+setup(
+    name='ovirt-scheduler-proxy',
+    version='0.1',
+    license='ASL2',
+    description='oVirt Scheduler Proxy',
+    author='Laszlo Hornyak',
+    author_email='lhorn...@redhat.com',
+    url='http://www.ovirt.org/Features/oVirt_External_Scheduling_Proxy',
+    packages=['ovirtscheduler'],
+    package_dir={ '': 'src' },
+    long_description=open('README').read(),
+)
+
diff --git a/src/API.py b/src/ovirtscheduler/API.py
similarity index 100%
rename from src/API.py
rename to src/ovirtscheduler/API.py
diff --git a/src/__init__.py b/src/ovirtscheduler/__init__.py
similarity index 100%
rename from src/__init__.py
rename to src/ovirtscheduler/__init__.py
diff --git a/src/loader.py b/src/ovirtscheduler/loader.py
similarity index 100%
rename from src/loader.py
rename to src/ovirtscheduler/loader.py
diff --git a/src/oschedproxyd.py b/src/ovirtscheduler/oschedproxyd.py
similarity index 96%
rename from src/oschedproxyd.py
rename to src/ovirtscheduler/oschedproxyd.py
index b13b49f..aa78849 100644
--- a/src/oschedproxyd.py
+++ b/src/ovirtscheduler/oschedproxyd.py
@@ -32,8 +32,7 @@
     pass
 
 
-log_filename = '/var/log/ovirt/ovirt-scheduler-proxy.'\
-    + strftime("%Y%m%d_%H%M%S") + '.log'
+log_filename = '/var/log/ovirt-scheduler-proxy/ovirt-scheduler-proxy.log'
 
 try:
     logging.basicConfig(level=logging.DEBUG,
diff --git a/src/request_handler.py b/src/ovirtscheduler/request_handler.py
similarity index 100%
rename from src/request_handler.py
rename to src/ovirtscheduler/request_handler.py
diff --git a/src/request_handler_test.py 
b/src/ovirtscheduler/request_handler_test.py
similarity index 100%
rename from src/request_handler_test.py
rename to src/ovirtscheduler/request_handler_test.py
diff --git a/src/runner.py b/src/ovirtscheduler/runner.py
similarity index 100%
rename from src/runner.py
rename to src/ovirtscheduler/runner.py
diff --git a/src/runner_test.py b/src/ovirtscheduler/runner_test.py
similarity index 100%
rename from src/runner_test.py
rename to src/ovirtscheduler/runner_test.py
diff --git a/src/utils.py b/src/ovirtscheduler/utils.py
similarity index 100%
rename from src/utils.py
rename to src/ovirtscheduler/utils.py


-- 
To view, visit http://gerrit.ovirt.org/17955
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8aa86f5ee80f40eb25a719fd72e75f7b275f38a0
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-scheduler-proxy
Gerrit-Branch: master
Gerrit-Owner: Doron Fediuck <dfedi...@redhat.com>
Gerrit-Reviewer: Juan Hernandez <juan.hernan...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to