Files
monasca-agent/monasca_setup/detection/args_plugin.py
Joe Keen 1ded0b7b1c Fixing flake8 errors now that tox is working again
Change-Id: Id34991711c57f20922f003928008143032723af3
2015-07-30 14:47:02 -06:00

39 lines
1.3 KiB
Python

import logging
from plugin import Plugin
log = logging.getLogger(__name__)
class ArgsPlugin(Plugin):
"""Base plugin for detection plugins that take arguments for configuration rather than do detection."""
def _build_instance(self, arg_list):
"""If a value for each arg in the arg_list was specified build it into an instance dictionary. Also check for dimensions and add if they were specified.
:param arg_list: Arguments to include
:return: instance dictionary
"""
instance = {}
if 'dimensions' in self.args:
instance['dimensions'] = dict(item.strip().split(":") for item in self.args['dimensions'].split(","))
for arg in arg_list:
if arg in self.args:
instance[arg] = self.args[arg]
return instance
def _check_required_args(self, arg_list):
"""Check that the required args were specified
:param arg_list: A list of arguments to verify were specified
:return: True if the required args exist false otherwise
"""
if self.args is None:
return False
for arg in arg_list:
if arg not in self.args:
return False
return True
def dependencies_installed(self):
return True