Commit 5d7fe1c5 authored by Robert Ricci's avatar Robert Ricci

Add three new code samples

Asking for a raw PC, asking for ARM machines, and setting up a
parameterized profile. Also re-worked #:tags to be more meaningful
parent 780b409c
import geni.portal as portal
import as RSpec
# The legal types of nodes - note that the first string in each pair is the
# string that will get put in the RSpec, and the second is the one that will
# get shown to the user. If there is no need to show the user a different string,
# each element of the array can be a simple string rather than a tuple.
hw_types = [("m400", "ARM64"), ("dl360", "x86-64")]
pc = portal.Context()
# Define parameters - see this page for API documentation for the
# defineParameter() call:
pc.defineParameter("N", "Number of nodes",
portal.ParameterType.INTEGER, 5)
pc.defineParameter("hwtype", "Hardware type",
portal.ParameterType.NODETYPE, "m400", hw_types)
pc.defineParameter("lan", "Put all nodes in a LAN",
portal.ParameterType.BOOLEAN, False)
# Get values for the parameters - since a default is required by defineParameter,
# the params object is guaranteed to contain a vale for every parameter
params = pc.bindParameters()
rspec = RSpec.Request()
# Create a LAN iff one was requested
if (params.lan):
lan = RSpec.LAN()
# Loop through the number of nodes requested, settting up each and adding it
# to the RSpec
for i in range(1, params.N+1):
node = RSpec.RawPC("node%d" % i)
node.hardware_type = params.hwtype
# Only create an interface if we are putting all nodes into a LAN
if params.lan:
iface = node.addInterface("eth0")
# Import the Portal object.
import geni.portal as portal
# Import the ProtoGENI library.
import as pg
# Create the Portal context.
pc = portal.Context()
# Create a Request object to start building the RSpec.
rspec = pg.Request()
# Create a raw PC and add it to the RSpec.
node = pg.RawPC("node")
# Print the RSpec to the enclosing page.
import geni.portal as portal
import as pg
pc = portal.Context()
rspec = pg.Request()
# Create two raw "PC" nodes
node1 = pg.RawPC("node1")
node2 = pg.RawPC("node2")
# Set each of the two to specifically request "m400" nodes, which in CloudLab, are ARM
node1.hardware_type = "m400"
node2.hardware_type = "m400"
# Create interfaces for each node.
iface1 = node1.addInterface("if1")
iface2 = node2.addInterface("if2")
# Create a link with the type of LAN.
link = pg.LAN("lan")
# Add both node interfaces to the link.
# Add the link to the RSpec.
......@@ -246,22 +246,28 @@ The following examples demonstrate basic @tt{geni-lib} usage. More information
about @tt{geni-lib} and additional examples, can be found in the
@hyperlink[""]{@tt{geni-lib} repository}.
@subsection[#:tag "geni-lib-example-1"]{A Single XEN VM node}
@subsection[#:tag "geni-lib-example-single-vm"]{A single XEN VM node}
@subsection[#:tag "geni-lib-example-single-pc"]{A single physical host}
@subsection[#:tag "geni-lib-example-2"]{Two XenVM nodes with a LAN between them}
@subsection[#:tag "geni-lib-example-two-vm-lan"]{Two XenVM nodes with a LAN between them}
@subsection[#:tag "geni-lib-example-two-arm-lan"]{Two ARM64 servers in a LAN}:w
@subsection[#:tag "geni-lib-example-3"]{Set a specific IP address on each node}
@subsection[#:tag "geni-lib-example-node-ips"]{Set a specific IP address on each node}
@subsection[#:tag "geni-lib-example-4"]{Specify an operating system and set install and execute scripts}
@subsection[#:tag "geni-lib-example-os-install-scripts"]{Specify an operating system and set install and execute scripts}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment