This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Usage

Not much documentation at the moment but just some quick typical usage scripts you can do with this library. This is based on the latest version from :

http://docs.rackspacecloud.com/loadbalancers/api/clb-devguide-latest.pdf

Create a LoadBalancer:

#!/usr/bin/python
import cloudlb
clb = cloudlb.CloudLoadBalancer("username", "apikey","chicago")

node1 = cloudlb.Node(address="10.180.160.131",
                     port=80,
                     condition="ENABLED")


virtualIP1 = cloudlb.VirtualIP(
                 type="PUBLIC")

clb.loadbalancers.create(name="mytestinglb",
                         port=80,
                         protocol="HTTP",
                         nodes=[node1],
                         virtualIps=[virtualIp1])

List LoadBalancers:

#!/usr/bin/python
import cloudlb
clb = cloudlb.CloudLoadBalancer("username", "apikey","chicago")

lbs = clb.loadbalancers.list()
for lb in lbs:
    print "%s has %s node attached with IP addresses:" % (lb.name, len(lb.nodes))
    for ip in lb.virtualIps:
        print "%s/%s" % (ip.ipVersion, ip.address)

List LoadBalancers who have nodes that belong to it:

#!/usr/bin/python
import cloudlb
clb = cloudlb.CloudLoadBalancer("username", "apikey","chicago")

ip = '10.1.1.1'
lbs = clb.loadbalancers.search(ip)
for lb in lbs:
    print "%s has %s node attached" % (lb.name, ip))

Get LB by ID:

#!/usr/bin/python
import cloudlb
clb = cloudlb.CloudLoadBalancer("username", "apikey","chicago")
clb.authenticate()

lb = clb.loadbalancers.get(LoadBalancerID)

Delete LB:

#!/usr/bin/python
import cloudlb
clb = cloudlb.CloudLoadBalancer("username", "apikey","chicago")

lb = clb.loadbalancers.get(LoadBalancerID)
lb.delete()

List nodes of a LB:

#!/usr/bin/python
import cloudlb
clb = cloudlb.CloudLoadBalancer("username", "apikey","chicago")

lbs = clb.loadbalancers.list()
lb = lbs[0] #get the first one
nodes=lb.nodes.filter(status='ENABLED')
for node in nodes:
    print node.address

Filter nodes via condition of a LB:

#!/usr/bin/python
import cloudlb
clb = cloudlb.CloudLoadBalancer("username", "apikey","chicago")

lbs = clb.loadbalancers.list()
lb = lbs[0] #get the first one
for node in lb.nodes:
    print node.address

Add a node to a LB:

#!/usr/bin/python
import cloudlb
clb = cloudlb.CloudLoadBalancer("username", "apikey","chicago")

newnode =  cloudlb.Node(address="10.180.160.131",
                        port=80,
                        condition="ENABLED")

lbs = clb.loadbalancers.list()
lb = lbs[0] #add to the first one

lb.add_nodes([newnode])

Delete a node from a LB:

#!/usr/bin/python
import cloudlb
clb = cloudlb.CloudLoadBalancer("username", "apikey","chicago")

lbs = clb.loadbalancers.list()
lb = lbs[0] #add to the first one

node = lb.nodes[0] #get the first node

node.delete() #delete it

Update attributes of a node:

#!/usr/bin/python
import cloudlb
clb = cloudlb.CloudLoadBalancer("username", "apikey","chicago")

lbs = clb.loadbalancers.list()
mylb = lbs[0] #add to the first one

nodeid = 14106
nodes = mylb.nodes
node = mylb.nodes.get(nodeid)
toggle_status = node.condition == "ENABLED" and "DISABLED" or "ENABLED"
node.condition = toggle_status
node.update()

Get weight of a node by using .get():

#!/usr/bin/python
import cloudlb
clb = cloudlb.CloudLoadBalancer("username", "apikey","chicago")

lbs = clb.loadbalancers.list()
mylb = lbs[0] #add to the first one

nodeid = 14106
nodes = mylb.nodes
node = mylb.nodes.get(nodeid)
print node.weight

Update attributes on LoadBalancer:

#!/usr/bin/python
import cloudlb
clb = cloudlb.CloudLoadBalancer("username", "apikey","chicago")

lbs = clb.loadbalancers.list()
mylb = lbs[0] #first lb

mylb.protocol = "FTP"
mylb.name = "APrettyNewName"

mylb.update()

Get usage statistics on all LoadBalancers:

#!/usr/bin/python
import cloudlb
clb = cloudlb.CloudLoadBalancer("username", "apikey","chicago")

print clb.get_usage()

Get usage statistics on a specfic LoadBalancer:

#!/usr/bin/python
import cloudlb
clb = cloudlb.CloudLoadBalancer("username", "apikey","chicago")

lbs = clb.loadbalancers.list()
mylb = lbs[0] #first lb

print mylb.get_usage()

Get real-time statistics on a specific LoadBalancer:

#!/usr/bin/python
import cloudlb
clb = cloudlb.CloudLoadBalancer("username", "apikey","chicago")

lbs = clb.loadbalancers.list()
mylb = lbs[0] #first lb

print mylb.get_stats()

Get limits on all LoadBalancers:

#!/usr/bin/python
import cloudlb
clb = cloudlb.CloudLoadBalancer("username", "apikey","chicago")

print clb.get_limits()

Get Load Balancing Algorithms:

#!/usr/bin/python
import cloudlb
clb = cloudlb.CloudLoadBalancer("username", "apikey","chicago")

print clb.get_algorithms()

Get Load Balancing Protocols:

#!/usr/bin/python
import cloudlb
clb = cloudlb.CloudLoadBalancer("username", "apikey","chicago")

print clb.get_protocols()

Get current Health Monitor:

#!/usr/bin/python
import cloudlb
clb = cloudlb.CloudLoadBalancer("username", "apikey","chicago")

lbs = clb.loadbalancers.list()
mylb = lbs[0] #first lb

hm_monitor = mylb.healthmonitor()
print hm_monitor.get()

Monitor loadbalancer using simple TCP Connect:

#!/usr/bin/python
import cloudlb
clb = cloudlb.CloudLoadBalancer("username", "apikey","chicago")

lbs = clb.loadbalancers.list()
mylb = lbs[0] #first lb

hm_monitor = mylb.healthmonitor()
hm = cloudlb.healthmonitor.HealthMonitor(
  type="CONNECT",
  delay=10,
  timeout=10,
  attemptsBeforeDeactivation=3)

hm_monitor.add(hm)

Monitor loadbalancer using HTTP(s):

#!/usr/bin/python
import cloudlb
clb = cloudlb.CloudLoadBalancer("username", "apikey","chicago")

lbs = clb.loadbalancers.list()
mylb = lbs[0] #first lb

hm_monitor = mylb.healthmonitor()
hm = cloudlb.healthmonitor.HealthMonitor(
    type="HTTP", #or HTTPS
    delay=10,
    timeout=10,
    attemptsBeforeDeactivation=3,
    path="/",
    statusRegex="^[234][0-9][0-9]$",
    bodyRegex="testing")
hm_monitor.add(hm)

Delete Health Monitor rule:

#!/usr/bin/python
import cloudlb
clb = cloudlb.CloudLoadBalancer("username", "apikey","chicago")

lbs = clb.loadbalancers.list()
mylb = lbs[0] #first lb

hm_monitor = mylb.healthmonitor()
hm_monitor.delete()

Add http cookie session persistence:

#!/usr/bin/python
import cloudlb
clb = cloudlb.CloudLoadBalancer("username", "apikey","chicago")

lbs = clb.loadbalancers.list()
mylb = lbs[0] #first lb

ss = cloudlb.sessionpersistence.SessionPersistence(persistenceType="HTTP_COOKIE")

ssp = mylb.session_persistence()
ssp.add(ss)

Get session persistence:

#!/usr/bin/python
import cloudlb
clb = cloudlb.CloudLoadBalancer("username", "apikey","chicago")

lbs = clb.loadbalancers.list()
mylb = lbs[0] #first lb

ssp = mylb.session_persistence()
print ssp.get()

Delete session persistence configuration:

#!/usr/bin/python
import cloudlb
clb = cloudlb.CloudLoadBalancer("username", "apikey","chicago")

lbs = clb.loadbalancers.list()
mylb = lbs[0] #first lb

ssp = mylb.session_persistence()
ssp.delete()

Enable/Disable Connection Logging:

#!/usr/bin/python
import cloudlb
clb = cloudlb.CloudLoadBalancer("username", "apikey","chicago")

lbs = clb.loadbalancers.list()
mylb = lbs[0] #first lb
cl = mylb.connection_logging()

#Get connection logging status
print cl.get()

#Enable connection logging
cl.enable()

#Disable connection logging
cl.disable()

Access Lists:

#!/usr/bin/python
import cloudlb
clb = cloudlb.CloudLoadBalancer("username", "apikey","chicago")

lbs = clb.loadbalancers.list()
mylb = lbs[0] #first lb
accesslist = mylb.accesslist()

networkItem1 = cloudlb.accesslist.NetworkItem(
    address="10.20.30.40", type="ALLOW")

networkItem2 = cloudlb.accesslist.NetworkItem(
    address="0.0.0.0/0", type="DENY")

# Allow only 10.20.30.40
accesslist.add([networkItem1, networkItem2])

# List accesslists
print accesslist.list()

# Delete all accesslist
accesslist.delete()

# Delete accesslist by ID
accesslist.delete(id=62)

Custom Error Page:

#!/usr/bin/python
import cloudlb
clb = cloudlb.CloudLoadBalancer("username", "apikey","chicago")

lbs = clb.loadbalancers.list()
mylb = lbs[0] #first lb
errorpage = mylb.errorpage()

# Display current error page
print errorpage.get()

# Change the error page
errorpage.add('<html><body><h1>Error</h1></body></html>')

# Revert to the default error page
errorpage.delete()

LICENSE

See COPYING for license information. Copyright © 2011, Rackspace US, Inc.

Author

Chmouel Boudjnah <chmouel@chmouel.com>

Release History

Release History

0.6.2

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.6.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.5.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
python-cloudlb-0.6.2.tar.gz (20.4 kB) Copy SHA256 Checksum SHA256 Source Jun 5, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting