Code Monkey home page Code Monkey logo

openstack-guest-agents-unix's Introduction

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('<command_name>')
  • (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)

openstack-guest-agents-unix's People

Contributors

comstud avatar abhishekkr avatar naterh avatar gtmanfred avatar nicholaskuechler avatar jmeridth avatar scsannalli avatar philips avatar sridevikoushik31 avatar the-gball avatar matiu2 avatar sivel avatar jpward1981 avatar johngarbutt avatar jerdfelt avatar jimrollenhagen avatar dprince avatar cblument avatar nikolawannabe avatar

Watchers

Antony Ingram avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.