Exemple #1
0
def open_port(identity, username, eventcomment=""):
    """
    Takes as input the identityid of the block and username. Opens the
    port (either enable or change vlan) and updates the database.

    If port is not found in the database we assume that the
    switch/module has been replaced. As this normally means that the
    port is enabled, we enable the port in the arnold-database.

    """

    try:
        identity.interface
    except Interface.DoesNotExist:
        LOGGER.info("Interface did not exist, enabling in database only")
    else:
        LOGGER.info("Trying to lift detention for %s on %s",
                    identity.mac, identity.interface)
        if identity.status == 'disabled':
            change_port_status('enable', identity)
        elif identity.status == 'quarantined':
            change_port_vlan(identity, identity.fromvlan)

    identity.status = 'enabled'
    identity.last_changed = datetime.now()
    identity.fromvlan = None
    identity.tovlan = None
    identity.autoenable = None
    identity.save()

    event = Event(identity=identity, comment=eventcomment, action='enabled',
                  executor=username)
    event.save()

    LOGGER.info("openPort: Port successfully opened")
Exemple #2
0
def open_port(identity, username, eventcomment=""):
    """
    Takes as input the identityid of the block and username. Opens the
    port (either enable or change vlan) and updates the database.

    If port is not found in the database we assume that the
    switch/module has been replaced. As this normally means that the
    port is enabled, we enable the port in the arnold-database.

    """

    try:
        identity.interface
    except Interface.DoesNotExist:
        LOGGER.info("Interface did not exist, enabling in database only")
    else:
        LOGGER.info("Trying to lift detention for %s on %s" % (
            identity.mac, identity.interface))
        if identity.status == 'disabled':
            change_port_status('enable', identity)
        elif identity.status == 'quarantined':
            change_port_vlan(identity, identity.fromvlan)

    identity.status = 'enabled'
    identity.last_changed = datetime.now()
    identity.fromvlan = None
    identity.tovlan = None
    identity.save()

    event = Event(identity=identity, comment=eventcomment, action='enabled',
                  executor=username)
    event.save()

    LOGGER.info("openPort: Port successfully opened")
Exemple #3
0
def create_event(identity, comment, username):
    """Create event for the action specified in identity"""
    event = Event(identity=identity, comment=comment, action=identity.status,
                  justification=identity.justification,
                  autoenablestep=identity.autoenablestep,
                  executor=username)
    event.save()
Exemple #4
0
def create_event(identity, comment, username):
    """Create event for the action specified in identity"""
    event = Event(identity=identity, comment=comment, action=identity.status,
                  justification=identity.justification,
                  autoenablestep=identity.autoenablestep,
                  executor=username)
    event.save()