-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy_code.py
More file actions
91 lines (71 loc) · 2.94 KB
/
deploy_code.py
File metadata and controls
91 lines (71 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#@author dposch
import os
import paramiko
import ssh_lib as ssh
import node_parser as np
MNG_PREFIX = "192.168.0."
EMU_PREFIX = "192.168.1."
ITEC_GATEWAY = "10.0.0.1" # todo change this once router is setup
PI_START_SUFFIX = 10
PI_END_SUFFIX = 29
DEPLOY_MODE = "DEBUG"
print "Deploying Code:"
# available pis: PREFIX.NR = IP
pi_list = range(PI_START_SUFFIX,PI_END_SUFFIX+1) # returns [start, ..., end-1]
print "Available PIs(" + str(len(pi_list)) + "): " + str(pi_list)
commands = {}
for i in pi_list:
commands[MNG_PREFIX+str(i)] = []
#change into ndn folder
commands[MNG_PREFIX+str(i)].append("cd ~/ndn")
#update itec-NFD
commands[MNG_PREFIX+str(i)].append("cd NFD")
commands[MNG_PREFIX+str(i)].append("git pull")
commands[MNG_PREFIX+str(i)].append("./waf")
commands[MNG_PREFIX+str(i)].append("sudo ./waf install")
commands[MNG_PREFIX+str(i)].append("cd ..")
#checkout ndn-apps
commands[MNG_PREFIX+str(i)].append("git clone https://github.com/danposch/ndn-apps.git")
commands[MNG_PREFIX+str(i)].append("cd ndn-apps")
commands[MNG_PREFIX+str(i)].append("git pull")
commands[MNG_PREFIX+str(i)].append("./waf")
commands[MNG_PREFIX+str(i)].append("sudo ./waf install")
commands[MNG_PREFIX+str(i)].append("cd ..")
#checkout and build libdash
commands[MNG_PREFIX+str(i)].append("git clone https://github.com/bitmovin/libdash.git")
commands[MNG_PREFIX+str(i)].append("cd libdash/")
commands[MNG_PREFIX+str(i)].append("git pull")
commands[MNG_PREFIX+str(i)].append("cd libdash/")
commands[MNG_PREFIX+str(i)].append("mkdir build")
commands[MNG_PREFIX+str(i)].append("cd build")
commands[MNG_PREFIX+str(i)].append("cmake ../")
commands[MNG_PREFIX+str(i)].append("make")
commands[MNG_PREFIX+str(i)].append("cd ../../../")
commands[MNG_PREFIX+str(i)].append("sudo cp ./libdash/libdash/build/bin/libdash.so /usr/lib/")
commands[MNG_PREFIX+str(i)].append("sudo mkdir /usr/include/libdash")
commands[MNG_PREFIX+str(i)].append("sudo cp -r ./libdash/libdash/libdash/include/* /usr/include/libdash/")
#checkout and build ndn-demo apps
commands[MNG_PREFIX+str(i)].append("git clone https://github.com/theuerse/ndn-DemoApps.git")
commands[MNG_PREFIX+str(i)].append("cd ndn-DemoApps/")
commands[MNG_PREFIX+str(i)].append("git pull")
commands[MNG_PREFIX+str(i)].append("./waf configure")
commands[MNG_PREFIX+str(i)].append("./waf")
commands[MNG_PREFIX+str(i)].append("sudo ./waf install")
commands[MNG_PREFIX+str(i)].append("cd ..")
for pi in commands:
#if pi != "192.168.0.13":
#continue
f = open(os.getenv("HOME")+"/deploy_code.sh",'w')
f.write('#!/bin/sh\n') # python will convert \n to os.linesep
print "Deploying Code to PI: " + pi
for c in commands[pi]:
#print c
f.write(c+"\n")
print
f.close()
s = ssh.Connection(pi, 'nfd', password = 'nfd')
s.put(os.getenv("HOME")+"/deploy_code.sh", '/home/nfd/deploy_code.sh')
s.execute("chmod +x /home/nfd/deploy_code.sh")
s.execute("screen -d -m /home/nfd/deploy_code.sh")
s.close()
print "Code deployed on PIs!\n"