Example #1
0
    def start_job(self, context, job):
        LOG.info('start job')
        central_dbapi = dbapi.DBAPI()
        central_dbapi.update_task_status(current_status='queued', owner=CONF.host,
                                         status='processing', method='job', target=job['name'])
        cluster = job['cluster']
        result_map = client('job', cluster)
        LOG.info(result_map)
        all_result = 0
        msg = ''
        for fabscript, status in result_map['fabscript_map'].items():
            result = status['status'] + status['task_status']
            all_result += result
            if result == 0:
                msg += 'Success {0}.\n'.format(fabscript)
            else:
                msg += 'Failed {0}: status={1}, task_status={2}.\n'.format(
                    fabscript, status['status'], status['task_status'])

        if all_result == 0:
            central_dbapi.update_task_status(current_status='processing', active=False, msg=msg,
                                             status='completed', method='job', target=job['name'])
        else:
            central_dbapi.update_task_status(current_status='processing', active=False, msg=msg,
                                             status='error', method='job', target=job['name'])

        LOG.info('end job')
        return
Example #2
0
    def setup(self, context, arg):
        LOG.info('start setup: {0}'.format(arg))
        random_wait = arg.get('random_wait', 0)
        if random_wait > 0:
            wait_time = random.randint(0, random_wait)
            time.sleep(wait_time)

        result_map = client('setup')

        setup_status = 0
        for cluster in result_map.values():
            for result in cluster['fabscript_map'].values():
                setup_status += result['status']

        result_map = json.dumps(result_map)

        agent_data = {
            'agent_type': 'agent',
            'host': CONF.host,
            'setup_status': setup_status,
            'setup_timestamp': datetime.datetime.utcnow(),
            'fabscript_map': result_map,
        }

        self.centralapi.notify_setup(agent_data)
Example #3
0
    def check(self, context):
        LOG.info('start check')

        result_map = client('check')
        setup_status = 0
        check_status = 0
        for cluster in result_map.values():
            for result in cluster['fabscript_map'].values():
                print result
                setup_status += result['status']
                check_status += result['check_status']

        result_map = json.dumps(result_map)

        agent_data = {
            'agent_type': 'agent',
            'host': CONF.host,
            'status': 'active',
            'check_status': check_status,
            'check_timestamp': datetime.datetime.utcnow(),
            'setup_status': setup_status,
            'fabscript_map': result_map,
        }

        self.centralapi.notify_check(agent_data)
Example #4
0
    def setup(self, context, arg):
        LOG.info('start setup: {0}'.format(arg))
        random_wait = arg.get('random_wait', 0)
        if random_wait > 0:
            wait_time = random.randint(0, random_wait)
            time.sleep(wait_time)

        result_map = client('setup')

        setup_status = 0
        for cluster in result_map.values():
            for result in cluster['fabscript_map'].values():
                setup_status += result['status']

        result_map = json.dumps(result_map)

        agent_data = {
            'agent_type': 'agent',
            'host': CONF.host,
            'setup_status': setup_status,
            'setup_timestamp': datetime.datetime.utcnow(),
            'fabscript_map': result_map,
        }

        self.centralapi.notify_setup(agent_data)
Example #5
0
    def check(self, context):
        LOG.info('start check')

        result_map = client('check')
        setup_status = 0
        check_status = 0
        for cluster in result_map.values():
            for result in cluster['fabscript_map'].values():
                print result
                setup_status += result['status']
                check_status += result['check_status']

        result_map = json.dumps(result_map)

        agent_data = {
            'agent_type': 'agent',
            'host': CONF.host,
            'status': 'active',
            'check_status': check_status,
            'check_timestamp': datetime.datetime.utcnow(),
            'setup_status': setup_status,
            'fabscript_map': result_map,
        }

        self.centralapi.notify_check(agent_data)
Example #6
0
    def start_job(self, context, job):
        LOG.info("start job")
        central_dbapi = dbapi.DBAPI()
        central_dbapi.update_task_status(
            current_status="queued", owner=CONF.host, status="processing", method="job", target=job["name"]
        )
        cluster = job["cluster"]
        result_map = client("job", cluster)
        LOG.info(result_map)
        all_result = 0
        msg = ""
        for fabscript, status in result_map["fabscript_map"].items():
            result = status["status"] + status["task_status"]
            all_result += result
            if result == 0:
                msg += "Success {0}.\n".format(fabscript)
            else:
                msg += "Failed {0}: status={1}, task_status={2}.\n".format(
                    fabscript, status["status"], status["task_status"]
                )

        if all_result == 0:
            central_dbapi.update_task_status(
                current_status="processing", active=False, msg=msg, status="completed", method="job", target=job["name"]
            )
        else:
            central_dbapi.update_task_status(
                current_status="processing", active=False, msg=msg, status="error", method="job", target=job["name"]
            )

        LOG.info("end job")
        return