def get_monitor(self): """Returns the configured monitor for this Strike configuration :returns: The configured monitor :rtype: :class:`ingest.strike.monitors.monitor.Monitor` """ monitor_type = self._configuration['monitor']['type'] monitor = factory.get_monitor(monitor_type) self.load_monitor_configuration(monitor) return monitor
def validate(self): """Validates the Strike configuration :returns: A list of warnings discovered during validation :rtype: list[:class:`ingest.strike.configuration.strike_configuration.ValidationWarning`] :raises :class:`ingest.strike.configuration.exceptions.InvalidStrikeConfiguration`: If the configuration is invalid. """ warnings = [] monitor_type = self._configuration['monitor']['type'] if monitor_type not in factory.get_monitor_types(): raise InvalidStrikeConfiguration( '\'%s\' is an invalid monitor type' % monitor_type) monitored_workspace_name = self._configuration['workspace'] workspace_names = {monitored_workspace_name} for rule in self._file_handler.rules: if rule.new_workspace: workspace_names.add(rule.new_workspace) for workspace in Workspace.objects.filter(name__in=workspace_names): if workspace.name == monitored_workspace_name: broker_type = workspace.get_broker().broker_type monitor = factory.get_monitor(monitor_type) if broker_type not in monitor.supported_broker_types: msg = 'Monitor type %s does not support broker type %s' raise InvalidStrikeConfiguration( msg % (monitor_type, broker_type)) if not workspace.is_active: raise InvalidStrikeConfiguration( 'Workspace is not active: %s' % workspace.name) workspace_names.remove(workspace.name) if workspace_names: raise InvalidStrikeConfiguration('Unknown workspace name: %s' % workspace_names.pop()) return warnings
def validate(self): """Validates the Strike configuration :returns: A list of warnings discovered during validation :rtype: list[:class:`ingest.strike.configuration.strike_configuration.ValidationWarning`] :raises :class:`ingest.strike.configuration.exceptions.InvalidStrikeConfiguration`: If the configuration is invalid. """ warnings = [] monitor_type = self._configuration['monitor']['type'] if monitor_type not in factory.get_monitor_types(): raise InvalidStrikeConfiguration('\'%s\' is an invalid monitor type' % monitor_type) monitored_workspace_name = self._configuration['workspace'] workspace_names = {monitored_workspace_name} for rule in self._file_handler.rules: if rule.new_workspace: workspace_names.add(rule.new_workspace) for workspace in Workspace.objects.filter(name__in=workspace_names): if workspace.name == monitored_workspace_name: broker_type = workspace.get_broker().broker_type monitor = factory.get_monitor(monitor_type) if broker_type not in monitor.supported_broker_types: msg = 'Monitor type %s does not support broker type %s' raise InvalidStrikeConfiguration(msg % (monitor_type, broker_type)) if not workspace.is_active: raise InvalidStrikeConfiguration('Workspace is not active: %s' % workspace.name) workspace_names.remove(workspace.name) if workspace_names: raise InvalidStrikeConfiguration('Unknown workspace name: %s' % workspace_names.pop()) return warnings
def validate(self): """Validates the Strike configuration :returns: A list of warnings discovered during validation :rtype: list[:class:`util.validation.ValidationWarning`] :raises :class:`ingest.strike.configuration.exceptions.InvalidStrikeConfiguration`: If the configuration is invalid. """ warnings = [] monitor_type = self.configuration['monitor']['type'] if monitor_type not in factory.get_monitor_types(): raise InvalidStrikeConfiguration( '\'%s\' is an invalid monitor type' % monitor_type) if 'recipe' in self.configuration: recipe_name = self.configuration['recipe'][ 'name'] if 'name' in self.configuration['recipe'] else None revision_num = self.configuration['recipe'][ 'revision_num'] if 'revision_num' in self.configuration[ 'recipe'] else None if not recipe_name: msg = 'Recipe Type name is not defined' raise InvalidStrikeConfiguration(msg) if RecipeType.objects.filter(name=recipe_name).count() == 0: msg = 'Recipe Type %s does not exist' raise InvalidStrikeConfiguration(msg % recipe_name) if revision_num: rt = RecipeType.objects.get(name=recipe_name) if RecipeTypeRevision.objects.filter( recipe_type=rt, revision_num=revision_num).count() == 0: msg = 'Recipe Type revision number %s does not exist for recipe type %s' raise InvalidStrikeConfiguration( msg % (revision_num, recipe_name)) monitored_workspace_name = self.configuration['workspace'] workspace_names = {monitored_workspace_name} for rule in self.file_handler.rules: if rule.new_workspace: workspace_names.add(rule.new_workspace) for workspace in Workspace.objects.filter(name__in=workspace_names): if workspace.name == monitored_workspace_name: broker_type = workspace.get_broker().broker_type monitor = factory.get_monitor(monitor_type) if broker_type not in monitor.supported_broker_types: msg = 'Monitor type %s does not support broker type %s' raise InvalidStrikeConfiguration( msg % (monitor_type, broker_type)) if not workspace.is_active: raise InvalidStrikeConfiguration( 'Workspace is not active: %s' % workspace.name) workspace_names.remove(workspace.name) if workspace_names: raise InvalidStrikeConfiguration('Unknown workspace name: %s' % workspace_names.pop()) return warnings