pools

Pools

class stingray.config.pools.Pools(host=None, port=None, user=None, password=None, api_version=None, ssl_verify=None)[source]

Bases: stingray.apiclient.Client

Class for interacting with Pools via the REST API

add(pool, nodes=None, **pool_props)[source]

Add a new load balancer pool

Parameters:
  • pool (str) – The name of the pool to add
  • nodes (list) – List of nodes for the pool
  • pool_props (dict) –

    Additional arguments to set properties of the pool at time of creation. Must be a dict in the form of:

    {'section': {'key': 'value'}}
    
Returns:

The new pool

Return type:

(Pool)

delete(pool)[source]

Delete a load balancer pool

Parameters:pool (str) – The name of the pool to delete
Returns:Response from the _api_delete method
Return type:(dict)
classmethod from_client(client)[source]
get(pool)[source]

Get a Pool object for the request pool.

Parameters:pool (str) – The name of the pool to get
Returns:The requested pool
Return type:(Pool)

Pool

class stingray.config.pools.Pool(pool_name, pool_path, pool_properties=None, host=None, port=None, user=None, password=None, api_version=None, ssl_verify=None)[source]

Bases: stingray.apiclient.Client

Class for interacting with individual pools via the REST API

add_node(node, state='active', priority=1, weight=1)[source]

Add a new node to the pool

Parameters:
  • node (str) – The node to add. Must be in accepted pool node config format: <ip or dns name>:<port>
  • state (str) – active, draining, or disabled. Default is active because it should be pretty rare to add a node in any other state.
  • priority (int) – Load balancer priority for the node
  • weight (int) – Load balancer weight for the node
Returns:

Pool nodes status

Return type:

(dict)

delete_node(node)[source]

Delete a node from the pool

Parameters:node (str) – The node to delete
Returns:Pool nodes status
Return type:(dict)
disable_node(node)[source]

Disable a node in the pool

Parameters:node (str) – The node to disable
Returns:Pool nodes status
Return type:(dict)
drain_node(node)[source]

Set a node in the pool to draining status

Parameters:node (str) – The node to drain
Returns:Pool nodes status
Return type:(dict)
enable_node(node)[source]

Reenable a node in the pool

Parameters:node (str) – The node to enable
Returns:Pool nodes status
Return type:(dict)
classmethod from_client(client, pool_name, pool_path=None, pool_properties=None)[source]
nodes_status()[source]

Get status info for the nodes in the pool. Some info is found in the node properties, some in the node statistics.

Returns:Nodes and their status, e.g.:
{
    u'10.0.0.1': {
        u'connections': 0,
        u'health': u'alive',
        u'requests': 0,
        u'state': u'active'
    }
}
Return type:(dict)
statistics()[source]

Get statistics for the pool

Returns:Pool statistics
Return type:(dict)