Skip to content

Instantly share code, notes, and snippets.

@EdLeafe
EdLeafe / gist:3995892
Created November 1, 2012 19:31
Sample usage script
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import datetime
import os
import pyrax
creds_file = os.path.expanduser("~/.rackspace_cloud_credentials")
pyrax.set_credential_file(creds_file)
clb = pyrax.cloud_loadbalancers
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import eventlet
import requests
import time
url = "http://daboserver.com/eventlet"
def getit(seq):
req = requests.request("GET", url)
@EdLeafe
EdLeafe / gist:4693677
Created February 1, 2013 19:57
output of eventlet test
(green)ed@MGM6AEDV7M:~/projects/green$ pw green_test.py
Spawning #0 at Fri Feb 1 13:46:56 2013
Spawning #1 at Fri Feb 1 13:46:56 2013
Spawning #2 at Fri Feb 1 13:46:56 2013
Spawning #3 at Fri Feb 1 13:46:56 2013
Spawning #4 at Fri Feb 1 13:46:56 2013
Spawning #5 at Fri Feb 1 13:46:56 2013
Spawning #6 at Fri Feb 1 13:46:56 2013
Spawning #7 at Fri Feb 1 13:46:56 2013
Spawning #8 at Fri Feb 1 13:46:56 2013
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import eventlet
from eventlet.green import urllib2
import time
url = "http://daboserver.com/eventlet/%s"
def getit(seq):
print "requesting", seq
@EdLeafe
EdLeafe / gist:5192405
Created March 19, 2013 00:23
Demonstration of creating Rackspace Cloud Files containers in different regions.
import pyrax
pyrax.keyring_auth()
cf_ord = pyrax.connect_to_cloudfiles("ORD")
cf_dfw = pyrax.connect_to_cloudfiles("DFW")
my_ord_cont = cf_ord.create_container("test")
my_dfw_cont = cf_dfw.create_container("test")
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
import threading
import time
import sys
import pyrax
pyrax.keyring_auth()
cs = pyrax.cloudservers

#pyrax

pyrax is the Python SDK for OpenStack-based cloud providers, and includes support for additional services provided by Rackspace.

Installation

Installation works the same as any Python package:

pip install pyrax

If you are not using virtualenv, you will need to run the above as an admin.

def _checkSizer(self):
"""Makes sure the sizer is created before setting props that need it."""
if self.Sizer is None:
self.Sizer = self.SizerClass(Parent=self)
self.Sizer.Orientation = self.Orientation
self.Sizer.Caption = self.Caption
[private]
identity_type = keystone
region = RegionOne
custom_user_agent =
debug = True
auth_endpoint = http://192.168.0.1:5000/v2.0/
tenant_name = demo
tenant_id = abc123456
keyring_username = demo
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import pyrax
pyrax.keyring_auth()
cs = pyrax.cloudservers