Openstack Unix Guest Agent
Python C Shell
Latest commit 4837cb0 Dec 2, 2015 @gtmanfred gtmanfred Merge pull request #66 from pwnall1337/master
Added handling for network restarts when ubuntu is using upstart.
Permalink
Failed to load latest commit information.
commands Added handling for network restarts when ubuntu is using upstart. Dec 2, 2015
common Add kmsactivate command for testing purposes Jul 20, 2011
include fix the src tree May 25, 2012
lib Added addditional logic to deterine if the hardware address for and i… Apr 29, 2014
plugins Fix nova-agent not starting on some systems Feb 13, 2014
scripts Added conditional to check for conf.d instance config Jan 14, 2015
src fix the src tree May 25, 2012
tests Updated regexp to work with config headers added sometime ago Oct 20, 2014
tools shebang fixed for installer.sh and bintar script; gitignore updated Jan 21, 2014
.gitignore shebang fixed for installer.sh and bintar script; gitignore updated Jan 21, 2014
AUTHORS fix the src tree May 25, 2012
CHANGELOG.md v1.39.0 minor release Changelog; changed to semantec versioning Dec 31, 2013
Common.am fix the src tree May 25, 2012
INSTALL Update ubuntu package name Mar 5, 2015
LICENSE fix the src tree May 25, 2012
Makefile.am Removing last change, making ENV var for ./configure to allow install… Aug 5, 2013
README fix the src tree May 25, 2012
README.md README.md added for cleaner verbose view at GitHub Sep 30, 2013
autogen.sh fix the src tree May 25, 2012
configure.ac bump version Oct 15, 2014
install_libs.py install_lib fixed to provide /usr/lib/python2.x/config & /usr/include… Aug 6, 2013
install_modules.py fix the src tree May 25, 2012
nova-agent.py nova-agent.py: check length of sys.argv for resetnetwork May 23, 2013
patch_binary.py fix the src tree May 25, 2012
patch_libs.py fix the src tree May 25, 2012

README.md

Unix Guest Agent for Openstack

This guest agent provides functionality such as configuring the networking for a guest.

Layout:

src/       -- The main agent daemon code, written in C, which embeds the
              python interpreter
include/   -- Include files for src/
lib/       -- Supporting code for the main agent daemon, along with a
              python module wrapper
plugins/   -- Python plugin modules (for communication and command parsing)
commands/  -- Python modules that implement the real code for commands
tests/     -- Unit tests
scripts/   -- Startup and misc scripts

Plug-in Info

There are currently 2 types of plugins, exchanges and parsers. Exchange plugins are those that handle the low level communication between a client and the daemon. Parser plugins are those that can decode the communication protocol.

Currently, there's 1 exchange plugin, xscomm.py, and 1 parser plugin, jsonparser.py. xscomm.py handles communication via XenStore and the parser plugin will decode/encode json for the requests/responses.


Exchange Plug-in

Needs to define a class that contains the following methods:

  • get_request():

    • Has no arguments
    • Returns some sort of request object
  • put_response(request, response):

    • Has request and response arguments
    • Returns None (return value is ignored)

Parser Plug-in

Needs to define a class that contains the following methods:

  • parse_request(request): > - Takes a request object returned from an Exchange plugin's get_request() > - Returns a response object that will be passed to an Exchange plugin's put_response()

~


Command Modules

commands/init.py implements a class called 'CommandBase' that is used to create commands by subclassing it. This automatic registering of commands via the subclassing occurs via a metaclass.

To create a new command:

  • create a class that derrives from commands.CommandBase
  • define a method in your class that uses this decorator: > - @commands.command_add('') > - (obviously replace the decorator argument with the right command name)

Misc.

jsonparser.py requires a class instance to be passed on init which defines a 'run_command' method.

When importing 'commands', it replaces the 'commands' module with a wrapper, so you can use the 'commands' attribute directly instead of having to use commands.CommandBase

Call commands.init() to init all of the command classes Pass the result to JsonParser


Example Configuration File

  • Needed to register the exchange/parser plugin combiniation with the

    • main daemon > - import agentlib
  • To get jsonparser and xscomm

    • import plugins
  • Loads 'commands' plus all modules that contain command classes

    • import commands.command_list
  • Not required, as the default is False

    • test_mode = False
  • Inits all command classes

    • c = commands.init()
  • Creates instance of JsonParser, passing in available commands

    • parser = plugins.JsonParser(c)
  • Create the XSComm intance

    • xs = plugins.XSComm()
  • Register an exchange/parser combination with the main daemon

    • agentlib.register(xs, parser)