Changes between Version 7 and Version 8 of HowTo/SetupGENILIB


Ignore:
Timestamp:
10/02/15 11:36:25 (9 years ago)
Author:
nriga@bbn.com
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • HowTo/SetupGENILIB

    v7 v8  
    33== For up to date information about geni-lib, please refer to the official documentation at [http://geni-lib.readthedocs.org] ==
    44
    5 
    6 = How to Setup geni-lib =
    7 
    8 [https://bitbucket.org/barnstorm/geni-lib/src geni-lib] is a python library written by Nick Bastin of Barnstormer Softworks. It can be used to create RSpec file for large topology. In this page, we show how to install and configure geni-lib. The installation and configuration of geni-lib has been tested on MacOS 10.9.3, and python27 installed from !MacPort is set to be the default python.
    9 
    10 To use geni-lib, you will first need to download it from the [https://bitbucket.org/barnstorm/geni-lib/src geni-lib repository].
    11 
    12 
    13  
    14 == Download geni-lib ==
    15 
    16 For MacOS Experimenters:
    17 
    18  * Install Mercurial
    19    * If you are using !MacPort, you can Install mercurial with
    20 {{{
    21 sudo port install mercurial
    22 }}}
    23    * You can also find the Mercurial download page [http://mercurial.selenic.com/downloads here]
    24 
    25  * Configure Mercurial
    26    * Create $HOME/.hgrc and add your name and email address
    27 {{{
    28 [ui]
    29 username = Your Name <xxx@xxx.xxx>
    30 }}}
    31 
    32  * Clone geni-lib
    33 {{{
    34 hg clone https://bitbucket.org/barnstorm/geni-lib
    35 }}}
    36 
    37  * Check and Pull Update
    38 {{{
    39 hg pull && hg update default
    40 }}}
    41 
    42 
    43 
    44 Once you have downloaded the geni-lib to your local machine, you will see two directories under ./geni-lib/
    45 {{{
    46 dhcp89-69-127:geni-lib xliu$ ls
    47 geni    samples
    48 }}}
    49 
    50 The directory "geni" is the library for RSpec generation and other purposes, and "samples" contains examples of using the library, as well as a sample configuration file that you need to modify it before writing and  testing your scripts.
    51 
    52 
    53 == Download Dependencies and Configure PYTHONPATH ==
    54 
    55 In the system that has been tested, a python package lxml is needed for geni-lib, and you may need to install m2crypto module as well.
    56 
    57  * Install lxml, m2crypto python packages
    58  
    59  If you are using !MacPort, you can use
    60  {{{
    61  $ sudo port install py27-lxml
    62  $ sudo port install py27-m2crypto
    63  }}}
    64 
    65  * Add PYTHONPATH:
    66 
    67  For MacOS experimenters, you can add following lines to the end of your ~/.profile
    68  {{{
    69  # add python path
    70  export PYTHONPATH=$PYTHONPATH:<your path to geni-lib>
    71  }}}
    72  Then, run
    73  {{{
    74  source ~/.profile
    75  }}}
    76 
    77   * Optional Step: Switch Python Version
    78  
    79  Sometimes you may have problems with python versions if you have two different versions of python installed. If you installed python27 and python modules from !MacPort, so you may need to select python27 installed by !MacPort as your default python.
    80 {{{
    81 $ sudo port select --set python python27
    82 }}}
    83 
    84 
    85 == Configure geni-lib ==
    86 
    87  * Modify the configuration file
    88 
    89  To use geni-lib, you will need to create a configuration file that contains your credential to GENI and other information about your experiments. Go to ./geni-lib/samples/, and open the file
    90 
    91  {{{
    92 dhcp89-69-127:samples xliu$ cat example_config.py
    93 from geni.aggregate import FrameworkRegistry
    94 from geni.aggregate.context import Context
    95 from geni.aggregate.user import User
    96 
    97 def buildContext ():
    98   portal = FrameworkRegistry.get("portal")()
    99   portal.cert = "/home/nbastin/.ssh/portal-nbastin.pem"
    100   portal.key = "/home/nbastin/.ssh/portal-nbastin.key"
    101 
    102   nbastin = User()
    103   nbastin.name = "nbastin"
    104   nbastin.urn = "urn:publicid:IDN+ch.geni.net+user+nickbas"
    105   nbastin.addKey("/home/nbastin/.ssh/geni_dsa.pub")
    106 
    107   context = Context()
    108   context.addUser(nbastin, default = True)
    109   context.cf = portal
    110   context.project = "bss-sw-test"
    111 
    112   return context
    113  }}}
    114 
    115  You will modify this module on from line 7 to line 13, line 16 and line 18 with your own information, and you may want to save it as a different file, for example, with name <your initial>_config.py
    116 
    117  ''Note that portal.cert and portal.key should be the same SSL certificate file that you have downloaded from protal, the extension (either .pem or .key) does not matter ''
    118 
    119 
    120  To see examples on how to use geni-lib to generate RSpec, please go to [wiki:HowTo/GenerateRSpecUsingGENILIB RSpec Generation Using geni-lib]