Ubuntu 22.04
Sponsored Link

OpenStack Antelope : CloudKitty का उपयोग कैसे करें2023/09/11

 
OpenStack रेटिंग सेवा (CloudKitty) का उपयोग इस प्रकार करें।
यह उदाहरण निम्न प्रकार से पर्यावरण पर आधारित है।
------------+--------------------------+--------------------------+------------
            |                          |                          |
        eth0|10.0.0.30             eth0|10.0.0.50             eth0|10.0.0.51
+-----------+-----------+  +-----------+-----------+  +-----------+-----------+
|   [ dlp.srv.world ]   |  | [ network.srv.world ] |  |  [ node01.srv.world ] |
|     (Control Node)    |  |     (Network Node)    |  |     (Compute Node)    |
|                       |  |                       |  |                       |
|  MariaDB    RabbitMQ  |  |      Open vSwitch     |  |        Libvirt        |
|  Memcached  Nginx     |  |     Neutron Server    |  |      Nova Compute     |
|  Keystone   httpd     |  |      OVN-Northd       |  |      Open vSwitch     |
|  Glance     Nova API  |  |  Nginx  iSCSI Target  |  |   OVN Metadata Agent  |
|  Cinder API           |  |     Cinder Volume     |  |     OVN-Controller    |
|                       |  |     Gnocchi httpd     |  |   Ceilometer Compute  |
|                       |  |   Ceilometer Central  |  |                       |
|                       |  |     CloudKitty API    |  |                       |
+-----------------------+  +-----------------------+  +-----------------------+

[1] प्रत्येक प्रोजेक्ट के लिए [cloudkitty] उपयोगकर्ता को [rating] भूमिका में जोड़ें जिसे आप रेटिंग देना चाहते हैं।
root@dlp ~(keystone)#
openstack project list

+----------------------------------+-----------+
| ID                               | Name      |
+----------------------------------+-----------+
| cac657ec003e4c95aaaa30bc0321895f | admin     |
| d3dd87fb1a034f7883539a6a4f83781f | service   |
| e294bd7c00314facacdb46c36fb54ee9 | hiroshima |
+----------------------------------+-----------+

root@dlp ~(keystone)#
openstack role add --user cloudkitty --project hiroshima rating

[2] [Hashmap] मॉड्यूल सक्षम करें।
root@dlp ~(keystone)#
openstack rating module list

+-----------+---------+----------+
| Module    | Enabled | Priority |
+-----------+---------+----------+
| hashmap   | False   |        1 |
| noop      | True    |        1 |
| pyscripts | False   |        1 |
+-----------+---------+----------+

root@dlp ~(keystone)#
openstack rating module enable hashmap

+---------+---------+----------+
| Module  | Enabled | Priority |
+---------+---------+----------+
| hashmap | True    |        1 |
+---------+---------+----------+

root@dlp ~(keystone)#
openstack rating module list

+-----------+---------+----------+
| Module    | Enabled | Priority |
+-----------+---------+----------+
| hashmap   | True    |        1 |
| noop      | True    |        1 |
| pyscripts | False   |        1 |
+-----------+---------+----------+
[3] दर को इंस्टेंस अपटाइम पर सेट करें।
जब प्रोजेक्ट में उपयोगकर्ता [1] पर सेट होते हैं तो आपके द्वारा सेट किए गए [flavor_id] के साथ इंस्टेंस बनाते हैं और शुरू करते हैं, लक्ष्य परियोजना पर आपके द्वारा [cloudkitty.conf] में निर्धारित [अवधि] के प्रत्येक अंतराल पर आपके द्वारा निर्धारित दर पर शुल्क लिया जाता है।
# सेवा मिलान नियम जोड़ें

root@dlp ~(keystone)#
openstack rating hashmap service create instance

+----------+--------------------------------------+
| Name     | Service ID                           |
+----------+--------------------------------------+
| instance | e42aae57-507e-4e7d-96ca-aa860e0b510b |
+----------+--------------------------------------+

# फ़ील्ड मिलान नियम जोड़ें

root@dlp ~(keystone)#
openstack rating hashmap field create e42aae57-507e-4e7d-96ca-aa860e0b510b flavor_id

+-----------+--------------------------------------+--------------------------------------+
| Name      | Field ID                             | Service ID                           |
+-----------+--------------------------------------+--------------------------------------+
| flavor_id | b342c47b-a43e-47bf-a443-e069f5e7efc7 | e42aae57-507e-4e7d-96ca-aa860e0b510b |
+-----------+--------------------------------------+--------------------------------------+

root@dlp ~(keystone)#
openstack flavor list

+----+-----------+------+------+-----------+-------+-----------+
| ID | Name      |  RAM | Disk | Ephemeral | VCPUs | Is Public |
+----+-----------+------+------+-----------+-------+-----------+
| 1  | m1.small  | 2048 |   10 |         0 |     1 | True      |
| 2  | m1.medium | 4096 |   10 |         0 |     2 | True      |
| 3  | m1.large  | 8192 |   20 |        10 |     4 | True      |
+----+-----------+------+------+-----------+-------+-----------+

# मैपिंग नियम जोड़ें
# [flavor_id] = [2] वाले उदाहरणों के लिए [0.5] की लागत निर्धारित करें
root@dlp ~(keystone)# openstack rating hashmap mapping create 0.5 \
--field-id b342c47b-a43e-47bf-a443-e069f5e7efc7 \
--value 2 -t flat 
+--------------------------------------+-------+--------------------------------+------+--------------------------------------+------------+----------+------------+
| Mapping ID                           | Value | Cost                           | Type | Field ID                             | Service ID | Group ID | Project ID |
+--------------------------------------+-------+--------------------------------+------+--------------------------------------+------------+----------+------------+
| 82393b12-94b1-4047-8453-17369285888b | 2     | 0.5000000000000000000000000000 | flat | b342c47b-a43e-47bf-a443-e069f5e7efc7 | None       | None     | None       |
+--------------------------------------+-------+--------------------------------+------+--------------------------------------+------------+----------+------------+
[4] उस उपयोगकर्ता के साथ सेटिंग्स सत्यापित करें जो उस प्रोजेक्ट में है जिसे आपने इंस्टेंस बनाने या शुरू करने के लिए [1] पर सेट किया है।
ubuntu@dlp ~(keystone)$
openstack server list

+--------------------------------------+-------------+---------+-------------------------------------+------------+-----------+
| ID                                   | Name        | Status  | Networks                            | Image      | Flavor    |
+--------------------------------------+-------------+---------+-------------------------------------+------------+-----------+
| 11987eec-fb38-4de1-a386-3d1d6001bbd3 | Ubuntu-2204 | SHUTOFF | private=10.0.0.252, 192.168.100.100 | Ubuntu2204 | m1.medium |
+--------------------------------------+-------------+---------+-------------------------------------+------------+-----------+
ubuntu@dlp ~(keystone)$
openstack server start Ubuntu-2204
# एक निश्चित अवधि के बाद, लागत वसूल की जाती है

ubuntu@dlp ~(keystone)$
openstack rating summary get

+----------------------------------+---------------+------+---------------------+---------------------+
| Tenant ID                        | Resource Type | Rate | Begin Time          | End Time            |
+----------------------------------+---------------+------+---------------------+---------------------+
| e294bd7c00314facacdb46c36fb54ee9 | ALL           | 0.5  | 2023-03-01T00:00:00 | 2023-04-01T00:00:00 |
+----------------------------------+---------------+------+---------------------+---------------------+

# यदि इंस्टेंस चलता रहता है, तो प्रत्येक [अवधि] में लागत ली जाती है

ubuntu@dlp ~(keystone)$
openstack rating summary get

+----------------------------------+---------------+------+---------------------+---------------------+
| Tenant ID                        | Resource Type | Rate | Begin Time          | End Time            |
+----------------------------------+---------------+------+---------------------+---------------------+
| e294bd7c00314facacdb46c36fb54ee9 | ALL           | 1.0  | 2023-03-01T00:00:00 | 2023-04-01T00:00:00 |
+----------------------------------+---------------+------+---------------------+---------------------+

# डेटा फ़्रेम प्रदर्शित करें

ubuntu@dlp ~(keystone)$
openstack rating dataframes get

+---------------------+---------------------+----------------------------------
| Begin               | End                 | Project ID                       
+---------------------+---------------------+----------------------------------
| 2023-03-29T02:10:00 | 2023-03-29T02:20:00 | e294bd7c00314facacdb46c36fb54ee9 
| 2023-03-29T04:20:00 | 2023-03-29T04:30:00 | e294bd7c00314facacdb46c36fb54ee9 
| 2023-03-29T04:30:00 | 2023-03-29T04:40:00 | e294bd7c00314facacdb46c36fb54ee9 
+---------------------+---------------------+----------------------------------
+--------------------------------------------------------------------------------
| Resources                                                                      
+--------------------------------------------------------------------------------
| [{'rating': '0.0', 'service': 'instance', 'desc': {'flavor_name': 'm1.medium', 
| [{'rating': '0.5', 'service': 'instance', 'desc': {'flavor_name': 'm1.medium', 
| [{'rating': '0.5', 'service': 'instance', 'desc': {'flavor_name': 'm1.medium', 
+--------------------------------------------------------------------------------
-----------------------------------------------------------------------------
                                                                             
-----------------------------------------------------------------------------
'flavor_id': '2', 'vcpus': '', 'id': '11987eec-fb38-4de1-a386-3d1d6001bbd3', 
'flavor_id': '2', 'vcpus': '', 'id': '11987eec-fb38-4de1-a386-3d1d6001bbd3', 
'flavor_id': '2', 'vcpus': '', 'id': '11987eec-fb38-4de1-a386-3d1d6001bbd3', 
-----------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------
                                                                                                 
-------------------------------------------------------------------------------------------------
'project_id': 'e294bd7c00314facacdb46c36fb54ee9', 'user_id': '85236576a97e492791abe70c217c8898', 
'project_id': 'e294bd7c00314facacdb46c36fb54ee9', 'user_id': '85236576a97e492791abe70c217c8898', 
'project_id': 'e294bd7c00314facacdb46c36fb54ee9', 'user_id': '85236576a97e492791abe70c217c8898', 
-------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------+
                                                                                             |
---------------------------------------------------------------------------------------------+
'tenant_id': 'e294bd7c00314facacdb46c36fb54ee9'}, 'volume': '1', 'rate_value': '0.0000'}]    |
'tenant_id': 'e294bd7c00314facacdb46c36fb54ee9'}, 'volume': '1', 'rate_value': '0.5000'}]    |
'tenant_id': 'e294bd7c00314facacdb46c36fb54ee9'}, 'volume': '1', 'rate_value': '0.5000'}]    |
---------------------------------------------------------------------------------------------+
[5] दर को वॉल्यूम आकार पर सेट करें।
जब प्रोजेक्ट में उपयोगकर्ता [1] पर सेट होते हैं तो cinder वॉल्यूम बनाते हैं, लक्ष्य परियोजना से आपके द्वारा प्रति गीगाबाइट निर्धारित दर पर शुल्क लिया जाता है।
# सेवा मिलान नियम जोड़ें

root@dlp ~(keystone)#
openstack rating hashmap service create volume.size

+-------------+--------------------------------------+
| Name        | Service ID                           |
+-------------+--------------------------------------+
| volume.size | f76586d4-e609-4f6f-a446-5ec5d52f8224 |
+-------------+--------------------------------------+

# मैपिंग नियम जोड़ें
# प्रति गीगाबाइट [1.5] की लागत निर्धारित करें
root@dlp ~(keystone)# openstack rating hashmap mapping create 1.5 \
-s f76586d4-e609-4f6f-a446-5ec5d52f8224 \
-t flat 
+--------------------------------------+-------+--------------------------------+------+----------+--------------------------------------+----------+------------+
| Mapping ID                           | Value | Cost                           | Type | Field ID | Service ID                           | Group ID | Project ID |
+--------------------------------------+-------+--------------------------------+------+----------+--------------------------------------+----------+------------+
| 96914ec1-3d01-4974-8f0a-50ee935ae602 | None  | 1.5000000000000000000000000000 | flat | None     | f76586d4-e609-4f6f-a446-5ec5d52f8224 | None     | None       |
+--------------------------------------+-------+--------------------------------+------+----------+--------------------------------------+----------+------------+

# 30 जीबी से अधिक वॉल्यूम पर 10% की छूट निर्धारित करें
root@dlp ~(keystone)# openstack rating hashmap threshold create 30 0.90 \
-s f76586d4-e609-4f6f-a446-5ec5d52f8224 \
-t rate 
+--------------------------------------+-------------+--------------------------------+------+----------+--------------------------------------+----------+------------+
| Threshold ID                         | Level       | Cost                           | Type | Field ID | Service ID                           | Group ID | Project ID |
+--------------------------------------+-------------+--------------------------------+------+----------+--------------------------------------+----------+------------+
| 4f75632a-22e3-47c6-a9d9-6abe22fbd203 | 30.00000000 | 0.9000000000000000222044604925 | rate | None     | f76586d4-e609-4f6f-a446-5ec5d52f8224 | None     | None       |
+--------------------------------------+-------------+--------------------------------+------+----------+--------------------------------------+----------+------------+
[6] उस उपयोगकर्ता के साथ सेटिंग्स सत्यापित करें जो उस प्रोजेक्ट में है जिसे आपने वॉल्यूम बनाने के लिए [1] पर सेट किया है।
ubuntu@dlp ~(keystone)$
openstack rating summary get

+----------------------------------+---------------+------+---------------------+---------------------+
| Tenant ID                        | Resource Type | Rate | Begin Time          | End Time            |
+----------------------------------+---------------+------+---------------------+---------------------+
| e294bd7c00314facacdb46c36fb54ee9 | ALL           | 1.0  | 2023-03-01T00:00:00 | 2023-04-01T00:00:00 |
+----------------------------------+---------------+------+---------------------+---------------------+

ubuntu@dlp ~(keystone)$ openstack volume create --size 10 disk01 

ubuntu@dlp ~(keystone)$
openstack volume list

+--------------------------------------+--------+-----------+------+-------------+
| ID                                   | Name   | Status    | Size | Attached to |
+--------------------------------------+--------+-----------+------+-------------+
| d33457d5-34d5-4316-8a10-10e8198a7e7f | disk01 | available |   10 |             |
+--------------------------------------+--------+-----------+------+-------------+

# एक निश्चित अवधि के बाद, लागत वसूल की जाती है

ubuntu@dlp ~(keystone)$
openstack rating summary get

+----------------------------------+---------------+------+---------------------+---------------------+
| Tenant ID                        | Resource Type | Rate | Begin Time          | End Time            |
+----------------------------------+---------------+------+---------------------+---------------------+
| e294bd7c00314facacdb46c36fb54ee9 | ALL           | 16.0 | 2023-03-01T00:00:00 | 2023-04-01T00:00:00 |
+----------------------------------+---------------+------+---------------------+---------------------+

ubuntu@dlp ~(keystone)$
openstack rating dataframes get

+---------------------+---------------------+----------------------------------
| Begin               | End                 | Project ID                       
+---------------------+---------------------+----------------------------------
| 2023-03-29T02:10:00 | 2023-03-29T02:20:00 | e294bd7c00314facacdb46c36fb54ee9 
| 2023-03-29T02:20:00 | 2023-03-29T02:30:00 | e294bd7c00314facacdb46c36fb54ee9 
| 2023-03-29T04:20:00 | 2023-03-29T04:30:00 | e294bd7c00314facacdb46c36fb54ee9 
| 2023-03-29T04:30:00 | 2023-03-29T04:40:00 | e294bd7c00314facacdb46c36fb54ee9 
| 2023-03-29T04:30:00 | 2023-03-29T04:40:00 | e294bd7c00314facacdb46c36fb54ee9 
+---------------------+---------------------+----------------------------------
+--------------------------------------------------------------------------------------------------------------
| Resources                                                                                                    
+--------------------------------------------------------------------------------------------------------------
| [{'rating': '0.0', 'service': 'instance', 'desc': {'flavor_name': 'm1.medium', 'flavor_id': '2', 'vcpus': '',
| [{'rating': '0.0', 'service': 'volume.size', 'desc': {'volume_type': '2740bc05-65be-4824-9224-d4a9645065fa', 
| [{'rating': '0.5', 'service': 'instance', 'desc': {'flavor_name': 'm1.medium', 'flavor_id': '2', 'vcpus': '',
| [{'rating': '0.5', 'service': 'instance', 'desc': {'flavor_name': 'm1.medium', 'flavor_id': '2', 'vcpus': '',
| [{'rating': '15.0', 'service': 'volume.size', 'desc': {'volume_type': '2740bc05-65be-4824-9224-d4a9645065fa',
+--------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
                                                                                                
------------------------------------------------------------------------------------------------
 'id': '11987eec-fb38-4de1-a386-3d1d6001bbd3', 'project_id': 'e294bd7c00314facacdb46c36fb54ee9',
'id': '3a3a1349-4cee-45d6-adc1-381d6467619e', 'project_id': 'e294bd7c00314facacdb46c36fb54ee9', 
 'id': '11987eec-fb38-4de1-a386-3d1d6001bbd3', 'project_id': 'e294bd7c00314facacdb46c36fb54ee9',
 'id': '11987eec-fb38-4de1-a386-3d1d6001bbd3', 'project_id': 'e294bd7c00314facacdb46c36fb54ee9',
 'id': '3a3a1349-4cee-45d6-adc1-381d6467619e', 'project_id': 'e294bd7c00314facacdb46c36fb54ee9',
------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------+
                                                                                                                                             |
---------------------------------------------------------------------------------------------------------------------------------------------+
 'user_id': '85236576a97e492791abe70c217c8898', 'tenant_id': 'e294bd7c00314facacdb46c36fb54ee9'}, 'volume': '1', 'rate_value': '0.0000'}]    |
'user_id': '85236576a97e492791abe70c217c8898', 'tenant_id': 'e294bd7c00314facacdb46c36fb54ee9'}, 'volume': '1E+1', 'rate_value': '0.0000'}]  |
 'user_id': '85236576a97e492791abe70c217c8898', 'tenant_id': 'e294bd7c00314facacdb46c36fb54ee9'}, 'volume': '1', 'rate_value': '0.5000'}]    |
 'user_id': '85236576a97e492791abe70c217c8898', 'tenant_id': 'e294bd7c00314facacdb46c36fb54ee9'}, 'volume': '1', 'rate_value': '0.5000'}]    |
 'user_id': '85236576a97e492791abe70c217c8898', 'tenant_id': 'e294bd7c00314facacdb46c36fb54ee9'}, 'volume': '1E+1', 'rate_value': '1.5000'}] |
---------------------------------------------------------------------------------------------------------------------------------------------+

ubuntu@dlp ~(keystone)$
openstack volume create --size 30 disk02

ubuntu@dlp ~(keystone)$
openstack volume list

+--------------------------------------+--------+-----------+------+-------------+
| ID                                   | Name   | Status    | Size | Attached to |
+--------------------------------------+--------+-----------+------+-------------+
| 15f94205-29eb-4b66-9401-930f456afe83 | disk02 | available |   30 |             |
| d33457d5-34d5-4316-8a10-10e8198a7e7f | disk01 | available |   10 |             |
+--------------------------------------+--------+-----------+------+-------------+

# एक निश्चित अवधि के बाद, लागत वसूल की जाती है
# 1.5 x 30 x 0.9 = 40.5

ubuntu@dlp ~(keystone)$
openstack rating summary get

+----------------------------------+---------------+------+---------------------+---------------------+
| Tenant ID                        | Resource Type | Rate | Begin Time          | End Time            |
+----------------------------------+---------------+------+---------------------+---------------------+
| e294bd7c00314facacdb46c36fb54ee9 | ALL           | 56.5 | 2023-03-01T00:00:00 | 2023-04-01T00:00:00 |
+----------------------------------+---------------+------+---------------------+---------------------+

ubuntu@dlp ~(keystone)$
openstack rating dataframes get

+---------------------+---------------------+----------------------------------
| Begin               | End                 | Project ID                       
+---------------------+---------------------+----------------------------------
| 2023-03-29T02:10:00 | 2023-03-29T02:20:00 | e294bd7c00314facacdb46c36fb54ee9 
| 2023-03-29T02:20:00 | 2023-03-29T02:30:00 | e294bd7c00314facacdb46c36fb54ee9 
| 2023-03-29T04:20:00 | 2023-03-29T04:30:00 | e294bd7c00314facacdb46c36fb54ee9 
| 2023-03-29T04:30:00 | 2023-03-29T04:40:00 | e294bd7c00314facacdb46c36fb54ee9 
| 2023-03-29T04:30:00 | 2023-03-29T04:40:00 | e294bd7c00314facacdb46c36fb54ee9 
| 2023-03-29T05:00:00 | 2023-03-29T05:10:00 | e294bd7c00314facacdb46c36fb54ee9 
+---------------------+---------------------+----------------------------------
+--------------------------------------------------------------------------------------------------------------
| Resources                                                                                                    
+--------------------------------------------------------------------------------------------------------------
| [{'rating': '0.0', 'service': 'instance', 'desc': {'flavor_name': 'm1.medium', 'flavor_id': '2', 'vcpus': '',
| [{'rating': '0.0', 'service': 'volume.size', 'desc': {'volume_type': '2740bc05-65be-4824-9224-d4a9645065fa', 
| [{'rating': '0.5', 'service': 'instance', 'desc': {'flavor_name': 'm1.medium', 'flavor_id': '2', 'vcpus': '',
| [{'rating': '0.5', 'service': 'instance', 'desc': {'flavor_name': 'm1.medium', 'flavor_id': '2', 'vcpus': '',
| [{'rating': '15.0', 'service': 'volume.size', 'desc': {'volume_type': '2740bc05-65be-4824-9224-d4a9645065fa',
| [{'rating': '40.5', 'service': 'volume.size', 'desc': {'volume_type': '2740bc05-65be-4824-9224-d4a9645065fa',
+--------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
                                                                                                
------------------------------------------------------------------------------------------------
 'id': '11987eec-fb38-4de1-a386-3d1d6001bbd3', 'project_id': 'e294bd7c00314facacdb46c36fb54ee9',
'id': '3a3a1349-4cee-45d6-adc1-381d6467619e', 'project_id': 'e294bd7c00314facacdb46c36fb54ee9', 
 'id': '11987eec-fb38-4de1-a386-3d1d6001bbd3', 'project_id': 'e294bd7c00314facacdb46c36fb54ee9',
 'id': '11987eec-fb38-4de1-a386-3d1d6001bbd3', 'project_id': 'e294bd7c00314facacdb46c36fb54ee9',
 'id': '3a3a1349-4cee-45d6-adc1-381d6467619e', 'project_id': 'e294bd7c00314facacdb46c36fb54ee9',
 'id': '15f94205-29eb-4b66-9401-930f456afe83', 'project_id': 'e294bd7c00314facacdb46c36fb54ee9',
------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------+
                                                                                                                                             |
---------------------------------------------------------------------------------------------------------------------------------------------+
 'user_id': '85236576a97e492791abe70c217c8898', 'tenant_id': 'e294bd7c00314facacdb46c36fb54ee9'}, 'volume': '1', 'rate_value': '0.0000'}]    |
'user_id': '85236576a97e492791abe70c217c8898', 'tenant_id': 'e294bd7c00314facacdb46c36fb54ee9'}, 'volume': '1E+1', 'rate_value': '0.0000'}]  |
 'user_id': '85236576a97e492791abe70c217c8898', 'tenant_id': 'e294bd7c00314facacdb46c36fb54ee9'}, 'volume': '1', 'rate_value': '0.5000'}]    |
 'user_id': '85236576a97e492791abe70c217c8898', 'tenant_id': 'e294bd7c00314facacdb46c36fb54ee9'}, 'volume': '1', 'rate_value': '0.5000'}]    |
 'user_id': '85236576a97e492791abe70c217c8898', 'tenant_id': 'e294bd7c00314facacdb46c36fb54ee9'}, 'volume': '1E+1', 'rate_value': '1.5000'}] |
 'user_id': '85236576a97e492791abe70c217c8898', 'tenant_id': 'e294bd7c00314facacdb46c36fb54ee9'}, 'volume': '3E+1', 'rate_value': '1.3500'}] |
---------------------------------------------------------------------------------------------------------------------------------------------+
मिलान सामग्री