标签:extend python libvirt nova openstack
Openstack Nova 二次开发之Nova-extend service 扩展
主要是讲如何启动openstack nova-extend services,该服务用于Openstack 二次扩展及部分需求开发,例如 ,节点巡检,动态迁移(基于FUSE 文件系统实现,分布式系统,如MooseFS),文件注入,Nova 服务的自身修复,instances IO 控制,instances CPU 隔离技术实现等其他需求开发
第一章:如何create openstack nova-extend service
a) 创建python-extend 文件
cp -fr /usr/bin/python /usr/bin/python-extend
用于启动openstack nova-extend 服务,Python 服务启动nova-extend ,socket 模块不能正常果子,具体原因在于协程分装,无法使用socket,threading等模块属性
b)创建启动程序python-extend 文件,保留在/usr/bin/
#!/usr/bin/python-extend # PBR Generated from ‘console_scripts‘ import sys from nova.cmd.extend import main if __name__ == "__main__": sys.exit(main())
c) 创建from nova.cmd.extend import main 程序,调用nova.services.py
# vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright 2012 IBM Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """Starter script for Nova Extend.""" import sys from oslo.config import cfg from nova import config from nova import objects from nova.openstack.common import log as logging from nova import service from nova import utils CONF = cfg.CONF CONF.import_opt(‘topic‘, ‘nova.extend.api‘, group=‘extend‘) def main(): objects.register_all() config.parse_args(sys.argv) logging.setup("nova") utils.monkey_patch() server = service.Service.create(binary=‘nova-extend‘, topic=CONF.extend.topic, manager=CONF.extend.manager) service.serve(server, workers=CONF.extend.workers) service.wait()
d) /etc/nova.conf 配置
extend_manager=nova.extend.manager.ExtendManager
e) 创建openstack-nova-extend 启动服务脚步
#!/bin/sh # # openstack-nova-extend OpenStack Nova Compute DB Access service # # chkconfig: - 98 02 # description: Implementation of an S3-like storage server based on local files. ### BEGIN INIT INFO # Provides: # Required-Start: $remote_fs $network $syslog # Required-Stop: $remote_fs $syslog # Default-Stop: 0 1 6 # Short-Description: OpenStack Nova Compute DB Access service # Description: Service to handle database access for compute nodes ### END INIT INFO . /etc/rc.d/init.d/functions suffix=extend prog=openstack-nova-$suffix exec="/usr/bin/nova-$suffix" config="/etc/nova/nova.conf" pidfile="/var/run/nova/nova-$suffix.pid" logfile="/var/log/nova/$suffix.log" [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog lockfile=/var/lock/subsys/$prog start() { [ -x $exec ] || exit 5 [ -f $config ] || exit 6 echo -n $"Starting $prog: " daemon --user nova --pidfile $pidfile "$exec --logfile $logfile &>/dev/null & echo \$! > $pidfile" retval=$? echo [ $retval -eq 0 ] && touch $lockfile return $retval } stop() { echo -n $"Stopping $prog: " killproc -p $pidfile $prog retval=$? echo [ $retval -eq 0 ] && rm -f $lockfile return $retval } restart() { stop start } reload() { restart } force_reload() { restart } rh_status() { status -p $pidfile $prog } rh_status_q() { rh_status >/dev/null 2>&1 } case "$1" in start) rh_status_q && exit 0 $1 ;; stop) rh_status_q || exit 0 $1 ;; restart) $1 ;; reload) rh_status_q || exit 7 $1 ;; force-reload) force_reload ;; status) rh_status ;; condrestart|try-restart) rh_status_q || exit 0 restart ;; *) echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" exit 2 esac exit $?
f) 启动openstack-nova-extend服务
[root@athController cmd]# service openstack-nova-extend restart [root@athController cmd]# tar -xzf /var/log/nova/extend.log 2014-08-04 23:18:58.325 47419 INFO nova.openstack.common.service [-] Caught SIGTERM, exiting 2014-08-04 23:19:00.151 45666 INFO nova.openstack.common.periodic_task [-] Skipping periodic task _periodic_update_dns because its interval is negative 2014-08-04 23:19:00.183 45666 AUDIT nova.service [-] Starting extend node (version 2013.2.1-1.el6) 2014-08-04 23:19:00.513 45666 INFO nova.openstack.common.rpc.common [req-d6b00731-baaa-47fa-bfa2-75f9ec4ef568 None None] Connected to AMQP server on 192.168.8.180:5672
g) openstack-nova-extend 消息队列信息
[root@athController cmd]# rabbitmqctl list_queues|grep extend extend 0 extend.athCloud.8.180.abs.com.cn 0 extend_fanout_6dbb351ab48445cfaadc9de37e87d68f 0 extend_fanout_e870b14296354eddba09389319a9c590 0
h) nova-manager service list 查看nova-extend服务状态
[root@athController cmd]# nova-manage service list Binary Host Zone Status State Updated_At nova-conductor athController.8.180.abs.com.cn internal enabled :-) 2014-08-04 15:22:20 nova-consoleauth athController.8.180.abs.com.cn internal enabled :-) 2014-08-04 15:22:19 nova-cert athController.8.180.abs.com.cn internal enabled :-) 2014-08-04 15:22:20 nova-scheduler athController.8.180.abs.com.cn internal enabled :-) 2014-08-04 15:22:18 nova-network athController.8.180.abs.com.cn internal enabled :-) 2014-08-04 15:22:11 nova-compute athController.8.180.abs.com.cn nova enabled :-) 2014-08-04 15:22:10 nova-console athController.8.180.abs.com.cn internal enabled :-) 2014-08-04 15:22:17 nova-extend athController.8.180.abs.com.cn internal enabled :-) 2014-08-04 15:22:10
i) 总结
openstack开发其实并不是很难,只要了解nova-compute,nova-api启动过程,参照文档基本都能实现
到此openstack Nova extend 服务启动实现完毕,下一章节将会在下周一撰写openstack nova-extend nova.extend.manager 功能实现,谢谢大家,如有不明白的地方请留言,我会在中午时间一一帮助大家解答,欢迎点评
写的不好的地方还希望大牛们指点,共同学习
本文出自 “欢迎评论,欢迎点赞” 博客,转载请与作者联系!
Openstack Nova 二次开发之Nova-extend服务实现并启动验证,布布扣,bubuko.com
Openstack Nova 二次开发之Nova-extend服务实现并启动验证
标签:extend python libvirt nova openstack
原文地址:http://swq499809608.blog.51cto.com/797714/1535750