Beispiel #1
0
def job_status(db, data):
    if data is None:
        jobs = db.jobs
        if jobs.find().count() > 0:
            utils.print_title('Jobs')
            rows = [['name', 'module', 'status', 'completed']]
            for job in jobs.find():
                total, completed = completed_fragments(db, job['_id'])
                rows.append([job['name'], job['module'], job['status'], '{0}/{1}'.format(completed, total)])
            utils.print_table(rows)

        else:
            print 'No jobs in database'
Beispiel #2
0
def status(db, data):
    command_queue = db.master_commands.find()
    if command_queue.count() > 0:
        utils.print_title('Pending commands')
        for command in command_queue:
            print('{0: <20}'.format(command['command']))
    else:
        print('No pending commands for master')

    jobs = db.jobs.find()
    if jobs.count() > 0:
        print 
        utils.print_title('Jobs')
        for job in jobs:
            print(job['name'])
    else:
        print 'No jobs in database'
Beispiel #3
0
def fragment_status(db, data):
    fragments = db.fragments.find().sort([('name' , 1)])
    if fragments.count() > 0:
        utils.print_title('Fragments')
        rows = [['fragment', 'job', 'slave', 'status', 'progress']]
        for fragment in fragments:
            job = db.jobs.find_one({'_id': fragment['job']})
            if job is not None:
                slave = db.slaves.find_one({'_id': fragment['owner']})
                if slave is not None:
                    slave_name = slave['name']
                else:
                    slave_name = '-'
                rows.append([fragment['name'], job['name'], slave_name, fragment['status'], '{0} %'.format(int(fragment['progress'] * 100))])

        utils.print_table(rows)

    else:
        print 'No fragments in database'
Beispiel #4
0
def slave_status(db, data):
    if data is None:
        slaves = db.slaves.find()
    else:
        slaves = db.slaves.find({'name' : data[1:]})

    if slaves is not None:
        if slaves.count() > 0:
            utils.print_title('Slaves')
            rows = [['name', 'ip', 'status', 'fragment']]
            for slave in slaves:
                if slave['fragment'] is not None:
                    fragment = db.fragments.find_one({'_id' : slave['fragment']})
                    if fragment is not None:
                        fragment = fragment['name']
                    else:
                        fragment = '-'
                else:
                    fragment = '-'
                rows.append([slave['name'], slave['ip'], slave['status'], fragment])
            utils.print_table(rows)
        else:
            print 'No slaves on database'