openstack bilean 计费服务的手动安装
一、简要介绍
bilean是openstack一个计费服务,这个相对另一个计费服务(cloudkitty)用的人相对少,最近在分析计费功能,看到了这个模块,并且相关资料较少,就简单写了这个安装部署文档,方便以后自己学习
bilean的架构相关的资料可以见: https://wiki.openstack.org/wiki/Bilean,这里简单提下:
各个组件的功能:
An overall summary of Bilean logical architecture.
The main components of Bilean are:
- The bileanclient component is A CLI communicates with the bilean-api.
- The bilean-api component provides an OpenStack-native ReST API that processes API requests by sending them to the bilean-engine over RPC.
- The bilean-scheduler component manages all the jobs related to users and scheduler jobs to bilean-engine over RPC, a job is a timing task related to a user(Notify user to recharge .e.g.).
- The bilean-notification component monitors the message bus for data provided by other OpenStack components such as Nova, then converts notifications into billing resources and sends to bilean-engine over AMQP.
- The bilean-engine does the main billing work, operates all users, rules and policies.
二、安装
1, 下载最新的源码包
https://github.com/openstack/bilean
https://github.com/openstack/python-bileanclient
2,拷贝对应的源码到环境上
bilean的代码如下:
[[email protected] bilean-master]# ll
total 72
drwxr-xr-x 13 root root 4096 Jul 6 09:40 bilean
drwxr-xr-x 2 root root 4096 Jul 6 09:50 bilean.egg-info
drwxr-xr-x 3 root root 4096 Jul 6 09:50 build
-rw-r--r-- 1 root root 1175 Jul 6 09:40 CONTRIBUTING.rst
drwxr-xr-x 3 root root 4096 Jul 6 09:40 devstack
drwxr-xr-x 3 root root 4096 Jul 6 09:40 doc
drwxr-xr-x 3 root root 4096 Jul 6 09:40 etc
-rw-r--r-- 1 root root 10143 Jul 6 09:40 LICENSE
-rw-r--r-- 1 root root 1579 Jul 6 09:50 PKG-INFO
-rw-r--r-- 1 root root 607 Jul 6 09:40 README.rst
-rw-r--r-- 1 root root 865 Jul 6 09:40 requirements.txt
-rw-r--r-- 1 root root 1613 Jul 6 09:40 setup.cfg
-rw-r--r-- 1 root root 1045 Jul 6 09:40 setup.py
-rw-r--r-- 1 root root 629 Jul 6 09:40 test-requirements.txt
drwxr-xr-x 2 root root 4096 Jul 6 09:40 tools
-rw-r--r-- 1 root root 813 Jul 6 09:40 tox.ini
其中PKG-INFO需要自己拷贝一个过来,内容如下:
Metadata-Version: 1.1
Name: bilean
Version: 9.1.0
Summary: OpenStack Block Storage
Home-page: http://docs.openstack.org/developer/bilean/
Author: OpenStack
Author-email: [email protected]
License: UNKNOWN
Description: ======
bilean
======
Platform: UNKNOWN
Classifier: Environment :: OpenStack
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
同理 python-bileanclient-master 中的PKG-INFO信息如下:
Metadata-Version: 1.1
Name: python-bileanclient
Version: 9.1.0
Summary: OpenStack Block Storage
Home-page: http://docs.openstack.org/developer/python-bileanclient/
Author: OpenStack
Author-email: [email protected]
License: UNKNOWN
Description: ======
python-bileanclient
======
Platform: UNKNOWN
Classifier: Environment :: OpenStack
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
3,安装
在bilean-master 执行
python setup.py build
python setup.py install
需要手动将 bilean/db/sqlalchemy/migrate_repo/下面的 migrate.cfg README 拷贝到 /usr/lib/python2.7/site-packages/bilean/db/sqlalchemy/migrate_repo/
(使用setup安装的,中间的一些配置文件丢了,所以需要手动拷贝下)
cp -rf bilean/db/sqlalchemy/migrate_repo/migrate.cfg /usr/lib/python2.7/site-packages/bilean/db/sqlalchemy/migrate_repo/
cp -rf bilean/db/sqlalchemy/migrate_repo/migrate.cfg /usr/lib/python2.7/site-packages/bilean/db/sqlalchemy/migrate_repo/
在python-bileanclient-master 执行
python setup.py build
python setup.py install
4,创建bilean的用户以及endpoint (bilean可以根据自己需要是否创建)
openstack user create --password password --email [email protected] bilean
openstack role add --user bilean --project services admin
openstack service create --name billing --description 'billing' billing;
openstack endpoint create billing --region RegionOne --publicurl http://192.168.6.69:8770/v1 --adminurl http://192.168.6.69:8770/v1 --internalurl http://192.168.6.69:8770/v1 --region RegionOne
5, 创建bilean数据库
MariaDB [(none)]> CREATE DATABASE bilean;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON bilean.* TO 'bilean'@'localhost' IDENTIFIED BY 'password';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON bilean.* TO 'bilean'@'%' IDENTIFIED BY 'password';
6.配置/etc/bilean/bilean.conf,参考如下,keystone必须使用v3
[DEFAULT]
debug = True
log_dir = /var/log/bilean
[bilean_api]
bind_host = 0.0.0.0
bind_port = 8770
[database]
connection=mysql+pymysql://bilean:[email protected]/bilean
[keystone_authtoken]
auth_uri=http://192.168.6.69:5000/v3
auth_version = 3
identity_uri=http://192.168.6.69:35357
admin_password=admin
admin_user=admin
admin_tenant_name=admin
[authentication]
auth_url = http://192.168.6.69:5000/v3
service_username = admin
service_password = admin
service_project_name = admin
[oslo_messaging_rabbit]
amqp_durable_queues=False
rabbit_hosts=192.168.6.69:5672
rabbit_userid = guest
rabbit_password = guest
7.初始化数据库
bilean-manage --debug db_sync
9.开启服务
nohup bilean-api --config-file /etc/bilean/bilean.conf &
nohup bilean-engine --config-file /etc/bilean/bilean.conf &
nohup bilean-scheduler --config-file /etc/bilean/bilean.conf &
nohup bilean-notification --config-file /etc/bilean/bilean.conf &
10. 验证服务OK
bilean user-list
+----+------+---------+--------+------+--------+
| id | name | balance | credit | rate | status |
+----+------+---------+--------+------+--------+
+----+------+---------+--------+------+--------+
11. bilean命令行
policy-add-rules
policy-create Create a policy.
policy-list List policies.
policy-show Show the policy details.
resource-list List resources.
resource-show Show detailed information for a resource.
rule-create Create a rule.
rule-delete Delete rule(s).
rule-list List rules.
rule-show Show the rule details.
user-attach-policy Attach a specified policy to user.
user-list List users.
user-recharge Recharge for a user.
user-show Show detailed information for a user.
bash-completion Prints arguments for bash_completion.
help Display help about this program or one of its
subcommands.
12. 具体的使用过程待输出