In [2]:
import pyrax
In [ ]:
class MR_Worker(object):
'''
init (rack space credentials), create
get next id
status
since
create worker
rtn w
delete()
get_status() build work idle
get_since()
get_id()
get credentials?
'''
In [ ]:
In [3]:
def worker_create(id):
name = 'medareda_worker_%s' %id
pyrax.set_setting("identity_type", "rackspace")
pyrax.set_default_region('LDN')
pyrax.set_credentials('markhallett', 'c71cc6f2db354fa1adf234baf1e48244')
cs = pyrax.cloudservers
images = pyrax.images.list()
print len(images)
image = pyrax.images.get('1ddfcb56-c397-47a6-a6b0-2f90e82e0368')
flavor = cs.list_flavors()[0]
server = cs.servers.create(name, image.id, flavor.id)
#pyrax.utils.wait_for_build(server, verbose=True)
return server
worker_create(4)
Out[3]:
In [6]:
def get_worker(id):
image = pyrax.images.get('1ddfcb56-c397-47a6-a6b0-2f90e82e0368')
print image
#images = pyrax.images.list()
#print len(images)
worker =None
return worker
get_worker(4)
In [ ]:
def worker_delete(id):
worker = get_worker(id)
worker.delete()
In [ ]:
In [ ]:
In [ ]: