How the LAVA Extension works

Asked by Terry Guo on 2012-02-21

Hi there,

I setup the LAVA server by following the Quickstart part in the README of LAVA Deployment Tool.

 $ ./lava-deployment-tool setup
 $ ./lava-deployment-tool bundle requirements-mini.txt
 $ ./lava-deployment-tool install testinstance lava.pybundle
 $ sudo start lava-instance LAVA_INSTANCE=testinstance

Only the LAVA server is installed. I can see the webpage of LAVA, that thrilled me. But soon I run into following questions, please help me:

1). The lava-server/setup.py does contain lines like:

entry_points="""
        [console_scripts]
        lava-server = lava_server.manage:main
        [lava_server.commands]
        manage=lava_server.manage:manage
        [lava_server.extensions]
        project=lava_projects.extension:ProjectExtension

Then how can I add my extension? Is it possible to make more than one extensions? Is the following code correct?

        [lava_server.extensions]
        project=lava_projects.extension:ProjectExtension
       demo = demo_app.extension:DemoExtension

Is ProjectExtension a must have extension? Can I change the content of class ProjectExtension?

2). Suppose my testinstance is running and I made some changes to my extension, what's the way to rebuild the bundle and make my changes take effect?

Thanks very much.

Terry

Question information

Language:
English Edit question
Status:
Solved
For:
LAVA Server Edit question
Assignee:
No assignee Edit question
Solved by:
Terry Guo
Solved:
2012-02-29
Last query:
2012-02-29
Last reply:
2012-02-21
Zygmunt Krynicki (zyga) said : #1

1) Install additional python packages that have your extensions. See the demo extension in the server tree

2) You don't need to do that, just release on pypi and you are done

Zygmunt Krynicki (zyga) said : #2

2) Sorry, I mis-read your question.

You can actually develop against a live server. Do a few things to achieve that:

-> create a development instance _or_ put your code in $LAVA_PREFIX/$LAVA_INSTANCE/src
-> enable your virtualenv and pip uninstall the thing you are hacking on (for existing components, if it's a new extension then obviously it will not be installed yet)
-> get the branch you are working on to $LAVA_PREFIX/$LAVA_INSTANCE/src, go inside and run setup.py develop THIS HAS TO RUN INSIDE THE VIRTUALENV (propmpt will be different, make sure you get this right)
-> edit $LAVA_PREFIX/$LAVA_INSTANCE/etc/lava-server/settings.conf and change DEBUG to True (from the default False), be very careful with editing, JSON is very strict about syntax, a comma is enough to break it
-> touch $LAVA_PREFIX/$LAVA_INSTANCE/etc/lava-server/uwsgi.reload

Then you can develop most of your app as you normally would. Changes to templates are live, they don't require anything more than a page reload in your browser. Changes to application code require you to touch the uwsgi.reload file. Since you enabled debugging you will see exceptions and tracebacks right in the browser. Remember that debugging _LEAKS MEMORY_ by design so if your uwsgi worker processes inflate just touch uwsgi.reload. Usually this is never a problem.

If you need to add models (or change existing models) then you MUST read south tutorial and be fluent in south usage, ask questions if you need help with that. http://south.aeracode.org/docs/tutorial/index.html

Terry Guo (terry.guo) said : #3

Hi Zygmunt,

Thanks for your explanation. But after the step:

-> touch $LAVA_PREFIX/$LAVA_INSTANCE/etc/lava-server/uwsgi.reload

The server can't be accessed in browser. The content of log file var/log/lava-uwsgi.log are:

[pid: 1825|app: 0|req: 1/7] 10.164.2.22 () {40 vars in 770 bytes} [Wed Feb 29 16:03:36 2012] GET / => generated 0 bytes in 65 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)
Traceback (most recent call last):
  File "/srv/lava/instances/dev/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 250, in __call__
    self.load_middleware()
  File "/srv/lava/instances/dev/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 39, in load_middleware
    for middleware_path in settings.MIDDLEWARE_CLASSES:
  File "/srv/lava/instances/dev/local/lib/python2.7/site-packages/django/utils/functional.py", line 276, in __getattr__
    self._setup()
  File "/srv/lava/instances/dev/local/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup
    self._wrapped = Settings(settings_module)
  File "/srv/lava/instances/dev/local/lib/python2.7/site-packages/django/conf/__init__.py", line 87, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/srv/lava/instances/dev/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/srv/lava/instances/dev/src/lava-server/lava_server/settings/debian.py", line 11, in <module>
    debian_settings = Settings("lava-server")
  File "/srv/lava/instances/dev/local/lib/python2.7/site-packages/django_debian/settings.py", line 70, in __init__
    self._settings = self._load_settings()
  File "/srv/lava/instances/dev/local/lib/python2.7/site-packages/django_debian/settings.py", line 100, in _load_settings
    return json.load(stream)
  File "/usr/lib/python2.7/json/__init__.py", line 278, in load
    **kw)
  File "/usr/lib/python2.7/json/__init__.py", line 326, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
[pid: 1830|app: 0|req: 2/8] 10.164.2.22 () {38 vars in 701 bytes} [Wed Feb 29 16:03:36 2012] GET /favicon.ico => generated 0 bytes in 4 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)

What I am doing is to add my own extension to lava-server. So I edited the file $LAVA_PREFIX/$LAVA_INSTANCE/src/lava-server/setup.py. I want my change works, but it doesn't.

BR,
Terry

Terry Guo (terry.guo) said : #4

Figured it out by myself. After all the steps stated in file SETUP-WEBDEV-ENV, one still needs to start the lava instance by command "sudo start lava-instance LAVA_INSTANCE=dev".