Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 8 additions & 17 deletions metrics_utility/automation_controller_billing/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,20 @@ def __init__(self, collection_type=base.Collector.SCHEDULED_COLLECTION, collecto
collector_module = collectors

self.ship_target = ship_target
self.billing_provider_params = billing_provider_params

super(Collector, self).__init__(collection_type=collection_type, collector_module=collector_module)
super(Collector, self).__init__(
collection_type=collection_type,
collector_module=collector_module,
billing_provider_params=billing_provider_params,
)

# TODO: extract advisory lock name in the superclass and log message, so we can change it here and then use
# this method from superclass
# TODO: extract to superclass ability to push extra params into config.json
def gather(self, dest=None, subset=None, since=None, until=None, billing_provider_params=None):
# FIXME: subset is only used for tests, mock registered collectors instead?
def gather(self, subset=None, since=None, until=None, billing_provider_params=None):
"""Entry point for gathering

:param dest: (default: /tmp/awx-analytics-*) - directory for temp files
:param subset: (list) collector_module's function names if only subset is required (typically tests)
:param since: (datetime) - low threshold of data changes (max. and default - 28 days ago)
:param until: (datetime) - high threshold of data changes (defaults to now)
Expand All @@ -57,7 +60,7 @@ def gather(self, dest=None, subset=None, since=None, until=None, billing_provide
logger.log(self.log_level, 'Not gathering Automation Controller billing data, another task holds lock')
return None

self._gather_initialize(dest, subset, since, until)
self._gather_initialize(subset, since, until)

if not self._gather_config():
return None
Expand All @@ -74,18 +77,6 @@ def gather(self, dest=None, subset=None, since=None, until=None, billing_provide

return self.all_tar_paths()

def _gather_config(self):
if not super()._gather_config():
return False

# Extend the config collection to contain billing specific info:
config_collection = self.collections['config']
data = json.loads(config_collection.data)
data['billing_provider_params'] = self.billing_provider_params
config_collection._save_gathering(data)

return True

@staticmethod
def db_connection():
return connection
Expand Down
Loading