コード例 #1
0
ファイル: slaveTab.py プロジェクト: DrQueue/drQt
    def _set_values(self):
        comp = client.identify_computer(self._drq_node_object, 300)

        self._tab_id.setText("%d" % self._drq_node_object)
        self._tab_hostname.setText("%s" % comp['hostname'])
        self._tab_arch.setText("%s" % comp['arch'])
        #self._tab_enabled.setPixmap( self.icons[self._drq_node_object.limits.enabled].scaled(25,25))
        self._tab_os.setText("%s" % comp['os'])
        self._tab_nbits.setText("%d" % comp['nbits'])
        self._tab_procspeed.setText("%s" % comp['procspeed'])
        self._tab_ncpus.setText("%d" % comp['ncpus'])
        self._tab_ncorescpu.setText("%d" % comp['ncorescpu'])
        self._tab_memory.setText("%s GB" % comp['memory'])
        #self._tab_running.setText("%s" % "TODO")
        
        #self._tab_loadavg.setText("%d:%d:%d"%(self._drq_node_object.status.get_loadavg(0),
        #                                      self._drq_node_object.status.get_loadavg(1),
        #                                      self._drq_node_object.status.get_loadavg(2)))
        load = comp['load'].split(" ")
        load_0 = int(float(load[0].replace(',', '.'))*100)
        load_1 = int(float(load[1].replace(',', '.'))*100)
        load_2 = int(float(load[2].replace(',', '.'))*100)
        self._tab_loadavg.setText("%d : %d : %d" % (load_0, load_1, load_2))

        #self._tab_running.setText("")
        self._tab_pools.setText(", ".join(DrQueueComputer.get_pools(self._drq_node_object)))
コード例 #2
0
def main():
    # parse arguments
    parser = OptionParser()
    parser.usage = "%prog [options] -i id"
    parser.add_option("-i", "--id ",
                      dest="id", default=None, help="id of computer")
    parser.add_option("-a", "--all ",
                      action="store_true", dest="all", default=False, help="use all computers")
    parser.add_option("-s", "--shutdown",
                      action="store_true", dest="shutdown", default=False, help="shutdown computer")
    parser.add_option("-p", "--pools",
                      dest="pools", default=None, help="add computer to one or more pools")
    parser.add_option("--info",
                      action="store_true", dest="info", default=False, help="show information about computer")
    parser.add_option("-t", "--status",
                      action="store_true", dest="status", default=False, help="show status of computer")
    parser.add_option("-v", "--verbose",
                      action="store_true", dest="verbose", default=False, help="verbose output")
    (options, args) = parser.parse_args()

    # initialize DrQueue client
    client = DrQueueClient()

    cache_time = 60

    # engines to work on
    if options.id != None:
        computers = []
        computers.append(int(options.id))
    if options.all == True:
        computers = client.ip_client.ids

    # run specified action
    if options.shutdown:
        for computer in computers:
            client.engine_stop(computer)
        print("Computer %s has been shut down." % str(computers))
        return True
    if options.pools:
        for computer in computers:
            DrQueueComputer.set_pools(computer, options.pools.split(","))
            print("Computer %i has been added to pools %s." % (computer, options.pools.split(",")))
        return True
    if options.info:
        for computer in computers:
            print("Engine "+str(computer)+ ":")
            comp = client.identify_computer(computer, cache_time)
            print(" hostname: "+comp['hostname'])
            print(" arch: "+comp['arch'])
            print(" os: "+comp['os'])
            print(" nbits: "+str(comp['nbits']))
            print(" procspeed: "+comp['procspeed'])
            print(" ncpus: "+str(comp['ncpus']))
            print(" ncorescpu: "+str(comp['ncorescpu']))
            print(" memory: "+comp['memory'])
            print(" load: "+comp['load'])
            print(" pools: "+str(DrQueueComputer.get_pools(computer))+"\n")
        return True
    if options.status:
        for computer in computers:
            print("Engine "+str(computer)+ ":")
            status = client.ip_client.queue_status(computer, verbose=True)
            print(" status:")
            print("  in queue: "+str(status['queue']))
            print("  completed: "+str(status['completed']))
            print("  tasks: "+str(status['tasks']))
        return True
コード例 #3
0
from IPython.parallel import Client
from DrQueue import Computer as DrQueueComputer


client = Client()

engine_ids = DrQueueComputer.query_all()
for engine_id in engine_ids:
    print("Deleting engine %s from DB." % engine_id)
    DrQueueComputer.delete_from_db_by_engine_id(engine_id)

コード例 #4
0

if "DRQUEUE_SLAVE" in os.environ:
    SLAVE_IP = os.environ["DRQUEUE_SLAVE"]
else:
    SLAVE_IP = socket.gethostbyname(socket.getfqdn())

IPENGINE_STARTUP_LOGPATH = os.path.join(os.environ["DRQUEUE_ROOT"], "logs", "ipengine_" + SLAVE_IP + ".log")
IPENGINE_STARTUP_LOGFILE = open(IPENGINE_STARTUP_LOGPATH, "ab")

# connect to current IPython engine instance
app = Application.instance()
# get engine_id
engine_id = app.engine.id

# get computer information
engine = DrQueueComputer()
# set creation time
engine["created_at"] = int(time.time())
# set engine_id
engine["engine_id"] = engine_id
# store entry in database
DrQueueComputer.store_db(engine)

IPENGINE_STARTUP_LOGFILE.write("\nComputer info: \n")
IPENGINE_STARTUP_LOGFILE.write(str(engine) + "\n\n")

# flush buffers
IPENGINE_STARTUP_LOGFILE.flush()
os.fsync(IPENGINE_STARTUP_LOGFILE.fileno())
コード例 #5
0
if "DRQUEUE_SLAVE" in os.environ:
    SLAVE_IP = os.environ["DRQUEUE_SLAVE"]
else:
    SLAVE_IP = socket.gethostbyname(socket.getfqdn())

IPENGINE_STARTUP_LOGPATH = os.path.join(os.environ["DRQUEUE_ROOT"], "logs",
                                        "ipengine_" + SLAVE_IP + ".log")
IPENGINE_STARTUP_LOGFILE = open(IPENGINE_STARTUP_LOGPATH, "ab")

# connect to current IPython engine instance
app = Application.instance()
# get engine_id
engine_id = app.engine.id

# get computer information
engine = DrQueueComputer()
# set creation time
engine['created_at'] = int(time.time())
# set engine_id
engine['engine_id'] = engine_id
# store entry in database
DrQueueComputer.store_db(engine)

IPENGINE_STARTUP_LOGFILE.write("\nComputer info: \n")
IPENGINE_STARTUP_LOGFILE.write(str(engine) + "\n\n")

# flush buffers
IPENGINE_STARTUP_LOGFILE.flush()
os.fsync(IPENGINE_STARTUP_LOGFILE.fileno())