Skip to content
This repository was archived by the owner on Apr 11, 2019. It is now read-only.

Development

Michael Smart edited this page Jan 20, 2015 · 1 revision

Development

Keep in mind, in order to use an AM you'll need a clearinghouse server to be running (omni connects to it): python src/gcf-ch.py.
If you run in production mode you'll have to restart the WSGI server each time: python src/main.py.

Usually, you want the log open: tail -f log/eisoil.log.
If you have wait_on installed it might be handy to execute the following to get notice of new files written by omni (Run this in the directory you are calling omni):

  while [ 1 ]; do f=`wait_on -hw . * | cut -d':' -f1`; echo; echo '------'; echo $f; echo '------'; echo; cat $f; done

Please see the GENI page for more information.

Folder structure

When developing, please note the following file structure. Usually, you would create one or more folders under src/plugins and start developing there. When you have files which are local and instance specific (e.g. a database), please put these files in deploy.

    |-- admin                   The config client and administrator's certificate for the config client (see Links)
    |-- deploy                  All deployment related files, such as local databases and config files for nginx
    |   `-- trusted             Certificates of the trusted clearinhouses
    |-- doc                     Documentation
    |   |-- img                 Illustrations
    |   `-- wiki                A git sub-module which contains the Github wiki pages (see Links)
    |-- log                     eiSoil's log
    |-- src
    |   |-- eisoil              eiSoil's core implementation (Usually, you do not need to change things here)
    |   |   `-- core
    |   |-- vendor              Repository for (core) plugins maintained by the eiSoil guys
    |   |   `-- ...
    |   `-- plugins             Plugins to be loaded when bootstrapping eiSoil. Symlinks to vendor and your plugins.
    |       `-- ...
    `-- test                    Testing resources

Note

Please create your plugins in the plugins folder (e.g. by copying the example from vendor). If you want to disable a plugin, please remove the symlink in plugins. When you start creating your own plugins, please do so within the plugins folder (read Plugins).

Links

Development process

eiSoil provides a development server which supports automatic reloading (see flask and werkzeug). This means every time you change your code the server reloads automatically. So all you need to do is code your stuff, save the file and send a test request with omni. But: Be aware that all objects in memory - which are not persistent - are gone/reinstanciated when you save a file.

For debugging, you can throw exceptions everywhere to check what is going on (e.g. raise RuntimeException(questionable_value)). Omni or the eiSoil log will the show you the error message. Using an actual debugger within the server is harder. Also consider to use logging for debugging.

Testing with omni

To send requests to your AM via the GENI AM API v3 consider the following examples:

    python src/omni.py -o -a https://localhost:8001 -V 3 --debug getversion
    python src/omni.py -o -a https://localhost:8001 -V 3 --debug --no-compress listresources
    python src/omni.py -o -a https://localhost:8001 -V 3 --debug describe slicename
    python src/omni.py -o -a https://localhost:8001 -V 3 --debug allocate slicename rspec-req.xml 
    # OR python src/omni.py -o -a https://localhost:8001 -V 3 --debug --end-time=2014-04-12T23:20:50.52Z allocate slicename rspec-req.xml
    python src/omni.py -o -a https://localhost:8001 -V 3 --debug renew slicename 2013-02-07T15:00:50.52Z
    python src/omni.py -o -a https://localhost:8001 -V 3 --debug provision slicename
    # OR python src/omni.py -o -a https://localhost:8001 -V 3 --debug --end-time=2014-04-12T23:20:50.52Z provision slicename
    python src/omni.py -o -a https://localhost:8001 -V 3 --debug status slicename
    python src/omni.py -o -a https://localhost:8001 -V 3 --debug performoperationalaction slicename geni_start
    # OR python src/omni.py -o -a https://localhost:8001 -V 3 --debug performoperationalaction slicename geni_stop
    # OR python src/omni.py -o -a https://localhost:8001 -V 3 --debug performoperationalaction slicename geni_restart
    python src/omni.py -o -a https://localhost:8001 -V 3 --debug delete slicename
    python src/omni.py -o -a https://localhost:8001 -V 3 --debug shutdown slicename

Example RSpec for rspec-req.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <rspec type="request"
           xmlns="http://www.geni.net/resources/rspec/3"
           xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:dhcp="http://example.com/dhcp"
           xs:schemaLocation="http://www.geni.net/resources/rspec/3 http://www.geni.net/resources/rspec/3/ad.xsd http://example.com/dhcp/req.xsd">
        <dhcp:ip>192.168.1.1</dhcp:ip>
        <dhcp:ip>192.168.1.2</dhcp:ip>
        <dhcp:iprange>
            <from>192.168.1.3</from>
            <to>192.168.1.6</to>
        </dhcp:iprange>
    </rspec>

If everything is working properly you should see something like this:

Result Summary: Slice urn:publicid:IDN+geni:gpo:gcf+slice+slicename expires in <= 3 hours on ...
Reserved resources on https://localhost:8001. 
Saved createsliver results to slicename-manifest-rspec-localhost-8001.xml. 

Troubleshooting If you this error message request.shutdown(socket.SHUT_WR) ... TypeError: shutdown() takes exactly 0 arguments (1 given) from the server, please try this fix.

Next Steps

Please continue reading the plugin section.

Clone this wiki locally