def do_qstat(self, args, arguments): """ :: Usage: qstat HOST [-a] [(--view VIEW | ATTRIBUTES...)] [--output=(dict|table)] tests via ping if the host ith the give NAME is reacahble Arguments: VIEW the name of the view [default: default]. HOST Name of the machine to test Options: -v verbose mode """ if arguments["HOST"]: host = arguments["HOST"] Console.info("trying to reach {0}".format(host)) if len(arguments['ATTRIBUTES']) == 0 and not arguments['--view']: arguments['--view'] = True arguments['VIEW'] = 'default' # pprint(arguments) r = {} try: pbs = OpenPBS(deploy=True) if arguments["-a"]: r = pbs.qstat(host, user=False) else: r = pbs.qstat(host) Console.info("machine " + host + " has been found. ok.") if len(arguments['ATTRIBUTES'] ) != 0 and not arguments['--view']: r = OpenPBS.list(r, arguments['ATTRIBUTES']) elif arguments['--view']: view = arguments['VIEW'] attributes = pbs.data.get( "cloudmesh.pbsview.{0}".format(view)) r = OpenPBS.list(r, attributes) except Exception, e: Console.error("machine " + host + " not reachable. error.") print(e) if len(r.keys()) == 0: Console.info("No jobs found") else: if arguments['--output'] == 'dict' or None: pprint(r) else: print(dict_printer(r))
def get(self, host): """gets all jobs""" pbs = OpenPBS(deploy=True) manager = pbs.manager(host) r = pbs.qstat(host, user=False, format="dict") return r
qsub = False db = DbPBS() db.clear() db.info() db.update(host="india", user=False) print(db.list(output="table")) print(db.list(output="csv")) print(db.list(output="dict")) print(db.list(output="yaml")) banner("user") db.clear() db.update(host="india") print(db.list(output="table")) if qsub: banner('qsub') pbs = OpenPBS() jobname = "job-" + pbs.jobid + ".pbs" host = "india" script_template = pbs.read_script("etc/job.pbs") print(script_template) r = db.qsub(jobname, host, 'echo "Hello"', template=script_template) pprint(r) banner('variable list') pprint(OpenPBS.variable_list(r))
def __init__(self, filename=None): self.pbs = OpenPBS(deploy=True) self.open()
def setup(self): # HEADING() self.pbs = OpenPBS(deploy=True) self.manager = self.pbs.manager(self.host)