Example #1
0
 def run(self, args):
     """Run 'clean' subcommand."""
     optparser = CleanOptions(go_args=args, envvar_prefix=self.envvar_prefix, usage=self.usage_txt)
     try:
         pbs = rm_pbs.Pbs(optparser)
         state = pbs.state()
         labels = hc.known_cluster_labels()
         rm_master = rm_pbs.master_hostname()
         info = hc.mk_cluster_info_dict(labels, state, master=rm_master)
         hc.clean_cluster_info(rm_master, info)
     except StandardError as err:
         fancylogger.setLogFormat(fancylogger.TEST_LOGGING_FORMAT)
         fancylogger.logToScreen(enable=True)
         _log.raiseException(err.message)
Example #2
0
    def run(self, args):
        """Run 'clean' subcommand."""
        optparser = CleanOptions(go_args=args, envvar_prefix=self.envvar_prefix, usage=self.usage_txt)
        try:
            pbs = rm_pbs.Pbs(optparser)
            state = pbs.state()
            labels = hc.known_cluster_labels()
            rm_master = rm_pbs.master_hostname()
            info = hc.mk_cluster_info_dict(labels, state, master=rm_master)
            hc.clean_cluster_info(rm_master, info)
        except StandardError as err:
            self._log_and_raise(err)

        return 0
Example #3
0
    def run(self, args):
        """Run 'list' subcommand."""
        optparser = ListOptions(go_args=args, envvar_prefix=self.envvar_prefix, usage=self.usage_txt)
        try:
            pbs = rm_pbs.Pbs(optparser)
            state = pbs.state()
            labels = hc.known_cluster_labels()
            info = hc.mk_cluster_info_dict(labels, state)
            if not info:
                print 'No jobs found'
                sys.exit(0)

            headers = ['Cluster label', 'Job ID', 'State', 'Hosts']
            info_rows = format_list_rows(info)
            print ht.format_table(info_rows, headers)
        except StandardError as err:
            self._log_and_raise(err)

        return 0
Example #4
0
    def run(self, args):
        """Run 'list' subcommand."""
        optparser = ListOptions(go_args=args, envvar_prefix=self.envvar_prefix, usage=self.usage_txt)
        try:
            pbs = rm_pbs.Pbs(optparser)
            state = pbs.state()
            labels = hc.known_cluster_labels()
            info = hc.mk_cluster_info_dict(labels, state)
            if not info:
                print 'No jobs found'
                sys.exit(0)

            headers = ['Cluster label', 'Job ID', 'State', 'Hosts']
            info_rows = format_list_rows(info)
            print ht.format_table(info_rows, headers)
        except StandardError as err:
            fancylogger.setLogFormat(fancylogger.TEST_LOGGING_FORMAT)
            fancylogger.logToScreen(enable=True)
            _log.raiseException(err)
        return 0
Example #5
0
 def test_mk_cluster_info_dict(self):
     jobs = [PbsJob('123', 'R', 'host1'), PbsJob('abc', 'Q', '')]
     expected = [hc.ClusterInfo('banana', '123', jobs[0]), hc.ClusterInfo('apple', 'abc', jobs[1])]
     with patch('hod.cluster.cluster_jobid', side_effect=lambda lbl: dict(banana='123', apple='abc')[lbl]):
         self.assertEqual(expected, hc.mk_cluster_info_dict(['banana', 'apple'], jobs))
Example #6
0
 def test_mk_cluster_info_dict(self):
     jobs = [PbsJob('123', 'R', 'host1'), PbsJob('abc', 'Q', '')]
     expected = [hc.ClusterInfo('banana', '123', jobs[0]), hc.ClusterInfo('apple', 'abc', jobs[1])]
     with patch('hod.cluster.cluster_jobid', side_effect=lambda lbl: dict(banana='123', apple='abc')[lbl]):
         self.assertEqual(expected, hc.mk_cluster_info_dict(['banana', 'apple'], jobs))