#!/usr/bin/env python

import sys
import argparse
from soma_workflow import connection

parser = argparse.ArgumentParser(
    'Kill soma-workflow servers on a given computing resource')
parser.add_argument('-r', '--resource', help='computing resource id')
parser.add_argument('-u', '--user', help='user name')
parser.add_argument('-p', '--password', help='password')
parser.add_argument('-c', '--clear', action='store_true',
                    help='clear (remove) SQLite database: '
                    'all workflows and jobs will be lost.')

options = parser.parse_args(sys.argv[1:])

resource_id = options.resource
login = options.user
passwd = options.password
clear_db = options.clear

connection.RemoteConnection.kill_remote_servers(
    resource_id, login=login, passwd=passwd, clear_db=clear_db)
