2d3e2fc python: Add inquire()

Authored and Committed by nsoffer 2 years ago
    python: Add inquire()
    
    Use sanlock_inquire() to query the resource held by the current process
    (using the slkfd= argument) or held by another program (using the pid=
    argument).
    
    When using the slkfd= argument, we communicate with sanlock daemon using
    slkfd, ensuring that the current process is connected to sanlock. If the
    current process is not connected, sanlock assumes that the process is
    dead, and release all the leases acquired by the process.
    
    When using the pid= argument, the function opens a new socket to sanlock
    daemon and query the status of resources owned by specified pid.
    
    In both cases the information comes from sanlock daemon, without
    accessing storage. To verify storage content, the caller should use
    read_resource() and read_resource_owners().
    
    The call returns list of resources dicts that can be used for verifying
    that sanlock state matches the program state.
    
    sanlock_inquire() reports the SANLOCK_RES_LVER or sanlock.RES_SHARED
    flags in the resource flags field. Add the field to the returned dict
    and add sanlock constants for the flag.
    
    The resource flags are needed if you want to restore a lease after it
    was released, ensuring that nobody else acquired the lease after it was
    released. This flow is used by libvirt using libsanlock. With this
    change we can implement the same flow using the python binding.
    
    Signed-off-by: Nir Soffer <nsoffer@redhat.com>
    
        
file modified
+173 -0
file modified
+84 -0