|
| 1 | +""" |
| 2 | +Setup script for deploying train-ticket on CloudLab |
| 3 | +""" |
| 4 | + |
| 5 | +# Import the Portal object. |
| 6 | +import geni.portal as portal |
| 7 | +# Import the ProtoGENI library. |
| 8 | +import geni.rspec.pg as pg |
| 9 | + |
| 10 | +# Create a portal context. |
| 11 | +pc = portal.Context() |
| 12 | + |
| 13 | +# Create a Request object to start building the RSpec. |
| 14 | +request = pc.makeRequestRSpec() |
| 15 | + |
| 16 | +# Pick your OS. |
| 17 | +imageList = [ |
| 18 | + ('default', 'Default Image'), |
| 19 | + ('urn:publicid:IDN+emulab.net+image+emulab-ops//UBUNTU18-64-STD', 'UBUNTU 18.04'), |
| 20 | + ('urn:publicid:IDN+emulab.net+image+emulab-ops//UBUNTU20-64-STD', 'UBUNTU 20.04'), |
| 21 | + ('urn:publicid:IDN+emulab.net+image+emulab-ops//CENTOS7-64-STD', 'CENTOS 7'), |
| 22 | + ('urn:publicid:IDN+emulab.net+image+emulab-ops//CENTOS8-64-STD', 'CENTOS 8'), |
| 23 | + ('urn:publicid:IDN+emulab.net+image+emulab-ops//FBSD114-64-STD', 'FreeBSD 11.4'), |
| 24 | + ('urn:publicid:IDN+emulab.net+image+emulab-ops//FBSD122-64-STD', 'FreeBSD 12.2')] |
| 25 | + |
| 26 | +pc.defineParameter("osImage", "Select OS image", |
| 27 | + portal.ParameterType.IMAGE, |
| 28 | + imageList[0], imageList, |
| 29 | + longDescription="Most clusters have this set of images, " + |
| 30 | + "pick your favorite one.") |
| 31 | + |
| 32 | +# Optional physical type for all nodes. |
| 33 | +pc.defineParameter("physType", "Optional physical node type", |
| 34 | + portal.ParameterType.STRING, "", |
| 35 | + longDescription="Specify a physical node type (pc3000,d710,etc) " + |
| 36 | + "instead of letting the resource mapper choose for you.") |
| 37 | + |
| 38 | +# Optional ephemeral blockstore |
| 39 | +pc.defineParameter("tempFileSystemSize", "Temporary Filesystem Size", |
| 40 | + portal.ParameterType.INTEGER, 0,advanced=True, |
| 41 | + longDescription="The size in GB of a temporary file system to mount on each of your " + |
| 42 | + "nodes. Temporary means that they are deleted when your experiment is terminated. " + |
| 43 | + "The images provided by the system have small root partitions, so use this option " + |
| 44 | + "if you expect you will need more space to build your software packages or store " + |
| 45 | + "temporary files.") |
| 46 | + |
| 47 | +# Instead of a size, ask for all available space. |
| 48 | +pc.defineParameter("tempFileSystemMax", "Temp Filesystem Max Space", |
| 49 | + portal.ParameterType.BOOLEAN, False, |
| 50 | + advanced=True, |
| 51 | + longDescription="Instead of specifying a size for your temporary filesystem, " + |
| 52 | + "check this box to allocate all available disk space. Leave the size above as zero.") |
| 53 | + |
| 54 | +pc.defineParameter("tempFileSystemMount", "Temporary Filesystem Mount Point", |
| 55 | + portal.ParameterType.STRING,"/mydata",advanced=True, |
| 56 | + longDescription="Mount the temporary file system at this mount point; in general you " + |
| 57 | + "you do not need to change this, but we provide the option just in case your software " + |
| 58 | + "is finicky.") |
| 59 | + |
| 60 | +# Retrieve the values the user specifies during instantiation. |
| 61 | +params = pc.bindParameters() |
| 62 | + |
| 63 | +if params.tempFileSystemSize < 0 or params.tempFileSystemSize > 200: |
| 64 | + pc.reportError(portal.ParameterError("Please specify a size greater then zero and " + |
| 65 | + "less then 200GB", ["tempFileSystemSize"])) |
| 66 | +pc.verifyParameters() |
| 67 | + |
| 68 | +# Add a raw PC to the request. |
| 69 | +node = request.RawPC("node") |
| 70 | + |
| 71 | +# Set OS Image |
| 72 | +if params.osImage and params.osImage != "default": |
| 73 | + node.disk_image = params.osImage |
| 74 | + |
| 75 | +# Optional hardware type. |
| 76 | +if params.physType != "": |
| 77 | + node.hardware_type = params.physType |
| 78 | + |
| 79 | +# Optional Blockstore |
| 80 | +if params.tempFileSystemSize > 0 or params.tempFileSystemMax: |
| 81 | + bs = node.Blockstore("node-bs", params.tempFileSystemMount) |
| 82 | + if params.tempFileSystemMax: |
| 83 | + bs.size = "0GB" |
| 84 | + else: |
| 85 | + bs.size = str(params.tempFileSystemSize) + "GB" |
| 86 | + bs.placement = "any" |
| 87 | + |
| 88 | +# Install and execute a script that is contained in the repository. |
| 89 | +node.addService(pg.Execute(shell="bash", command="/local/repository/changeShells.sh")) |
| 90 | +node.addService(pg.Execute(shell="bash", command="/local/repository/setupAll.sh")) |
| 91 | + |
| 92 | +# Print the RSpec to the enclosing page. |
| 93 | +pc.printRequestRSpec(request) |
| 94 | + |
0 commit comments