예제 #1
0
파일: client_utils.py 프로젝트: ido/cobalt
def cb_geometry(option,opt_str,value,parser,*args):
    """
    This callback will validate the geometry value and store it
    """
    opts = args[0]
    try:
        geom_str = ''
        geom_str = parse_geometry_string(value)
    except:
        logger.error("Invalid geometry entered: %s" % geom_str)
        sys.exit(1)
    setattr(parser.values,option.dest,geom_str) # set the option
    opts[option.dest] = value
예제 #2
0
def cb_geometry(option, opt_str, value, parser, *args):
    """
    This callback will validate the geometry value and store it
    """
    opts = args[0]
    try:
        geom_str = ''
        geom_str = parse_geometry_string(value)
    except:
        logger.error("Invalid geometry entered: %s" % geom_str)
        sys.exit(1)
    setattr(parser.values, option.dest, geom_str)  # set the option
    opts[option.dest] = value
예제 #3
0
파일: qalter.py 프로젝트: ido/cobalt
        else:
            jobdata = None
            try:
                cqm = ComponentProxy("queue-manager", defer=False)
                jobdata = cqm.get_jobs(spec)
            except ComponentLookupError:
                print >> sys.stderr, "Failed to connect to queue manager"
                sys.exit(1)
            for job in jobdata:
                try:
                    Cobalt.Util.validate_geometry(opts["geometry"], int(job["nodes"]))
                except JobValidationError as err:
                    print >> sys.stderr, err.message
                    print >> sys.stderr, "Jobs not altered."
                    sys.exit(1)
            updates.update({"geometry": parse_geometry_string(opts["geometry"])})

    if str(opts["attrs"]).lower() == "none":
        updates.update({"attrs": {}})

    elif opts["attrs"] is not False:
        attrs = {}
        newoptsattrs = {}
        for attr in opts["attrs"].split(":"):
            if len(attr.split("=")) == 2:
                key, value = attr.split("=")
                attrs.update({key: value})
                newoptsattrs.update({key: value})
            elif len(attr.split("=")) == 1:
                if attr[:3] == "no_":
                    attrs.update({attr[3:]: "false"})
예제 #4
0
        else:
            jobdata = None
            try:
                cqm = ComponentProxy("queue-manager", defer=False)
                jobdata = cqm.get_jobs(spec)
            except ComponentLookupError:
                print >> sys.stderr, "Failed to connect to queue manager"
                sys.exit(1)
            for job in jobdata:
                try:
                    Cobalt.Util.validate_geometry(opts['geometry'], int(job['nodes']))
                except JobValidationError as err:
                    print >> sys.stderr, err.message
                    print >> sys.stderr, "Jobs not altered."
                    sys.exit(1)
            updates.update({'geometry': parse_geometry_string(opts['geometry'])})

    if str(opts['attrs']).lower() == 'none':
        updates.update({'attrs':{}})

    elif opts['attrs'] is not False:
        attrs = {}
        newoptsattrs = {}
        for attr in opts["attrs"].split(":"):
            if len(attr.split("=")) == 2:
                key, value = attr.split("=")
                attrs.update({key:value})
                newoptsattrs.update({key:value})
            elif len(attr.split("=")) == 1:
                if attr[:3] == "no_":
                    attrs.update({attr[3:]:"false"})
예제 #5
0
        ]
        for auth_user in jobspec['user_list']:
            try:
                pwd.getpwnam(auth_user)
            except KeyError:
                logger.error("user %s does not exist." % auth_user)
                sys.exit(1)
            except Exception:
                raise
    else:
        jobspec['user_list'] = [user]
    if user not in jobspec['user_list']:
        jobspec['user_list'].insert(0, user)

    if opts['geometry']:
        jobspec['geometry'] = parse_geometry_string(opts['geometry'])

    jobspec.update({
        'user': user,
        'outputdir': opts['cwd'],
        'walltime': opts['time'],
        'jobid': '*',
        'path': os.environ['PATH'],
        'mode': opts.get('mode', 'co'),
        'kernel': opts['kernel'],
        'queue': opts['queue'],
        'procs': opts.get('proccount'),
        'nodes': opts.get('nodecount')
    })
    if opts['outputprefix']:
        if opts['outputprefix'][0] == '/':
예제 #6
0
        jobspec['user_list'] = [auth_user for auth_user in opts['user_list'].split(':')]  
        for auth_user in jobspec['user_list']:
            try:
                pwd.getpwnam(auth_user)
            except KeyError:
                logger.error("user %s does not exist." % auth_user)
                sys.exit(1)
            except Exception:
                raise
    else:
        jobspec['user_list'] = [user]
    if user not in jobspec['user_list']:
        jobspec['user_list'].insert(0, user)

    if opts['geometry']:
        jobspec['geometry'] = parse_geometry_string(opts['geometry'])

    jobspec.update({'user':user, 'outputdir':opts['cwd'], 'walltime':opts['time'],
                    'jobid':'*', 'path':os.environ['PATH'], 'mode':opts.get('mode', 'co'),
                    'kernel':opts['kernel'], 'queue':opts['queue'],
                    'procs':opts.get('proccount'), 'nodes':opts.get('nodecount')})
    if opts['outputprefix']:
        if opts['outputprefix'][0] == '/':
            jobspec.update({'outputpath':"%s.output" % (opts['outputprefix']),
                            'errorpath':"%s.error" % (opts['outputprefix']),
                            'cobalt_log_file':"%s.cobaltlog" % (opts['outputprefix'])})
        else:
            jobspec.update({'outputpath':"%s/%s.output" % (opts['cwd'],
                                                           opts['outputprefix']),
                            'errorpath':"%s/%s.error" % (opts['cwd'], opts['outputprefix']),
                            'cobalt_log_file':"%s/%s.cobaltlog" % (opts['cwd'], opts['outputprefix'])})