-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile.py
45 lines (36 loc) · 1.55 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
"""Decentralized-Py
"""
# Import the Portal object.
import geni.portal as portal
# Import the ProtoGENI library.
import geni.rspec.pg as pg
# Import the Emulab specific extensions.
import geni.rspec.emulab as emulab
# Create a portal object,
pc = portal.Context()
# Create a Request object to start building the RSpec.
request = pc.makeRequestRSpec()
pc.defineParameter("node_type", "Hardware spec of nodes to use. <br> Refer <a href=\"http://docs.aptlab.net/hardware.html#%28part._apt-cluster%29\">manual</a> for more details.",
portal.ParameterType.NODETYPE, "d750", legalValues=[], advanced=False, groupId=None)
pc.defineParameter("num_nodes", "Number of nodes to use.<br> Check cluster availability <a href=\"https://www.cloudlab.us/cluster-graphs.php\">here</a>.",
portal.ParameterType.INTEGER, 3, legalValues=[], advanced=False, groupId=None)
DISK_IMAGE = 'urn:publicid:IDN+emulab.net+image+emulab-ops//UBUNTU20-64-STD'
params = pc.bindParameters()
if params.num_nodes < 1:
pc.reportError(portal.ParameterError("You must choose a minimum of 1 node "))
pc.verifyParameters()
# Link link-0
link = request.Link('link-0')
link.Site('site-1')
for i in range(params.num_nodes):
node = request.RawPC("node-%s" % i)
node.hardware_type = params.node_type
node.disk_image = DISK_IMAGE
node.routable_control_ip = True
node.Site("site-1")
iface = node.addInterface("interface-%s" % i)
ip = "10.0.1." + str(i+1)
iface.addAddress(pg.IPv4Address(ip, "255.255.255.0"))
link.addInterface(iface)
# Print the generated rspec
pc.printRequestRSpec(request)