Custom Search

Tuesday, November 19, 2013

Working of Openstack Keystone Service

A)
Simple example : How to serve an app using python paste
################################################


1)
* config.ini

[app:main]
paste.app_factory = service_app:app_factory


2)
* deploy.py

from paste import httpserver
from paste.deploy import loadapp
app = loadapp('config:config.ini', relative_to='.')
httpserver.serve(app, host='127.0.0.1', port='8080')


3)
* service_app.py

def application(environ, start_response):
    """Simple WSGI application"""
    response_headers = [('Content-type','text/plain')]
    status = '200 OK'
    start_response(status, response_headers)
    if environ['PATH_INFO'] == '/login':
    #http://pythonpaste.org/modules/recursive.html
        return ["login page"]
    else:
        return ['Hello world']

def app_factory(global_config, **local_config):
    """This function wraps our simple WSGI app so it
    can be used with paste.deploy"""
    return application

4)
How to run

#python deploy.py
serving on http://127.0.0.1:8080

5)
goto the urls

http://127.0.0.1:8080
http://127.0.0.1:8080/login


B)
Keystone files
################

1)
vim /opt/stack/keystone/bin/keystone-all


def create_server(conf, name, host, port):
    app = deploy.loadapp('config:%s' % conf, name=name)
    server = environment.Server(app, host=host, port=port)
    return name, server

def serve(*servers):
    for name, server in servers:
        server.start()


2)
vim /opt/stack/keystone/keystone/common/environment/__init__.py


Server = eventlet_server.Server

3)
vim /opt/stack/keystone/keystone/common/environment/eventlet_server.py


class Server(object):
    def start(self, key=None, backlog=128):


4)
vim /opt/stack/keystone/etc/keystone-paste.ini


[filter:access_log]
paste.filter_factory = keystone.contrib.access:AccessLogMiddleware.factory

[app:public_service]
paste.app_factory = keystone.service:public_app_factory

[app:service_v3]
paste.app_factory = keystone.service:v3_app_factory

[app:admin_service]
paste.app_factory = keystone.service:admin_app_factory


1 comment:

  1. http://pythonpaste.org/do-it-yourself-framework.html

    http://pythonpaste.org/deploy/

    http://docs.repoze.org/moonshining/tools/paste.html <==== IMP

    app_factory example
    http://lionfacelemonface.wordpress.com/2011/03/30/wsgi-and-paste-deploy-the-bare-necessities/

    openstack & wsgi
    http://www.slideshare.net/lhrc_mikeyp/openstack-apis-and-wsgi <====IMP

    http://pythonpaste.org/modules/recursive.html

    ReplyDelete