def validate(config): """ Validates the configuration for the puppet module importer. :param config: configuration passed in by Pulp :type config: pulp.plugins.config.PluginCallConfiguration :return: the expected return from the plugin's validate_config method :rtype: tuple """ validations = (_validate_feed, _validate_remove_missing, _validate_queries) for v in validations: result, msg = v(config) if not result: return result, msg try: # This will raise an InvalidConfig if there are problems importer_config.validate_config(config) return True, None except importer_config.InvalidConfig, e: # Because the validate() API is silly, we must concatenate all the failure messages into # one. msg = _(u"Configuration errors:\n") msg += "\n".join(e.failure_messages) # Remove the last newline msg = msg.rstrip() return False, msg
def validate(config): """ Validates the configuration for the puppet module importer. :param config: configuration passed in by Pulp :type config: pulp.plugins.config.PluginCallConfiguration :return: the expected return from the plugin's validate_config method :rtype: tuple """ validations = ( _validate_feed, _validate_remove_missing, _validate_queries, ) for v in validations: result, msg = v(config) if not result: return result, msg try: # This will raise an InvalidConfig if there are problems importer_config.validate_config(config) return True, None except importer_config.InvalidConfig, e: # Because the validate() API is silly, we must concatenate all the failure messages into # one. msg = _(u'Configuration errors:') + '\n' msg += '\n'.join(e.failure_messages) # Remove the last newline msg = msg.rstrip() return False, msg
def validate_config(self, repo, config): try: importer_config.validate_config(config) return True, None except importer_config.InvalidConfig, e: # Concatenate all of the failure messages into a single message msg = _('Configuration errors:\n') for failure_message in e.failure_messages: msg += failure_message + '\n' msg = msg.rstrip() # remove the trailing \n return False, msg
def validate(config): """ Validates a potential configuration for the yum importer. :param config: configuration instance passed to the importer :type config: pulp.plugins.config.PluginCallConfiguration :return: tuple of valid flag and error message :rtype: (bool, str) """ config = config.flatten( ) # squish it into a dictionary so we can manipulate it error_messages = [] validations = ( _validate_allowed_keys, _validate_lazy_compatibility, ) for v in validations: v(config, error_messages) if error_messages: for msg in error_messages: _logger.error(msg) return False, '\n'.join(error_messages) try: importer_config.validate_config(config) return True, None except importer_config.InvalidConfig, e: # Concatenate all of the failure messages into a single message msg = _('Configuration errors:\n') for failure_message in e.failure_messages: msg += failure_message + '\n' msg = msg.rstrip() # remove the trailing \n return False, msg
def validate(config): """ Validates a potential configuration for the yum importer. :param config: configuration instance passed to the importer :type config: pulp.plugins.config.PluginCallConfiguration :return: tuple of valid flag and error message :rtype: (bool, str) """ try: importer_config.validate_config(config) return True, None except importer_config.InvalidConfig, e: # Concatenate all of the failure messages into a single message msg = _('Configuration errors:\n') for failure_message in e.failure_messages: msg += failure_message + '\n' msg = msg.rstrip() # remove the trailing \n return False, msg
def validate(config): """ Validates a potential configuration for the yum importer. :param config: configuration instance passed to the importer :type config: pulp.plugins.config.PluginCallConfiguration :return: tuple of valid flag and error message :rtype: (bool, str) """ config = config.flatten() # squish it into a dictionary so we can manipulate it error_messages = [] validations = ( _validate_allowed_keys, _validate_lazy_compatibility, ) for v in validations: v(config, error_messages) if error_messages: for msg in error_messages: _logger.error(msg) return False, '\n'.join(error_messages) try: importer_config.validate_config(config) return True, None except importer_config.InvalidConfig, e: # Concatenate all of the failure messages into a single message msg = _('Configuration errors:\n') for failure_message in e.failure_messages: msg += failure_message + '\n' msg = msg.rstrip() # remove the trailing \n return False, msg
def test_all_pass(self): # All options are optional, so we can run them without concern config = PluginCallConfiguration({}, {}) importer_config.validate_config(config)