-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathprofile.py
237 lines (202 loc) · 8.99 KB
/
profile.py
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
#!/usr/bin/env python
kube_description= \
"""
Nervion's Powder profile
"""
kube_instruction= \
"""
Find a complete how-to guide here: https://github.com/j0lama/nervion-powder/blob/master/README.md
"""
#
# Standard geni-lib/portal libraries
#
import geni.portal as portal
import geni.rspec.pg as PG
import geni.rspec.emulab as elab
import geni.rspec.igext as IG
import geni.urn as URN
#
# PhantomNet extensions.
#
import geni.rspec.emulab.pnext as PN
def newMachine(rspec, params, name):
if params.Hardware == 'VM':
machine = rspec.XenVM(name)
machine.cores = int(params.cores)
machine.ram = 1024 * int(params.ram)
else:
machine = rspec.RawPC(name)
machine.hardware_type = params.Hardware
return machine
#
# Globals
#
class GLOBALS(object):
OAI_DS = "urn:publicid:IDN+emulab.net:phantomnet+ltdataset+oai-develop"
OAI_SIM_DS = "urn:publicid:IDN+emulab.net:phantomnet+dataset+PhantomNet:oai"
UE_IMG = URN.Image(PN.PNDEFS.PNET_AM, "PhantomNet:ANDROID444-STD")
ADB_IMG = URN.Image(PN.PNDEFS.PNET_AM, "PhantomNet:UBUNTU14-64-PNTOOLS")
OAI_EPC_IMG = URN.Image(PN.PNDEFS.PNET_AM, "PhantomNet:UBUNTU16-64-OAIEPC")
OAI_ENB_IMG = URN.Image(PN.PNDEFS.PNET_AM, "PhantomNet:OAI-Real-Hardware.enb1")
OAI_SIM_IMG = URN.Image(PN.PNDEFS.PNET_AM, "PhantomNet:UBUNTU14-64-OAI")
OAI_SRS_EPC = URN.Image(PN.PNDEFS.PNET_AM, "PhantomNet:srsEPC-OAICN")
OAI_CONF_SCRIPT = "/usr/bin/sudo /local/repository/bin/config_oai.pl"
MSIMG = "urn:publicid:IDN+emulab.net+image+PhantomNet:mobilestream-v1"
def connectOAI_DS(node):
# Create remote read-write clone dataset object bound to OAI dataset
bs = rspec.RemoteBlockstore("ds-%s" % node.name, "/opt/oai")
bs.dataset = GLOBALS.OAI_DS
bs.Site('Core')
bs.rwclone = True
# Create link from node to OAI dataset rw clone
node_if = node.addInterface("dsif_%s" % node.name)
bslink = rspec.Link("dslink_%s" % node.name)
bslink.addInterface(node_if)
bslink.addInterface(bs.interface)
bslink.vlan_tagging = True
bslink.best_effort = True
#
# This geni-lib script is designed to run in the PhantomNet Portal.
#
pc = portal.Context()
#
# Profile parameters.
#
pc.defineParameter("computeNodeCount", "Number of slave/compute nodes",
portal.ParameterType.INTEGER, 1)
#pc.defineParameter("EPC", "EPC implementation",
# portal.ParameterType.STRING,"OAI",[("OAI","Open Air Inrterface"),("srsLTE","srsLTE"), ("MobileStream", "MobileStream"), ("NextEPC", "NextEPC"), ("free5GC", "free5GC"), ("Open5GS", "Open5GS"), ('Empty','Empty')])
pc.defineParameter("EPC", "EPC implementation",
portal.ParameterType.STRING,"OAI",[("OAI","Open Air Inrterface"),("srsLTE","srsLTE"), ("MobileStream", "MobileStream"), ("NextEPC", "NextEPC"), ("free5GC", "free5GC"), ("Open5GS", "Open5GS"), ("CoreKube", "CoreKube"), ('Empty','Empty')])
pc.defineParameter("Hardware", "EPC hardware",
portal.ParameterType.STRING,"d430",[("d430","d430"),("d710","d710"), ("d820", "d820"), ("pc3000", "pc3000"), ("VM", "VM")])
pc.defineParameter("multi", "Multiplexer (True or False)",
portal.ParameterType.BOOLEAN, True)
pc.defineParameter("cores", "VM number of cores",
portal.ParameterType.STRING,"4",[("4","4"),("6","6"), ("8", "8"), ("10", "10"), ("12", "12")],
longDescription="Number of cores of each Nervion node.",
advanced=True)
pc.defineParameter("ram", "RAM size",
portal.ParameterType.STRING,"4",[("4","4"),("8","8"), ("12", "12"), ("16", "16"), ("20", "20"), ("24", "24"), ("32", "32")],
longDescription="VM RAM size (GB)",
advanced=True)
pc.defineParameter("ck_nodes", "Number of slave/compute nodes for CoreKube",
portal.ParameterType.INTEGER, 1, advanced=True)
pc.defineParameter("ck_version", "CoreKube version",
portal.ParameterType.STRING,"4G",[("4G","4G"),("5G","5G")], longDescription='CoreKube 4G or 5G', advanced=True)
params = pc.bindParameters()
#
# Give the library a chance to return nice JSON-formatted exception(s) and/or
# warnings; this might sys.exit().
#
pc.verifyParameters()
if params.EPC == "OAI":
rspec = pc.makeRequestRSpec()
epc = newMachine(rspec, params, "epc")
epc.disk_image = GLOBALS.OAI_EPC_IMG
epc.addService(PG.Execute(shell="sh", command="/usr/bin/sudo /local/repository/bin/config_oai.pl -r EPC"))
connectOAI_DS(epc)
elif params.EPC == "srsLTE":
rspec = pc.makeRequestRSpec()
epc = newMachine(rspec, params, "epc")
epc.disk_image = GLOBALS.OAI_EPC_IMG
epc.addService(PG.Execute(shell="sh", command="/usr/bin/sudo /local/repository/scripts/srslte.sh"))
elif params.EPC == "MobileStream":
rspec = PG.Request()
epc = newMachine(rspec, params, "node0")
epc.disk_image = GLOBALS.MSIMG
elif params.EPC == "NextEPC":
rspec = PG.Request()
epc = newMachine(rspec, params, "epc")
epc.disk_image = 'urn:publicid:IDN+emulab.net+image+emulab-ops:UBUNTU18-64-STD'
epc.addService(PG.Execute(shell="sh", command="/usr/bin/sudo /local/repository/scripts/nextepc.sh"))
elif params.EPC == "Open5GS":
rspec = PG.Request()
epc = newMachine(rspec, params, "epc")
epc.disk_image = 'urn:publicid:IDN+emulab.net+image+emulab-ops:UBUNTU18-64-STD'
epc.addService(PG.Execute(shell="sh", command="/usr/bin/sudo /local/repository/scripts/open5gs_setup.sh"))
elif params.EPC == "free5GC":
rspec = PG.Request()
epc = newMachine(rspec, params, "epc")
epc.disk_image = 'urn:publicid:IDN+emulab.net+image+emulab-ops:UBUNTU18-64-STD'
elif params.EPC == "CoreKube":
rspec = PG.Request()
ck_master = newMachine(rspec, params, "masterck")
ck_master.routable_control_ip = True
ck_master.disk_image = 'urn:publicid:IDN+emulab.net+image+emulab-ops:UBUNTU18-64-STD'
if params.ck_version == '4G':
ck_master.addService(PG.Execute(shell="bash", command="/local/repository/scripts/ck_master.sh"))
else:
ck_master.addService(PG.Execute(shell="bash", command="/local/repository/scripts/ck_5g_master.sh"))
elif params.EPC == "Empty":
rspec = PG.Request()
epc = newMachine(rspec, params, "core")
epc.disk_image = 'urn:publicid:IDN+emulab.net+image+emulab-ops:UBUNTU18-64-STD'
tour = IG.Tour()
tour.Description(IG.Tour.TEXT,kube_description)
tour.Instructions(IG.Tour.MARKDOWN,kube_instruction)
rspec.addTour(tour)
netmask="255.255.255.0"
epclink = rspec.Link("s1-lan")
if params.EPC == 'CoreKube':
ck_master.Site('CK')
iface = ck_master.addInterface()
iface.addAddress(PG.IPv4Address("192.168.4.80", netmask))
epclink.addInterface(iface)
else:
epc.Site('Core')
iface = epc.addInterface()
iface.addAddress(PG.IPv4Address("192.168.4.80", netmask))
epclink.addInterface(iface)
# CK Slaves
if params.EPC == 'CoreKube':
for i in range(0,params.ck_nodes):
#ck_s = rspec.XenVM('ck_slave'+str(i))
#ck_s.cores = int(params.cores)
#ck_s.ram = 1024 * int(params.ram)
ck_s = newMachine(rspec, params, 'ck_slave'+str(i))
ck_s.routable_control_ip = True
ck_s.disk_image = 'urn:publicid:IDN+emulab.net+image+emulab-ops:UBUNTU18-64-STD'
ck_s.Site('CK')
iface = ck_s.addInterface()
iface.addAddress(PG.IPv4Address("192.168.4." + str(79-i), netmask))
epclink.addInterface(iface)
ck_s.addService(PG.Execute(shell="bash", command="/local/repository/scripts/ck_slave.sh"))
# MULTIPLEXER
if params.multi == True:
multiplexer = rspec.XenVM('multiplexer')
multiplexer.cores = 2
multiplexer.ram = 1024 * 4
multiplexer.routable_control_ip = True
multiplexer.disk_image = 'urn:publicid:IDN+emulab.net+image+emulab-ops:UBUNTU18-64-STD'
multiplexer.Site('Nervion')
iface = multiplexer.addInterface()
iface.addAddress(PG.IPv4Address("192.168.4.81", netmask))
epclink.addInterface(iface)
multiplexer.addService(PG.Execute(shell="bash", command="/local/repository/scripts/multiplexer/run.sh"))
# Nervion Master
kube_m = newMachine(rspec, params, "master")
kube_m.routable_control_ip = True
kube_m.disk_image = 'urn:publicid:IDN+emulab.net+image+emulab-ops:UBUNTU18-64-STD'
kube_m.Site('Nervion')
iface = kube_m.addInterface()
iface.addAddress(PG.IPv4Address("192.168.4.82", netmask))
epclink.addInterface(iface)
kube_m.addService(PG.Execute(shell="bash", command="/local/repository/scripts/master.sh"))
# Nervion Slaves
for i in range(0,params.computeNodeCount):
kube_s = newMachine(rspec, params, 'slave'+str(i))
kube_s.routable_control_ip = True
kube_s.disk_image = 'urn:publicid:IDN+emulab.net+image+emulab-ops:UBUNTU18-64-STD'
kube_s.Site('Nervion')
iface = kube_s.addInterface()
iface.addAddress(PG.IPv4Address("192.168.4." + str(i+83), netmask))
epclink.addInterface(iface)
kube_s.addService(PG.Execute(shell="bash", command="/local/repository/scripts/slave.sh"))
epclink.link_multiplexing = True
epclink.vlan_tagging = True
epclink.best_effort = True
#
# Print and go!
#
pc.printRequestRSpec(rspec)