Package: varlink
python-varlinkAvarlinkimplementation for Python.GIT RepositoryAPI documentationpython varlink installationFrom pypi:$pip3install--uservarlinkWith Fedora 28/rawhide:$sudodnfinstallpython3-varlinkExamplesSee thetestsdirectory.$python3-mvarlink.tests.test_orgexamplemore--varlink="unix:/tmp/test"&[1]6434$python-mvarlink.clihelpunix:/tmp/test/org.example.more# Example Varlink serviceinterfaceorg.example.more# Enum, returning either start, progress or end# progress: [0-100]typeState(start:?bool,progress:?int,end:?bool)# Returns the same stringmethodPing(ping:string)->(pong:string)# Dummy progress method# n: number of progress stepsmethodTestMore(n:int)->(state:State)# Stop servingmethodStopServing()->()# Something failed in TestMoreerrorTestMoreError(reason:string)$python-mvarlink.clicallunix:/tmp/test/org.example.more.Ping'{ "ping": "Ping"}'{"pong":"Ping"}$fgpython3-mvarlink.tests.test_orgexamplemore--varlink="unix:/tmp/test"^C$python3-mvarlink.tests.test_orgexamplemore--client-A'python3 -m varlink.tests.test_orgexamplemore --varlink=$VARLINK_ADDRESS'Connectingtounix:/tmp/tmppxrbqk9p/4927

Listeningon/tmp/tmppxrbqk9p/4927
---Start---
Progress:0Progress:10Progress:20Progress:30Progress:40Progress:50Progress:60Ping:Test
Progress:70Ping:Test
Progress:80Ping:Test
Progress:90Ping:Test
Progress:100Ping:Test
---End---$PYTHONPATH=$(pwd)python3./varlink/tests/test_orgexamplemore.py
Connectingtounix:/tmp/tmp7n6zc67d/5257

Listeningon/tmp/tmp7n6zc67d/5257
---Start---
Progress:0Progress:10Progress:20Progress:30Progress:40Progress:50Progress:60Ping:Test
Progress:70Ping:Test
Progress:80Ping:Test
Progress:90Ping:Test
Progress:100Ping:Test
---End---$python3-mvarlink.tests.test_orgexamplemore--varlink="unix:/tmp/test"&Listeningon/tmp/test[1]6434python3-mvarlink.tests.test_orgexamplemore--client--varlink="unix:/tmp/test"Connectingtounix:/tmp/test

Ping:Test
---Start---
Progress:0Progress:10Progress:20Progress:30Progress:40Progress:50Progress:60Ping:Test
Progress:70Ping:Test
Progress:80Ping:Test
Progress:90Ping:Test
Progress:100Ping:Test
---End---

$python3-mvarlink.clicall--moreunix:/tmp/test/org.example.more.TestMore'{ "n": 10 }'{'state':{'start':True}}{'state':{'progress':0}}{'state':{'progress':10}}{'state':{'progress':20}}{'state':{'progress':30}}{'state':{'progress':40}}{'state':{'progress':50}}{'state':{'progress':60}}{'state':{'progress':70}}{'state':{'progress':80}}{'state':{'progress':90}}{'state':{'progress':100}}{'state':{'end':True}}$fgpython3-mvarlink.tests.test_orgexamplemore--varlink="unix:/tmp/test"^CYou can also start the clients and server with URLs following thevarlink URL standardwithunix:andtcp:.
E.g.unix:@anonudsunix:/run/myserver/socketfiletcp:127.0.0.1:12345tcp:[::1]:12345Activation ModeActivation mode starts the service to connect to and passes the socket via socket activation.
TheVARLINK_ADDRESSenvironment variable contains the varlink address URI.$python3-mvarlink.cli--activate'python3 -m varlink.tests.test_orgexamplemore --varlink=$VARLINK_ADDRESS'callorg.example.more.Ping'{ "ping": "Ping"}'Listeningon@00352{'pong':'Ping'}Bridge ModeBridge mode allows to tunnel to a remote point via stdin/stdout and call a method.
Runningvarlink bridgeallows to connect stdio to the host services viaorg.varlink.resolverinterface resolving.# python3 -m varlink.cli -b "ssh host.example.org varlink bridge" call com.redhat.machine.GetInfo '{}'{"hostname":"host.example.org","system":{"id":"fedora","kernel_version":"4.18.0-0.rc5.git1.2.fc29.x86_64","name":"Fedora","version":"29"},"virtualization":{"name":"none"}}Varlink Certification Server$ python3 -m varlink.tests.test_certification --varlink=tcp:127.0.0.1:12345Varlink Certification Client$ python3 -m varlink.tests.test_certification --varlink=tcp:127.0.0.1:12345 --client