ctdb client python bindings

Ralph Boehme slow at samba.org
Thu Apr 28 07:16:13 UTC 2022


Hi Andrew,

great stuff, nice work! Just had a quick look and it seems that the 
bindings are duplicating quite some code like get_node_by_pnn(), 
node_map_add() and so on.

Maybe Martin can advice on the easiest and best way to make the existing 
functions usable for the bindings.

Cheers!
-slow

On 4/27/22 19:25, Andrew Walker via samba-technical wrote:
> Hey all,
> 
> I threw together some quick python bindings for a ctdb client. WIP, but any
> feedback would be appreciated (either in-list or direct email to this
> address).
> 
> I've currently thrown together
> 
> https://gitlab.com/samba-team/devel/samba/-/commits/anodos325-ctdb_python_bindings
> 
> below are some basic operations
> * initializing client
> * getting cluster status
> * creating a new persistent ctdb file (if that's your thing)
> * listing current nodes
> * getting pnn0 object and printing its current status
> 
> ```
>>>> import ctdb
>>>> cl = ctdb.Client()
>>>> cl.status()
> {'nodemap': {'node_count': 1, 'deleted_node_count': 0, 'nodes': [{'pnn': 0,
> 'address': {'type': 'INET', 'address': '192.168.0.92'}, 'flags': [],
> 'flags_raw': 0, 'partially_online': False, 'this_node': True}]}, 'vnnmap':
> {'size': 1, 'generation': 705683446, 'entries': [{'hash': 0, 'lmaster':
> 0}]}, 'recovery_mode_raw': 0, 'recovery_mode_str': 'NORMAL'}
>>>> import os
>>>> db = ctdb.Ctdb(cl, "curly.tdb", os.O_CREAT)
>>>> db.exists
> False
>>>> db.attach(ctdb.DB_PERSISTENT)
>>>> db.exists
> True
>>>> db.status()
> {'dbid': '0x3c05769c', 'dbid_raw': 1006991004, 'name': 'curly.tdb', 'path':
> '/usr/local/samba/var/lib/ctdb/persistent/curly.tdb.0', 'persistent': True,
> 'replicated': False, 'sticky': False, 'readonly': False, 'flags_raw': 1,
> 'health': 'OK'}
>>>> cl.listnodes()
> {'node_count': 1, 'deleted_node_count': 0, 'nodes': [<ctdb.CtdbNode object
> at 0x7f013deb95a0>]}
>>>> my_node = cl.listnodes()['nodes'][0]
>>>> my_node.
> my_node.ban(             my_node.disable(         my_node.flags
>   my_node.private_address  my_node.unban(
> my_node.current_node     my_node.enable(          my_node.pnn
>   my_node.rebalance(
>>>> my_node.pnn
> 0
>>>> my_node.flags
> {'parsed': [], 'raw': 0}
> ```
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20220428/4f87e6d4/OpenPGP_signature.sig>


More information about the samba-technical mailing list