码迷,mamicode.com
首页 > Windows程序 > 详细

nova-api扩展(1)

时间:2015-05-21 21:49:02      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:

实现nova-api调用的filter,将调用记录保存到本地文件中和保存到数据库中

普通流程

关闭api

killall nova-api

编写filter

nova/api/openstack/compute/customs.py

from nova import wsgi as base_wsgi

import webob.dec

from oslo_log import log as logging

from nova.api.openstack import wsgi

LOG = logging.getLogger(__name__)

class RecordsMiddleware(base_wsgi.Middleware):

        def __init__(self,application):

                base_wsgi.Middleware.__init__(self,application)

        @webob.dec.wsgify(RequestClass=wsgi.Request)

        def __call__(self,req):

                file = open(/home/stack/customs/records,a)

                record = req.path_info + \n

                #LOG

                file.write(record)

                file.close()

                return self.application

配置filter

/etc/nova/api-paste.ini

1、增加filter

 技术分享

2、把filter添加到composit的keystone pipeline下

 技术分享

启动api

nova-api

查看~/stack/coutoms/record

 技术分享

nova-api扩展(1)

标签:

原文地址:http://www.cnblogs.com/yippee/p/4520431.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!