Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Holland Computing Center
HCCPiCluster
Commits
7298bea5
Commit
7298bea5
authored
Jun 03, 2019
by
Caughlin Bohn
Browse files
Network LED update
parent
bac7cba1
Changes
3
Hide whitespace changes
Inline
Side-by-side
DisplayNode/WorkerNetwork.py
View file @
7298bea5
...
...
@@ -3,6 +3,8 @@ import sys
from
neopixel
import
*
import
argparse
from
random
import
randint
import
os
,
stat
import
subprocess
# LED strip configuration:
LED_COUNT
=
100
# Number of LED pixels.
LED_PIN
=
18
# GPIO pin connected to the pixels (18 uses PWM!).
...
...
@@ -54,7 +56,7 @@ NetLights ={
'CA'
:
[
12
,
11
,
10
,
9
,
8
,
7
,
6
,
5
,
4
,
3
,
2
,
1
,
0
],
'CB'
:
[
12
,
13
,
14
,
15
,
16
,
17
,
18
,
19
],
'CD'
:
[
22
,
23
,
24
,
25
,
26
,
27
,
28
,
29
,
30
],
'DC'
:
[
30
,
29
,
28
,
2
,
7
,
26
,
25
,
24
,
23
,
22
],
'DC'
:
[
30
,
29
,
28
,
27
,
26
,
25
,
24
,
23
,
22
],
'DE'
:
[
31
,
50
,
51
],
'ED'
:
[
51
,
50
,
31
],
'DG'
:
[
31
,
32
,
33
],
...
...
@@ -77,8 +79,8 @@ NetLights ={
'KG'
:[
38
,
37
,
34
],
'HI'
:[
43
,
44
,
45
],
'IH'
:[
45
,
44
,
43
],
'HJ'
:[
4
3
,
46
,
47
],
'JH'
:[
47
,
46
,
4
3
]
'HJ'
:[
4
5
,
46
,
47
],
'JH'
:[
47
,
46
,
4
5
]
}
...
...
@@ -104,37 +106,65 @@ def find_path(graph, start, end, path=[]):
print
(
"starting"
)
import
random
iter
=
0
while
iter
<
int
(
sys
.
argv
[
3
]
):
def
delFile
(
fileName
):
start
=
NodePath
[
sys
.
argv
[
1
]]
end
=
NodePath
[
sys
.
argv
[
2
]]
### To do random
start_path
=
find_path
(
NetPath
,
start
,
end
)
path
=
[]
try
:
for
i
in
range
(
0
,
len
(
start_path
)
-
1
):
path
.
append
(
start_path
[
i
]
+
start_path
[
i
+
1
])
except
:
print
(
"empty path"
)
pipe
=
os
.
popen
(
"su pi"
,
'w'
)
pipe
.
write
(
"rm %s"
%
fileName
)
while
True
:
try
:
for
a
in
path
:
data
=
128
for
i
in
NetLights
.
get
(
a
):
strip
.
setPixelColor
(
i
,
Color
(
255
,
128
,
255
))
strip
.
show
()
time
.
sleep
(
0.01
)
files
=
[
filename
for
filename
in
os
.
listdir
(
'/work/netLogs/'
)
if
"host"
in
filename
]
filesTemp
=
[]
for
l
in
files
:
filesTemp
.
append
(
str
(
l
[
5
:]))
for
l
in
files
:
if
min
(
filesTemp
)
in
l
:
fi
=
l
fi
=
"/work/netLogs/"
+
fi
#fi = "/work/netLogs/"+os.listdir("/work/netLogs/")[0]
f
=
open
(
fi
,
'r'
)
data
=
f
.
readline
().
split
(
","
)
delFile
(
fi
)
print
(
data
)
iter
=
0
while
iter
<
int
(
data
[
2
]):
for
i
in
range
(
0
,
100
):
strip
.
setPixelColor
(
i
,
Color
(
0
,
0
,
0
))
strip
.
show
()
time
.
sleep
(
0.05
)
iter
+=
1
start
=
NodePath
[
data
[
0
]]
end
=
NodePath
[
data
[
1
]]
### To do random
start_path
=
find_path
(
NetPath
,
start
,
end
)
path
=
[]
try
:
for
i
in
range
(
0
,
len
(
start_path
)
-
1
):
path
.
append
(
start_path
[
i
]
+
start_path
[
i
+
1
])
except
:
print
(
"empty path"
)
old
=
100
r
,
g
,
b
=
randint
(
0
,
255
),
randint
(
0
,
255
),
randint
(
0
,
255
)
r
,
g
,
b
=
255
,
255
,
255
try
:
for
a
in
path
:
data
=
128
for
i
in
NetLights
.
get
(
a
):
strip
.
setPixelColor
(
i
,
Color
(
r
,
g
,
b
))
strip
.
setPixelColor
(
old
,
Color
(
0
,
0
,
0
))
old
=
i
strip
.
show
()
time
.
sleep
(
0.01
)
strip
.
setPixelColor
(
old
,
Color
(
0
,
0
,
0
))
for
i
in
range
(
0
,
100
):
strip
.
setPixelColor
(
i
,
Color
(
0
,
0
,
0
))
strip
.
show
()
#time.sleep(0.05)
iter
+=
1
except
Exception
as
e
:
print
(
str
(
e
))
x
=
0
print
(
"ERROR"
)
except
Exception
as
e
:
print
(
str
(
e
))
x
=
0
print
(
"ERROR"
)
pass
Workers/workDir/HPCMagic.py
View file @
7298bea5
...
...
@@ -7,23 +7,26 @@ 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
send
Command
(
"bash net.sh
head
worker"
+
host
+
"
5"
)
send
Command
(
"bash net.sh
worker"
+
host
+
"
file
5"
)
send
Command
(
"bash net.sh
file
worker"
+
host
+
"
5"
)
send
File
(
host
,
"
head
,
worker"
+
host
+
"
,
5"
)
send
File
(
host
,
"
worker"
+
host
+
"
,
file
,
5"
)
send
File
(
host
,
"
file
,
worker"
+
host
+
"
,
5"
)
for
i
in
workers
:
if
i
!=
host
:
#sendCommand("bash net.sh worker"+host+" worker"+i+" 1")
time
.
sleep
(
0.75
)
print
(
"sbatch slave"
+
i
+
".sh"
)
time
.
sleep
(
0.25
)
sendCommand
(
"sbatch slave"
+
i
+
".sh"
)
send
Command
(
"bash net.sh
worker"
+
host
+
"
worker"
+
i
+
"
1"
)
send
File
(
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
\"
"
)
...
...
@@ -31,8 +34,8 @@ for i in workers:
#sendCommand("bash slaveSubmit.sh")
end
=
time
.
time
()
+
40
while
time
.
time
()
<
end
:
send
Command
(
"bash net.sh
worker"
+
str
(
randint
(
1
,
8
))
+
"
worker"
+
str
(
randint
(
1
,
8
))
+
"
1"
)
send
File
(
host
,
"
worker"
+
str
(
randint
(
1
,
8
))
+
"
,
worker"
+
str
(
randint
(
1
,
8
))
+
"
,
1"
)
x
=
0
send
Command
(
"bash net.sh
worker"
+
host
+
"
file
5"
)
send
Command
(
"bash net.sh
worker"
+
host
+
"
head
5"
)
send
File
(
host
,
"
worker"
+
host
+
"
,
file
,
5"
)
send
File
(
host
,
"
worker"
+
host
+
"
,
head
,
5"
)
Workers/workDir/HTC.py
0 → 100755
View file @
7298bea5
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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment