views.py 文件源码

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

项目:mist.api 作者: mistio 项目源码 文件源码
def create_dns_zone(request):
    """
    Create a new DNS zone under a specific cloud.
    ---
    """
    auth_context = auth_context_from_request(request)

    cloud_id = request.matchdict['cloud']
    auth_context.check_perm("cloud", "read", cloud_id)
    auth_context.check_perm("cloud", "create_resources", cloud_id)
    tags = auth_context.check_perm("zone", "add", None)
    # Try to get the specific cloud for which we will create the zone.
    try:
        cloud = Cloud.objects.get(owner=auth_context.owner, id=cloud_id)
    except me.DoesNotExist:
        raise CloudNotFoundError

    params = params_from_request(request)
    new_zone = Zone.add(owner=cloud.owner, cloud=cloud, **params).as_dict()

    if tags:
        resolve_id_and_set_tags(auth_context.owner, 'zone', new_zone['id'],
                                tags, cloud_id=cloud_id)

    # Schedule a UI update
    trigger_session_update(auth_context.owner, ['zones'])
    return new_zone
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号