-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathprofile.py
91 lines (75 loc) · 3.62 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
"""This profile sets up a simple NFS server and a network of clients. The NFS server uses
*temporary* storage on one of your nodes, the contents will be lost when you terminate your
experiment. We have a different profile available if you need your NFS server data to
persist after your experiment is terminated.
Instructions:
Click on any node in the topology and choose the `shell` menu item. Your shared NFS directory is mounted at `/nfs` on all nodes."""
# 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 context.
pc = portal.Context()
# Create a Request object to start building the RSpec.
request = pc.makeRequestRSpec()
# Client image list
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//CENTOS8-64-STD', 'CENTOS 8'),
('urn:publicid:IDN+emulab.net+image+emulab-ops//CENTOS7-64-STD', 'CENTOS 7'),
('urn:publicid:IDN+emulab.net+image+emulab-ops//FBSD131-64-STD', 'FreeBSD 13.1'),
('urn:publicid:IDN+emulab.net+image+emulab-ops//FBSD123-64-STD', 'FreeBSD 12.3'),
]
# Server image list, not tested with CentOS
imageList2 = [
('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//FBSD131-64-STD', 'FreeBSD 13.1'),
('urn:publicid:IDN+emulab.net+image+emulab-ops//FBSD123-64-STD', 'FreeBSD 12.3'),
]
# Do not change these unless you change the setup scripts too.
nfsServerName = "nfs"
nfsLanName = "nfsLan"
nfsDirectory = "/nfs"
# Number of NFS clients (there is always a server)
pc.defineParameter("clientCount", "Number of NFS clients",
portal.ParameterType.INTEGER, 2)
pc.defineParameter("osImage", "Select OS image for clients",
portal.ParameterType.IMAGE,
imageList[0], imageList)
pc.defineParameter("osServerImage", "Select OS image for server",
portal.ParameterType.IMAGE,
imageList2[0], imageList2)
pc.defineParameter("nfsSize", "Size of NFS Storage",
portal.ParameterType.STRING, "200GB",
longDescription="Size of disk partition to allocate on NFS server")
# Always need this when using parameters
params = pc.bindParameters()
# The NFS network. All these options are required.
nfsLan = request.LAN(nfsLanName)
nfsLan.best_effort = True
nfsLan.vlan_tagging = True
nfsLan.link_multiplexing = True
# The NFS server.
nfsServer = request.RawPC(nfsServerName)
nfsServer.disk_image = params.osServerImage
# Attach server to lan.
nfsLan.addInterface(nfsServer.addInterface())
# Storage file system goes into a local (ephemeral) blockstore.
nfsBS = nfsServer.Blockstore("nfsBS", nfsDirectory)
nfsBS.size = params.nfsSize
# Initialization script for the server
nfsServer.addService(pg.Execute(shell="sh", command="sudo /bin/bash /local/repository/nfs-server.sh"))
# The NFS clients, also attached to the NFS lan.
for i in range(1, params.clientCount+1):
node = request.RawPC("node%d" % i)
node.disk_image = params.osImage
nfsLan.addInterface(node.addInterface())
# Initialization script for the clients
node.addService(pg.Execute(shell="sh", command="sudo /bin/bash /local/repository/nfs-client.sh"))
pass
# Print the RSpec to the enclosing page.
pc.printRequestRSpec(request)