Commit 8a1043ca authored by Kostas Papadimitriou's avatar Kostas Papadimitriou

Added snf-common package

split out of some commonly used code in a seperate package
parent a17d60e3
......@@ -42,30 +42,48 @@ virtualenv --no-site-packages -ppython2.6 env
source env/bin/activate
export PIP_DOWNLOAD_CACHE=/tmp/.pip_cache
pip install -r requirements.pip
rm -rf build dist
python setup.py sdist
pip install dist/synnefo-*.tar.gz
cd env
# avoid vncauthproxy errors
rm bin/vncauthproxy.py
echo "running django tests..." >&2
snf-manage test aai admin api db helpdesk invitations logic userdata --settings=synnefo.settings.test
cd ..
deactivate
rm -rf env
virtualenv --no-site-packages -ppython2.7 env
source env/bin/activate
export PIP_DOWNLOAD_CACHE=/tmp/.pip_cache
pip install -r requirements.pip
cd snf-common
rm -rf build dist
python setup.py install
cd ../snf-app
rm -rf build dist
python setup.py install
cd ../snf-ganeti-tools
rm -rf build dist
python setup.py sdist
pip install dist/synnefo-*.tar.gz
cd env
python setup.py install
cd ../env
# avoid vncauthproxy errors
rm bin/vncauthproxy.py
echo "running django tests..." >&2
export SYNNEFO_SETTINGS_DIR=/etc/lala
snf-manage test aai admin api db helpdesk invitations logic userdata --settings=synnefo.settings.test
cd ..
deactivate
rm -rf env
#rm -rf env
#virtualenv --no-site-packages -ppython2.7 env
#source env/bin/activate
#export PIP_DOWNLOAD_CACHE=/tmp/.pip_cache
#pip install -r requirements.pip
#cd snf-common
#rm -rf build dist
#python setup.py install
#cd ../snf-app
#rm -rf build dist
#python setup.py install
#cd ../snf-ganeti-tools
#rm -rf build dist
#python setup.py install
#cd env
## avoid vncauthproxy errors
#rm bin/vncauthproxy.py
#echo "running django tests..." >&2
#snf-manage test aai admin api db helpdesk invitations logic userdata --settings=synnefo.settings.test
#cd ..
#deactivate
#rm -rf env
......@@ -38,9 +38,8 @@
set -e
echo "Running snf-app tests..." >&2
export PYTHONPATH=$PYTHONPATH:./snf-app
python snf-app/synnefo/manage.py test aai admin api db helpdesk invitations logic userdata --settings=synnefo.settings.test
python snf-manage test aai admin api db helpdesk invitations logic userdata --settings=synnefo.settings.test
echo "Running snf-ganeti-tools tests..." >&2
PYTHONPATH=snf-ganeti-tools:$PYTHONPATH ./snf-ganeti-tools/test/synnefo.ganeti_unittest.py
./snf-ganeti-tools/test/synnefo.ganeti_unittest.py
......@@ -40,12 +40,12 @@ import os
from distutils.util import convert_path
from fnmatch import fnmatchcase
from setuptools import setup, find_packages
from synnefo.version import get_version
from synnefo.version import vcs_version
HERE = os.path.abspath(os.path.normpath(os.path.dirname(__file__)))
# Package info
VERSION = get_version().replace(" ","")
VERSION = vcs_version()
README = open(os.path.join(HERE, 'README')).read()
CHANGES = open(os.path.join(HERE, 'Changelog')).read()
SHORT_DESCRIPTION = 'Package short description'
......@@ -171,7 +171,7 @@ def find_package_data(
return out
setup(
name = 'synnefo',
name = 'snf-app',
version = VERSION,
license = 'BSD',
url = 'http://code.grnet.gr/',
......@@ -202,6 +202,10 @@ setup(
'snf-admin = synnefo.tools.admin:main',
'snf-cloud = synnefo.tools.cloud:main',
],
'synnefo': [
'settings = synnefo.app_settings',
'apps = synnefo.app_settings:getapps',
]
},
)
from synnefo.app_settings.default import *
def getapps():
return INSTALLED_APPS
......@@ -31,21 +31,21 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from synnefo.settings.common.admins import *
from synnefo.settings.common.apps import *
from synnefo.settings.common.deploy import *
from synnefo.settings.common.logging import *
from synnefo.settings.common.site import *
from synnefo.settings.common.backend import *
from synnefo.settings.common.database import *
from synnefo.settings.common.queues import *
from synnefo.settings.common.api import *
from synnefo.settings.common.plankton import *
from synnefo.settings.common.ui import *
from synnefo.settings.common.userdata import *
from synnefo.settings.common.aai import *
from synnefo.settings.common.invitations import *
from synnefo.settings.common.reconciliation import *
from synnefo.settings.common.helpdesk import *
from synnefo.settings.common.tests import *
from synnefo.app_settings.default.admins import *
from synnefo.app_settings.default.apps import *
from synnefo.app_settings.default.deploy import *
from synnefo.app_settings.default.logging import *
from synnefo.app_settings.default.site import *
from synnefo.app_settings.default.backend import *
from synnefo.app_settings.default.database import *
from synnefo.app_settings.default.queues import *
from synnefo.app_settings.default.api import *
from synnefo.app_settings.default.plankton import *
from synnefo.app_settings.default.ui import *
from synnefo.app_settings.default.userdata import *
from synnefo.app_settings.default.aai import *
from synnefo.app_settings.default.invitations import *
from synnefo.app_settings.default.reconciliation import *
from synnefo.app_settings.default.helpdesk import *
from synnefo.app_settings.default.tests import *
......@@ -4,7 +4,7 @@ from django.core.management import ManagementUtility, setup_environ, \
BaseCommand, LaxOptionParser, handle_default_options
from optparse import Option, make_option
from synnefo import get_version
from synnefo.version import get_component_version
import sys
import os
......@@ -36,7 +36,7 @@ class SynnefoManagementUtility(ManagementUtility):
# These options could affect the commands that are available, so they
# must be processed early.
parser = LaxOptionParser(usage="%prog subcommand [options] [args]",
version=get_version(),
version=get_component_version('synnefo.manage'),
option_list=option_list)
self.autocomplete()
try:
......
......@@ -46,7 +46,7 @@ from django.core.urlresolvers import reverse
from django.core.mail import send_mail
from django.http import Http404
from synnefo import get_version
from synnefo.version import get_version
SYNNEFO_JS_LIB_VERSION = get_version()
IMAGE_ICONS = settings.IMAGE_ICONS
......
Changelog
=========
README
=======
Synnefo top level package
This diff is collapsed.
# Copyright 2011 GRNET S.A. All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
#
# 1. Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
#
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
#
import distribute_setup
distribute_setup.use_setuptools()
import os
from distutils.util import convert_path
from fnmatch import fnmatchcase
from setuptools import setup, find_packages
from synnefo.version import vcs_version
HERE = os.path.abspath(os.path.normpath(os.path.dirname(__file__)))
# Package info
VERSION = vcs_version()
README = open(os.path.join(HERE, 'README')).read()
CHANGES = open(os.path.join(HERE, 'Changelog')).read()
SHORT_DESCRIPTION = 'Package short description'
PACKAGES_ROOT = '.'
PACKAGES = find_packages(PACKAGES_ROOT, exclude=['okeanos_site'])
# Package meta
CLASSIFIERS = []
# Package requirements
INSTALL_REQUIRES = [
]
EXTRAS_REQUIRES = {
}
TESTS_REQUIRES = [
]
setup(
name = 'snf-common',
version = VERSION,
license = 'BSD',
url = 'http://code.grnet.gr/',
description = SHORT_DESCRIPTION,
long_description=README + '\n\n' + CHANGES,
classifiers = CLASSIFIERS,
author = 'Package author',
author_email = 'author@grnet.gr',
maintainer = 'Package maintainer',
maintainer_email = 'maintainer@grnet.gr',
packages = PACKAGES,
package_dir= {'': PACKAGES_ROOT},
include_package_data = True,
zip_safe = False,
install_requires = INSTALL_REQUIRES,
extras_require = EXTRAS_REQUIRES,
tests_require = TESTS_REQUIRES,
)
# this is a namespace package
try:
import pkg_resources
pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
......@@ -34,14 +34,21 @@
import os
import sys
import glob
import pkg_resources
# import common settings
from synnefo.settings.common import *
from synnefo.util.entry_points import extend_settings
SYNNEFO_SETTINGS_DIR = os.environ.get('SYNNEFO_SETTINGS_DIR', "/etc/synnefo/")
# import default settings
from synnefo.settings.default import *
# autodetect default settings provided by synnefo applications
extend_settings('synnefo', __name__)
# extend default settings with settings provided within *.conf user files
# located in directory specified in the SYNNEFO_SETTINGS_DIR
# environmental variable
SYNNEFO_SETTINGS_DIR = os.environ.get('SYNNEFO_SETTINGS_DIR', "/etc/synnefo/")
if os.path.exists(SYNNEFO_SETTINGS_DIR):
# extend common settings with settings set in /etc/synnefo dir
conffiles = glob.glob(os.path.join(SYNNEFO_SETTINGS_DIR, '*.conf'))
conffiles.sort()
for f in conffiles:
......@@ -50,3 +57,5 @@ if os.path.exists(SYNNEFO_SETTINGS_DIR):
except Exception as e:
print >>sys.stderr, "Failed to read settings file: %s" % \
os.path.abspath(f)
......@@ -11,3 +11,4 @@ DATABASES = {
}
LOGGING['handlers']['console']['level'] = 'WARNING'
LOGIN_URL = 'http://host:port/'
import sys
import pkg_resources
import inspect
def get_entry_ponts(ns, name):
for entry_point in pkg_resources.iter_entry_points(group=ns):
if entry_point.name == name:
yield entry_point
def extend_settings(ns, module_name):
"""
Extend module from entry_point hooks
"""
settings = sys.modules[module_name]
# apps hook
app_entry_points = get_entry_ponts(ns, 'apps')
# settings hook
settings_entry_points = get_entry_ponts(ns, 'settings')
# extend INSTALLED_APPS setting
NEW_INSTALLED_APPS = list(getattr(settings, 'INSTALLED_APPS', []));
# if failed to execute app hook as function parse it as string
# synnefo.app:get_additional_apps or app1,app2,app3
for e in app_entry_points:
try:
NEW_INSTALLED_APPS = list(e.load()())
except Exception, e:
for e in app_entry_points:
NEW_INSTALLED_APPS = NEW_INSTALLED_APPS + \
e.module_name.split(",")
# extend additional settings
# TODO: existing settings logic ??
for e in settings_entry_points:
module = e.load()
for k in dir(module):
if k == k.upper():
setattr(settings, k, getattr(module, k))
setattr(settings, 'INSTALLED_APPS', NEW_INSTALLED_APPS)
......@@ -33,7 +33,7 @@
import logging
from django.conf import settings
from synnefo import settings
from synnefo.util.dictconfig import dictConfig
......@@ -47,14 +47,14 @@ logging.NullHandler = NullHandler
def disable_unused_loggers():
"""Disable handlers that are not used by any logger"""
logging = settings.LOGGING
active_handlers = set()
loggers = logging.get('loggers', {})
for logger in loggers.values():
active_handlers.update(logger.get('handlers', []))
handlers = logging.get('handlers', {})
for handler in handlers:
if handler not in active_handlers:
......
VERSION = (0, 8, 0, 'alpha', 0)
__version__ = VERSION
import pkg_resources
def get_version():
def get_dist_from_module(modname):
pkgroot = pkg_resources.get_provider(modname).egg_root
return list(pkg_resources.find_distributions(pkgroot))[0]
def get_dist(dist_name):
return pkg_resouces.get_distribution(dist_name)
def get_dist_version(dist_name):
"""
Utility to parse version tuple to string
Get the version for the specified distribution name
"""
version = '%s.%s' % (VERSION[0], VERSION[1])
if VERSION[2]:
version = '%s.%s' % (version, VERSION[2])
if VERSION[3:] == ('alpha', 0):
version = '%s pre-alpha' % version
else:
if VERSION[3] != 'final':
version = '%s %s %s' % (version, VERSION[3], VERSION[4])
return version
try:
return get_dist(dist_name).version
except Exception, e:
return 'unknown'
def vcs_version():
def get_component_version(modname):
"""
Return the version of a synnefo module/package based on its
corresponding distributed package version
"""
try:
return get_dist_from_module(modname).version
except Exception, e:
return 'unknown'
def vcs_info():
"""
Return current git HEAD commit information
"""
......@@ -27,6 +43,15 @@ def vcs_version():
branch = callgit('git branch | grep -Ei "\* (.*)" | cut -f2 -d" "')
revid = callgit("git --no-pager log --max-count=1 | cut -f2 -d' ' | head -1")
revno = callgit('git --no-pager log --oneline | wc -l')
desc = callgit('git describe')
return branch, revid, revno, desc
return branch, revid, revno
def vcs_version():
"""
Package version based on `git describe`, compatible with setuptools
version format
"""
return vcs_info()[3].replace('v', '')
#!/usr/bin/env python
from setuptools import setup
from synnefo.version import vcs_version
setup(
name="snf-ganeti-tools",
version="0.7.1",
version=vcs_version(),
description="Synnefo Ganeti supplementary tools",
author="Synnefo Development Team",
author_email="synnefo@lists.grnet.gr",
......@@ -17,7 +18,6 @@ setup(
'pyinotify',
'amqplib',
'prctl',
'ganeti',
],
scripts=['snf-ganeti-eventd.py', 'snf-ganeti-hook.py',
'snf-progress-monitor.py'],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment