Пример #1
0
def ip_blocking_disable(handle):
    """
    Disables IP Blocking

    Args:
        handle (ImcHandle)

    Returns:
        None

    Examples:
        ip_blocking_disable(handle)
    """
    mo = IpBlocking(parent_mo_or_dn=_get_mgmt_if_dn(handle))
    mo.enable = 'no'
    handle.set_mo(mo)
Пример #2
0
def ip_blocking_disable(handle):
    """
    Disables IP Blocking

    Args:
        handle (ImcHandle)

    Returns:
        None

    Examples:
        ip_blocking_disable(handle)
    """
    mo = IpBlocking(parent_mo_or_dn=_get_mgmt_if_dn(handle))
    mo.enable = 'no'
    handle.set_mo(mo)
Пример #3
0
def ip_blocking_enable(handle,
                       fail_count='5',
                       fail_window='60',
                       penalty_time='300',
                       **kwargs):
    """
    Enables IP Blocking

    Args:
        handle (ImcHandle)
        fail_count (str): Number of times a user can attempt to log in
                          unsuccessfully, before the system locks that user out
                          Range [3-10] attempts
        fail_window (str): Length of time, in seconds, in which the
                           unsuccessful login attempts must occur in order
                           for the user to be locked out.
                           Range [60-120] seconds
        penalty_time (str): The number of seconds the user remains locked out.
                            Range [300-900] seconds
        kwargs: Key-Value paired arguments for future use

    Returns:
        IpBlocking object

    Examples:
        ip_blocking_enable(handle, fail_count='6',
                           fail_window='120', penalty_time='800')
    """

    mo = IpBlocking(parent_mo_or_dn=_get_mgmt_if_dn(handle))

    params = {
        'enable': 'yes',
        'fail_count': str(fail_count),
        'fail_window': str(fail_window),
        'penalty_time': str(penalty_time)
    }
    mo.set_prop_multiple(**params)
    mo.set_prop_multiple(**kwargs)
    handle.set_mo(mo)
    return handle.query_dn(mo.dn)
Пример #4
0
def ip_blocking_exists(handle, **kwargs):
    """
    Checks if IP blocking settings match according to the parameters specified.

    Args:
        handle (ImcHandle)
        kwargs: Key-Value paired arguments relevant to IpBlocking object

    Returns:
        (True, IpBlocking object) if exists, else (False, None)

    Examples:
        ip_blocking_exists(handle, fail_count='6',
                           fail_window='120', penalty_time='800')
    """
    mo = IpBlocking(parent_mo_or_dn=_get_mgmt_if_dn(handle))
    mo = _get_mo(handle, dn=mo.dn)

    if mo.check_prop_match(**kwargs):
        return (True, mo)

    return (False, None)
Пример #5
0
def ip_blocking_exists(handle, **kwargs):
    """
    Checks if IP blocking settings match according to the parameters specified.

    Args:
        handle (ImcHandle)
        kwargs: Key-Value paired arguments relevant to IpBlocking object

    Returns:
        (True, IpBlocking object) if exists, else (False, None)

    Examples:
        ip_blocking_exists(handle, fail_count='6',
                           fail_window='120', penalty_time='800')
    """
    mo = IpBlocking(parent_mo_or_dn=_get_mgmt_if_dn(handle))
    mo = _get_mo(handle, dn=mo.dn)

    if mo.check_prop_match(**kwargs):
        return (True, mo)

    return (False, None)
Пример #6
0
def ip_blocking_enable(handle, fail_count='5', fail_window='60',
                       penalty_time='300', **kwargs):
    """
    Enables IP Blocking

    Args:
        handle (ImcHandle)
        fail_count (str): Number of times a user can attempt to log in
                          unsuccessfully, before the system locks that user out
                          Range [3-10] attempts
        fail_window (str): Length of time, in seconds, in which the
                           unsuccessful login attempts must occur in order
                           for the user to be locked out.
                           Range [60-120] seconds
        penalty_time (str): The number of seconds the user remains locked out.
                            Range [300-900] seconds
        kwargs: Key-Value paired arguments for future use

    Returns:
        IpBlocking object

    Examples:
        ip_blocking_enable(handle, fail_count='6',
                           fail_window='120', penalty_time='800')
    """

    mo = IpBlocking(parent_mo_or_dn=_get_mgmt_if_dn(handle))

    params = {
        'enable': 'yes',
        'fail_count': str(fail_count),
        'fail_window': str(fail_window),
        'penalty_time': str(penalty_time)
    }
    mo.set_prop_multiple(**params)
    mo.set_prop_multiple(**kwargs)
    handle.set_mo(mo)
    return handle.query_dn(mo.dn)
Пример #7
0
def is_ip_blocking_enabled(handle):
    """
    Checks if IP Blocking is enabled

    Args:
        handle (ImcHandle)

    Returns:
        bool

    Examples:
        is_ip_blocking_enabled(handle)
    """
    mo = IpBlocking(parent_mo_or_dn=_get_mgmt_if_dn(handle))
    mo = handle.query_dn(mo.dn)
    return mo.enable.lower() in ['yes', 'true']