예제 #1
0
    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))
예제 #2
0
    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))