Developer HowTo for RO Module

From OSM Public Wiki
Jump to: navigation, search

Getting Started

Check out the RO module following the instructions @ Openmano installation (release 0).

Programming Language

The SO module uses Python2. However python3 conventions for a possible future migration should be used as far as possible. For example format string instead of %, print arguments with parenthesis, etc.

Descriptors can be YAML (prefered because more readable and allow comments) or JSON

Code Style

Please follow PEP8 style guide for all the Python code.

Logging

Use the appropriate logging levels when logging the messages. An example is shown below:

   self.log.debug("Changing state to %s", next_state)

Note that not all part of code uses this logging system, but it will be migrated soon

Exceptions

Use exceptions for the functions that fails instead of returning a negative or false value.

Note that not all part of code uses this rule, but it will be migrated soon

Directory Organization

The code organized into the following high level directories:

  • / contains the openmano code
  • /test contains scripts and code for testing
  • /database_utils contains scripts for database creation, dumping and migration
  • /scripts general scripts, as installation, execution, reporting
  • /scenarios examples and templates of network scnario descriptors
  • /vnfs examples and templates of VNF descriptors

RO Architecture

OpenmanoArchitecture.png

The RO module contains the following modules

  • openmanod.py is the main program. It reads the configuration file (openmanod.cfg) and execute the httpserver and wait for the end
  • nfvo.py is the main engine, implementing all the methods for the creation, deletion and management of vnfs, scenarios and instances
  • httpserver.py is a thread that implements the northbound API interface, uses python bottle module
  • nfvo_db.py is the module in charge of database operations. Uses MySQLdb python module
  • openmano_schemas.py is a dictionary schemas used to validate API request and response content using jsonschema library
  • vimconn.py is the base class for the VIM connector modules. The inherited vimconn_openstack.py and vimconn_openvim.py implements the connection to these two VIMs. Openstack ones uses the client-python libraris, meanwhile the Openvim ones uses direct http requests
  • console_proxy_thread.py is a thread that implements a TCP/IP proxy for the console access to a VIM

Other modules not part of the server are:

  • openmnao is a CLI client
  • openmanoclient.py is a client python library for managing openmano server

Northbound Interface

The RO uses a REST API with YAML/JSON content. The primitives are explained here (TODO)

Running Unit Tests

TODO

Creating a new VIM connector

Create a new module vimconn_XXX.py derived from vimconn.py class. Implement the relevant functions. You have two already connector created, for openstack and openvim. Openstack uses the python openstack client libraries, meanwhile openvim uses a direct http request.

Integration with the main project is automatic, just create a new datacenter of type XXX and this module will be automatically loaded. No other module of the main program need to be updated.