03 worker class


In [2]:
import pyrax


/Library/Python/2.7/site-packages/novaclient/v1_1/__init__.py:30: UserWarning: Module novaclient.v1_1 is deprecated (taken as a basis for novaclient.v2). The preferable way to get client class or object you can find in novaclient.client module.
  warnings.warn("Module novaclient.v1_1 is deprecated (taken as a basis for "

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)


/Library/Python/2.7/site-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
/Library/Python/2.7/site-packages/requests/packages/urllib3/connection.py:251: SecurityWarning: Certificate has no `subjectAltName`, falling back to check for a `commonName` for now. This feature is being removed by major browsers and deprecated by RFC 2818. (See https://github.com/shazow/urllib3/issues/497 for details.)
  SecurityWarning
/Library/Python/2.7/site-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
/Library/Python/2.7/site-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
/Library/Python/2.7/site-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
/Library/Python/2.7/site-packages/requests/packages/urllib3/connection.py:251: SecurityWarning: Certificate has no `subjectAltName`, falling back to check for a `commonName` for now. This feature is being removed by major browsers and deprecated by RFC 2818. (See https://github.com/shazow/urllib3/issues/497 for details.)
  SecurityWarning
/Library/Python/2.7/site-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
/Library/Python/2.7/site-packages/requests/packages/urllib3/connection.py:251: SecurityWarning: Certificate has no `subjectAltName`, falling back to check for a `commonName` for now. This feature is being removed by major browsers and deprecated by RFC 2818. (See https://github.com/shazow/urllib3/issues/497 for details.)
  SecurityWarning
/Library/Python/2.7/site-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
/Library/Python/2.7/site-packages/requests/packages/urllib3/connection.py:251: SecurityWarning: Certificate has no `subjectAltName`, falling back to check for a `commonName` for now. This feature is being removed by major browsers and deprecated by RFC 2818. (See https://github.com/shazow/urllib3/issues/497 for details.)
  SecurityWarning
25
Out[3]:
<Server: medareda_worker_4>

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)


<Image auto_disk_config=disabled, checksum=eb47b46bbc3d7e89d397eb10b29880b0, container_format=ovf, created_at=2015-06-24T20:07:03Z, disk_format=vhd, flavor_classes=*,!onmetal, id=1ddfcb56-c397-47a6-a6b0-2f90e82e0368, image_type=snapshot, min_disk=20, min_ram=512, name=MeDaReDa-01_2_bootup, os_distro=centos, os_type=linux, owner=10044862, protected=False, size=2757550080, status=active, tags=[], updated_at=2015-06-24T20:23:17Z, user_id=62fb5a305bc54b29b1d123f01534ea2c, virtual_size=None, visibility=private, vm_mode=hvm, xenapi_image_compression_level=1>
/Library/Python/2.7/site-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning

In [ ]:
def worker_delete(id):
    worker = get_worker(id)
    worker.delete()

In [ ]:


In [ ]:


In [ ]: