Example #1
0
def spool_file(name):
    """
    Form a path to the PBS spool directory with name as the last element.

    :param name: energy file name in format <jobid>.energy.
    :type name: str
    :returns: path to RUR/energy file in format PBS_HOME/spool/<jobid>.energy.
    """
    home = _pbs_conf("PBS_HOME")
    if home is None:
        raise BackendError("PBS_HOME not found")
    return os.path.join(home, "spool", name)
Example #2
0
def launch(jid, args):
    """
    Run capmc and return the structured output.

    :param jid: job id
    :type jid: str
    :param args: arguments for capmc command
    :type args: str
    :returns: capmc output in json format.
    """
    import json

    # full path to capmc given by Cray
    cmd = os.path.join(os.path.sep, 'opt', 'cray', 'capmc', 'default', 'bin',
                       'capmc')
    if not os.path.exists(cmd):
        cmd = "capmc"  # should be in PATH then
    cmd = cmd + " " + args
    fail = ""

    pbs.logjobmsg(jid, "launch: " + cmd)
    cmd_run = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
    (cmd_out, cmd_err) = cmd_run.communicate()
    exitval = cmd_run.returncode
    if exitval != 0:
        fail = "%s: exit %d" % (cmd, exitval)
    else:
        pbs.logjobmsg(jid, "launch: finished")

    try:
        out = json.loads(cmd_out)
    except Exception:
        out = None
    try:
        err = cmd_err.splitlines()[0]  # first line only
    except Exception:
        err = ""
    if out is not None:
        errno = out["e"]
        msg = out["err_msg"]
        if errno != 0 or (len(msg) > 0 and msg != "Success"):
            fail = "output: e=%d err_msg='%s'" % (errno, msg)
    if len(err) > 0:
        pbs.logjobmsg(jid, "stderr: %s" % err.strip())

    if len(fail) > 0:
        pbs.logjobmsg(jid, fail)
        raise BackendError(fail)
    return out
Example #3
0
This module is used for Cray systems.
"""

import os
import stat
import time
import random
from subprocess import Popen, PIPE
from pbs.v1._pmi_types import BackendError
import pbs
from pbs.v1._pmi_utils import _running_excl, _pbs_conf, _get_vnode_names, \
    _svr_vnode

pbsexec = _pbs_conf("PBS_EXEC")
if pbsexec is None:
    raise BackendError("PBS_EXEC not found")


def launch(jid, args):
    """
    Run capmc and return the structured output.

    :param jid: job id
    :type jid: str
    :param args: arguments for capmc command
    :type args: str
    :returns: capmc output in json format.
    """
    import json

    # full path to capmc given by Cray