Ejemplo n.º 1
0
def get_heartbeat_timeout():
    """Returns the HEARTBEAT_TIMEOUT value specified in worker.conf

    If there is no value found, we return a default timeout value 300.
    """
    settings = Settings("lava-server")
    worker_config_path = settings._get_pathname("worker")
    try:
        worker_config = ConfigFile.load(worker_config_path)
        if worker_config and worker_config.HEARTBEAT_TIMEOUT != '':
            return int(worker_config.HEARTBEAT_TIMEOUT)
        else:
            return 300
    except (IOError, AttributeError):
        return 300
Ejemplo n.º 2
0
def get_heartbeat_timeout():
    """Returns the HEARTBEAT_TIMEOUT value specified in worker.conf

    If there is no value found, we return a default timeout value 300.
    """
    settings = Settings("lava-server")
    worker_config_path = settings._get_pathname("worker")
    try:
        worker_config = ConfigFile.load(worker_config_path)
        if worker_config and worker_config.HEARTBEAT_TIMEOUT != '':
            return int(worker_config.HEARTBEAT_TIMEOUT)
        else:
            return 300
    except (IOError, AttributeError):
        return 300
Ejemplo n.º 3
0
    def handle(self, *args, **options):
        filename = None
        if len(args) > 0:
            filename = args[0]
        else:
            self.stderr.write("filename not specified, writing to stdout")

        settings = Settings("lava-server")
        server_uri = settings.get_setting("AUTH_LDAP_SERVER_URI", None)
        self.stdout.write("Trying to access %s ..." % server_uri)
        if LDAP_SERVER_HOST not in server_uri:
            self.stderr.write("This is a very rarely used management command, "
                              "hence many parameters within this command are "
                              "harcoded. The best way to use this command is"
                              " to copy and edit the python script '%s' to "
                              "work with other LDAP systems." %
                              _get_script_path())
            sys.exit(1)
        bind_dn = settings.get_setting("AUTH_LDAP_BIND_DN", None)
        bind_password = settings.get_setting("AUTH_LDAP_BIND_PASSWORD", None)

        user_dn = USER_DN
        search_scope = SEARCH_SCOPE
        attributes = ATTRIBUTES
        search_filter = SEARCH_FILTER

        if server_uri is not None:
            conn = ldap.initialize(server_uri)
            if bind_dn and bind_password:
                conn.simple_bind_s(bind_dn, bind_password)
                results = conn.search_s(user_dn, search_scope, search_filter,
                                        attributes)
                if filename:
                    with open(filename, 'wb') as csvfile:
                        file_handle = csv.writer(csvfile,
                                                 delimiter=',',
                                                 quotechar='|',
                                                 quoting=csv.QUOTE_MINIMAL)
                        for result in results:
                            result_type, result_data = result
                            file_handle.writerow([result_data['uid'][0]])
                else:
                    for result in results:
                        result_type, result_data = result
                        self.stdout.write(result_data['uid'][0])
                self.stdout.write('Total "%d" LDAP users' % len(results))
Ejemplo n.º 4
0
    def handle(self, *args, **options):
        filename = None
        if len(args) > 0:
            filename = args[0]
        else:
            self.stderr.write("filename not specified, writing to stdout")

        settings = Settings("lava-server")
        server_uri = settings.get_setting("AUTH_LDAP_SERVER_URI", None)
        self.stdout.write("Trying to access %s ..." % server_uri)
        if LDAP_SERVER_HOST not in server_uri:
            self.stderr.write("This is a very rarely used management command, "
                              "hence many parameters within this command are "
                              "harcoded. The best way to use this command is"
                              " to copy and edit the python script '%s' to "
                              "work with other LDAP systems."
                              % _get_script_path())
            sys.exit(1)
        bind_dn = settings.get_setting("AUTH_LDAP_BIND_DN", None)
        bind_password = settings.get_setting("AUTH_LDAP_BIND_PASSWORD", None)

        user_dn = USER_DN
        search_scope = SEARCH_SCOPE
        attributes = ATTRIBUTES
        search_filter = SEARCH_FILTER

        if server_uri is not None:
            conn = ldap.initialize(server_uri)
            if bind_dn and bind_password:
                conn.simple_bind_s(bind_dn, bind_password)
                results = conn.search_s(user_dn, search_scope, search_filter,
                                        attributes)
                if filename:
                    with open(filename, 'wb') as csvfile:
                        file_handle = csv.writer(csvfile, delimiter=',',
                                                 quotechar='|',
                                                 quoting=csv.QUOTE_MINIMAL)
                        for result in results:
                            result_type, result_data = result
                            file_handle.writerow([result_data['uid'][0]])
                else:
                    for result in results:
                        result_type, result_data = result
                        self.stdout.write(result_data['uid'][0])
                self.stdout.write('Total "%d" LDAP users' % len(results))
Ejemplo n.º 5
0
def get_ldap_user_properties(ldap_user):
    """Searches LDAP based on the parameters in settings.conf and returns LDAP
    user properties as a dictionary, eg:

    {uid: 'senthil.kumaran',
     mail: '*****@*****.**',
     sn: 'Kumaran',
     given_name: 'Senthil'
    }

    If given ldap_user does not exist, then raise ldap.NO_SUCH_OBJECT
    """
    settings = Settings("lava-server")
    server_uri = settings.get_setting("AUTH_LDAP_SERVER_URI", None)
    bind_dn = settings.get_setting("AUTH_LDAP_BIND_DN", None)
    bind_password = settings.get_setting("AUTH_LDAP_BIND_PASSWORD", None)
    user_dn_template = settings.get_setting("AUTH_LDAP_USER_DN_TEMPLATE",
                                            None)
    user_dn = user_dn_template % {'user': ldap_user}
    search_scope = ldap.SCOPE_SUBTREE
    attributes = ['uid', 'givenName', 'sn', 'mail']
    search_filter = "cn=*"

    user_properties = {}
    if server_uri is not None:
        conn = ldap.initialize(server_uri)
        if bind_dn and bind_password:
            conn.simple_bind_s(bind_dn, bind_password)
            try:
                result = conn.search_s(user_dn, search_scope,
                                       search_filter, attributes)
                if len(result) == 1:
                    result_type, result_data = result[0]
                    user_properties['uid'] = result_data.get('uid', [None])[0]
                    user_properties['mail'] = result_data.get('mail',
                                                              [None])[0]
                    user_properties['sn'] = result_data.get('sn', [None])[0]
                    user_properties['given_name'] = result_data.get('givenName',
                                                                    [None])[0]
                    return user_properties
            except ldap.NO_SUCH_OBJECT:
                raise
Ejemplo n.º 6
0
def get_software_info():
    """Returns git status and version information for LAVA related software.
    """
    sw_info = {}

    # Populate the git status of server code from exports directory.
    settings = Settings("lava-server")
    instance_config_path = settings._get_pathname("instance")
    instance_config = ConfigFile.load(instance_config_path)
    prefix = os.path.join(instance_config.LAVA_PREFIX,
                          instance_config.LAVA_INSTANCE)

    # Populate installed packages.
    sw_info.update(installed_packages(package_name='lava'))
    sw_info.update(installed_packages(package_name='linaro'))
    sw_info.update(installed_packages(prefix=prefix))

    # Summary of local build outs, if any.
    if instance_config.LAVA_DEV_MODE == 'yes':
        sw_info.update(local_diffstat(prefix))

    return simplejson.dumps(format_sw_info_to_html(sw_info))
Ejemplo n.º 7
0
def get_software_info():
    """Returns git status and version information for LAVA related software.
    """
    sw_info = {}

    # Populate the git status of server code from exports directory.
    settings = Settings("lava-server")
    instance_config_path = settings._get_pathname("instance")
    instance_config = ConfigFile.load(instance_config_path)
    prefix = os.path.join(instance_config.LAVA_PREFIX,
                          instance_config.LAVA_INSTANCE)

    # Populate installed packages.
    sw_info.update(installed_packages(package_name='lava'))
    sw_info.update(installed_packages(package_name='linaro'))
    sw_info.update(installed_packages(prefix=prefix))

    # Summary of local build outs, if any.
    if instance_config.LAVA_DEV_MODE == 'yes':
        sw_info.update(local_diffstat(prefix))

    return simplejson.dumps(format_sw_info_to_html(sw_info))
Ejemplo n.º 8
0
def get_ldap_user_properties(ldap_user):
    """Searches LDAP based on the parameters in settings.conf and returns LDAP
    user properties as a dictionary, eg:

    {uid: 'senthil.kumaran',
     mail: '*****@*****.**',
     sn: 'Kumaran',
     given_name: 'Senthil'
    }

    If given ldap_user does not exist, then raise ldap.NO_SUCH_OBJECT
    """
    settings = Settings("lava-server")
    server_uri = settings.get_setting("AUTH_LDAP_SERVER_URI", None)
    bind_dn = settings.get_setting("AUTH_LDAP_BIND_DN", None)
    bind_password = settings.get_setting("AUTH_LDAP_BIND_PASSWORD", None)
    user_dn_template = settings.get_setting("AUTH_LDAP_USER_DN_TEMPLATE", None)
    user_search = settings.get_setting("AUTH_LDAP_USER_SEARCH", None)

    search_scope = ldap.SCOPE_SUBTREE
    attributes = ['uid', 'givenName', 'sn', 'mail']
    search_filter = "cn=*"

    if user_dn_template:
        user_dn = user_dn_template % {'user': ldap_user}
    if user_search:
        from django_auth_ldap.config import LDAPSearch
        search = eval(user_search)
        user_dn = search.base_dn
        search_filter = search.filterstr % {'user': ldap_user}

    user_properties = {}
    if server_uri is not None:
        conn = ldap.initialize(server_uri)
        if bind_dn and bind_password:
            conn.simple_bind_s(bind_dn, bind_password)
            try:
                result = conn.search_s(user_dn, search_scope, search_filter,
                                       attributes)
                if len(result) == 1:
                    result_type, result_data = result[0]
                    user_properties['uid'] = result_data.get('uid', [None])[0]
                    user_properties['mail'] = result_data.get('mail',
                                                              [None])[0]
                    user_properties['sn'] = result_data.get('sn', [None])[0]
                    user_properties['given_name'] = result_data.get(
                        'givenName', [None])[0]
                    return user_properties
            except ldap.NO_SUCH_OBJECT:
                raise
Ejemplo n.º 9
0
def get_ldap_user_properties(ldap_user):
    """Searches LDAP based on the parameters in settings.conf and returns LDAP
    user properties as a dictionary, eg:

    {uid: 'senthil.kumaran',
     mail: '*****@*****.**',
     sn: 'Kumaran',
     given_name: 'Senthil'
    }

    If given ldap_user does not exist, then raise ldap.NO_SUCH_OBJECT
    """
    settings = Settings("lava-server")
    server_uri = settings.get_setting("AUTH_LDAP_SERVER_URI", None)
    bind_dn = settings.get_setting("AUTH_LDAP_BIND_DN", None)
    bind_password = settings.get_setting("AUTH_LDAP_BIND_PASSWORD", None)
    user_dn_template = settings.get_setting("AUTH_LDAP_USER_DN_TEMPLATE", None)
    user_search = settings.get_setting("AUTH_LDAP_USER_SEARCH", None)

    search_scope = ldap.SCOPE_SUBTREE
    attributes = ["uid", "givenName", "sn", "mail"]
    search_filter = "cn=*"

    if user_dn_template:
        user_dn = user_dn_template % {"user": ldap_user}
    if user_search:
        from django_auth_ldap.config import LDAPSearch

        search = eval(user_search)
        user_dn = search.base_dn
        search_filter = search.filterstr % {"user": ldap_user}

    user_properties = {}
    if server_uri is not None:
        conn = ldap.initialize(server_uri)
        if bind_dn and bind_password:
            conn.simple_bind_s(bind_dn, bind_password)
            try:
                result = conn.search_s(user_dn, search_scope, search_filter, attributes)
                if len(result) == 1:
                    result_type, result_data = result[0]
                    user_properties["uid"] = result_data.get("uid", [None])[0]
                    user_properties["mail"] = result_data.get("mail", [None])[0]
                    user_properties["sn"] = result_data.get("sn", [None])[0]
                    user_properties["given_name"] = result_data.get("givenName", [None])[0]
                    return user_properties
            except ldap.NO_SUCH_OBJECT:
                raise
Ejemplo n.º 10
0
# Django settings for django_hello project used on Debian systems.

import re
from lava_server.settings.getsettings import Settings
from lava_server.settings.production import *
from django.db.backends.signals import connection_created

# Load application settings from lava_server.settings integration package
distro_settings = Settings("lava-server")

# Use timezone
USE_TZ = True

# Load the mount point from settings file
MOUNT_POINT = distro_settings.mount_point

# Load default database from distro integration
DATABASES = {'default': distro_settings.default_database}

# Load debug settings from the configuration file
DEBUG = distro_settings.DEBUG

# Load secret key from distro integration
SECRET_KEY = distro_settings.SECRET_KEY

# Absolute filesystem path to the directory that will hold user-uploaded files.
MEDIA_ROOT = distro_settings.MEDIA_ROOT

# Absolute filesystem path to the directory that will hold archived files.
ARCHIVE_ROOT = distro_settings.ARCHIVE_ROOT
Ejemplo n.º 11
0
# Django settings for django_hello project used on Debian systems.

import re
from lava_server.settings.getsettings import Settings
from lava_server.settings.production import *
from django.db.backends.signals import connection_created

# Load application settings from lava_server.settings integration package
distro_settings = Settings("lava-server")

# Use timezone
USE_TZ = True

# Load the mount point from settings file
MOUNT_POINT = distro_settings.mount_point

# Load default database from distro integration
DATABASES = {'default': distro_settings.default_database}

# Load debug settings from the configuration file
DEBUG = distro_settings.DEBUG

# Load secret key from distro integration
SECRET_KEY = distro_settings.SECRET_KEY

# Absolute filesystem path to the directory that will hold user-uploaded files.
MEDIA_ROOT = distro_settings.MEDIA_ROOT

# Absolute filesystem path to the directory that will hold archived files.
ARCHIVE_ROOT = distro_settings.ARCHIVE_ROOT
Ejemplo n.º 12
0
# Django settings for django_hello project used on Debian systems.

import re
from lava_server.settings.getsettings import Settings
from lava_server.settings.production import *
from django.db.backends.signals import connection_created

# Load application settings from lava_server.settings integration package
distro_settings = Settings("lava-server")

# Use timezone
USE_TZ = True

# Load the mount point from settings file
MOUNT_POINT = distro_settings.mount_point

# Load default database from distro integration
DATABASES = {'default': distro_settings.default_database}

# Load debug settings from the configuration file
DEBUG = distro_settings.DEBUG

# Load secret key from distro integration
SECRET_KEY = distro_settings.SECRET_KEY

# Absolute filesystem path to the directory that will hold user-uploaded files.
MEDIA_ROOT = distro_settings.MEDIA_ROOT

# Absolute filesystem path to the directory that will hold archived files.
ARCHIVE_ROOT = distro_settings.ARCHIVE_ROOT
Ejemplo n.º 13
0
# Django settings for django_hello project used on Debian systems.

import os
from lava_server.settings.getsettings import Settings
from lava_server.extension import loader
from lava_server.settings.production import *

# Load application settings from lava_server.settings integration package
distro_settings = Settings("lava-server")

# Load the mount point from settings file
MOUNT_POINT = distro_settings.mount_point

# Load default database from distro integration
DATABASES = {'default': distro_settings.default_database}

# Load debug settings from the configuration file
DEBUG = distro_settings.DEBUG

# Load secret key from distro integration
SECRET_KEY = distro_settings.SECRET_KEY

# Absolute filesystem path to the directory that will hold user-uploaded files.
MEDIA_ROOT = distro_settings.MEDIA_ROOT

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = distro_settings.MEDIA_URL

# Absolute filesystem path to the directory that will hold static, read only
Ejemplo n.º 14
0
# Django settings for django_hello project used on Debian systems.

import os
from lava_server.settings.getsettings import Settings
from lava_server.extension import loader
from lava_server.settings.production import *
from django.db.backends.signals import connection_created

# Load application settings from lava_server.settings integration package
distro_settings = Settings("lava-server")

# Use timezone
USE_TZ = True

# Load the mount point from settings file
MOUNT_POINT = distro_settings.mount_point

# Load default database from distro integration
DATABASES = {'default': distro_settings.default_database}

# Load debug settings from the configuration file
DEBUG = distro_settings.DEBUG

# Load secret key from distro integration
SECRET_KEY = distro_settings.SECRET_KEY

# Absolute filesystem path to the directory that will hold user-uploaded files.
MEDIA_ROOT = distro_settings.MEDIA_ROOT

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
Ejemplo n.º 15
0
# Django settings for django_hello project used on Debian systems.

import os
from lava_server.settings.getsettings import Settings
from lava_server.extension import loader
from lava_server.settings.production import *

# Load application settings from lava_server.settings integration package
distro_settings = Settings("lava-server")

# Load the mount point from settings file
MOUNT_POINT = distro_settings.mount_point

# Load default database from distro integration
DATABASES = {'default': distro_settings.default_database}

# Load debug settings from the configuration file
DEBUG = distro_settings.DEBUG

# Load secret key from distro integration
SECRET_KEY = distro_settings.SECRET_KEY

# Absolute filesystem path to the directory that will hold user-uploaded files.
MEDIA_ROOT = distro_settings.MEDIA_ROOT

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = distro_settings.MEDIA_URL

# Absolute filesystem path to the directory that will hold static, read only
Ejemplo n.º 16
0
# Django settings for django_hello project used on Debian systems.

import os
from lava_server.settings.getsettings import Settings
from lava_server.extension import loader
from lava_server.settings.production import *
from django.db.backends.signals import connection_created

# Load application settings from lava_server.settings integration package
distro_settings = Settings("lava-server")

# Use timezone
USE_TZ = True

# Load the mount point from settings file
MOUNT_POINT = distro_settings.mount_point

# Load default database from distro integration
DATABASES = {'default': distro_settings.default_database}

# Load debug settings from the configuration file
DEBUG = distro_settings.DEBUG

# Load secret key from distro integration
SECRET_KEY = distro_settings.SECRET_KEY

# Absolute filesystem path to the directory that will hold user-uploaded files.
MEDIA_ROOT = distro_settings.MEDIA_ROOT

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).