Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
pyrax server list generator
#!/usr/bin/env python
import pyrax
pyrax.set_setting('identity_type', 'rackspace')
pyrax.set_credentials('myusername', 'myapikey', region='DFW')
def server_list_generator(detailed=True, search_opts=None, limit=None):
servers = pyrax.cloudservers.servers.list(detailed=detailed,
search_opts=search_opts,
limit=limit)
for server in servers:
yield server
while servers:
servers = pyrax.cloudservers.servers.list(detailed=detailed,
search_opts=search_opts,
marker=servers[-1].id,
limit=limit)
for server in servers:
yield server
# For testing on an account with fewer than 200 servers, you can pass
# limit=2 or similar to server_list_generator()
for server in server_list_generator():
print server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment