def is_master_node(client):
 my_node_id = list(client.nodes.info('_local')['nodes'])[0]
 master_node_id = client.cluster.state(metric='master_node')['master_node']
 return (my_node_id == master_node_id)

def is_master_node ( client ) : my_node_id = list ( client . nodes . info ( '_local' ) [ 'nodes' ] ) [ 0 ] master_node_id = client . cluster . state ( metric = 'master_node' ) [ 'master_node' ] return ( my_node_id == master_node_id )
return true if the connected client node is the elected master node in the elasticsearch cluster .