예제 #1
0
def update_neighbor_v4(obj, user):
    """Update NeighborV4."""

    try:
        obj_to_update = get_neighbor_v4_by_id(obj.get('id'))
        obj_to_update.update_v4(obj, user)
    except exceptions.NeighborV4Error as e:
        raise api_rest_exceptions.ValidationAPIException(str(e))
    except exceptions.DontHavePermissionForPeerGroupException as e:
        raise api_rest_exceptions.ValidationAPIException(str(e))
    except exceptions.LocalIpAndRemoteIpAreInDifferentVrfsException as e:
        raise api_rest_exceptions.ValidationAPIException(str(e))
    except exceptions.LocalIpAndLocalAsnAtDifferentEquipmentsException as e:
        raise api_rest_exceptions.ValidationAPIException(str(e))
    except exceptions.RemoteIpAndRemoteAsnAtDifferentEquipmentsException as e:
        raise api_rest_exceptions.ValidationAPIException(str(e))
    except exceptions.LocalIpAndPeerGroupAtDifferentEnvironmentsException as e:
        raise api_rest_exceptions.ValidationAPIException(str(e))
    except exceptions.NeighborDuplicatedException as e:
        raise api_rest_exceptions.ValidationAPIException(str(e))
    except exceptions.NeighborV4IsDeployed as e:
        raise api_rest_exceptions.ValidationAPIException(str(e))
    except api_rest_exceptions.ValidationAPIException as e:
        raise api_rest_exceptions.ValidationAPIException(str(e))
    except exceptions.NeighborV4DoesNotExistException as e:
        raise api_rest_exceptions.ObjectDoesNotExistException(str(e))
    except Exception as e:
        raise api_rest_exceptions.NetworkAPIException(str(e))

    return obj_to_update
예제 #2
0
def create_neighbor_v6(obj, user):
    """Create NeighborV6."""

    try:
        obj_to_create = NeighborV6()
        obj_to_create.create_v4(obj, user)
    except exceptions.NeighborV6Error as e:
        raise api_rest_exceptions.ValidationAPIException(str(e))
    except exceptions.DontHavePermissionForPeerGroupException as e:
        raise api_rest_exceptions.ValidationAPIException(str(e))
    except exceptions.LocalIpAndRemoteIpAreInDifferentVrfsException as e:
        raise api_rest_exceptions.ValidationAPIException(str(e))
    except exceptions.LocalIpAndLocalAsnAtDifferentEquipmentsException as e:
        raise api_rest_exceptions.ValidationAPIException(str(e))
    except exceptions.RemoteIpAndRemoteAsnAtDifferentEquipmentsException as e:
        raise api_rest_exceptions.ValidationAPIException(str(e))
    except exceptions.LocalIpAndPeerGroupAtDifferentEnvironmentsException as e:
        raise api_rest_exceptions.ValidationAPIException(str(e))
    except exceptions.NeighborDuplicatedException as e:
        raise api_rest_exceptions.ValidationAPIException(str(e))
    except api_rest_exceptions.ValidationAPIException as e:
        raise api_rest_exceptions.ValidationAPIException(str(e))
    except Exception as e:
        raise api_rest_exceptions.NetworkAPIException(str(e))

    return obj_to_create
예제 #3
0
def get_neighbor_v6_by_search(search=None):
    """Return a list of NeighborV6's by dict."""

    try:
        objects = NeighborV6.objects.filter()
        search_dict = search if search else dict()
        object_map = build_query_to_datatable_v3(objects, search_dict)
    except FieldError as e:
        raise api_rest_exceptions.ValidationAPIException(str(e))
    except Exception as e:
        raise api_rest_exceptions.NetworkAPIException(str(e))
    else:
        return object_map
예제 #4
0
def delete_neighbor_v6(obj_ids):
    """Delete NeighborV6."""

    for obj_id in obj_ids:
        try:
            obj_to_delete = get_neighbor_v6_by_id(obj_id)
            obj_to_delete.delete_v4()
        except exceptions.NeighborV6DoesNotExistException as e:
            raise api_rest_exceptions.ObjectDoesNotExistException(str(e))
        except exceptions.NeighborV6IsDeployed as e:
            raise api_rest_exceptions.ValidationAPIException(str(e))
        except exceptions.NeighborV6Error as e:
            raise api_rest_exceptions.NetworkAPIException(str(e))
        except Exception as e:
            raise api_rest_exceptions.NetworkAPIException(str(e))