Ejemplo n.º 1
0
def get_config():
    """
    Get the resalloc-server configuration dict
    """

    config_dir = "/etc/resallocserver"
    if 'CONFIG_DIR' in os.environ:
        config_dir = os.environ['CONFIG_DIR']

    # Setup defaults.
    config = {
        'db_url': 'sqlite:////var/lib/resalloc-server/db.sqlite',
        'logdir': '/var/log/resallocserver',
        # Bind the xmlrpc server to this hostname/port.
        'hostname': 'localhost',
        'port': 49100,
        'loglevel': 'info',
        # Maximum number of seconds Manager threads wait in loop.  Used for tests
        # only ATM.  Watcher sleeps sleeptime/2.
        'sleeptime': 20,
    }
    config["config_dir"] = config_dir

    config_file = os.path.join(config_dir, 'server.yaml')
    return merge_dict(config, load_config_file(config_file))
Ejemplo n.º 2
0
    def from_dict(self, data):
        allowed_types = [int, str, dict, type(None)]

        if type(data) != dict:
            # TODO: warning
            return

        for key in data:
            if not hasattr(self, key):
                warnings.warn("useless config option '{0}'".format(key))
                continue

            local = getattr(self, key)
            conf_type = type(local)
            if not conf_type in allowed_types:
                continue

            if conf_type == dict:
                setattr(self, key, helpers.merge_dict(local, data[key]))
            else:
                setattr(self, key, data[key])
Ejemplo n.º 3
0
# 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.

import os
from resalloc.helpers import merge_dict, load_config_file

config_dir = "/etc/resallocserver"
if 'CONFIG_DIR' in os.environ:
    config_dir = os.environ['CONFIG_DIR']

# Setup defaults.
CONFIG = {
    'db_url': 'sqlite:////var/lib/resalloc-server/db.sqlite',
    'logdir': '/var/log/resallocserver',
    # Bind the xmlrpc server to this hostname/port.
    'host': 'localhost',
    'port': 49100,
    'loglevel': 'info',
    # Maximum number of seconds Manager threads wait in loop.  Used for tests
    # only ATM.  Watcher sleeps sleeptime/2.
    'sleeptime': 20,
}

CONFIG_DIR = config_dir

config_file = os.path.join(config_dir, 'server.yaml')
CONFIG = merge_dict(CONFIG, load_config_file(config_file))