当前位置: 首页>>代码示例>>Python>>正文


Python PBSQuery.getnodes方法代码示例

本文整理汇总了Python中PBSQuery.PBSQuery.getnodes方法的典型用法代码示例。如果您正苦于以下问题:Python PBSQuery.getnodes方法的具体用法?Python PBSQuery.getnodes怎么用?Python PBSQuery.getnodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PBSQuery.PBSQuery的用法示例。


在下文中一共展示了PBSQuery.getnodes方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from PBSQuery import PBSQuery [as 别名]
# 或者: from PBSQuery.PBSQuery import getnodes [as 别名]
def main():

  p = PBSQuery()
  p.new_data_structure()

  #job = p.getjob('2983215')
  #print job['substate']
  #print job.substate
  #print job.queue
  #print job.Resource_List
  #print job.Resource_List.nodes 
  #print job.Resource_List.arch 
  #print job.Variable_List.PBS_O_HOME

  l = ['np', 'status', 'state' ]
  nodes = p.getnodes(l)
  for id in nodes:
	print id

	try:
		print nodes[id].np
		print nodes[id].status.arch
		print nodes[id].status.uname
		print nodes[id].state
	except PBSError, detail:
		print detail
		pass
开发者ID:hocks,项目名称:TSCC,代码行数:29,代码来源:new_interface.py

示例2: main

# 需要导入模块: from PBSQuery import PBSQuery [as 别名]
# 或者: from PBSQuery.PBSQuery import getnodes [as 别名]
def main():
    pq = PBSQuery()
    nodedict = pq.getnodes()
    for nodename, node in sorted(nodedict.iteritems()):
        print nodename
        for k, v in node.iteritems():
            print k, v
开发者ID:prehensilecode,项目名称:qstatviewer,代码行数:9,代码来源:pqnodes.py

示例3: getData

# 需要导入模块: from PBSQuery import PBSQuery [as 别名]
# 或者: from PBSQuery.PBSQuery import getnodes [as 别名]
def getData():
    p=PBSQuery()
    nodes=p.getnodes()
    for node in nodes.keys():
        host=TorqueHost(node)
        try:
            host.setState(nodes[node]['state'])
        except:
            pass

        try:
            host.setSlots(int(nodes[node]['np'][0]))
        except:
            pass

        try:
            host.setSlotsUsed(len(nodes[node]['jobs']))
        except:
            host.setSlotsUsed(0)

        try:
            jobs=nodes[node]['status']['jobs'][0].split()
            host.setJobList(jobs)
        except:
            pass
        try:
            availmem=nodes[node]['status']['availmem'][0]
            host.setAvailMem(availmem)
        except:
            pass
        try:
            totalmem=nodes[node]['status']['totmem'][0]
            host.setTotalMem(totalmem)
        except:
            pass
        try:
            rectime=nodes[node]['status']['rectime'][0]
            host.setRecTime(rectime)
        except:
            pass
        try:
            loadave=nodes[node]['status']['loadave'][0]
            host.setLoadAve(loadave)
        except:
            pass
        try:
            netload=nodes[node]['status']['netload'][0]
            host.setNetLoad(netload)
        except:
            pass

        Hosts[host.Name] = host
开发者ID:riby,项目名称:datacenter_monitoring,代码行数:54,代码来源:TorqueStatus.py

示例4: countcpu

# 需要导入模块: from PBSQuery import PBSQuery [as 别名]
# 或者: from PBSQuery.PBSQuery import getnodes [as 别名]
def countcpu(queue):
    p = PBSQuery()
    p.new_data_structure()
    nodes = p.getnodes()
    nptot = 0
    for id in nodes:
        if nodes[id].properties == [queue]:
            try:
                np = nodes[id].np
                np = int(np[0])
                nptot = nptot + np
            except PBSError, detail:
                print detail
            pass
开发者ID:sysmso,项目名称:sysadmin,代码行数:16,代码来源:pbscpu.py

示例5: get_ppn

# 需要导入模块: from PBSQuery import PBSQuery [as 别名]
# 或者: from PBSQuery.PBSQuery import getnodes [as 别名]
    def get_ppn(self):
        """Guess the ppn for full node"""
        pq = PBSQuery()
        node_vals = pq.getnodes().values()  # only the values, not the names
        interesni_nodes = ('free', 'job-exclusive',)
        res = {}
        for np in [int(x['np'][0]) for x in node_vals if x['state'][0] in interesni_nodes]:
            res.setdefault(np, 0)
            res[np] += 1

        # # return most frequent
        freq_count, freq_np = max([(j, i) for i, j in res.items()])
        self.log.debug("Found most frequent np %s (%s times) in interesni nodes %s" % (freq_np, freq_count, interesni_nodes))

        return freq_np
开发者ID:stdweird,项目名称:hanythingondemand,代码行数:17,代码来源:rm_pbs.py

示例6: __init__

# 需要导入模块: from PBSQuery import PBSQuery [as 别名]
# 或者: from PBSQuery.PBSQuery import getnodes [as 别名]
  def __init__(self, server, verbosity=0, diagOutputFile=None):
    self.SRList = {}
    self.activeNodes = {}
    self.verbosity = verbosity
    self.server = server

    # Load Torque configuration
    
    try:
        torqueConfig=PBSQuery(server)
        self.server_info=torqueConfig.get_serverinfo()[server]
        self.nodes=torqueConfig.getnodes()
        self.queues=torqueConfig.getqueues()
    except PBSError, e:
        self.__debug(0,"Error connecting to PBS server: %s" % e)
        sys.exit(1)
开发者ID:GRIF,项目名称:lcg-info-dynamic-maui,代码行数:18,代码来源:TorqueMauiConfParser.py

示例7: _get_ppn

# 需要导入模块: from PBSQuery import PBSQuery [as 别名]
# 或者: from PBSQuery.PBSQuery import getnodes [as 别名]
    def _get_ppn(self):
        """Guess PBS' `ppn` value for a full node."""
        # cache this value as it's not likely going to change over the
        # `eb` script runtime ...
        if not self._ppn:
            pq = PBSQuery()
            node_vals = pq.getnodes().values()  # only the values, not the names
            interesting_nodes = ('free', 'job-exclusive',)
            res = {}
            for np in [int(x['np'][0]) for x in node_vals if x['state'][0] in interesting_nodes]:
                res.setdefault(np, 0)
                res[np] += 1

            # return most frequent
            freq_count, freq_np = max([(j, i) for i, j in res.items()])
            self.log.debug("Found most frequent np %s (%s times) in interesting nodes %s" % (freq_np, freq_count, interesting_nodes))

            self._ppn = freq_np

        return self._ppn
开发者ID:FredHutch,项目名称:easybuild-framework,代码行数:22,代码来源:pbs_python.py

示例8: main

# 需要导入模块: from PBSQuery import PBSQuery [as 别名]
# 或者: from PBSQuery.PBSQuery import getnodes [as 别名]
def main():
    p = PBSQuery()
    p.new_data_structure()
    nodes = p.getnodes()
    l=list()
    for id in nodes:
        try:
            queue = nodes[id].properties[0]
            state = nodes[id].state[0]
            power = nodes[id].power_state[0]
            np = nodes[id].np[0]
            name = nodes[id].name
            if hasattr(nodes[id],"jobs"):
                jobs = nodes[id].jobs[0].split('/')
		if len(jobs) > 1:
                    jobs = jobs[1]
	        else:
		    jobs = jobs[0]	
            else:
                jobs = "none"
            l.append([name,state,power,queue,np,jobs])
        except PBSError, detail:
            print detail
        pass
开发者ID:sysmso,项目名称:sysadmin,代码行数:26,代码来源:clview.py

示例9: nicer

# 需要导入模块: from PBSQuery import PBSQuery [as 别名]
# 或者: from PBSQuery.PBSQuery import getnodes [as 别名]
class QstatViewer:
    """
    Presents a nicer (?) interface to PBSQuery
    The two main member objects are:
    * jobs -- a dictionary with job ID (as str) as the key, 
              and the corresponding Job object as the value
    * nodes -- a dictionary with node name as the key, 
               and a set of corresponding job IDs (of jobs 
               running on node)
    """
    def __init__(self, pbs_server=None, debug_p=False):
        """Creates a QstatViewer object. Arguments:
           - pbs_server : FQDN of the TORQUE server to query (string)"""
        self.debug_p = debug_p

        self.nodes = {}
        self.jobs = {}
        self.queues = {}

        self.pbsquery = PBSQuery(pbs_server)

        self.servername = self.pbsquery.get_server_name()

        self.__make_server()
        self.__make_queues()
        self.__make_jobs()
        self.__make_nodes()


    def __make_nodes(self):
        """Make dict with node names as keys, and list of job objects as values"""

        # make list of jobids running on the node
        #node_jobs = {}
        #for jobid,job in self.jobs.iteritems():
        #    if job.exec_host:
        #        for node_cpu in job.exec_host:
        #            node = node_cpu.split('/')[0]
        #            if node not in node_jobs:
        #                node_jobs[node] = []
        #            else:
        #                node_jobs[node].append(jobid)

        rawnodes = self.pbsquery.getnodes()
        for n,s in rawnodes.iteritems():
            self.nodes[n] = Node(name=n, pbsnodes_dict=dict(s), debug_p=self.debug_p)


    def __make_jobs(self):
        """Make dict with job IDs as keys, and job properties as values"""
        rawjobs = self.pbsquery.getjobs()
        for j,p in rawjobs.iteritems():
            self.jobs[j] = Job(id=j, pbsjobs_dict=dict(p), debug_p=self.debug_p)

    def __make_queues(self):
        """make dict with queue names as keys, and queue properties as values"""
        rawqueues = self.pbsquery.getqueues()
        for q,p in rawqueues.iteritems():
            self.queues[q] = Queue(name=q, pbsqueue_dict=p)

    def __make_server(self):
        self.__serverinfo = self.pbsquery.get_serverinfo()[self.servername]
        if self.debug_p:
            print 'FOOBAR: self.serverinfo =', self.__serverinfo
        for k,v in self.__serverinfo.iteritems():
            self.__dict__[k] = None
            if k == 'state_count':
                # Example of state_count: Transit:0 Queued:-6458 Held:6383 Waiting:0 Running:964 Exiting:0
                self.__dict__[k] = {}
                vals = v[0].strip().split(' ')
                for state in vals:
                    statename = state.split(':')[0]
                    stateval  = int(state.split(':')[1])
                    self.__dict__[k][statename] = stateval
            elif k == 'resources_default':
                v['mem'] = Memory(v['mem'][0])
                v['pmem'] = Memory(v['pmem'][0])
                v['cput'] = pbstimestr_to_timedelta(v['cput'][0])
                v['walltime'] = pbstimestr_to_timedelta(v['walltime'][0])
                self.__dict__[k] = v
            elif k == 'resources_assigned':
                if 'mem' in v:
                    v['mem'] = Memory(v['mem'][0])

                if 'vmem' in v:
                    v['vmem'] = Memory(v['vmem'][0])

                if 'ncpus' in v:
                    v['ncpus'] = int(v['ncpus'][0])
                
                if 'nodect' in v:
                    v['nodect'] = int(v['nodect'][0])

                self.__dict__[k] = v
            elif k == 'scheduling' or k == 'query_other_jobs':
                if v[0] == 'True':
                    v[0] = True
                elif v[0] == 'False':
                    v[0] = False
                self.__dict__[k] = v[0]
#.........这里部分代码省略.........
开发者ID:prehensilecode,项目名称:qstatviewer,代码行数:103,代码来源:QstatViewer.py

示例10: free_cpus

# 需要导入模块: from PBSQuery import PBSQuery [as 别名]
# 或者: from PBSQuery.PBSQuery import getnodes [as 别名]
                        unique_jobs.add(j.split('/')[1])
                self.unique_jobs = unique_jobs


    def free_cpus(self):
        """Returns the number of available CPUs"""

        retval = self.ncpus - len(self.jobs)
        return retval


    def __str__(self):
        return str(self.__dict__)
        

if __name__ == '__main__':
    pq = PBSQuery()
    nodes = {}
    for k,v in pq.getnodes().iteritems():
        nodes[k] = Node(name=k, pbsnodes_dict=dict(v))

    for nodename, node in sorted(nodes.iteritems()):
        print nodename, ': ', node
        print "Name = %s, State = %s, Free CPUs = %d, Clan = %s, Fabric = %s" % (node.name, node.state, node.free_cpus(), node.clan, node.fabric)
        print "     GPU status:"
        if 'gpu_status' in node.__dict__:
            for s in node.gpu_status:
                print '        ', s
        print '----'

开发者ID:prehensilecode,项目名称:qstatviewer,代码行数:31,代码来源:Node.py

示例11:

# 需要导入模块: from PBSQuery import PBSQuery [as 别名]
# 或者: from PBSQuery.PBSQuery import getnodes [as 别名]
#!/usr/bin/python

from PBSQuery import PBSQuery, PBSError
server = 'grid63.lal.in2p3.fr'

try:
    p=PBSQuery(server)
    pbs=p.get_serverinfo()
    nodes=p.getnodes()
    jobs=p.getjobs()
    queues=p.getqueues()
except PBSError, e:
    print "<h3>Error connecting to PBS server:</h3><tt>",e,"</tt>"
    sys.exit(1)


print ""
print "Server info:"
print pbs

print ""
print "Nodes:"
for node in nodes.keys():
  print "********** %s *********" % node
  print nodes[node]

print ""
print "Jobs:"
for job in jobs.keys():
  print "********** Job %s *********" % job
  print jobs[job]
开发者ID:GRIF,项目名称:lcg-info-dynamic-maui,代码行数:33,代码来源:test_pbs_python.py

示例12: PBSQuery

# 需要导入模块: from PBSQuery import PBSQuery [as 别名]
# 或者: from PBSQuery.PBSQuery import getnodes [as 别名]
#!/usr/bin/env python

import sys
import os

from PBSQuery import PBSQuery

pq = PBSQuery('torque')
nodes = pq.getnodes()

print '# There are %d nodes\n' % (len(nodes))

for k,v in nodes.iteritems():
    v = dict(v)
    print k
    for l,w in v.iteritems():
        print '\t',l,'\t\t',w
    print '-----'


开发者ID:prehensilecode,项目名称:qstatviewer,代码行数:20,代码来源:foonodes.py

示例13: main

# 需要导入模块: from PBSQuery import PBSQuery [as 别名]
# 或者: from PBSQuery.PBSQuery import getnodes [as 别名]
def main():
    pq = PBSQuery()
    nodes = pq.getnodes()
    for k,v in sorted(nodes.iteritems()):
        print k, v['state']
开发者ID:prehensilecode,项目名称:qstatviewer,代码行数:7,代码来源:pbsquerynodes.py


注:本文中的PBSQuery.PBSQuery.getnodes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。