Attempts an exclusive lock on the candidate configuration. This
    is a non-blocking call.

    .. note::
        When locking, it is important to remember to call
        :py:func:`junos.unlock <salt.modules.junos.unlock>` once finished. If
        locking during orchestration, remember to include a step in the
        orchestration job to unlock.

    CLI Example:

    .. code-block:: bash

        salt 'device_name' junos.lock

def lock():
    '''
    Attempts an exclusive lock on the candidate configuration. This
    is a non-blocking call.

    .. note::
        When locking, it is important to remember to call
        :py:func:`junos.unlock <salt.modules.junos.unlock>` once finished. If
        locking during orchestration, remember to include a step in the
        orchestration job to unlock.

    CLI Example:

    .. code-block:: bash

        salt 'device_name' junos.lock
    '''
    conn = __proxy__['junos.conn']()
    ret = {}
    ret['out'] = True
    try:
        conn.cu.lock()
        ret['message'] = "Successfully locked the configuration."
    except jnpr.junos.exception.LockError as exception:
        ret['message'] = 'Could not gain lock due to : "{0}"'.format(exception)
        ret['out'] = False

    return ret