OpenStack計費服務
- 2022 年 5 月 6 日
- 筆記
- openstack, openstack運維
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
+-------------------+--------------+----------+----+--------+--------------------+--------+----------+