Commit cc34bce5 authored by Robert Ricci's avatar Robert Ricci

Move geni-lib section to 'creating profiles'

parent e87522a8
...@@ -29,130 +29,6 @@ manipulate RSpecs directly. ...@@ -29,130 +29,6 @@ manipulate RSpecs directly.
@italic{Still to come: documentation of @(tb)'s extensions to the RSpec format.} @italic{Still to come: documentation of @(tb)'s extensions to the RSpec format.}
@section[#:tag "geni-lib"]{geni-lib}
Geni-lib is a tool that allows users to generate RSpec files from Python
code. An @bold{experimental} feature of @(tb) is the ability to use geni-lib
scripts as the definition of a profile, rather then the more primitive
RSpec format. When you supply a geni-lib script on the
@seclink["creating-profiles"]{Create Profile} page, your script is uploaded
to the server so that it can be executed in the geni-lib environment. This
allows the script to be verified for correctness, and also produces the
equivalent RSpec representation that you can view if you so desire.
When you provide a geni-lib script, you will see a slightly different set
of buttons on the @seclink["creating-profiles"]{Create Profile} page; next
to the ``Source'' button there is an ``XML'' button that will pop up the
RSpec XML for you to look at. The XML is read-only; if you want to change
the profile, you will need to change the python source code that is
displayed when you click on the ``Source'' button. Each time you change the
python source code, the script is uploaded to the server and processed. Be
sure to save your changes if you are
@seclink["updating-profiles"]{updating an existing profile}.
The following examples demonstrate basic geni-lib usage. More information
about geni-lib and additional examples, can be found in the
@hyperlink["https://bitbucket.org/barnstorm/geni-lib/src"]{geni-lib repository}.
@subsection[#:tag "geni-lib-example-1"]{A Single XEN VM node}
@codeblock|{
#; Import the ProtoGENI library.
import geni.rspec.pg as pg
#; Create a Request object to start building the RSpec.
rspec = pg.Request()
#; Create a XenVM and add it to the RSpec.
node = pg.XenVM("node")
rspec.addResource(node)
#; Output the RSpec to the enclosing page.
printRspec(rspec)
}|
@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)
#; Add the link to the RSpec.
rspec.addResource(link)
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)
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>"))
rspec.addResource(node1)
printRspec(rspec)
}|
@section[#:tag "public-ip-access"]{Public IP Access} @section[#:tag "public-ip-access"]{Public IP Access}
......
...@@ -186,6 +186,131 @@ your experiment expire. If something goes wrong, we do keep one previous image ...@@ -186,6 +186,131 @@ your experiment expire. If something goes wrong, we do keep one previous image
file for each profile; currently, the only way to get access to this backup file for each profile; currently, the only way to get access to this backup
is to @seclink["getting-help"]{contact us}. is to @seclink["getting-help"]{contact us}.
@section[#:tag "geni-lib"]{geni-lib}
Geni-lib is a tool that allows users to generate RSpec files from Python
code. An @bold{experimental} feature of @(tb) is the ability to use geni-lib
scripts as the definition of a profile, rather then the more primitive
RSpec format. When you supply a geni-lib script on the
@seclink["creating-profiles"]{Create Profile} page, your script is uploaded
to the server so that it can be executed in the geni-lib environment. This
allows the script to be verified for correctness, and also produces the
equivalent RSpec representation that you can view if you so desire.
When you provide a geni-lib script, you will see a slightly different set
of buttons on the @seclink["creating-profiles"]{Create Profile} page; next
to the ``Source'' button there is an ``XML'' button that will pop up the
RSpec XML for you to look at. The XML is read-only; if you want to change
the profile, you will need to change the python source code that is
displayed when you click on the ``Source'' button. Each time you change the
python source code, the script is uploaded to the server and processed. Be
sure to save your changes if you are
@seclink["updating-profiles"]{updating an existing profile}.
The following examples demonstrate basic geni-lib usage. More information
about geni-lib and additional examples, can be found in the
@hyperlink["https://bitbucket.org/barnstorm/geni-lib/src"]{geni-lib repository}.
@subsection[#:tag "geni-lib-example-1"]{A Single XEN VM node}
@codeblock|{
#; Import the ProtoGENI library.
import geni.rspec.pg as pg
#; Create a Request object to start building the RSpec.
rspec = pg.Request()
#; Create a XenVM and add it to the RSpec.
node = pg.XenVM("node")
rspec.addResource(node)
#; Output the RSpec to the enclosing page.
printRspec(rspec)
}|
@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)
#; Add the link to the RSpec.
rspec.addResource(link)
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)
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>"))
rspec.addResource(node1)
printRspec(rspec)
}|
@section[#:tag "creating-from-scratch"]{Creating a profile from scratch} @section[#:tag "creating-from-scratch"]{Creating a profile from scratch}
@future-work["planned-easier-profiles"] @future-work["planned-easier-profiles"]
......
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