Openstack Nova 二次开发之Nova-extend服务实现

主要是讲如何启动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/

1
2
3
4
5
6
7
#!/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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# 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 配置

1
extend_manager = nova.extend.manager.ExtendManager

 

    e) 创建openstack-nova-extend 启动服务脚步

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/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服务

    

1
2
3
4
5
6
7
8
9
[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 消息队列信息

1
2
3
4
5
6
7
8
9
[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服务状态

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[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 功能实现,谢谢大家,如有不明白的地方请留言,我会在中午时间一一帮助大家解答,欢迎点评

    写的不好的地方还希望大牛们指点,共同学习


本文转自 swq499809608 51CTO博客,原文链接:http://blog.51cto.com/swq499809608/1535750


优秀的个人博客,低调大师

微信关注我们

原文链接:https://yq.aliyun.com/articles/501688

转载内容版权归作者及来源网站所有!

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

相关文章

发表评论

资源下载

更多资源
Mario,低调大师唯一一个Java游戏作品

Mario,低调大师唯一一个Java游戏作品

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Oracle Database,又名Oracle RDBMS

Oracle Database,又名Oracle RDBMS

Oracle Database,又名Oracle RDBMS,或简称Oracle。是甲骨文公司的一款关系数据库管理系统。它是在数据库领域一直处于领先地位的产品。可以说Oracle数据库系统是目前世界上流行的关系数据库管理系统,系统可移植性好、使用方便、功能强,适用于各类大、中、小、微机环境。它是一种高效率、可靠性好的、适应高吞吐量的数据库方案。

Java Development Kit(Java开发工具)

Java Development Kit(Java开发工具)

JDK是 Java 语言的软件开发工具包,主要用于移动设备、嵌入式设备上的java应用程序。JDK是整个java开发的核心,它包含了JAVA的运行环境(JVM+Java系统类库)和JAVA工具。

Sublime Text 一个代码编辑器

Sublime Text 一个代码编辑器

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。