Support Swift Billing

Below changes are done in this patch for Swift billing:

1. Add new config section for conf.yaml to extract container
size from Ceilometer

2. Setting correct container name

Change-Id: I1752ad73b9a9f973371cd692fc7d1ca31b35a0d2
This commit is contained in:
Fei Long Wang
2016-04-20 15:04:34 +12:00
parent 3efcfcdf6a
commit a1a0076465
2 changed files with 19 additions and 0 deletions

View File

@@ -61,11 +61,17 @@ class Database(object):
query = self.session.query(Resource).\
filter(Resource.id == resource_id,
Resource.tenant_id == tenant_id)
if query.count() == 0:
info = self.merge_resource_metadata({'type': resource_type},
entry, md_def)
if resource_type == 'Virtual Machine':
info['os_distro'] = self._get_os_distro(entry)
if resource_type == 'Object Storage Container':
# NOTE(flwang): It's safe to get container name by /, since
# Swift doesn't allow container name with /.
idx = resource_id.index('/') + 1
info['name'] = resource_id[idx:]
self.session.add(Resource(
id=resource_id,
info=json.dumps(info),

View File

@@ -163,6 +163,19 @@ collection:
name:
sources:
- name
-
meter: storage.containers.objects.size
service: o1.standard
type: Object Storage Container
transformer: GaugeMax
unit: byte
# NOTE(flwang): Nothing in resource_metadata from ceilometer actually.
# But to avoid any unnecessary issue and keeping consistency. Just keep
# 'name' as default key.
metadata:
name:
sources:
- name
# transformer configs
transformers:
uptime: