示例#1
0
    def status(self, task_id, params, get_log=True):
        client = common.ssh_connect_with_retry(
            params['host'],
            params['port'],
            params['login'],
            pkey=self._config.get('pkey'),
            key_filename=self._config.get('key_filename')
            or self._config.get('privateKey'),
            login_cmd=params['login_cmd'])

        if 'container_id' in params:
            exit_status, stdout, stderr = common.run_docker_command(
                client,
                'inspect -f {{.State.Status}} %s' % params['container_id'])
        else:
            exit_status, stdout, stderr = common.run_command(
                client, 'kill -0 -%d' % params['pgid'])

        if get_log:
            common.update_log(task_id, client, params['log_dir'],
                              self._config.get('callback_url'))

        client.close()
        if exit_status != 0:
            return "dead"

        return "running"
示例#2
0
    def status(self, task_id, params, get_log=True):  # pylint: disable=arguments-differ
        ssh_client = get_client(params, self._config)
        if 'container_id' in params:
            exit_status, _, _ = common.run_docker_command(
                ssh_client, 'inspect -f {{.State.Status}} %s' % params['container_id'])
        else:
            exit_status, _, _ = common.run_command(ssh_client, 'kill -0 -%d' % params['pgid'])

        if get_log:
            common.update_log(task_id, ssh_client, params['log_dir'], self._config.get('callback_url'))

        ssh_client.close()
        if exit_status != 0:
            return "dead"
        return "running"