From 7e3e1f03e2139743adaba08187bee79211c6c27e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Albert?= Date: Mon, 16 Mar 2015 18:10:28 +0100 Subject: [PATCH] Added quote calls to rating processors Use self.process by default but overriding it can be useful in case a processors is tracking the state of a calculation and you don't want to disrupt it. Change-Id: I9505adfdc65b0decfa3586c0636d091f41ecfb7d --- cloudkitty/billing/__init__.py | 9 +++++++++ cloudkitty/orchestrator.py | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cloudkitty/billing/__init__.py b/cloudkitty/billing/__init__.py index eb314ba2..dd686dba 100644 --- a/cloudkitty/billing/__init__.py +++ b/cloudkitty/billing/__init__.py @@ -73,6 +73,15 @@ class BillingProcessorBase(object): client.cast({}, operation, name=self.module_name) return module_db.set_state(self.module_name, enabled) + def quote(self, data): + """Compute rating informations from data. + + :param data: An internal CloudKitty dictionary used to describe + resources. + :type data: dict(str:?) + """ + return self.process(data) + @abc.abstractmethod def process(self, data): """Add billing informations to data diff --git a/cloudkitty/orchestrator.py b/cloudkitty/orchestrator.py index ace88b32..321ab9f2 100644 --- a/cloudkitty/orchestrator.py +++ b/cloudkitty/orchestrator.py @@ -124,7 +124,7 @@ class APIWorker(BaseWorker): def quote(self, res_data): for processor in self._processors.values(): - processor.process(res_data) + processor.quote(res_data) price = decimal.Decimal(0) for res in res_data: