forked from OCT-FPGA/oct-u280
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile.py
137 lines (115 loc) · 5.68 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
"""Configure FPGA nodes using a post-boot script.
"""
# Import the Portal object.
import geni.portal as portal
# Import the ProtoGENI library.
"""fpga
"""
# Import the Portal object.
import geni.portal as portal
# Import the ProtoGENI library.
import geni.rspec.pg as pg
# We use the URN library below.
import geni.urn as urn
# Emulab extension
import geni.rspec.emulab
# Create a portal context.
pc = portal.Context()
# Create a Request object to start building the RSpec.
request = pc.makeRequestRSpec()
# Variable number of nodes.
pc.defineParameter("nodeCount", "Number of Nodes", portal.ParameterType.INTEGER, 1,
longDescription="Enter the number of FPGA nodes. Maximum is 16.")
# Pick your image.
imageList = [
#('urn:publicid:IDN+emulab.net+image+emulab-ops//UBUNTU20-64-STD', 'UBUNTU 20.04'),
('urn:publicid:IDN+emulab.net+image+emulab-ops//UBUNTU18-64-STD', 'UBUNTU 18.04'),
('urn:publicid:IDN+emulab.net+image+emulab-ops//UBUNTU16-64-STD', 'UBUNTU 16.04'),
#('urn:publicid:IDN+emulab.net+image+emulab-ops//CENTOS8-64-STD', 'CENTOS 8.4'),
('urn:publicid:IDN+emulab.net+image+emulab-ops//CENTOS7-64-STD', 'CENTOS 7.9')]
toolVersion = [#('2022.1'),
('2021.1'),
('2020.2.1'),
('2020.2'),
('2020.1.1'),
('2020.1'),
('Do not install tools')]
pc.defineParameter("toolVersion", "Tool Version",
portal.ParameterType.STRING,
toolVersion[0], toolVersion,
longDescription="Select a tool version. It is recommended to use the latest version for the deployment workflow. For more information, visit https://www.xilinx.com/products/boards-and-kits/alveo/u280.html#gettingStarted")
pc.defineParameter("osImage", "Select Image",
portal.ParameterType.IMAGE,
imageList[0], imageList,
longDescription="Supported operating systems are Ubuntu and CentOS.")
# Optional ephemeral blockstore
pc.defineParameter("tempFileSystemSize", "Temporary Filesystem Size",
portal.ParameterType.INTEGER, 0,advanced=True,
longDescription="The size in GB of a temporary file system to mount on each of your " +
"nodes. Temporary means that they are deleted when your experiment is terminated. " +
"The images provided by the system have small root partitions, so use this option " +
"if you expect you will need more space to build your software packages or store " +
"temporary files.")
# Instead of a size, ask for all available space.
pc.defineParameter("tempFileSystemMax", "Temp Filesystem Max Space",
portal.ParameterType.BOOLEAN, False,
advanced=True,
longDescription="Instead of specifying a size for your temporary filesystem, " +
"check this box to allocate all available disk space. Leave the size above as zero.")
pc.defineParameter("tempFileSystemMount", "Temporary Filesystem Mount Point",
portal.ParameterType.STRING,"/mydata",advanced=True,
longDescription="Mount the temporary file system at this mount point; in general you " +
"you do not need to change this, but we provide the option just in case your software " +
"is finicky.")
# Retrieve the values the user specifies during instantiation.
params = pc.bindParameters()
# Check parameter validity.
if params.nodeCount < 1 or params.nodeCount > 8:
pc.reportError(portal.ParameterError("The number of FPGA nodes should be greater than 1 and less than 16.", ["nodeCount"]))
pass
if params.osImage == "urn:publicid:IDN+emulab.net+image+emulab-ops//CENTOS8-64-STD" and params.toolVersion == "2020.1":
pc.reportError(portal.ParameterError("OS and tool version mismatch.", ["osImage"]))
pass
pc.verifyParameters()
lan = request.LAN()
# Process nodes, adding to FPGA network
for i in range(params.nodeCount):
# Create a node and add it to the request
name = "node" + str(i)
node = request.RawPC(name)
node.disk_image = params.osImage
# Assign to the node hosting the FPGA.
node.hardware_type = "fpga-alveo"
node.component_manager_id = "urn:publicid:IDN+cloudlab.umass.edu+authority+cm"
# Since we want to create network links to the FPGA, it has its own identity.
fpganame = "fpga" + str(i)
fpga = request.RawPC(fpganame)
# UMass cluster
fpga.component_manager_id = "urn:publicid:IDN+cloudlab.umass.edu+authority+cm"
# Assign to the fgpa node
fpga.component_id = "fpga"
# Use the default image for the type of the node selected.
fpga.setUseTypeDefaultImage()
# Secret sauce.
fpga.SubNodeOf(node)
fpga_iface1 = fpga.addInterface()
fpga_iface1.component_id = "eth0"
fpga_iface2 = fpga.addInterface()
fpga_iface2.component_id = "eth1"
lan.addInterface(fpga_iface1)
lan.addInterface(fpga_iface2)
# Optional Blockstore
if params.tempFileSystemSize > 0 or params.tempFileSystemMax:
bs = node.Blockstore(name + "-bs", params.tempFileSystemMount)
if params.tempFileSystemMax:
bs.size = "0GB"
else:
bs.size = str(params.tempFileSystemSize) + "GB"
pass
bs.placement = "any"
pass
if params.toolVersion != "Do not install tools":
node.addService(pg.Execute(shell="bash", command="sudo /local/repository/post-boot.sh " + params.toolVersion + " >> /local/repository/output_log.txt"))
pass
pass
pc.printRequestRSpec(request)