#!/usr/bin/python2.2 # ----------------------------------------------------------------------------- # SETUP # ----------------------------------------------------------------------------- import sys import os import string # OpenGL Application might need head node to be DISPLAY :0 #os.environ['DISPLAY'] = ':0' # ----------------------------------------------------------------------------- # OPTIONS # ----------------------------------------------------------------------------- crsite_file = sys.argv[1] # ----------------------------------------------------------------------------- # CRSITE # ----------------------------------------------------------------------------- if not os.access (crsite_file, os.F_OK): print '%s cannot read file %s.' % (sys.argv[0], crsite_file) sys.exit (1) f = open (crsite_file, 'r') exec (f.read()) f.close() # fetch environment for Chromium based on environment cr_path = crsite["chromium"] os.environ['LD_LIBRARY_PATH'] = cr_path + '/lib/Linux' sys.path.append (cr_path + "/mothership/server") from mothership import * print "Running " + cr_path # ----------------------------------------------------------------------------- # CHROMIUM STUFF # ----------------------------------------------------------------------------- # create mothership cr = CR() cr.MTU (9048 * 1024) # ----------------------------------------------------------------------------- # HANDLE LOCAL APPLICATIONS # ----------------------------------------------------------------------------- render_nodes = crsite["render_nodes"] for local in crsite["local_run"]: machine = render_nodes[local[0] - 1][0] os.system('/usr/bin/ssh ' + machine + ' "/bin/sh -c \'DISPLAY=:0; ' + local[1] + '\'" &') os.system('sleep 1') # ----------------------------------------------------------------------------- # HANDLE CLIENT NODE # ----------------------------------------------------------------------------- for client in crsite["client_nodes"]: # setup a tilesort SPU tilesort_spu = SPU ('tilesort') #tilesort_spu.Conf ('bucket_mode', 'Uniform Grid') # If one monitor, turn off sync for performance if len(client[2]) == 1: tilesort_spu.Conf('sync_on_swap', 0) tilesort_spu.Conf('sync_on_finish', 0) # setup a client/application node client_node = CRApplicationNode (client[0]) # set starting directory and executable for client client_node.StartDir(client[3]) client_node.SetApplication (client[4]) client_node.AutoStart ('/usr/bin/ssh ' + client[0] + ' /bin/sh -c \'DISPLAY=:0; ' + cr_path + '/bin/Linux/crappfaker\'') #client_node.AutoStart ('/usr/bin/ssh ' + client[0] + ' setenv DISPLAY :0; ' + cr_path + '/bin/Linux/crappfaker') client_node.AddSPU (tilesort_spu) if client[5] != 0: client_node.Conf ('match_window_count', client[5]) w = 0 h = client[1][1] - 1 # ----------------------------------------------------------------------------- # HANDLE RENDERING NODES # ----------------------------------------------------------------------------- for i in client[2]: machine = render_nodes[i-1] # each tile will do some rendering render_spu = SPU ('render') render_spu.Conf ('display_string', machine[0] + ':0') render_spu.Conf ('window_geometry', machine[1]) render_spu.Conf ('ontop', 1) #render_spu.Conf ('fullscreen', 1) #render_spu.Conf ('system_gl_path', '/usr/lib/tls') # set up a rendering node node = CRNetworkNode (machine[0]) node.AddTile (machine[1][2]*w, machine[1][3]*h, machine[1][2], machine[1][3]) w = w + 1 if w == client[1][0]: w = 0 h = h - 1 #if options.dist_texture: # tex_spu = SPU ('dist_texture') # node.AddSPU (tex_spu) node.AddSPU (render_spu) node.AutoStart ('/usr/bin/ssh ' + machine[0] + ' crserver') # add rendering node to mothership cr.AddNode (node) tilesort_spu.AddServer (node, protocol='tcpip') cr.AddNode (client_node) cr.Go() # ----------------------------------------------------------------------------- # CLEAN UP # ----------------------------------------------------------------------------- #Remove crserver, crappfaker, or opengl program print "Killing" #Kill all crserver and crappfaker for client in crsite["client_nodes"]: #Connect to each server node and kill crserver for i in client[2]: os.system('/usr/bin/ssh ' + render_nodes[i-1][0] + ' killall -9 crserver') os.system('/usr/bin/ssh ' + client[0] + ' killall -9 crappfaker') program = string.split(client[4]) os.system('/usr/bin/ssh ' + client[0] + ' killall -9 -e ' + program[0]) #Kill all programs that running locally on cluster for local in crsite["local_run"]: machine = render_nodes[local[0] - 1][0] program = string.split(local[1]) os.system('/usr/bin/ssh ' + machine + ' killall -9 -e ' + program[0])