serializers.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:mdb 作者: edb-gjengen 项目源码 文件源码
def validate(self, attrs):
        # custom validation
        host = self._get_host_by_fqdn(attrs)

        if host is None:
            raise ValidationError('Host \'{}\' not found.'.format(attrs['certname']))

        if not host.pxe_installable:
            raise ValidationError('Host \'{}\' is marked as not installable via PXE.'.format(attrs['certname']))

        if not host.pxe_key:
            raise ValidationError('Host \'{}\' has no pxe_key.'.format(attrs['certname']))

        if host.pxe_key != attrs['pxe_key']:
            raise ValidationError('Supplied pxe_key \'{}\' does not match host \'{}\'.'.format(
                    attrs['pxe_key'],
                    attrs['certname']))

        self.host = host

        return attrs
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号