cloudkitty服務介紹
當前版本cloudkitty可以完成虛擬機器例項(compute),雲硬碟(volume),映象(image),網路進出流量(network.bw.in,network.bw.out),浮動IP(network.floating)的計費。得益於Cloudkitty的巧妙而優秀的設計,軟體外掛化思想更是體現的淋漓盡致,使得新增新的計費源異常容易,版本升級十分方便。同樣也能方便將cloudkitty用於cloudstack,VMWare等環境中。
Cloudkitty主要依賴於遙測相關的專案,包括ceilometer和gnocchi,甚至是將要使用panko;計費策略和hashmap計費模型是其核心;模組外掛化是其設計靈魂;
使用命令編輯/etc/openstack/openrc.sh配置檔案,新增Cloudkitty環境變數引數
##--------------------Cloudkitty Config----------------##
##Password for Mysql Cloudkitty user. exmaple:000000
CLOUDKITTY_DBPASS=000000
##Password for Keystore Cloudkitty user. exmaple:000000
CLOUDKITTY_PASS=000000
使用CRT等遠端連線工具,連線至172.30.17.14控制節點,執行iaas-install- cloudkitty.sh安裝指令碼
[root@controller ~]# iaas-install-cloudkitty.sh
例項型別收費
建立雲主機服務instance_test,通過命令建立service服務
[root@controller ~]# openstack rating hashmap service create instance_test
+---------------+--------------------------------------+
| Name | Service ID |
+---------------+--------------------------------------+
| instance_test | cf8029bf-dc35-4e40-b8fd-5af4a4d25a30 |
+---------------+--------------------------------------+
並對其建立名為flavor_name的fields
[root@controller ~]# openstack rating hashmap field create cf8029bf-dc35-4e40-b8fd-5af4a4d25a30 flavor_name
+-------------+--------------------------------------+--------------------------------------+
| Name | Field ID | Service ID |
+-------------+--------------------------------------+--------------------------------------+
| flavor_name | b2f0d485-df20-4f2e-bd44-d3696971cb8f | cf8029bf-dc35-4e40-b8fd-5af4a4d25a30 |
+-------------+--------------------------------------+--------------------------------------+
並設定規格為m1.small的雲主機單價為1元
[root@controller ~]# openstack rating hashmap mapping create --field-id b2f0d485-df20-4f2e-bd44-d3696971cb8f -t flat --value m1.small 1
+--------------------+--------+----------+----+--------------------+----------+--------+----------+
| Mapping ID |Value |Cost |Type| Field ID |Service ID|Group ID|Project ID|
+--------------------+--------+----------+----+--------------------+----------+--------+----------+
| c1b7d4db-c1d2-4488 |m1.small|1.00000000|flat| b2f0d485-df20-4f2e | None | None | None |
-ac46-1a8eb70d76e4 -bd44-d3696971cb8f
+--------------------+--------+----------+----+--------------------+----------+--------+----------+
映象服務費用
建立映象收費服務image_size_test
[root@controller ~]# openstack rating hashmap service create image_size_test
+-----------------+--------------------------------------+
| Name | Service ID |
+-----------------+--------------------------------------+
| image_size_test | 80a098cf-d793-47cf-b63e-df6cbd56e88d |
+-----------------+--------------------------------------+
併為該服務單價設定為0.8元
[root@controller ~]# openstack rating hashmap mapping create -s 80a098cf-d793-47cf-b63e-df6cbd56e88d -t flat 0.8
+--------------------+-------+------------+------+----------+--------------------+--------+----------+
| Mapping ID | Value | Cost | Type | Field ID | Service ID |Group ID|Project ID|
+--------------------+-------+------------+------+----------+--------------------+--------+----------+
| 64952e70-6e37-4c8a | None | 0.80000000 | flat | None | 80a098cf-d793-47cf | None | None |
-9d3a-b4c70de1fb87 -b63e-df6cbd56e88d
+--------------------+-------+------------+------+----------+--------------------+--------+----------
建立優惠服務
建立名為dis_tests的服務
[root@controller ~]# openstack rating hashmap service create dis_tests
+-----------+--------------------------------------+
| Name | Service ID |
+-----------+--------------------------------------+
| dis_tests | b6190077-80ff-4e1f-9938-ddaff11c3506 |
+-----------+--------------------------------------+
為dis_tests服務設定單價為0.8元
[root@controller ~]# openstack rating hashmap mapping create -s b6190077-80ff-4e1f-9938-ddaff11c3506 -t flat 0.8
+--------------------+-------+------------+----+--------+--------------------+----------+------------+
| Mapping ID | Value | Cost |Type|Field ID| Service ID | Group ID | Project ID |
+--------------------+-------+------------+----+--------+--------------------+----------+------------+
| f5a51b26-82f8-45a4 | None | 0.80000000 |flat| None | b6190077-80ff-4e1f | None | None |
-8784-f7f131c2e4cd -9938-ddaff11c3506
+--------------------+-------+------------+----+--------+--------------------+----------+------------+
並設定dis_tests服務使用量超過10000時提供8折優惠
[root@controller ~]# openstack rating hashmap threshold create -s b6190077-80ff-4e1f-9938-ddaff11c3506 -t rate 10000 0.8
+-------------------+--------------+----------+----+--------+--------------------+--------+----------+
| Threshold ID | Level |Cost |Type|Field ID| Service ID |Group ID|Project ID|
+-------------------+--------------+----------+----+--------+--------------------+--------+----------+
|11be2ecb-b7fa-42cd |10000.00000000|0.80000000|rate| None | b6190077-80ff-4e1f | None | None |
-a8d1-a0b679181912 -9938-ddaff11c3506
+-------------------+--------------+----------+----+--------+--------------------+--------+----------+