Commit 7807ade7 authored by Keith Downie's avatar Keith Downie

Moved geni-lib examples to their own files and updated them for the new geni-lib methods

parent 4b06f4cd
import geni.portal as portal
import geni.rspec.pg as pg
pc = portal.Context()
rspec = pg.Request()
node1 = pg.XenVM("node1")
iface1 = node1.addInterface("if1")
# Specify the component id and the IPv4 address
iface1.component_id = "eth1"
iface1.addAddress(pg.IPv4Address("192.168.1.1", "255.255.255.0"))
rspec.addResource(node1)
node2 = pg.XenVM("node2")
iface2 = node2.addInterface("if2")
# Specify the component id and the IPv4 address
iface2.component_id = "eth2"
iface2.addAddress(pg.IPv4Address("192.168.1.2", "255.255.255.0"))
rspec.addResource(node2)
link = pg.LAN("lan")
link.addInterface(iface1)
link.addInterface(iface2)
rspec.addResource(link)
pc.printRequestRSpec(rspec)
\ No newline at end of file
import geni.portal as portal
import geni.rspec.pg as pg
pc = portal.Context()
rspec = pg.Request()
node1 = pg.XenVM("node1")
# Specify the URL for the disk image
node1.disk_image = "<URL to disk image>"
# Install and execute scripts on the VM
node1.addService(pg.Install(url="<URL to the tarball file>", path="local"))
node1.addService(pg.Execute(shell="bash", command="<Path to executable>"))
rspec.addResource(node1)
pc.printRequestRSpec(rspec)
\ No newline at end of file
# Import the Portal object.
import geni.portal as portal
# Import the ProtoGENI library.
import geni.rspec.pg as pg
# Create the Portal context.
pc = portal.Context()
# Create a Request object to start building the RSpec.
rspec = pg.Request()
......@@ -8,5 +13,5 @@ rspec = pg.Request()
node = pg.XenVM("node")
rspec.addResource(node)
# Output the RSpec to the enclosing page.
printRspec(rspec)
# Print the RSpec to the enclosing page.
pc.printRequestRSpec(rspec)
\ No newline at end of file
import geni.portal as portal
import geni.rspec.pg as pg
pc = portal.Context()
rspec = pg.Request()
# Create a XenVM nodes.
node1 = pg.XenVM("node1")
node2 = pg.XenVM("node2")
# Create interfaces for each node.
iface1 = node1.addInterface("if1")
iface2 = node2.addInterface("if2")
rspec.addResource(node1)
rspec.addResource(node2)
# Create a link with the type of LAN.
link = pg.LAN("lan")
# Add both node interfaces to the link.
link.addInterface(iface1)
link.addInterface(iface2)
# Add the link to the RSpec.
rspec.addResource(link)
pc.printRequestRSpec(rspec)
\ No newline at end of file
......@@ -249,88 +249,21 @@ about @tt{geni-lib} and additional examples, can be found in the
@code-sample["geni-lib-single-vm.py"]
@subsection[#:tag "geni-lib-example-2"]{Two XenVM nodes with a LAN between them}
@codeblock|{
import geni.rspec.pg as pg
rspec = pg.Request()
#; Create a XenVM nodes.
node1 = pg.XenVM("node1")
node2 = pg.XenVM("node2")
#; Create interfaces for each node.
iface1 = node1.addInterface("if1")
iface2 = node2.addInterface("if2")
rspec.addResource(node1)
rspec.addResource(node2)
#; Create a link with the type of LAN.
link = pg.LAN("lan")
#; Add both node interfaces to the link.
link.addInterface(iface1)
link.addInterface(iface2)
@subsection[#:tag "geni-lib-example-2"]{Two XenVM nodes with a LAN between them}
#; Add the link to the RSpec.
rspec.addResource(link)
@code-sample["geni-lib-two-vm-lan.py"]
printRspec(rspec)
}|
@subsection[#:tag "geni-lib-example-3"]{Set a specific IP address on each node}
@codeblock|{
import geni.rspec.pg as pg
rspec = pg.Request()
node1 = pg.XenVM("node1")
iface1 = node1.addInterface("if1")
#; Specify the component id and the IPv4 address
iface1.component_id = "eth1"
iface1.addAddress(pg.IPv4Address("192.168.1.1", "255.255.255.0"))
rspec.addResource(node1)
@code-sample["geni-lib-node-ips.py"]
node2 = pg.XenVM("node2")
iface2 = node2.addInterface("if2")
#; Specify the component id and the IPv4 address
iface2.component_id = "eth2"
iface2.addAddress(pg.IPv4Address("192.168.1.2", "255.255.255.0"))
rspec.addResource(node2)
link = pg.LAN("lan")
link.addInterface(iface1)
link.addInterface(iface2)
rspec.addResource(link)
printRspec(rspec)
}|
@subsection[#:tag "geni-lib-example-4"]{Specify an operating system and set install and execute scripts}
@codeblock|{
import geni.rspec.pg as pg
rspec = pg.Request()
node1 = pg.XenVM("node1")
#; Specify the URL for the disk image
node1.disk_image = "<URL to disk image>"
#; Install and execute scripts on the VM
node1.addService(pg.Install(url="<URL to the tarball file>", path="local"))
node1.addService(pg.Execute(shell="bash", command="<Path to executable>"))
@code-sample["geni-lib-os-install-scripts.py"]
rspec.addResource(node1)
printRspec(rspec)
}|
@section[#:tag "creating-from-scratch"]{Creating a profile from scratch}
......
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