geni-lib-two-vm-lan.py 770 Bytes
Newer Older
1 2 3 4 5 6 7
"""An example of constructing a profile with two VMs connected by a LAN.

Instructions:
Wait for the profile instance to start, and then log in to either VM via the
ssh ports specified below.
"""

8 9 10 11 12 13
import geni.portal as portal
import geni.rspec.pg as pg 

pc = portal.Context()
rspec = pg.Request()

14
# Create two XenVM nodes.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
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)

35
pc.printRequestRSpec(rspec)