Skip to main content
===============================
pyray
===============================

.. image:: https://badge.fury.io/py/pyray.png
:target: http://badge.fury.io/py/pyray

.. image:: https://travis-ci.org/intr1nsic/pyray.png?branch=master
:target: https://travis-ci.org/intr1nsic/pyray

A python client to interact with the Riverbed Stingray REST API.

* Initial Release
* Requires Stingray API version 2.0

Documentation
-------------

http://pyray.readthedocs.org/en/latest/

Features
--------

* Add Nodes Module
* Add test coverage

Usage
========

Quick sample of pyray::

from pyray import client
cl = client.HTTPClient('https://1.1.1.1', 'admin', 'password')

Connectivity
============

The HTTPClient method has a few optional and helpful parameters that will
help troubleshoot issues or connectivity.

Debug
-----

The client has an optional debug flag that will log the request as well as
a curl command you can run against. For security reasons, username and password
are not displayed in any logging.::

from pyray import client
cl = client.HTTPClient('https://1.1.1.1', 'admin', 'password', debug=True)

To allow insecure SSL connectivity for invalid certs::

from pyray import client
cl = client.HTTPClient('https://1.1.1.1', 'admin', 'password', insecure=True)

You can also change the port if that is configured::

from pyray import client
cl = client.HTTPClient('https://1.1.1.1', 'admin', 'password', port='1234')

Generic Pool Queries
====================

All pools
---------

To list all the pools configured::

from pyray import client
cl = client.HTTPClient('https://1.1.1.1', 'admin', 'password')
pools = cl.pools.get()
for pool in pools:
print pool

Get a specific pool
-------------------

To get a specific pool::

from pyray import client
cl = client.HTTPClient('https://1.1.1.1', 'admin', 'password')
pool = cl.pools.get(name='pool1')

Delete a specific pool
----------------------

To delete a specific pool::

from pyray import client
cl = client.HTTPClient('https://1.1.1.1', 'admin', 'password')
cl.pools.delete(name='pool1')

Get all nodes draining in the pool
----------------------------------

To get draining nodes::

from pyray import client
cl = client.HTTPClient('https://1.1.1.1', 'admin', 'password')
pool = cl.pools.get(name='pool1')
draining_nodes = pool.draining_nodes
for node in draining_nodes:
print node

Get all configured nodes in a pool
----------------------------------

To get all the configured nodes::

from pyray import client
cl = client.HTTPClient('https://1.1.1.1', 'admin', 'password')
pool = cl.pools.get(name='pool1')
for node in pool.nodes:
print node

Making changes to a pool
========================

Drain
-----

Lets say you want to drain a group of nodes in a pool::

from pyray import client
cl = client.HTTPClient('https://1.1.1.1', 'admin', 'password')
pool = cl.pools.get(name='pool1')
pool.drain_nodes(nodes=['1.2.3.4:80'])

or quickly drain all nodes::

from pyray import client
cl = client.HTTPClient('https://1.1.1.1', 'admin', 'password')
pool = cl.pools.get(name='pool1')
pool.drain_nodes(nodes=pool.nodes)

Undrain
-------

To undrain nodes in a pool::

from pyray import client
cl = client.HTTPClient('https://1.1.1.1', 'admin', 'password')
pool = cl.pools.get(name='pool1')
pool.undrain_nodes(nodes=['1.2.3.4:80'])

or quickly undrain all draining nodes::

from pyray import client
cl = client.HTTPClient('https://1.1.1.1', 'admin', 'password')
pool = cl.pools.get(name='pool1')
pool.undrain_nodes(nodes=pool.draining_nodes)

Query node details in a pool
============================

To get node details for all the nodes in a pool accross all traffic managers::

from pyray import client
cl = client.HTTPClient('https://1.1.1.1', 'admin', 'password')
pool = cl.pools.get(name='pool1')
nodes = pool.get_details()
for node, details in nodes.iteritems():
print node
print node['statistics']['current_conn']

For the full node details::

{u'statistics':
{u'bytes_from_node': 23776,
u'bytes_to_node': 3659117,
u'current_conn': 0,
u'current_requests': 0,
u'errors': 4,
u'failures': 1,
u'idle_conns': 0,
u'new_conn': 38,
u'node_port': 80,
u'pooled_conn': 0,
u'response_max': 0,
u'response_mean': 0,
u'response_min': 0,
u'state': u'draining',
u'total_conn': 38
}
}



History
-------

0.1.0 (2014-01-02)
++++++++++++++++++

* First release on PyPI.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyray-0.1.0.tar.gz (8.8 kB view details)

Uploaded Source

File details

Details for the file pyray-0.1.0.tar.gz.

File metadata

  • Download URL: pyray-0.1.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyray-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6abd8ce68cf466f1594daa602c2ae4e9a19ce0b5acec907f78b0355234c73df5
MD5 69a80a0dbb910d2bb832fcd17f77a4fa
BLAKE2b-256 ce217a0167367ec62512ccc98795eef0c807f2ec2866f66e5fdba228e3bcfacb

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page