当前位置: 首页>>代码示例>>Python>>正文


Python voluptuous.MultipleInvalid方法代码示例

本文整理汇总了Python中voluptuous.MultipleInvalid方法的典型用法代码示例。如果您正苦于以下问题:Python voluptuous.MultipleInvalid方法的具体用法?Python voluptuous.MultipleInvalid怎么用?Python voluptuous.MultipleInvalid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在voluptuous的用法示例。


在下文中一共展示了voluptuous.MultipleInvalid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: validate

# 需要导入模块: import voluptuous [as 别名]
# 或者: from voluptuous import MultipleInvalid [as 别名]
def validate(schema, data):
    """
    Wrap the call to voluptuous schema to raise the proper exception.

    Args:
        schema: The voluptuous Schema object
        data: The validation data for the schema object

    Raises:
        PicoException with 400 status code and the voluptuous error message

    """
    try:
        schema(data)
    except MultipleInvalid as error:
        raise PicoException(error.msg, 400) 
开发者ID:picoCTF,项目名称:picoCTF,代码行数:18,代码来源:common.py

示例2: process_config_enviroment

# 需要导入模块: import voluptuous [as 别名]
# 或者: from voluptuous import MultipleInvalid [as 别名]
def process_config_enviroment(self):
        log.log(log.LOG_INFO, "Processing Environments")
        envlist = self.fm.environments.index(per_page=99999)['results']
        for env in self.get_config_section('environment'):
            try:
                self.validator.enviroment(env)
            except MultipleInvalid as e:
                log.log(log.LOG_WARN, "Cannot create Environment '{0}': YAML validation Error: {1}".format(env['name'], e))
                continue

            env_id = False
            # fm.media.show(name) does not work, we need to iterate over fm.media.index()
            for envc in envlist:
                if (env['name'] == envc['name']):
                    env_id = envc['id']
                    log.log(log.LOG_DEBUG, "Environment '{0}' (id={1}) already present.".format(env['name'], env_id))
                    continue
            if not env_id:
                log.log(log.LOG_INFO, "Create Environment '{0}'".format(env['name']))
                self.fm.environments.create( environment = { 'name': env['name'] } ) 
开发者ID:adfinis-sygroup,项目名称:foreman-yml,代码行数:22,代码来源:importer.py

示例3: process_config_model

# 需要导入模块: import voluptuous [as 别名]
# 或者: from voluptuous import MultipleInvalid [as 别名]
def process_config_model(self):
        log.log(log.LOG_INFO, "Processing Models")
        for model in self.get_config_section('model'):
            try:
                self.validator.model(model)
            except MultipleInvalid as e:
                log.log(log.LOG_WARN, "Cannot create Model '{0}': YAML validation Error: {1}".format(model['name'], e))
                continue
            try:
                model_id = self.fm.models.show(model['name'])['id']
                log.log(log.LOG_DEBUG, "Model '{0}' (id={1}) already present.".format(model['name'], model_id))
            except:
                log.log(log.LOG_INFO, "Create Model '{0}'".format(model['name']))
                model_tpl = {
                    'name':             model['name'],
                    'info':             model['info'],
                    'vendor_class':     model['vendor-class'],
                    'hardware_model':   model['hardware-model']
                }
                self.fm.models.create( model = model_tpl ) 
开发者ID:adfinis-sygroup,项目名称:foreman-yml,代码行数:22,代码来源:importer.py

示例4: process_config_medium

# 需要导入模块: import voluptuous [as 别名]
# 或者: from voluptuous import MultipleInvalid [as 别名]
def process_config_medium(self):
        log.log(log.LOG_INFO, "Processing Media")
        medialist = self.fm.media.index(per_page=99999)['results']
        for medium in self.get_config_section('medium'):
            try:
                self.validator.medium(medium)
            except MultipleInvalid as e:
                log.log(log.LOG_WARN, "Cannot create Media '{0}': YAML validation Error: {1}".format(medium['name'], e))
                continue

            medium_id = False
            # fm.media.show(name) does not work, we need to iterate over fm.media.index()
            for mediac in medialist:
                if (mediac['name'] == medium['name']):
                    medium_id = mediac['id']
                    log.log(log.LOG_DEBUG, "Medium '{0}' (id={1}) already present.".format(medium['name'], medium_id))
            if not medium_id:
                log.log(log.LOG_INFO, "Create Medium '{0}'".format(medium['name']))
                medium_tpl = {
                    'name':        medium['name'],
                    'path':        medium['path'],
                    'os_family':   medium['os-family']
                }
                self.fm.media.create( medium = medium_tpl ) 
开发者ID:adfinis-sygroup,项目名称:foreman-yml,代码行数:26,代码来源:importer.py

示例5: process_config_ptable

# 需要导入模块: import voluptuous [as 别名]
# 或者: from voluptuous import MultipleInvalid [as 别名]
def process_config_ptable(self):
        log.log(log.LOG_INFO, "Processing Partition Tables")
        for ptable in self.get_config_section('partition-table'):
            try:
                self.validator.ptable(ptable)
            except MultipleInvalid as e:
                log.log(log.LOG_WARN, "Cannot create Partition Table '{0}': YAML validation Error: {1}".format(ptable['name'], e))
                continue
            try:
                ptable_id = self.fm.ptables.show(ptable['name'])['id']
                log.log(log.LOG_DEBUG, "Partition Table '{0}' (id={1}) already present.".format(ptable['name'], ptable_id))
            except:
                log.log(log.LOG_INFO, "Create Partition Table '{0}'".format(ptable['name']))
                ptable_tpl = {
                    'name':             ptable['name'],
                    'layout':           ptable['layout'],
                    'snippet':          ptable['snippet'],
                    'audit_comment':    ptable['audit-comment'],
                    'locked':           ptable['locked'],
                    'os_family':        ptable['os-family']
                }
                self.fm.ptables.create( ptable = ptable_tpl ) 
开发者ID:adfinis-sygroup,项目名称:foreman-yml,代码行数:24,代码来源:importer.py

示例6: process_auth_sources_ldap

# 需要导入模块: import voluptuous [as 别名]
# 或者: from voluptuous import MultipleInvalid [as 别名]
def process_auth_sources_ldap(self):
        log.log(log.LOG_INFO, "Processing LDAP auth sources")
        for auth in self.get_config_section('auth-source-ldap'):
            # validate yaml
            try:
                self.validator.auth_source_ldaps(auth)
            except MultipleInvalid as e:
                log.log(log.LOG_WARN, "Cannot create LDAP source '{0}': YAML validation Error: {1}".format(auth['name'], e))
                continue
            try:
                as_id   = self.fm.auth_source_ldaps.show(auth['name'])['id']
                log.log(log.LOG_WARN, "LDAP source {0} allready exists".format(auth['name']))
                continue
            except TypeError:
                pass
            ldap_auth_obj = self.dict_underscore(auth)
            try:
                self.fm.auth_source_ldaps.create( auth_source_ldap=ldap_auth_obj )
            except:
                log.log(log.LOG_ERROR, "Something went wrong creating LDAP source {0}".format(auth['name'])) 
开发者ID:adfinis-sygroup,项目名称:foreman-yml,代码行数:22,代码来源:importer.py

示例7: process_cleanup_computeprfl

# 需要导入模块: import voluptuous [as 别名]
# 或者: from voluptuous import MultipleInvalid [as 别名]
def process_cleanup_computeprfl(self):
        log.log(log.LOG_INFO, "Processing Cleanup of Compute profiles")
        for computeprfl in self.get_config_section('cleanup-compute-profile'):
            try:
                self.validator.cleanup_computeprfl(computeprfl)
            except MultipleInvalid as e:
                log.log(log.LOG_WARN, "Cannot delete Compute profile '{0}': YAML validation Error: {1}".format(computeprfl['name'], e))
                continue

            try:
                self.fm.compute_profiles.show(computeprfl['name'])['id']
                log.log(log.LOG_INFO, "Delete Compute profile '{0}'".format(computeprfl['name']))

                self.fm.compute_profiles.destroy( computeprfl['name'] )
            except:
                log.log(log.LOG_WARN, "Compute profile '{0}' already absent.".format(computeprfl['name'])) 
开发者ID:adfinis-sygroup,项目名称:foreman-yml,代码行数:18,代码来源:cleanup.py

示例8: process_cleanup_medium

# 需要导入模块: import voluptuous [as 别名]
# 或者: from voluptuous import MultipleInvalid [as 别名]
def process_cleanup_medium(self):
        log.log(log.LOG_INFO, "Processing Cleanup of Media")
        medialist = self.fm.media.index(per_page=99999)['results']
        for medium in self.get_config_section('cleanup-medium'):
            try:
                self.validator.cleanup_medium(medium)
            except MultipleInvalid as e:
                log.log(log.LOG_WARN, "Cannot delete Medium '{0}': YAML validation Error: {1}".format(medium['name'], e))
                continue

            medium_deleted = False
            # fm.media.show(name) does not work, we need to iterate over fm.media.index()
            for mediac in medialist:
                if (mediac['name'] == medium['name']):
                    medium_deleted = True
                    log.log(log.LOG_INFO, "Delete Medium '{0}'".format(medium['name']))

                    self.fm.media.destroy( medium['name'] )
                    continue
            if not medium_deleted:
                log.log(log.LOG_WARN, "Medium '{0}' already absent.".format(medium['name'])) 
开发者ID:adfinis-sygroup,项目名称:foreman-yml,代码行数:23,代码来源:cleanup.py

示例9: process_cleanup_ptable

# 需要导入模块: import voluptuous [as 别名]
# 或者: from voluptuous import MultipleInvalid [as 别名]
def process_cleanup_ptable(self):
        log.log(log.LOG_INFO, "Processing Cleanup of Partition Tables")
        for ptable in self.get_config_section('cleanup-partition-table'):
            try:
                self.validator.cleanup_ptable(ptable)
            except MultipleInvalid as e:
                log.log(log.LOG_WARN, "Cannot delete Partition Table '{0}': YAML validation Error: {1}".format(ptable['name'], e))
                continue

            try:
                self.fm.ptables.show(ptable['name'])['id']
                log.log(log.LOG_INFO, "Delete Partition Table '{0}'".format(ptable['name']))

                self.fm.ptables.destroy( ptable['name'] )
            except:
                log.log(log.LOG_WARN, "Partition Table '{0}' already absent.".format(ptable['name'])) 
开发者ID:adfinis-sygroup,项目名称:foreman-yml,代码行数:18,代码来源:cleanup.py

示例10: validate

# 需要导入模块: import voluptuous [as 别名]
# 或者: from voluptuous import MultipleInvalid [as 别名]
def validate(self, config: dict) -> dict:
        """Validates a given voluptuous schema

        Args:
            config: Takeoff configuration

        Returns:
            The validated schema

        Raises:
            MultipleInvalid
            Invalid
        """
        try:
            return self.schema()(config)
        except (vol.MultipleInvalid, vol.Invalid) as e:
            logger.error(e)
            logger.error(pprint.pformat(config))
            raise e 
开发者ID:schipholgroup,项目名称:takeoff,代码行数:21,代码来源:step.py

示例11: test_root_schema_invalid

# 需要导入模块: import voluptuous [as 别名]
# 或者: from voluptuous import MultipleInvalid [as 别名]
def test_root_schema_invalid(self):

        test_data = {
            'kind': 'RootCA',
            'metadata': {
                'name': 'test-root-ca',
                'description': 'Test Root CA'
            },
            'spec': {
                'key_type': 'rsa',
                'key_bits': 4096,
            }
        }

        with self.assertRaises(voluptuous.MultipleInvalid):
            self.assertIsInstance(schemas.RootCASchema(test_data), dict) 
开发者ID:bincyber,项目名称:pkictl,代码行数:18,代码来源:test_schemas.py

示例12: test_intermediate_schema_invalid

# 需要导入模块: import voluptuous [as 别名]
# 或者: from voluptuous import MultipleInvalid [as 别名]
def test_intermediate_schema_invalid(self):

        test_data = {
            'kind': 'IntermediateCA',
            'metadata': {
                'name': 'test-intermediate-ca',
                'description': 'Test Intermediate CA',
                'issuer': 'test-root-ca'
            },
            'spec': {
                'type': 'internal',
                'key_type': 'ec',
                'key_bits': 8192
            }
        }

        with self.assertRaises(voluptuous.MultipleInvalid):
            self.assertIsInstance(schemas.IntermediateCASchema(test_data), dict) 
开发者ID:bincyber,项目名称:pkictl,代码行数:20,代码来源:test_schemas.py

示例13: _check_certificate

# 需要导入模块: import voluptuous [as 别名]
# 或者: from voluptuous import MultipleInvalid [as 别名]
def _check_certificate(cert):
    _errors = []
    cert = load_certificate(cert)
    is_expired = verify_certificate_expiration(cert)
    has_supported_alg = verify_certificate_algorithm(cert)
    no_sha1 = verify_bad_certificate_algorithm(cert)
    if is_expired:
        _errors.append(
            Invalid('Il certificato è scaduto.')
        )
    if not has_supported_alg:
        _errors.append(
            Invalid('Il certificato deve essere firmato con un algoritmo valido.')
        )
    if not no_sha1:
        _errors.append(
            Invalid('Il certificato non deve essere firmato tramite algoritmo SHA1 (deprecato).')
        )
    if _errors:
        raise MultipleInvalid(errors=_errors)
    return cert 
开发者ID:italia,项目名称:spid-testenv2,代码行数:23,代码来源:validators.py

示例14: get_all_metrics

# 需要导入模块: import voluptuous [as 别名]
# 或者: from voluptuous import MultipleInvalid [as 别名]
def get_all_metrics():
    try:
        metrics_conf = collector.validate_conf(
            ck_utils.load_conf(CONF.collect.metrics_conf))
    except (voluptuous.Invalid, voluptuous.MultipleInvalid):
        msg = 'Invalid endpoint: no metrics in current configuration.'
        pecan.abort(405, msg)

    policy.authorize(pecan.request.context, 'info:list_metrics_info', {})
    metrics_info_list = []
    for metric_name, metric in metrics_conf.items():
        info = metric.copy()
        info['metric_id'] = info['alt_name']
        metrics_info_list.append(
            info_models.CloudkittyMetricInfo(**info))
    return info_models.CloudkittyMetricInfoCollection(
        metrics=metrics_info_list) 
开发者ID:openstack,项目名称:cloudkitty,代码行数:19,代码来源:info.py

示例15: validate

# 需要导入模块: import voluptuous [as 别名]
# 或者: from voluptuous import MultipleInvalid [as 别名]
def validate(logger, data, schema, where):
    """
    Generic validation of a data structure against schema
    using Voluptuous data validation library
    Parameters:
     - logger: valid logger reference
     - data: structure to validate
     - schema: a valid Voluptuous schema
     - where: string for debugging purposes to identity the policy location
    """
    logger.debug("validating data=%s", data)
    try:
        #*** Check correctness of data against schema with Voluptuous:
        schema(data)
    except MultipleInvalid as exc:
        #*** There was a problem with the data:
        logger.critical("Voluptuous detected a problem where=%s, exception=%s",
                                                                    where, exc)
        sys.exit("Exiting nmeta. Please fix error in main_policy.yaml")
    return 1 
开发者ID:mattjhayes,项目名称:nmeta,代码行数:22,代码来源:policy.py


注:本文中的voluptuous.MultipleInvalid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。