Coder Social home page Coder Social logo

pyray's Introduction

pyray

https://badge.fury.io/py/pyray.png https://travis-ci.org/intr1nsic/pyray.png?branch=master

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)

Nodes

To add a node:

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

or to remove a node:

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

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
    }
}

pyray's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.