Update fields of CSV reports.

Gnocchi being the default collector, the metadata field to check for ItemName
has been renamed from 'flavor' to 'flavor_name' ('flavor_name' is a required
attribute for 'instance' resources in gnocchi).

The ResourceId field is now available for all services, through the
'resource_id' attribute.

An 'ItemFlavorId' field has been added.

The RateId and ItemDescription fields have been removed, because the only key of
the 'rating' dict is 'price'.

Change-Id: I5aed4b813940effa5e0b14ba6a4eca0d16ac0c40
This commit is contained in:
Luka Peschke 2017-12-19 12:14:49 +01:00
parent 51d1dd4635
commit e225fad711
1 changed files with 3 additions and 5 deletions

View File

@ -39,12 +39,11 @@ class CSVMapped(csv_base.BaseCSVBackend):
('UserId', 'desc:user_id'),
('ProjectId', 'desc:project_id'),
('ItemName', 'desc:name'),
('ItemFlavor', 'desc:flavor'),
('ItemFlavor', 'desc:flavor_name'),
('ItemFlavorId', 'desc:flavor_id'),
('AvailabilityZone', 'desc:availability_zone'),
('Service', self._trans_service),
('ItemDescription', 'rating:description'),
('UsageQuantity', 'vol:qty'),
('RateId', 'rating:rate_id'),
('RateValue', 'rating:price'),
('Cost', self._trans_calc_cost),
('user:*', 'desc:metadata:*')])
@ -135,8 +134,7 @@ class CSVMapped(csv_base.BaseCSVBackend):
"""Context dependent resource id transformation function.
"""
if context == 'compute':
return report_data['desc'].get('instance_id')
return report_data['desc'].get('resource_id')
def _trans_calc_cost(self, context, report_data):
"""Cost calculation function.