Beispiel #1
0
def host_acl_ip_delete(host_id, host_acl_ip_id):
    """ Delete a host_acl_ip.
    """
    form = forms.ConfirmationForm()
    if form.validate_on_submit():
        hostobj = mmlib.get_host(SESSION, host_id)

        if hostobj is None:
            flask.abort(404, 'Host not found')

        if not (is_site_admin(flask.g.fas_user, hostobj.site)
                or is_mirrormanager_admin(flask.g.fas_user)):
            flask.abort(403, 'Access denied')

        hostaclobj = mmlib.get_host_acl_ip(SESSION, host_acl_ip_id)

        if hostaclobj is None:
            flask.abort(404, 'Host ACL IP not found')
        else:
            SESSION.delete(hostaclobj)
        try:
            SESSION.flush()
            flask.flash('Host ACL IP deleted')
        except SQLAlchemyError as err:  # pragma: no cover
            # We check everything before deleting so the only error we could
            # run in is DB server related, and that we can't fake in our
            # tests
            SESSION.rollback()
            flask.flash('Could not add ACL IP to the host')
            APP.logger.debug('Could not add ACL IP to the host')
            APP.logger.exception(err)

        SESSION.commit()
    return flask.redirect(flask.url_for('host_view', host_id=host_id))
Beispiel #2
0
def host_acl_ip_delete(host_id, host_acl_ip_id):
    """ Delete a host_acl_ip.
    """
    hostobj = mmlib.get_host(SESSION, host_id)

    if hostobj is None:
        flask.abort(404, 'Host not found')

    hostaclobj = mmlib.get_host_acl_ip(SESSION, host_acl_ip_id)

    if hostaclobj is None:
        flask.abort(404, 'Host ACL IP not found')
    else:
        SESSION.delete(hostaclobj)
    try:
        SESSION.flush()
        flask.flash('Host ACL IP deleted')
    except SQLAlchemyError as err:
        SESSION.rollback()
        flask.flash('Could not add ACL IP to the host')
        APP.logger.debug('Could not add ACL IP to the host')
        APP.logger.exception(err)

    SESSION.commit()
    return flask.redirect(flask.url_for('host_view', host_id=host_id))
Beispiel #3
0
def host_acl_ip_delete(host_id, host_acl_ip_id):
    """ Delete a host_acl_ip.
    """
    form = forms.ConfirmationForm()
    if form.validate_on_submit():
        hostobj = mmlib.get_host(SESSION, host_id)

        if hostobj is None:
            flask.abort(404, 'Host not found')

        if not (is_site_admin(flask.g.fas_user, hostobj.site)
                or is_mirrormanager_admin(flask.g.fas_user)):
            flask.abort(403, 'Access denied')

        hostaclobj = mmlib.get_host_acl_ip(SESSION, host_acl_ip_id)

        if hostaclobj is None:
            flask.abort(404, 'Host ACL IP not found')
        else:
            SESSION.delete(hostaclobj)
        try:
            SESSION.flush()
            flask.flash('Host ACL IP deleted')
        except SQLAlchemyError as err:  # pragma: no cover
            # We check everything before deleting so the only error we could
            # run in is DB server related, and that we can't fake in our
            # tests
            SESSION.rollback()
            flask.flash('Could not add ACL IP to the host')
            APP.logger.debug('Could not add ACL IP to the host')
            APP.logger.exception(err)

        SESSION.commit()
    return flask.redirect(flask.url_for('host_view', host_id=host_id))
Beispiel #4
0
def host_acl_ip_delete(host_id, host_acl_ip_id):
    """ Delete a host_acl_ip.
    """
    hostobj = mmlib.get_host(SESSION, host_id)

    if hostobj is None:
        flask.abort(404, 'Host not found')

    hostaclobj = mmlib.get_host_acl_ip(SESSION, host_acl_ip_id)

    if hostaclobj is None:
        flask.abort(404, 'Host ACL IP not found')
    else:
        SESSION.delete(hostaclobj)
    try:
        SESSION.flush()
        flask.flash('Host ACL IP deleted')
    except SQLAlchemyError as err:
        SESSION.rollback()
        flask.flash('Could not add ACL IP to the host')
        APP.logger.debug('Could not add ACL IP to the host')
        APP.logger.exception(err)

    SESSION.commit()
    return flask.redirect(flask.url_for('host_view', host_id=host_id))