Example #1
0
def main():
    config['LOG_FILE'] = '/tmp/oar_kamelot.log'
    logger = get_logger("oar.kamelot_fifo", forward_stderr=True)
    config.setdefault_config(DEFAULT_CONFIG)
    plt = Platform()
    schedule_fifo_cycle(plt, "default")
    logger.info("That's all folks")
Example #2
0
 def __init__(self, command, api_host, zeromq_bind_uri,
              api_credentials=None, nodes=1, walltime=3600, **kwargs):
     self.nodes = 1
     self.command = command
     self.walltime = walltime
     self.zeromq_bind_uri = zeromq_bind_uri
     self.api_host = api_host
     self.api_credentials = api_credentials
     for key in kwargs:
         setattr(self, key, kwargs[key])
     from oar.lib import get_logger
     self.logger = get_logger("oar.coorm", forward_stderr=True)
Example #3
0
def main():
    config['LOG_FILE'] = '/tmp/oar_kamelot.log'
    logger = get_logger("oar.kamelot", forward_stderr=True)
    config.setdefault_config(DEFAULT_CONFIG)

    plt = Platform()

    logger.debug("argv..." + str(sys.argv))

    if len(sys.argv) > 2:
        schedule_cycle(plt, int(float(sys.argv[2])), sys.argv[1])
    elif len(sys.argv) == 2:
        schedule_cycle(plt, plt.get_time(), sys.argv[1])
    else:
        schedule_cycle(plt, plt.get_time())

    logger.info("That's all folks")
    from oar.lib import db
    db.commit()
Example #4
0
from copy import deepcopy
# Initialize some variables to default value or retrieve from oar.conf
# configuration file *)


# Set undefined config value to default one
DEFAULT_CONFIG = {
    'HIERARCHY_LABELS': 'resource_id,network_address',
    'SCHEDULER_RESOURCE_ORDER': "resource_id ASC",
    'SCHEDULER_JOB_SECURITY_TIME': '60',
    'SCHEDULER_AVAILABLE_SUSPENDED_RESOURCE_TYPE': 'default',
    'FAIRSHARING_ENABLED': 'no',
}


logger = get_logger("oar.kamelot_fifo")


def schedule_fifo_cycle(plt, queue="default", hierarchy_use=False):

    assigned_jobs = {}

    now = plt.get_time()

    logger.info("Begin scheduling....now: " + str(now) + ", queue: " + queue)

    #
    # Retrieve waiting jobs
    #
    waiting_jobs, waiting_jids, nb_waiting_jobs = plt.get_waiting_jobs(queue)
Example #5
0
    from http import client as httplib
    from urllib import parse as urlencode
    from urllib import parse as urlparse
else:
    from urlparse import urlparse
    from urllib import urlencode
    import httplib

from flask import request, Response, url_for, abort
from werkzeug.datastructures import Headers

from oar.lib.utils import JSONEncoder
from oar.lib.compat import json, reraise
from oar.lib import get_logger

logger = get_logger("oar.rest-api.proxy", forward_stderr=True)


def iterform(multidict):
    for key in multidict.keys():
        for value in multidict.getlist(key):
            yield (key.encode("utf8"), value.encode("utf8"))


def proxy_request(path, proxy_host, proxy_port, proxy_prefix, proxy_auth):
    request_headers = {}
    for h in ["Cookie", "Referer", "X-Csrf-Token"]:
        if h in request.headers:
            request_headers[h] = request.headers[h]

    proxy_path = path
Example #6
0
    'APPENDICE_SERVER_PORT': '6668',
    'BIPBIP_COMMANDER_SERVER': 'localhost',
    'BIPBIP_COMMANDER_PORT': '6669',
}

config.setdefault_config(DEFAULT_CONFIG)


OAR_EXEC_RUNJOB_LEON = r'(OAREXEC|OARRUNJOB|LEONEXTERMINATE)_(\d+)(.*)'
# Regexp of the notification received from oarexec processes
#   $1: OAREXEC|OARRUNJOB|LEONEXTERMINATE
#   $2: job id
#   $3: for OAREXEC: oarexec exit code, job script exit code,
#                    secret string that identifies the oarexec process (for security)

logger = get_logger("oar.modules.appendice_proxy", forward_stderr=True)
logger.info('Start Appendice Proxy')

class AppendiceProxy(object):
    def __init__(self):
        self.context = zmq.Context()
        self.socket_proxy = self.context.socket(zmq.STREAM)
        self.socket_proxy.bind("tcp://*:" + str(config['SERVER_PORT']))

        self.appendice = self.context.socket(zmq.PUSH)
        self.appendice.connect("tcp://" + config['SERVER_HOSTNAME'] + ":"
                               + config['APPENDICE_SERVER_PORT'])

        self.bipbip_commander = self.context.socket(zmq.PUSH)
        self.bipbip_commander.connect("tcp://" + config['BIPBIP_COMMANDER_SERVER'] + ":"
                                      + config['BIPBIP_COMMANDER_PORT'])
Example #7
0
# coding: utf-8
"""Collection of Job Sorting functions to provide priority policies
"""
from __future__ import unicode_literals, print_function
from oar.lib.compat import itervalues
from oar.lib import (get_logger, config)

import json

logger = get_logger("oar.kamelot")

def job_sorting_simple_priority(queue, now, jids, jobs, str_config, plt):
    priority_config = json.loads(str_config)

    # import pdb; pdb.set_trace()
    if 'WAITING_TIME_WEIGHT' in config:
        waiting_time_weight = float(priority_config['WAITING_TIME_WEIGHT'])
    else:
        waiting_time_weight = 0.0


    #
    # establish  job priori 
    #

    for job in itervalues(jobs):
        if 'priority' in job.types:
            try:
                priority = float(job.types['priority'])
            except ValueError:
                logger.warn("job priority failed to convert to float: " % job.types['priority'])
Example #8
0
import sys
import time
import re
import os
import socket
from sqlalchemy import func, distinct
from oar.lib import (db, config, get_logger, Resource, AssignedResource,
                     EventLog)
from oar.lib.compat import is_py2

if is_py2:
    from subprocess32 import (Popen, call, PIPE, TimeoutExpired)
else:
    from subprocess import (Popen, call, PIPE, TimeoutExpired)  # noqa

logger = get_logger("oar.lib.tools")

almighty_socket = None

notification_user_socket = None


def init_judas_notify_user():  # pragma: no cover

    logger.debug("init judas_notify_user (launch judas_notify_user.pl)")

    global notify_user_socket
    uds_name = "/tmp/judas_notify_user.sock"
    if not os.path.exists(uds_name):
        binary = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                              "judas_notify_user.pl")
Example #9
0
    "BIPBIP_COMMANDER_PORT": "6669",
    "MAX_CONCURRENT_JOBS_STARTING_OR_TERMINATING": "25",
    "DETACH_JOB_FROM_SERVER": "1",
    "LOG_FILE": "/var/log/oar.log",
}

config.setdefault_config(DEFAULT_CONFIG)

# Max number of concurrent bipbip processes
Max_bipbip_processes = int(config["MAX_CONCURRENT_JOBS_STARTING_OR_TERMINATING"])
Detach_oarexec = config["DETACH_JOB_FROM_SERVER"]

# Maximum duration a a bipbip process (after that time the process is killed)
Max_bipbip_process_duration = 30 * 60

logger = get_logger("oar.modules.bipbip_commander", forward_stderr=True)
logger.info("Start Bipbip Commander")

if "OARDIR" in os.environ:
    binpath = os.environ["OARDIR"] + "/"
else:
    binpath = "/usr/local/lib/oar/"
    os.environ["OARDIR"] = binpath
    logger.warning("OARDIR env variable must be defined, " + binpath + " is used by default")

leon_command = binpath + "leon"
bipbip_command = binpath + "bipbip"


class BipbipCommander(object):
    def __init__(self):
Example #10
0
def main():
    logger = get_logger("oar.kamelot_basic", forward_stderr=True)
    config.setdefault_config(DEFAULT_CONFIG)
    plt = Platform()
    schedule_cycle(plt)
    logger.info("That's all folks")
Example #11
0
from oar.lib import config, get_logger
from oar.kao.platform import Platform
from oar.kao.job import NO_PLACEHOLDER, JobPseudo
from oar.kao.slot import SlotSet, MAX_TIME
from oar.kao.scheduling_basic import schedule_id_jobs_ct


# Set undefined config value to default one
DEFAULT_CONFIG = {
    'HIERARCHY_LABELS': 'resource_id,network_address',
    'SCHEDULER_RESOURCE_ORDER': 'resource_id ASC',
    'SCHEDULER_JOB_SECURITY_TIME': '60',
}


logger = get_logger('oar.kamelot_basic')


def schedule_cycle(plt, queue='default'):
    now = plt.get_time()

    logger.info('Begin scheduling....', now)

    #
    # Retrieve waiting jobs
    #
    waiting_jobs, waiting_jids, nb_waiting_jobs = plt.get_waiting_jobs(queue)

    logger.info(waiting_jobs, waiting_jids, nb_waiting_jobs)

    if nb_waiting_jobs > 0:
Example #12
0
# coding: utf-8
from __future__ import unicode_literals, print_function

from oar.lib import config, get_logger

logger = get_logger("oar.kao.tools")


def fork_and_feed_stdin(cmd, timeout_cmd, nodes):
    logger.error("OAR::Tools::fork_and_feed_stdin NOT YET IMPLEMENTED")
    return True


def send_to_hulot(cmd, data):
    config.setdefault_config({"FIFO_HULOT": "/tmp/oar_hulot_pipe"})
    fifoname = config["FIFO_HULOT"]
    try:
        with open(fifoname, 'w') as fifo:
            fifo.write('HALT:%s\n' % data)
            fifo.flush()
    except IOError as e:
        e.strerror = 'Unable to communication with Hulot: %s (%s)' % fifoname % e.strerror
        logger.error(e.strerror)
        return 1
    return 0


def get_oar_pid_file_name(job_id):
    logger.error("get_oar_pid_file_name id not YET IMPLEMENTED")

Example #13
0
# Set undefined config value to default one
DEFAULT_CONFIG = {
    'HIERARCHY_LABELS': 'resource_id,network_address',
    'SCHEDULER_RESOURCE_ORDER': "resource_id ASC",
    'SCHEDULER_JOB_SECURITY_TIME': '60',
    'SCHEDULER_AVAILABLE_SUSPENDED_RESOURCE_TYPE': 'default',
    'FAIRSHARING_ENABLED': 'no',
    'SCHEDULER_FAIRSHARING_MAX_JOB_PER_USER': '******',
    'QUOTAS': 'no',
    'JOB_SORTING': 'default',
    'JOB_SORTING_CONFIG': ''
}


logger = get_logger("oar.kamelot")


if ('QUOTAS' in config) and (config['QUOTAS'] == 'yes'):
    if 'QUOTAS_FILE' not in config:
        config['QUOTAS_FILE'] = './quotas_conf.json'
    load_quotas_rules()



def karma_job_sorting(queue, now, waiting_jids, waiting_jobs, plt):

    waiting_ordered_jids = waiting_jids
    #
    # Karma job sorting (Fairsharing)
    #
Example #14
0
    'SCHEDULER_FAIRSHARING_MAX_JOB_PER_USER': '******',
    'RESERVATION_WAITING_RESOURCES_TIMEOUT': '300',
    'SCHEDULER_TIMEOUT': '10',
    'ENERGY_SAVING_INTERNAL': 'no',
    'SCHEDULER_NODE_MANAGER_WAKEUP_TIME': 1
}

config.setdefault_config(DEFAULT_CONFIG)


# waiting time when a reservation has not all of its nodes
reservation_waiting_timeout = int(config['RESERVATION_WAITING_RESOURCES_TIMEOUT'])

config['LOG_FILE'] = ':stderr:'
# Log category
logger = get_logger('oar.kao.meta_sched')

exit_code = 0

# stock the job ids that where already send to almighty
to_launch_jobs_already_treated = {}

# order_part = config['SCHEDULER_RESOURCE_ORDER']

##########################################################################
# Initialize Gantt tables with scheduled reservation jobs, Running jobs,
# toLaunch jobs and Launching jobs;
##########################################################################


def gantt_init_with_running_jobs(plt, initial_time_sec, job_security_time):
Example #15
0
File: kao.py Project: fr0uty/oartm
#!/usr/bin/env python
# coding: utf-8
from __future__ import unicode_literals, print_function

from oar.lib import get_logger
from oar.kao.meta_sched import meta_schedule

logger = get_logger("oar.kao")


def main():
    logger.info("Starting Kao Meta Scheduler")
    meta_schedule()

if __name__ == '__main__':  # pragma: no cover
    logger = get_logger("oar.kao", forward_stderr=True)
    main()
Example #16
0
    "SERVER_PORT": 6666,
    "ENERGY_SAVING_INTERNAL": "no",
    "SQLALCHEMY_CONVERT_UNICODE": True,
    "SQLALCHEMY_ECHO": False,
    "SQLALCHEMY_MAX_OVERFLOW": None,
    "SQLALCHEMY_POOL_RECYCLE": None,
    "SQLALCHEMY_POOL_SIZE": None,
    "SQLALCHEMY_POOL_TIMEOUT": None,
    "TAKTUK_CMD": "/usr/bin/taktuk -t 30 -s",
}

# config.clear()
# config.update(BATSIM_DEFAULT_CONFIG)

config["LOG_FILE"] = "/tmp/batsim.log"
logger = get_logger("oar.batsim")


def monkeypatch_oar_lib_tools():
    global orig_func

    orig_func["init_judas_notify_user"] = oar.lib.tools.init_judas_notify_user
    orig_func["create_almighty_socket"] = oar.lib.tools.create_almighty_socket
    orig_func["notify_almighty"] = oar.lib.tools.notify_almighty
    orig_func["notify_tcp_socket"] = oar.lib.tools.notify_tcp_socket
    orig_func["notify_user"] = oar.lib.tools.notify_user

    oar.lib.tools.init_judas_notify_user = lambda: None
    oar.lib.tools.create_almighty_socket = lambda: None
    oar.lib.tools.notify_almighty = lambda x: len(x)
    oar.lib.tools.notify_tcp_socket = lambda addr, port, msg: len(msg)
Example #17
0
File: node.py Project: fr0uty/oartm
# coding: utf-8
from __future__ import unicode_literals, print_function

from sqlalchemy import func
from oar.lib import (db, Resource, GanttJobsResource, GanttJobsPrediction, Job,
                     EventLog, EventLogHostname, MoldableJobDescription,
                     get_logger)

logger = get_logger("oar.kao")


def search_idle_nodes(date):
    result = db.query(Resource.network_address)\
               .filter(Resource.id == GanttJobsResource.resource_id)\
               .filter(GanttJobsPrediction.start_time <= date)\
               .filter(Resource.network_address != '')\
               .filter(Resource.type == 'default')\
               .filter(GanttJobsPrediction.moldable_id == GanttJobsResource.moldable_id)\
               .group_by(Resource.network_address)\
               .all()

    busy_nodes = {}
    for network_address in result:
        if network_address not in busy_nodes:
            busy_nodes[network_address] = True

    result = db.query(Resource.network_address,
                      func.max(Resource.last_job_date))\
               .filter(Resource.state == 'Alive')\
               .filter(Resource.network_address != '')\
               .filter(Resource.type == 'default')\
Example #18
0
# coding: utf-8
"""Extra metascheduling functions which can be called between each queue handling
"""
from __future__ import unicode_literals, print_function

from oar.lib import (db, get_logger, config, Resource)

logger = get_logger("oar.extra_metasched")


def extra_metasched_foo(prev_queue, plt, scheduled_jobs, all_slot_sets,
                        job_security_time, queue, initial_time_sec,
                        extra_metasched_config):

    if prev_queue is None:
        # set first resource deployable
        first_id = db.query(Resource).first().id
        db.query(Resource).filter(Resource.id == first_id)\
                          .update({Resource.deploy: 'YES'}, synchronize_session=False)
        db.commit()
Example #19
0
from codecs import open
from copy import deepcopy
from tempfile import mkstemp
from oar.kao.job import JobPseudo
from oar.kao.slot import Slot, SlotSet
from oar.lib.interval import equal_itvs
from oar.kao.scheduling import (schedule_id_jobs_ct,
                                set_slots_with_prev_scheduled_jobs)
import oar.kao.quotas as qts
import oar.lib.resource as rs

from oar.lib import config, get_logger
# import pdb

config['LOG_FILE'] = ':stderr:'
logger = get_logger("oar.test")

"""
    quotas[queue, project, job_type, user] = [int, int, float];
                                               |    |     |
              maximum used resources ----------+    |     |
              maximum number of running jobs -------+     |
              maximum resources times (hours) ------------+
"""


def compare_slots_val_ref(slots, v):
    sid = 1
    i = 0
    while True:
        slot = slots[sid]
Example #20
0
# retrieve umask and set new one
old_umask = os.umask(0o022)

# TODO
# my $oldfh = select(STDERR); $| = 1; select($oldfh);
# $oldfh = select(STDOUT); $| = 1; select($oldfh);


# Everything is run by oar user (The real uid of this process.)
#os.environ['OARDO_UID'] = str(os.geteuid())

# TODO
# my $Redirect_STD_process = OAR::Modules::Judas::redirect_everything();

logger = get_logger("oar.modules.almighty", forward_stderr=True)
logger.info('Start Almighty')
# TODO
# send_log_by_email("Start OAR server","[Almighty] Start Almighty");

if 'OARDIR' in os.environ:
    binpath = os.environ['OARDIR'] + '/'
else:
    binpath = '/usr/local/lib/oar/'
    logger.warning("OARDIR env variable must be defined, " + binpath + " is used by default")

meta_sched_command = config['META_SCHED_CMD']
m = re.match(r'^\/', meta_sched_command)
if not m:
    meta_sched_command = binpath + meta_sched_command
    
Example #21
0
# Set undefined config value to default one
DEFAULT_CONFIG = {
    'SERVER_HOSTNAME': 'localhost',
    'SERVER_PORT': '6666'
}
servermaxconnect = 100


# This timeout is used by appendice to prevent a client to block
# reception by letting a connection opened
# should be left at a positive value
appendice_connection_timeout = 5

config.setdefault_config(DEFAULT_CONFIG)
logger = get_logger('oar.modules.appendice', forward_stderr=True)
logger.info('Start appendice')

if 'OARDIR' in os.environ:
    binpath = os.environ['OARDIR'] + '/'
else:
    binpath = '/usr/local/lib/oar/'
    logger.warning("OARDIR env variable must be defined, " + binpath + " is used by default")


server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind((config['SERVER_HOSTNAME'], config['SERVER_PORT']))
server.listen(servermaxconnect)

while True: