base.py 文件源码

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

项目:mist.api 作者: mistio 项目源码 文件源码
def create_record(self, record, **kwargs):
        """
        This is the public method that is called to create a new DNS record
        under a specific zone.
        """
        record.name = kwargs['name']
        record.type = kwargs['type']
        if isinstance(kwargs['data'], list):
            record.rdata = kwargs['data']
        else:
            record.rdata = [kwargs['data']]
        record.ttl = kwargs['ttl']

        try:
            record.clean()
        except me.ValidationError as exc:
            log.error("Error validating %s: %s", record, exc.to_dict())
            raise BadRequestError({'msg': exc.message,
                                   'errors': exc.to_dict()})

        self._create_record__prepare_args(record.zone, kwargs)
        pr_record = self._create_record__for_zone(record.zone, **kwargs)
        record.record_id = pr_record.id
        # This is not something that should be given by the user, e.g. we
        # are only using this to store the ttl, so we should onl save this
        # value if it's returned by the provider.
        record.extra = pr_record.extra
        try:
            record.save()
        except me.ValidationError as exc:
            log.error("Error validating %s: %s", record, exc.to_dict())
            raise BadRequestError({'msg': exc.message,
                                   'errors': exc.to_dict()})
        except me.NotUniqueError as exc:
            log.error("Record %s not unique error: %s", record, exc)
            raise RecordExistsError()
        self.cloud.owner.mapper.update(record)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号