Changes between Version 7 and Version 8 of HowTo/GenerateRSpecUsingGENILIB


Ignore:
Timestamp:
07/17/14 14:38:48 (10 years ago)
Author:
xliu@bbn.com
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • HowTo/GenerateRSpecUsingGENILIB

    v7 v8  
    11[[PageOutline]]
    22
    3 = How to Instsall geni-lib =
    4 
    5 [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, and show some examples of using 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.
    6 
    7 To use geni-lib, you will first need to download it from the [https://bitbucket.org/barnstorm/geni-lib/src geni-lib repository].
     3= Examples of Using geni-lib =
    84
    95
    10  
    11 == Download geni-lib ==
    12 
    13 For MacOS Experimenters:
    14 
    15  * Install Mercurial
    16    * If you are using !MacPort, you can Install mercurial with
    17 {{{
    18 sudo port install mercurial
    19 }}}
    20    * You can also find the Mercurial download page [http://mercurial.selenic.com/downloads here]
    21 
    22  * Configure Mercurial
    23    * Create .hg file under ~/.
    24 {{{
    25 [ui]
    26 username = Your User Name <xxx@xxx.xxx>
    27 }}}
    28 
    29  * Clone geni-lib
    30 {{{
    31 hg clone https://bitbucket.org/barnstorm/geni-lib
    32 }}}
    33 
    34  * Check and Pull Update
    35 {{{
    36 hg pull && hg update default
    37 }}}
     6[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 some examples of using geni-lib. The installation and configuration of geni-lib can be found [wiki:HowTo/SetupGENILIB here]
    387
    398
    409
    41 Once you have downloaded the geni-lib to your local machine, you will see two directories under ./geni-lib/
    42 {{{
    43 dhcp89-69-127:geni-lib xliu$ ls
    44 geni    samples
    45 }}}
    46 
    47 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.
    48 
    49 
    50 == Download Dependencies and Configure PYTHONPATH ==
    51 
    52 In the system that has been tested, a python package lxml is needed for geni-lib.
    53 
    54  * Install lxml python packages
    55  
    56  If you are using !MacPort, install lxml using
    57  {{{
    58  $ sudo port install python27-lxml
    59  }}}
    60 
    61  * Add PYTHONPATH:
    62 
    63  For MacOS experimenters, you can add following lines to the end of your ~/.profile
    64  {{{
    65  # add python path
    66  export PYTHONPATH=$PYTHONPATH:<your path to geni-lib>
    67  }}}
    68  Then, run
    69  {{{
    70  source ~/.profile
    71  }}}
    72 
    73   * Optional Step: Switch Python Version
    74  
    75  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.
    76 {{{
    77 $ sudo port select --set python python27
    78 }}}
    79 
    80 
    81 == Configure geni-lib ==
    82 
    83  * Modify the configuration file
    84 
    85  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
    86 
    87  {{{
    88 dhcp89-69-127:samples xliu$ cat example_config.py
    89 from geni.aggregate import FrameworkRegistry
    90 from geni.aggregate.context import Context
    91 from geni.aggregate.user import User
    92 
    93 def buildContext ():
    94   portal = FrameworkRegistry.get("portal")()
    95   portal.cert = "/home/nbastin/.ssh/portal-nbastin.pem"
    96   portal.key = "/home/nbastin/.ssh/portal-nbastin.key"
    97 
    98   nbastin = User()
    99   nbastin.name = "nbastin"
    100   nbastin.urn = "urn:publicid:IDN+ch.geni.net+user+nickbas"
    101   nbastin.addKey("/home/nbastin/.ssh/geni_dsa.pub")
    102 
    103   context = Context()
    104   context.addUser(nbastin, default = True)
    105   context.cf = portal
    106   context.project = "bss-sw-test"
    107 
    108   return context
    109  }}}
    110 
    111  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
    112 
    113  ''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 ''
    114 
    115 
    116  
    117 
    118 
    119 
    120 = Examples of Using geni-lib =
    12110 
    12211 Assuming the module with your credential and project information is named as my_config.py, which is modified from ''example_config.py'' under ./geni-lib/samples, we will illustrate a few examples on how to use geni-lib.