diff --git a/DisplayNode/README.md b/DisplayNode/README.md index 0baa603d52e464ed31173cc19dbc1a9c3ecb700c..47f87040dcc0bf205e3b5aa88c5e1caf93d88073 100644 --- a/DisplayNode/README.md +++ b/DisplayNode/README.md @@ -1,5 +1,7 @@ ## DisplayNode Scripts and Magic +Place the WorkerNode.py scripts in pi's home directory. + ALL SCRIPTS USING THE NEOPIXEL LIBRARY NEED ROOT PERMISSIONS TO RUN WorkerNode.py args - > [startNode, endNode, numberOfIterations] diff --git a/Head/README.md b/Head/README.md index 12952fd025d389aca6b702a800be995b7a644af0..cb21f7365dc618acdd0c7a563e3498412e868771 100644 --- a/Head/README.md +++ b/Head/README.md @@ -1,3 +1,12 @@ ## Head Node Specific Items -In order to provide a pretty user interface for the project, `Web` has the scripts for controlling and submitting items to the workers. It is used in conjunction with scripts in the Workers folder. \ No newline at end of file +In order to provide a pretty user interface for the project, `Web` has the scripts for controlling and submitting items to the workers. It is used in conjunction with scripts in the Scripts folder. + + +In `Scripts` there are two primary files. + + `cluster.py` is the primary library for interacting with the cluster simulations. Jobs can be added by adding a key pair to the jobs dictionary. The key is used as a CLI arguement and the value is the name of the script file to control the cluster. + +`LightControl.py` handles the general control of the lights as a library. + +The `Web` folder goes into the root of a webserver such as Apache2 or nginx. The folders `control` and `scripts` need to be created in the web root. The contents of the `Scripts` folder goes into `scripts`. diff --git a/Head/Scripts/HPC.py b/Head/Scripts/HPC.py new file mode 100644 index 0000000000000000000000000000000000000000..705a13a17dfe36f5f3f936e71391733f4e357d78 --- /dev/null +++ b/Head/Scripts/HPC.py @@ -0,0 +1,57 @@ +import time +from random import randint,choice +import socket +import subprocess +import sys +from LightControl import * + + +def slaveNodeOn(worker): + sendNetwork("worker1",worker,2) + changeLoadState(worker,1) + +def slaveNodeOff(worker): + sendNetwork(worker,"worker1",2) + changeLoadState(worker,0) + +availableWorkers = [] +for host in sys.argv[1].split(","): + if "worker" in host: + availableWorkers.append(host) + +turnAllNodesOff() +start = time.time() +print("Starting") +sendNetwork("LegionHead","worker1",1) ### Send job data and files to the master node and turn master node lights on +sendNetwork("LegionFile","worker1",4) +changeLoadState("worker1",1) +time.sleep(2) + +for i in range(0,2): ### Run two sets of mini jobs + + ### Turn on all of the slave worker nodes and turn off master processing node + for worker in availableWorkers: ### Send master to slave data + slaveNodeOn(worker) + changeLoadState("worker1",0) + time.sleep(1) + + + #for i in range(1,10): ### Random Internode chatter while they do work + # worker1 = "worker"+str(randint(2,8)) + # worker2 = "worker"+str(randint(2,8)) + # sendNetwork(worker1,worker2,1) + # sendNetwork(worker2,worker1,1) + for worker in availableWorkers: ### Send slave to master + slaveNodeOff(worker) + changeLoadState("worker1",1) ### Work is finished and the master distributes another load of mini jobs + +### Master procerssing node finished after the mini job sets and then sends results back. +sendNetwork("worker1","LegionFile",7) +sendNetwork("worker1","LegionFile",1) +turnAllNodesOff() + + + + + + diff --git a/Head/Scripts/HTC.py b/Head/Scripts/HTC.py new file mode 100644 index 0000000000000000000000000000000000000000..d836b0714e94909805ad02e2183a99b658e0c02f --- /dev/null +++ b/Head/Scripts/HTC.py @@ -0,0 +1,45 @@ +import time +import socket +from random import randint,choice +import sys +from LightControl import * + + +turnAllNodesOff() + +activeWorkers = [] +deadWorkers = [] +start = time.time() +### Get a list of all working workers +for host in sys.argv[1].split(","): + if "worker" in host: + deadWorkers.append(host) + + +while (time.time() - start) < 40: # How long to run the simulation for + if randint(0,1) == 1 and len(deadWorkers) > 0: # Add randomness and see if there are dead workers + currentWorker = choice(deadWorkers) # Choose a random worker, then send networking to it and turn it on, + sendNetwork("LegionHead", currentWorker,1) + sendNetwork("LegionFile", currentWorker,1) + time.sleep(0.05) + changeLoadState(currentWorker,1) + deadWorkers.remove(currentWorker) # Remove from the list of dead workers and add to active list + activeWorkers.append(currentWorker) + + if randint(0,1) == 1 and len(activeWorkers) > 0:# Add randomness and see if there are active workers + currentWorker = choice(activeWorkers) # Choose a random worker, + if (time.time() - nodes[currentWorker]["time"]) > 5: # if its been alive for atleast 5 seconds + sendNetwork(currentWorker,"LegionFile",1) # send networking to it and turn it on, + sendNetwork(currentWorker,"LegionHead",1) + changeLoadState(currentWorker,0) + activeWorkers.remove(currentWorker) # Remove from the list of active workers and add to dead list + deadWorkers.append(currentWorker) +for worker in activeWorkers: + sendNetwork(currentWorker,"LegionFile",1) # send networking to it and turn it on, + sendNetwork(currentWorker,"LegionHead",1) + changeLoadState(currentWorker,0) + +turnAllNodesOff() + + + diff --git a/Head/Scripts/LightControl.py b/Head/Scripts/LightControl.py new file mode 100644 index 0000000000000000000000000000000000000000..a6593044403bc9bb9ab8f8fa658ff313a00ab50e --- /dev/null +++ b/Head/Scripts/LightControl.py @@ -0,0 +1,51 @@ +### Library for interacting with the lights in the cluster. + +import os +import time + +###### Code for the networking LEDS +### Send commands to the Networking LEDS: +def sendNetwork(source, destination, numberOfTimes): + os.system('ssh -i ~pi/LegionKey pi@192.168.1.6 "sudo python ~pi/WorkerNetwork.py %s %s %d"' % (source, destination, numberOfTimes)) + #time.sleep(0.5) + + + +###### Code for the LED Hats on the workers +### Dictionary of nodes for use with the HATs. +nodes = { + "worker1": {"status":0,"time":0}, + "worker2": {"status":0,"time":0}, + "worker3": {"status":0,"time":0}, + "worker4": {"status":0,"time":0}, + "worker5": {"status":0,"time":0}, + "worker6": {"status":0,"time":0}, + "worker7": {"status":0,"time":0}, + "worker8": {"status":0,"time":0}, + "LegionHead":{"status":0,"time":0}, + "LegionFile":{"status":0,"time":0} +} + +### Change the state of a LED HAT on a node +def changeLoadState(node, state): + nodes[node]["status"] = state + nodes[node]["time"] = time.time() + writeLoadDataToWeb(nodes) + +### Write the nodes dictionary to a json file hosts on the head node. +def writeLoadDataToWeb(nodes): + payload = "{" + for node in nodes.keys(): + if list(nodes.keys()).index(node) < len(nodes.keys())-1: # If its not the last node in the dictionary, then have a have at the end + payload += ("\"%s\":%d," % (node,nodes[node]["status"])) + else: # If it is the last one, use a } rather than a comma to close off the + payload += ("\"%s\":%d}" % (node,nodes[node]["status"])) + with open("/var/www/html/control/index.html",'w') as f: + f.write(payload) + +def turnAllNodesOff(): + for node in nodes.keys(): + changeLoadState(node,0) +def turnAllNodesOn(): + for node in nodes.keys(): + changeLoadState(node,1) diff --git a/Head/Scripts/cluster.py b/Head/Scripts/cluster.py new file mode 100644 index 0000000000000000000000000000000000000000..4dce0f38728e1074d4d70521e80d5289eb293b02 --- /dev/null +++ b/Head/Scripts/cluster.py @@ -0,0 +1,40 @@ +from status import * +import sys +import os +### Check that the web server is running +if not checkWeb(): + exit() + +### Check to see if all hosts are up +## Repeats as a double checks +hosts = checkHosts() +if 0 in hosts.values(): + hosts = checkHosts() + +### Check to see if lights are running +hosts = checkLights(hosts) + +### Now that all alive hosts are known, we can safely start running scripts + +hostArg = [] +for host in hosts.keys(): + if hosts[host] == 1: + hostArg.append(host) +hostString = ",".join(hostArg) +print(hostString) + +#### +##### Still need a way to prevent rechecks each time +#### + +### Dictionary of all jobs +jobs = { + "htc":"HTC.py", + "hpc":"HPC.py" +} + + +if sys.argv[1].lower() in jobs.keys(): + os.system("python %s %s" %(jobs[sys.argv[1]], hostString)) +else: + print("Invalid Job Name") diff --git a/Head/Web/setLEDs.php b/Head/Web/setLEDs.php index 6209d634ce0d3313dc5b9001cce5ce14ee0cfbd0..19f0723a795d1d1a05e9d441e1fba265db21f8b0 100755 --- a/Head/Web/setLEDs.php +++ b/Head/Web/setLEDs.php @@ -5,34 +5,20 @@ //echo exec('whoami'); $job_name = "job"; $lights_name = "lights"; - $filename = "/work/LED.txt"; - exec("rm /work/LED.txt"); - $file = fopen($filename, "a"); - fwrite($file, $_COOKIE[$cookie_name]); - fclose($file); - - if ($_COOKIE[$job_name] == "start"){ - for ($x=1; $x<=8;$x++){ - exec("sudo -H -u pi bash -c \"ssh -i ~pi/LegionKey worker".(string)$x." 'screen -md python /work/LightPi.py'\"");} - exec("sudo -H -u pi bash -c \"ssh -i ~pi/LegionKey 192.168.1.1 'screen -md python /work/idleControl.py'\""); - exec("sudo -H -u pi bash -c \"ssh -i ~pi/LegionKey 192.168.1.5 'screen -md python /work/idleControl.py'\""); - exec("sudo -H -u pi bash -c \"ssh -i ~pi/LegionKey 192.168.1.6 'screen -md python /work/idleNet.py'\""); - } if ($_COOKIE[$job_name] == "HPC"){ - $random = (string)rand(5,30); - exec("cd /work/; sudo -H -u pi bash -c \"python /work/HPCWeb.py\""); + exec("cd /var/www/html/scripts; sudo -H -u pi bash -c \"python cluster.py hpc\""); } if ($_COOKIE[$job_name] == "HTC"){ - exec("cd /work/; sudo -H -u pi bash -c \"python /work/HTCWeb.py\"" ); + exec("cd /var/www/html/scripts; sudo -H -u pi bash -c \"python cluster.py htc\"" ); } if ($_COOKIE[$job_name] == "ION"){ - exec("sudo -H -u pi bash -c \"bash /work/idleOn.sh\""); + exec("sudo -H -u pi bash -c \"bash ~pi/idleOn.sh\""); } if ($_COOKIE[$job_name] == "IOFF"){ - exec("sudo -H -u pi bash -c \"bash /work/idleOff.sh\""); + exec("sudo -H -u pi bash -c \"bash ~pi/idleOff.sh\""); } diff --git a/Workers/workDir/LightPi.py b/Workers/LightPi.py old mode 100755 new mode 100644 similarity index 100% rename from Workers/workDir/LightPi.py rename to Workers/LightPi.py diff --git a/Workers/README.md b/Workers/README.md index c260b70f03d07d6cd0f398696a2c15d8d89481f1..6803681a9d8e4d2b88eed07a648b5f1bc5152ef9 100644 --- a/Workers/README.md +++ b/Workers/README.md @@ -1,3 +1,5 @@ ## Worker Specific Items -workDir contains items to be stored in /work \ No newline at end of file +LightPi.py is a service script that listens to the headnode for what to do. This script goes to the pi home directory on all visible nodes. + +IdleNet.py is used to create an idle network state. - This still needs to be adapted to the new format of the cluster's code. \ No newline at end of file diff --git a/Workers/workDir/idleNet.py b/Workers/idleNet.py similarity index 97% rename from Workers/workDir/idleNet.py rename to Workers/idleNet.py index e3d63237b4a6328b5357273a0d751550aabf7aa7..555cd124cd8f8de43d77be8c1e8a6e230455cbe3 100644 --- a/Workers/workDir/idleNet.py +++ b/Workers/idleNet.py @@ -1,35 +1,35 @@ -import time -import sys -from neopixel import * -import argparse -from random import randint,choice -import socket -import urllib2, json -# LED strip configuration: -LED_COUNT = 100 # Number of LED pixels. -LED_PIN = 18 # GPIO pin connected to the pixels (18 uses PWM!). -#LED_PIN = 10 # GPIO pin connected to the pixels (10 uses SPI /dev/spidev0.0). -LED_FREQ_HZ = 800000 # LED signal frequency in hertz (usually 800khz) -LED_DMA = 10 # DMA channel to use for generating signal (try 10) -LED_BRIGHTNESS = 255 # Set to 0 for darkest and 255 for brightest -LED_INVERT = False # True to invert the signal (when using NPN transistor level shift) -LED_CHANNEL = 0 # set to '1' for GPIOs 13, 19, 41, 45 or 53 - -strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL) -strip.begin() - -def getControlData(): - rawData = urllib2.urlopen("http://192.168.1.1/network").read() - print(rawData) - controls = json.loads(rawData) - print(controls) - host = socket.gethostname() - print(controls[host]) - return controls[host] - -while True: - if getControlData(): - r,g,b = randint(0,255),randint(0,255),randint(0,255) - strip.setPixelColor(randint(0,65),Color(r,g,b)) - strip.show() - +import time +import sys +from neopixel import * +import argparse +from random import randint,choice +import socket +import urllib2, json +# LED strip configuration: +LED_COUNT = 100 # Number of LED pixels. +LED_PIN = 18 # GPIO pin connected to the pixels (18 uses PWM!). +#LED_PIN = 10 # GPIO pin connected to the pixels (10 uses SPI /dev/spidev0.0). +LED_FREQ_HZ = 800000 # LED signal frequency in hertz (usually 800khz) +LED_DMA = 10 # DMA channel to use for generating signal (try 10) +LED_BRIGHTNESS = 255 # Set to 0 for darkest and 255 for brightest +LED_INVERT = False # True to invert the signal (when using NPN transistor level shift) +LED_CHANNEL = 0 # set to '1' for GPIOs 13, 19, 41, 45 or 53 + +strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL) +strip.begin() + +def getControlData(): + rawData = urllib2.urlopen("http://192.168.1.1/network").read() + print(rawData) + controls = json.loads(rawData) + print(controls) + host = socket.gethostname() + print(controls[host]) + return controls[host] + +while True: + if getControlData(): + r,g,b = randint(0,255),randint(0,255),randint(0,255) + strip.setPixelColor(randint(0,65),Color(r,g,b)) + strip.show() + diff --git a/Workers/idleOff.sh b/Workers/idleOff.sh new file mode 100644 index 0000000000000000000000000000000000000000..cb961bb6c7bfa9c57c132f45739ea3bcb50c9d9f --- /dev/null +++ b/Workers/idleOff.sh @@ -0,0 +1,2 @@ + echo \{\"worker1\":0,\"worker2\":0,\"worker3\":0,\"worker4\":0,\"worker5\":0,\"worker6\":0,\"worker7\":0,\"worker8\":0\,\"LegionDisplay\":0,\"LegionHead\":0,\"LegionFile\":0\} > /var/www/html/control/index.html + diff --git a/Workers/idleOn.sh b/Workers/idleOn.sh new file mode 100644 index 0000000000000000000000000000000000000000..0f811312500349b4fa7f8ac8d69de2b47901dfa9 --- /dev/null +++ b/Workers/idleOn.sh @@ -0,0 +1,2 @@ + echo \{\"worker1\":1,\"worker2\":1,\"worker3\":1,\"worker4\":1,\"worker5\":1,\"worker6\":1,\"worker7\":1,\"worker8\":1\,\"LegionDisplay\":1,\"LegionHead\":1,\"LegionFile\":1\} > /var/www/html/control/index.html + diff --git a/Workers/workDir/HPCMagic.py b/Workers/workDir/HPCMagic.py deleted file mode 100755 index 951f5bde0e7df7783ca11ebb777535a0048333b8..0000000000000000000000000000000000000000 --- a/Workers/workDir/HPCMagic.py +++ /dev/null @@ -1,41 +0,0 @@ -import time -import subprocess -from random import randint -import socket - -def sendCommand(command): - p = subprocess.Popen(command.split(" "), stdout=subprocess.PIPE, stderr=subprocess.PIPE) - (stdout, stderr) = p.communicate() - -def sendFile(host,command): - - f = open("/work/netLogs/host%s%d" % (host,int(time.time())),'w') - f.write(command) - f.close() -###Get Master Number -host = socket.gethostname()[-1:] -workers = ["1","2","3","4","5","6","7","8"] -###Send job from head to master, M - > F - > M -sendFile(host,"head,worker"+host+",5") -sendFile(host,"worker"+host+",file,5") -sendFile(host,"file,worker"+host+",5") - - -for i in workers: - if i != host: - #sendCommand("bash net.sh worker"+host+" worker"+i+" 1") - time.sleep(0.25) - sendCommand("sbatch slave"+i+".sh") - sendFile(host,"worker"+host+",worker"+i+",1") - #sendCommand("ssh -i /work/LegionKey pi@192.168.1.1"+i+" \"screen -md python /work/usage.py\"") - print("ssh -i /work/LegionKey pi@192.168.1.1"+i+" \"screen -md python /work/usage.py\"") - - -#sendCommand("bash slaveSubmit.sh") -end = time.time() + 40 -while time.time() < end: - sendFile(host,"worker"+str(randint(1,8))+",worker"+str(randint(1,8))+",1") - x = 0 -sendFile(host,"worker"+host+",file,5") -sendFile(host,"worker"+host+",head,5") - diff --git a/Workers/workDir/HPCWeb.py b/Workers/workDir/HPCWeb.py deleted file mode 100644 index 8836db0218e4984689a6ae22ed0e1f95f93aa92c..0000000000000000000000000000000000000000 --- a/Workers/workDir/HPCWeb.py +++ /dev/null @@ -1,111 +0,0 @@ -import time -from random import randint -import socket -import subprocess -workers = { - "worker1": {"status":0,"time":0}, - "worker2": {"status":0,"time":0}, - "worker3": {"status":0,"time":0}, - "worker4": {"status":0,"time":0}, - "worker5": {"status":0,"time":0}, - "worker6": {"status":0,"time":0}, - "worker7": {"status":0,"time":0}, - "worker8": {"status":0,"time":0} -} -### Format = from,To,Amount -def sendCommand(command): - p = subprocess.Popen(command.split(" "), stdout=subprocess.PIPE, stderr=subprocess.PIPE) - (stdout, stderr) = p.communicate() -### Format = from,To,Amount -def sendLights(command): - sendCommand("bash /work/net.sh %s" % command) -def writeWeb(data): - payload = "{\"worker1\":%s,\"worker2\":%s,\"worker3\":%s,\"worker4\":%s,\"worker5\":%s,\"worker6\":%s,\"worker7\":%s,\"worker8\":%s}" % (data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7]) - f =open("/var/www/html/control/index.html",'w') - f.write(payload) - f.close() -def workersToData(workers): - data = [] - for i in range(1,9): - data.append(workers["worker%d" % i]["status"]) - writeWeb(data) - -start = time.time() -print("Starting") -sendLights("head worker1 1") ### Send data to master -sendLights("file worker1 4") -workers["worker1"]["status"] = 1 ### Turn on master -workersToData(workers) -time.sleep(2) - -time.sleep(1) -print("Master On") -for i in range(2,9): ### Send master to slave data - currentWorker = "worker"+str(i) - print(currentWorker) - sendLights("worker1 %s 2" % currentWorker) - workers[currentWorker]["status"] = 1 - workersToData(workers) -workers["worker1"]["status"] = 0 -workersToData(workers) -time.sleep(1) -print("Slaves on and working") -for i in range(1,10): - currentWorker = "worker"+str(randint(1,8)) - w1 = "worker"+str(randint(2,8)) - w2 = "worker"+str(randint(2,8)) - sendLights("%s %s 1" % (w1,w2)) - sendLights("%s %s 1" % (w2,w1)) -workers["worker1"]["status"] = 1 -workersToData(workers) -for i in range(2,9): ### Send data back - currentWorker = "worker"+str(i) - print(currentWorker) - sendLights("%s worker1 2" % currentWorker) - workers[currentWorker]["status"] = 0 - workersToData(workers) - -for i in range(2,9): ### Send master to slave data - currentWorker = "worker"+str(i) - print(currentWorker) - sendLights("worker1 %s 2" % currentWorker) - workers[currentWorker]["status"] = 1 - workersToData(workers) -workers["worker1"]["status"] = 0 -workersToData(workers) -time.sleep(1) -print("Slaves on and working") -for i in range(1,10): - currentWorker = "worker"+str(randint(1,8)) - w1 = "worker"+str(randint(2,8)) - w2 = "worker"+str(randint(2,8)) - sendLights("%s %s 1" % (w1,w2)) - sendLights("%s %s 1" % (w2,w1)) -workers["worker1"]["status"] = 1 -workersToData(workers) -for i in range(2,9): ### Send data back - currentWorker = "worker"+str(i) - print(currentWorker) - sendLights("%s worker1 2" % currentWorker) - workers[currentWorker]["status"] = 0 - workersToData(workers) - -print("Doning") -time.sleep(6) -sendLights("worker1 file 7") -sendLights("worker1 head 1") ### Send data to head -workers["worker1"]["status"] = 0 ### Turn off master -workersToData(workers) - -workers = { - "worker1": {"status":0,"time":0}, - "worker2": {"status":0,"time":0}, - "worker3": {"status":0,"time":0}, - "worker4": {"status":0,"time":0}, - "worker5": {"status":0,"time":0}, - "worker6": {"status":0,"time":0}, - "worker7": {"status":0,"time":0}, - "worker8": {"status":0,"time":0} -} -workersToData(workers) - diff --git a/Workers/workDir/HTC.py b/Workers/workDir/HTC.py deleted file mode 100755 index 611de3f826d0ec4ea4b16163745c00b54f38914b..0000000000000000000000000000000000000000 --- a/Workers/workDir/HTC.py +++ /dev/null @@ -1,60 +0,0 @@ -from piglow import PiGlow -import time -import socket -import subprocess -import psutil -from random import randint - -p = PiGlow() -val = 100 -colour = 1 - -def sendCommand(command): - p = subprocess.Popen(command.split(" "), stdout=subprocess.PIPE, stderr=subprocess.PIPE) - (stdout, stderr) = p.communicate() -x = 0 -start = time.time() -host = socket.gethostname()[-1:] -time.sleep(randint(1,3)) -#sendCommand("bash /work/net.sh head worker"+host+" 3") -f = open("/work/netLogs/host%s%d" % (host,int(time.time())),'w') -#with open("/work/netlogs/host%s%d" % (host,int(time.time())),'w') as f: -f.write("head,worker"+host+",3") -f.close() - -time.sleep(0.5) -while True and (time.time() - start) < randint(5,20): - print("in") - p.white(10) - time.sleep(0.1) - p.blue(20) - time.sleep(0.1) - p.green(30) - time.sleep(0.1) - p.yellow(40) - time.sleep(0.1) - p.orange(50) - time.sleep(0.1) - p.red(60) - time.sleep(0.1) - p.white(255) - time.sleep(0.1) - p.red(0) - time.sleep(0.1) - p.orange(0) - time.sleep(0.1) - p.yellow(0) - time.sleep(0.1) - p.green(0) - time.sleep(0.1) - p.blue(0) - time.sleep(0.1) - p.white(0) - time.sleep(0.1) -p.all(0) -host = socket.gethostname()[-1:] -time.sleep(3) -#sendCommand("bash /work/net.sh worker"+host+" head 2") -f = open("/work/netLogs/host%s%d" % (host,int(time.time())),'w') -f.write("worker"+host+",head,2") -f.close() \ No newline at end of file diff --git a/Workers/workDir/HTCWeb.py b/Workers/workDir/HTCWeb.py deleted file mode 100644 index f995e2a014b5aa2ee7bd7f1660464a14961725d6..0000000000000000000000000000000000000000 --- a/Workers/workDir/HTCWeb.py +++ /dev/null @@ -1,122 +0,0 @@ -import time -import socket -from random import randint,choice -import subprocess -workers = { - "worker1": {"status":0,"time":0}, - "worker2": {"status":0,"time":0}, - "worker3": {"status":0,"time":0}, - "worker4": {"status":0,"time":0}, - "worker5": {"status":0,"time":0}, - "worker6": {"status":0,"time":0}, - "worker7": {"status":0,"time":0}, - "worker8": {"status":0,"time":0} -} - -def sendCommand(command): - p = subprocess.Popen(command.split(" "), stdout=subprocess.PIPE, stderr=subprocess.PIPE) - (stdout, stderr) = p.communicate() -### Format = from,To,Amount -def sendLights(command): - sendCommand("bash /work/net.sh %s" % command) -def writeWeb(data): - payload = "{\"worker1\":%s,\"worker2\":%s,\"worker3\":%s,\"worker4\":%s,\"worker5\":%s,\"worker6\":%s,\"worker7\":%s,\"worker8\":%s}" % (data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7]) - f =open("/var/www/html/control/index.html",'w') - f.write(payload) - f.close() -def workersToData(workers): - data = [] - for i in range(1,9): - data.append(workers["worker%d" % i]["status"]) - writeWeb(data) - - -active = [] -dead = [] -start = time.time() -for i in range(1,9): - dead.append("worker%d" % i) -workersToData(workers) - -while (time.time() - start) < 45: - if randint(0,1) == 1 and len(dead) > 0: - currentWorker = choice(dead) - workers[currentWorker]["status"] = 1 - workers[currentWorker]["time"] = time.time() - sendLights("head %s 1" % currentWorker) - sendLights("file %s 1" % currentWorker) - dead.remove(currentWorker) - active.append(currentWorker) - workersToData(workers) - if randint(0,1) == 1 and len(active) > 0: - currentWorker = choice(active) - if (time.time() - workers[currentWorker]["time"]) > 5: - workers[currentWorker]["status"] = 0 - sendLights("%s file 1" % currentWorker) - sendLights("%s head 1" % currentWorker) - workersToData(workers) - active.remove(currentWorker) - dead.append(currentWorker) - - - - - - -# for i in range(1,9): -# currentWorker = "worker%d" % i -# print(currentWorker) -# sendLights("head %s 1" % currentWorker) -# time.sleep(0.02) -# workers[currentWorker]["status"] = 1 -# workersToData(workers) -# print(workers[currentWorker]["status"]) -# time.sleep(0.3) -# time.sleep(8) -# for i in range(1,9): -# currentWorker = "worker%d" % i -# print(currentWorker) -# if currentWorker == "worker8": -# sendLights("%s head 1" % "worker1") -# time.sleep(0.2) -# workers["worker1"]["status"] = 1 -# workersToData(workers) -# sendLights("%s head 1" % currentWorker) -# time.sleep(0.2) -# workers[currentWorker]["status"] = 0 -# workersToData(workers) -# print(workers[currentWorker]["status"]) -# time.sleep(0.3) -# for i in range(2,9): -# currentWorker = "worker%d" % i -# print(currentWorker) -# sendLights("head %s 1" % currentWorker) -# time.sleep(0.02) -# workers[currentWorker]["status"] = 1 -# workersToData(workers) -# print(workers[currentWorker]["status"]) -# time.sleep(0.3) -# time.sleep(8) -# for i in range(1,9): -# currentWorker = "worker%d" % i -# print(currentWorker) -# sendLights("%s head 1" % currentWorker) -# time.sleep(0.2) -# workers[currentWorker]["status"] = 0 -# workersToData(workers) -# print(workers[currentWorker]["status"]) -# time.sleep(0.3) - - -workers = { - "worker1": {"status":0,"time":0}, - "worker2": {"status":0,"time":0}, - "worker3": {"status":0,"time":0}, - "worker4": {"status":0,"time":0}, - "worker5": {"status":0,"time":0}, - "worker6": {"status":0,"time":0}, - "worker7": {"status":0,"time":0}, - "worker8": {"status":0,"time":0} -} -workersToData(workers) - diff --git a/Workers/workDir/idleControl.py b/Workers/workDir/idleControl.py deleted file mode 100644 index 2090e4ae3f4d9fb1fe97ca81a00722e33ed434f9..0000000000000000000000000000000000000000 --- a/Workers/workDir/idleControl.py +++ /dev/null @@ -1,65 +0,0 @@ -from piglow import PiGlow -import time -import socket -import subprocess -import psutil -from random import randint -import urllib2, json -p = PiGlow() -val = 100 -colour = 1 - -def sendCommand(command): - p = subprocess.Popen(command.split(" "), stdout=subprocess.PIPE, stderr=subprocess.PIPE) - (stdout, stderr) = p.communicate() -def getControlData(): - rawData = urllib2.urlopen("http://192.168.1.1/network").read() - print(rawData) - controls = json.loads(rawData) - print(controls) - host = socket.gethostname() - print(controls[host]) - return controls[host] -p.green(255) -time.sleep(30) -delay = 0.05 -while True: - try: - p.all(0) - if getControlData(): - print("in") - p.white(10) - time.sleep(delay) - p.blue(20) - time.sleep(delay) - p.green(30) - time.sleep(delay) - p.yellow(40) - time.sleep(delay) - p.orange(50) - time.sleep(delay) - p.red(60) - time.sleep(delay) - p.white(255) - time.sleep(delay) - p.red(0) - time.sleep(delay) - p.orange(0) - time.sleep(delay) - p.yellow(0) - time.sleep(delay) - p.green(0) - time.sleep(delay) - p.blue(0) - time.sleep(delay) - p.white(0) - time.sleep(delay) - else: - p.all(0) - #time.sleep(0.5) - except Exception as e: - print(e) - p.all(0) - p.red(255) - p.white(255) - diff --git a/Workers/workDir/idleOff.sh b/Workers/workDir/idleOff.sh deleted file mode 100644 index 66e758df2a6ca3a961d5209e5a62a9cb3c55f428..0000000000000000000000000000000000000000 --- a/Workers/workDir/idleOff.sh +++ /dev/null @@ -1,2 +0,0 @@ - echo \{\"worker1\":0,\"worker2\":0,\"worker3\":0,\"worker4\":0,\"worker5\":0,\"worker6\":0,\"worker7\":0,\"worker8\":0\} > /var/www/html/control/index.html - echo \{\"LegionDisplay\":0,\"LegionHead\":0,\"LegionFile\":0\} > /var/www/html/network/index.html diff --git a/Workers/workDir/idleOn.sh b/Workers/workDir/idleOn.sh deleted file mode 100644 index 09a9a93f401587dbdb0f9f5882b3ff518241f145..0000000000000000000000000000000000000000 --- a/Workers/workDir/idleOn.sh +++ /dev/null @@ -1,2 +0,0 @@ - echo \{\"worker1\":1,\"worker2\":1,\"worker3\":1,\"worker4\":1,\"worker5\":1,\"worker6\":1,\"worker7\":1,\"worker8\":1\} > /var/www/html/control/index.html - echo \{\"LegionDisplay\":1,\"LegionHead\":1,\"LegionFile\":1\} > /var/www/html/network/index.html diff --git a/Workers/workDir/master.sh b/Workers/workDir/master.sh deleted file mode 100755 index cf0e22f45135a27a97256682b5d0c091757f7895..0000000000000000000000000000000000000000 --- a/Workers/workDir/master.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -#SBATCH --time=00:02:00 # Run time in hh:mm:ss -#SBATCH --mem-per-cpu=100 # Memory required in MB -#SBATCH --nodes=1 -#SBATCH --ntasks-per-node=4 -#SBATCH --job-name=Master -#SBATCH --error=/work/slurm/userJob%J.err -#SBATCH --output=/work/slurm/userJob.%J.out -#SBATCH --partition=Part1 - -python /work/HPCMagic.py diff --git a/Workers/workDir/slurmMock.sh b/Workers/workDir/slurmMock.sh deleted file mode 100755 index 25d467c8190062efe9ea39d81c6831cc5c3e7557..0000000000000000000000000000000000000000 --- a/Workers/workDir/slurmMock.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -#SBATCH --time=00:02:00 # Run time in hh:mm:ss -#SBATCH --mem-per-cpu=100 # Memory required in MB -#SBATCH --nodes=1 -#SBATCH --ntasks-per-node=4 -#SBATCH --job-name=SlurmMock -#SBATCH --error=/work/slurm/userJob%J.err -#SBATCH --output=/work/slurm/userJob.%J.out -#SBATCH --partition=Part1 - -python /work/HTC.py $A diff --git a/Workers/workDir/usage.py b/Workers/workDir/usage.py deleted file mode 100755 index 8a08b3208c1c7f4c0f5844a6182fa345bba49b84..0000000000000000000000000000000000000000 --- a/Workers/workDir/usage.py +++ /dev/null @@ -1,54 +0,0 @@ -from piglow import PiGlow -from time import sleep -import psutil -from random import randint -p = PiGlow() -val = 100 -colour = 1 -def cpu_temp(): - - with open('/sys/class/thermal/thermal_zone0/temp', 'r') as f: - temp = float(f.read()) / 1000.0 - - return temp -arm1 = [6,5,4,3,2,1] -arm2 = [12,11,10,9,8,7] -arm3 = [18,17,16,15,14,13] -arms = [arm1,arm2,arm3] -x = 0 -while True: - try: - cpuLoad = psutil.cpu_percent(percpu=True) - except: - print("Math dun goofed") - if cpu_temp() > 65: - p.red(255) - p.orange(255) - p.yellow(255) - sleep(0.005) - p.all(0) - else: - LEDList = [] - for i in range(0,3): - lights = randint(0,100)/17#cpuLoad[i]/17 -# print(cpuLoad) - LEDload = int(round(lights)) -# print("Core: " + str(i)) - for j in arms[i]: - if x <= LEDload: -# print("IF: " + str(x-int(lights)), x, int(lights)) - if (x-int(lights)) <=0: - p.led(j,128) - - else: -# print("ELSE",j,int(round((j-int(lights)*255)))) - p.led(j,int(round((j-int(lights)*64)))) - LEDList.append(j) -# print(j) - x = x + 1 - x = 0 - for k in range(1,18): - if k not in LEDList: - p.led(k,0) - sleep(0.08) -# print("-------------------") #print(cpu) diff --git a/configs/slurm.conf b/configs/slurm.conf deleted file mode 100644 index bf9a4c7cf3f09058f4de2c25820ecfec562145f8..0000000000000000000000000000000000000000 --- a/configs/slurm.conf +++ /dev/null @@ -1,59 +0,0 @@ -# -# csce 435/835 practicum slurm.conf -# - -# slurm.conf file generated by configurator easy.html. -# Put this file on all nodes of your cluster. -# See the slurm.conf man page for more information. -# -ControlMachine=LegionHead -ControlAddr=192.168.1.1 -NodeName=LegionHead - -#MailProg=/bin/mail -MpiDefault=none -#MpiParams=ports=#-# -ProctrackType=proctrack/pgid -ReturnToService=1 -SlurmctldPidFile=/var/run/slurm-llnl/slurmctld.pid -#SlurmctldPort=6817 -SlurmdPidFile=/var/run/slurm-llnl/slurmd.pid -#SlurmdPort=6818 -SlurmdSpoolDir=/var/lib/slurm-llnl/slurmd -SlurmUser=slurm -#SlurmdUser=root -StateSaveLocation=/var/lib/slurm-llnl/slurmctld -SwitchType=switch/none -TaskPlugin=task/none -# -# -# TIMERS -#KillWait=30 -#MinJobAge=300 -#SlurmctldTimeout=120 -#SlurmdTimeout=300 -# -# -# SCHEDULING -FastSchedule=1 -SchedulerType=sched/backfill -#SchedulerPort=7321 -SelectType=select/cons_res -SelectTypeParameters=CR_Core_Memory,CR_CORE_DEFAULT_DIST_BLOCK -# -# -# LOGGING AND ACCOUNTING -AccountingStorageType=accounting_storage/none -ClusterName=legion -#JobAcctGatherFrequency=30 -JobAcctGatherType=jobacct_gather/none -#SlurmctldDebug=3 -SlurmctldLogFile=/var/log/slurm-llnl/slurmctld.log -#SlurmdDebug=3 -SlurmdLogFile=/var/log/slurm-llnl/slurmd.log -# -# -# COMPUTE NODES -# NodeName=worker[1-10] CPUs=4 RealMemory=900 State=UNKNOWN -NodeName=worker[1-8] CPUs=4 RealMemory=900 State=UNKNOWN -PartitionName=Part1 Nodes=worker[1-8] Default=YES MaxTime=INFINITE State=UP