Showing posts with label scripting. Show all posts
Showing posts with label scripting. Show all posts

Wednesday, February 1, 2012

XML export

There's a new option under the Save As dialog box, to export your topology to an XML format. The supported schema can be found here. This is the NRL EmulationScript NetworkPlan with time 0 location information. Note that this format will see some updating as the spec evolves.
Sample output for two router nodes linked together is shown below. There is still much to be done in order to represent all of the data contained in the imn file format.
The XML export occurs at the Python (cored.py) level, with the GUI feeding the back-end the filename to write. This was done so that Python-scripted scenarios could be saved/loaded directly to/from XML without the GUI.

Thursday, August 25, 2011

yargh, hooks

One of the goals of the CORE project is hackability. In that spirit, you can now define hooks under the experiment menu. Hooks are optional shell scripts that run at the specified session state. (If you previously used the global experiment script, this is the same thing; the experiment script now becomes a runtime hook.) The hook script runs on the host as root, is not associated with any particular node, and is saved in the imn file.
 Below the hook configuration dialog is shown. You select the session state from a drop-down menu.

Here are the session states and their meanings:
  1. Definition - used by the GUI to tell the backend to clear any state.
  2. Configuration - when the user presses the Start button, node, link, and other configuration data is sent to the backend.
  3. Instantiation - after configuration data has been sent, just before the nodes are created.
  4. Runtime - all nodes and networks have been built and are running.
  5. Datacollect - the user has pressed the Stop button; a good time to collect log files before nodes are shut down.
  6. Shutdown - all nodes and networks have been shut down and destroyed.
Another related feature that has been added is a /tmp/pycore.nnnnn/state file. As a session changes states, it will write the current state number and name into this file. This would enable an external program or script to monitor that file.

Friday, May 21, 2010

CORE is now a Python package

The CORE Python code has been reorganized into a Python package. New example scripts are included in the source under core/python/examples/netns/. Here is a snippet from one of the samples, how you would make N nodes connected to a switch:

from core import pycore
from core.misc import ipaddr

def main:
...
# IP subnet
prefix = ipaddr.IPv4Prefix("10.83.0.0/16")
session = pycore.Session()
# emulated ethernet switch
switch = session.addobj(cls = pycore.nodes.SwitchNode)
print "creating %d nodes with addresses from %s" % \
(options.numnodes, prefix)
for i in xrange(1, options.numnodes + 1):
tmp = session.addobj(cls = pycore.nodes.LxcNode, name = "n%d" % i)
tmp.newnetif(switch, ["%s/%s" % (prefix.addr(i), prefix.prefixlen)])
tmp.cmd(["sysctl", "net.ipv4.icmp_echo_ignore_broadcasts=0"])
n.append(tmp)

# start a shell on node 1
n[1].term("bash")