예제 #1
0
파일: JobCmds.py 프로젝트: utsdab/usr
    def processObject(self, obj):
        """Operate on the provided job object."""

        # ask the user if we should continue
        if not obj.pre(self, "Change %s of the job?" % self.opts.key):
            return

        # represent value in type appropriate to member; it will be packed for transmission
        if self.opts.key in self.IntListAttrs:
            value = [int(v) for v in stringutil.str2list(self.opts.value)]
        elif self.opts.key in self.StrListAttrs:
            value = stringutil.str2list(self.opts.value)
        else:
            value = self.opts.value

        # try to run the operation
        query.jattr(obj, key=self.opts.key, value=value)
        obj.post(self, "%s changed" % self.opts.key)
예제 #2
0
    def processObject(self, obj):
        """Operate on the provided job object."""

        # ask the user if we should continue
        if not obj.pre(self, "Change %s of the job?" % self.opts.key):
            return

        # represent value in type appropriate to member; it will be packed for transmission
        if self.opts.key in self.IntListAttrs:
            value = [int(v) for v in stringutil.str2list(self.opts.value)]
        elif self.opts.key in self.StrListAttrs:
            value = stringutil.str2list(self.opts.value)
        else:
            value = self.opts.value

        # try to run the operation
        query.jattr(obj, key=self.opts.key, value=value)
        obj.post(self, "%s changed" % self.opts.key)
예제 #3
0
파일: test.py 프로젝트: utsdab/usr
def test_job_ops(job):
    print "chcrews"
    tq.chcrews(job, crews=["newcrew1", "newcrew2"])
    print "chpri"
    tq.chpri(job, priority=123)
    print "jattr"
    tq.jattr(job, key="comment", value="new comment")
    print "pause"
    tq.pause(job)
    print "unpause"
    tq.unpause(job)
    print "lock"
    tq.lock(job)
    print "unlock"
    tq.unlock(job)
    print "interrupt"
    try:
        tq.interrupt(job)
    except EngineClient.TransactionError, err:
        print "received exception for interrupting job - we should fix that"
예제 #4
0
    def run(self, task_owner, engine, priority, alf_script, task_uuid, unique_id, dep_file, operation, tactic_file, task_str, count, **kwargs):
        task_id = self.request.id
        self.task_uuid = task_uuid

        self.error_type = None

        self.task_owner = task_owner
        self.unique_id = unique_id
        self.dep_file = dep_file
        self.operation = operation
        self.alf_script = alf_script
        self.tactic_file = tactic_file
        self.task_str = task_str

        # First try 
        if count == 0:
            self.log.info("[{0}]: Inserting into the db: spool".format(task_id))
            self.db_insert_task(self.task_uuid)
        # Retry
        else:
           #6. Retry log
           self.log.info("[{0}]: Retry # {1}, task_uuid {2}".format(task_id, count, self.task_uuid)) 

        try:
            cmd = "task_queue.rfm.tractor.Spool(['--user={0}', --engine={1}', '--priority={2}', '{3}'])".format(task_owner, engine, priority, alf_script, tactic_file, task_str)
            self.log.info("[{0}]: Start command: {1}".format(task_id, cmd))

            # Execute `cmd`
            import paramiko

            ssh = paramiko.SSHClient()
            ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
            ssh.connect('119.81.131.43', port=7001, username='******', password='******')

            cmd = "{0} {1} {2};chown render:render {1};chmod 777 {1}".format(FIX_MAYA_FILE_BIN, self.tactic_file, self.task_str)
            print >>sys.stderr, "Executing cmd: ", cmd

            stdin, stdout, stderr = ssh.exec_command(cmd)

            stdout_msg = stdout.readlines()
            stderr_msg = stderr.readlines()

            print >>sys.stderr, 'STDOUT: ', stdout_msg
            print >>sys.stderr, 'STDERR: ', stderr_msg
            
            self.log.info("[{0}]: FIX_MAYA_FILE_BIN stdout: {1}".format(task_id, stdout_msg))
            self.log.info("[{0}]: FIX_MAYA_FILE_BIN stderr: {1}".format(task_id, stderr_msg))

            import task_queue.rfm.tractor
            import json
            retval = task_queue.rfm.tractor.Spool(['--user={0}'.format(task_owner), '--engine={0}'.format(engine), '--priority={0}'.format(priority), '{0}'.format(alf_script)])
            # Get the jid
            task_jid = json.loads(retval).get('jid')

            # Connect to the tractor engine in China, for now via the proxy in sgp
            tq.setEngineClientParam(hostname="119.81.131.43", port=1503, user=task_owner, debug=True)
            # Add the upload task ID as metadata to the task
            metadata = task_id.split('-')[1]
            tq.jattr('jid={0}'.format(task_jid), key='metadata', value=metadata)
            tq.closeEngineClient()
            self.log.info("[{0}]: Updated {1} with metadata: {2}".format(task_id, task_jid, metadata))

            self.log.info("[{0}]: Finish command: {1}".format(task_id, cmd))

            #db_update_task
            self.log.info("[{0}]: Updating the db: spool".format(task_id))
            self.db_update_task(self.task_uuid, retval=retval)

            return task_jid

            '''
            raise Exception("foo bar")
            '''
        except Exception as e:
            #8. DB update
            self.db_update_task(self.task_uuid, 'retry', count=count, exc=e.message)
            self.retry(args=[task_owner, engine, priority, alf_script, task_uuid, unique_id, dep_file, operation, tactic_file, task_str, count+1], exc=e, kwargs=kwargs)

        """
예제 #5
0
    def run(self, task_owner, engine, priority, alf_script, task_uuid,
            unique_id, dep_file, operation, tactic_file, task_str, count,
            **kwargs):
        task_id = self.request.id
        self.task_uuid = task_uuid

        self.error_type = None

        self.task_owner = task_owner
        self.unique_id = unique_id
        self.dep_file = dep_file
        self.operation = operation
        self.alf_script = alf_script
        self.tactic_file = tactic_file
        self.task_str = task_str

        # First try
        if count == 0:
            self.log.info(
                "[{0}]: Inserting into the db: spool".format(task_id))
            self.db_insert_task(self.task_uuid)
        # Retry
        else:
            #6. Retry log
            self.log.info("[{0}]: Retry # {1}, task_uuid {2}".format(
                task_id, count, self.task_uuid))

        try:
            cmd = "task_queue.rfm.tractor.Spool(['--user={0}', --engine={1}', '--priority={2}', '{3}'])".format(
                task_owner, engine, priority, alf_script, tactic_file,
                task_str)
            self.log.info("[{0}]: Start command: {1}".format(task_id, cmd))

            # Execute `cmd`
            import paramiko

            ssh = paramiko.SSHClient()
            ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
            ssh.connect('119.81.131.43',
                        port=7001,
                        username='******',
                        password='******')

            cmd = "{0} {1} {2};chown render:render {1};chmod 777 {1}".format(
                FIX_MAYA_FILE_BIN, self.tactic_file, self.task_str)
            print >> sys.stderr, "Executing cmd: ", cmd

            stdin, stdout, stderr = ssh.exec_command(cmd)

            stdout_msg = stdout.readlines()
            stderr_msg = stderr.readlines()

            print >> sys.stderr, 'STDOUT: ', stdout_msg
            print >> sys.stderr, 'STDERR: ', stderr_msg

            self.log.info("[{0}]: FIX_MAYA_FILE_BIN stdout: {1}".format(
                task_id, stdout_msg))
            self.log.info("[{0}]: FIX_MAYA_FILE_BIN stderr: {1}".format(
                task_id, stderr_msg))

            import task_queue.rfm.tractor
            import json
            retval = task_queue.rfm.tractor.Spool([
                '--user={0}'.format(task_owner), '--engine={0}'.format(engine),
                '--priority={0}'.format(priority), '{0}'.format(alf_script)
            ])
            # Get the jid
            task_jid = json.loads(retval).get('jid')

            # Connect to the tractor engine in China, for now via the proxy in sgp
            tq.setEngineClientParam(hostname="119.81.131.43",
                                    port=1503,
                                    user=task_owner,
                                    debug=True)
            # Add the upload task ID as metadata to the task
            metadata = task_id.split('-')[1]
            tq.jattr('jid={0}'.format(task_jid),
                     key='metadata',
                     value=metadata)
            tq.closeEngineClient()
            self.log.info("[{0}]: Updated {1} with metadata: {2}".format(
                task_id, task_jid, metadata))

            self.log.info("[{0}]: Finish command: {1}".format(task_id, cmd))

            #db_update_task
            self.log.info("[{0}]: Updating the db: spool".format(task_id))
            self.db_update_task(self.task_uuid, retval=retval)

            return task_jid
            '''
            raise Exception("foo bar")
            '''
        except Exception as e:
            #8. DB update
            self.db_update_task(self.task_uuid,
                                'retry',
                                count=count,
                                exc=e.message)
            self.retry(args=[
                task_owner, engine, priority, alf_script, task_uuid, unique_id,
                dep_file, operation, tactic_file, task_str, count + 1
            ],
                       exc=e,
                       kwargs=kwargs)
        """