Ejemplo n.º 1
0
def get_reverse(ip_address):
    if request.method == 'GET':
        resolution_list = Resolution.list_from_ip(ip_address)
        if len(resolution_list) == 0:
            return error_view(404, "no resolution found for this IP")

        return dn_resolutions_list_view(resolution_list)
Ejemplo n.º 2
0
def delete(domain_name):
    try:
        username = get_jwt_identity()
        if not UserDn.exists(username, domain_name):
            return error_view(403, "no ownership found")

        # remove ownership
        user_dn = UserDn.get(username, domain_name)
        if not user_dn.owned:
            return error_view(403, "you do not own this domain")

        user_dn.delete()

        # remove tags
        dn_linked_tags = TagDnIP.list_tags_from_object(domain_name,
                                                       DOMAIN_NAME_COLLECTION)
        for t in dn_linked_tags:
            t.delete()

        # remove resolution / IP
        resolution_list = Resolution.list_from_domain(domain_name)
        for r in resolution_list:
            r.delete()

            ip_address = r.ip_address
            res_ip_list = Resolution.list_from_ip(ip_address)
            if len(res_ip_list) == 0:
                ip_linked_tags = TagDnIP.list_tags_from_object(
                    ip_address, IP_ADDRESS_COLLECTION)
                for t in ip_linked_tags:
                    t.delete()

                ip = IPAddress.get(ip_address)
                ip.delete()

        dn = DomainName.get(domain_name)
        dn.delete()

        return dn_deleted_view(dn)
    except ObjectNotFound as o:
        return error_view(404, str(o))