#!/usr/bin/env python # This is an example showing a current SONAS configuration with 3 # interface node and a management node. When run with deterministic # IPs there are gratuitous IP reassignments. from ctdb_takeover import Cluster, Node, process_args process_args() addresses = ['A', 'B', 'C', 'D', 'E', 'F', 'G'] c = Cluster() for i in range(3): c.add_node(Node(addresses)) c.add_node(Node([])) c.recover() c.random_iterations()
#!/usr/bin/env python # 2 IP groups, across 2 nodes, with each group on different # interfaces. 4 addresses per group. A nice little canonical 2 node # configuration. from ctdb_takeover import Cluster, Node, process_args process_args() addresses1 = ['192.168.1.%d' % n for n in range(1, 5)] addresses2 = ['192.168.2.%d' % n for n in range(1, 5)] # Try detecting imbalance with square root of number of nodes? Or # just with a parameter indicating how unbalanced you're willing to # accept... c = Cluster() for i in range(2): c.add_node(Node([addresses1, addresses2])) c.recover() c.random_iterations()
#!/usr/bin/env python from ctdb_takeover import Cluster, Node, process_args process_args() addresses10 = ['10.4.20.%d' % n for n in range(154, 168)] addresses172a = ['172.20.106.%d' % n for n in range(110, 124)] addresses172b = ['172.20.107.%d' % n for n in range(110, 117)] c = Cluster() #for i in range(7): # c.add_node(Node([addresses10, addresses172])) for i in range(4): c.add_node(Node([addresses172a, addresses172b])) for i in range(3): c.add_node(Node(addresses10)) c.recover() c.random_iterations()
#!/usr/bin/env python # This is a contrived example that makes the balancing algorithm fail # for nondeterministic IPs (run with "-dv --nd" to see the failure). from ctdb_takeover import Cluster, Node, process_args process_args() addresses1 = ['A', 'B', 'C', 'D'] addresses2 = ['B', 'E', 'F'] c = Cluster() for i in range(2): c.add_node(Node(addresses1)) c.add_node(Node(addresses2)) c.recover() c.unhealthy(1) c.recover() c.healthy(1) c.recover()
#!/usr/bin/env python # 4 IP groups, across 10 nodes, with each group on different # interfaces/VLANs. 80 addresses in total but not evenly balanced, to # help check some of the more extreme behaviour. from ctdb_takeover import Cluster, Node, process_args process_args() addresses1 = ['192.168.1.%d' % n for n in range(1, 41)] addresses2 = ['192.168.2.%d' % n for n in range(1, 21)] addresses3 = ['192.168.3.%d' % n for n in range(1, 11)] addresses4 = ['192.168.4.%d' % n for n in range(1, 11)] # Try detecting imbalance with square root of number of nodes? Or # just with a parameter indicating how unbalanced you're willing to # accept... c = Cluster() for i in range(10): c.add_node(Node([addresses1, addresses2, addresses3, addresses4])) c.recover() c.random_iterations()
#!/usr/bin/env python # 2 IP groups, both on the same 5 nodes, with each group on different # interfaces/VLANs. One group has many more addresses to test how # well an "imbalanced" configuration will balance... from ctdb_takeover import Cluster, Node, process_args process_args() addresses20 = ['192.168.20.%d' % n for n in range(1, 13)] addresses128 = ['192.168.128.%d' % n for n in range(1, 5)] c = Cluster() for i in range(5): c.add_node(Node([addresses20, addresses128])) #for i in range(3): # c.add_node(Node([addresses20])) c.recover() c.random_iterations()