コード例 #1
0
ファイル: app.py プロジェクト: Flig/mirrormanager2
def host_asn_delete(host_id, host_asn_id):
    """ Delete a host_peer_asn.
    """
    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')

        hostasnobj = mmlib.get_host_peer_asn(SESSION, host_asn_id)

        if hostasnobj is None:
            flask.abort(404, 'Host Peer ASN not found')
        else:
            SESSION.delete(hostasnobj)

        try:
            SESSION.commit()
            flask.flash('Host Peer ASN 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 delete Peer ASN of the host')
            APP.logger.debug('Could not delete Peer ASN of the host')
            APP.logger.exception(err)

    return flask.redirect(flask.url_for('host_view', host_id=host_id))
コード例 #2
0
ファイル: __init__.py プロジェクト: yumsuresht/mirrormanager2
def host_asn_delete(host_id, host_asn_id):
    """ Delete a host_peer_asn.
    """
    hostobj = mmlib.get_host(SESSION, host_id)

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

    hostasnobj = mmlib.get_host_peer_asn(SESSION, host_asn_id)

    if hostasnobj is None:
        flask.abort(404, 'Host Peer ASN not found')
    else:
        SESSION.delete(hostasnobj)

    try:
        SESSION.commit()
        flask.flash('Host Peer ASN deleted')
    except SQLAlchemyError as err:
        SESSION.rollback()
        flask.flash('Could not delete Peer ASN of the host')
        APP.logger.debug('Could not delete Peer ASN of the host')
        APP.logger.exception(err)

    return flask.redirect(flask.url_for('host_view', host_id=host_id))
コード例 #3
0
ファイル: app.py プロジェクト: TroJan/mirrormanager2
def host_asn_delete(host_id, host_asn_id):
    """ Delete a host_peer_asn.
    """
    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')

        hostasnobj = mmlib.get_host_peer_asn(SESSION, host_asn_id)

        if hostasnobj is None:
            flask.abort(404, 'Host Peer ASN not found')
        else:
            SESSION.delete(hostasnobj)

        try:
            SESSION.commit()
            flask.flash('Host Peer ASN 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 delete Peer ASN of the host')
            APP.logger.debug('Could not delete Peer ASN of the host')
            APP.logger.exception(err)

    return flask.redirect(flask.url_for('host_view', host_id=host_id))
コード例 #4
0
ファイル: __init__.py プロジェクト: yumsuresht/mirrormanager2
def host_asn_delete(host_id, host_asn_id):
    """ Delete a host_peer_asn.
    """
    hostobj = mmlib.get_host(SESSION, host_id)

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

    hostasnobj = mmlib.get_host_peer_asn(SESSION, host_asn_id)

    if hostasnobj is None:
        flask.abort(404, 'Host Peer ASN not found')
    else:
        SESSION.delete(hostasnobj)

    try:
        SESSION.commit()
        flask.flash('Host Peer ASN deleted')
    except SQLAlchemyError as err:
        SESSION.rollback()
        flask.flash('Could not delete Peer ASN of the host')
        APP.logger.debug('Could not delete Peer ASN of the host')
        APP.logger.exception(err)

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