Example #1
0
 def CustomTypeDecoder(dct):
     if '__CloudManConfig__' in dct:
         return CloudManConfig(**dct['__CloudManConfig__'])
     elif '__Bunch__' in dct:
         return Bunch(**dct['__Bunch__'])
     else:
         return dct
Example #2
0
    def __init__(self, access_key, secret_key, cloud=None):
        """
        Define the environment in which this instance of CloudMan will be launched.

        Besides providing the credentials, optionally provide the ``cloud``
        object. This object must define the properties required to establish a
        `boto <https://github.com/boto/boto/>`_ connection to that cloud. See
        this method's implementation for an example of the required fields.
        Note that as long the as provided object defines the required fields,
        it can really by implemented as anything (e.g., a Bunch, a database
        object, a custom class). If no value for the ``cloud`` argument is
        provided, the default is to use the Amazon cloud.
        """
        self.access_key = access_key
        self.secret_key = secret_key
        if cloud is None:
            # Default to an EC2-compatible object
            self.cloud = Bunch(
                id='1',  # for compatibility w/ DB representation
                name="Amazon",
                cloud_type="ec2",
                bucket_default="cloudman",
                region_name="us-east-1",
                region_endpoint="ec2.amazonaws.com",
                ec2_port="",
                ec2_conn_path="/",
                cidr_range="",
                is_secure=True,
                s3_host="s3.amazonaws.com",
                s3_port="",
                s3_conn_path='/')
        else:
            self.cloud = cloud
        self.ec2_conn = self.connect_ec2(self.access_key, self.secret_key,
                                         self.cloud)
 def setUpClass(cls):
     if os.environ.get('BIOBLEND_CLOUD_TYPE') == 'EC2':
         cls.access_key = os.environ['BIOBLEND_ACCESS_KEY']
         cls.secret_key = os.environ['BIOBLEND_SECRET_KEY']
         cls.cluster_name = 'Blend CloudMan'
         cls.ami_id = os.environ['BIOBLEND_AMI_ID']
         cls.instance_type = 'm1.small'
         cls.password = '******'
         cls.cloud_metadata = Bunch(
             id='1',  # for compatibility w/ DB representation
             name="Amazon",
             cloud_type="ec2",
             bucket_default="cloudman",
             region_name="us-east-1",
             region_endpoint="ec2.amazonaws.com",
             ec2_port="",
             ec2_conn_path="/",
             cidr_range="",
             is_secure=True,
             s3_host="s3.amazonaws.com",
             s3_port="",
             s3_conn_path='/')
     else:
         # Assume OpenStack/NeCTAR
         cls.access_key = os.environ['BIOBLEND_ACCESS_KEY']
         cls.secret_key = os.environ['BIOBLEND_SECRET_KEY']
         cls.cloud_metadata = Bunch(
             id='-1',
             name="NeCTAR",
             cloud_type='openstack',
             bucket_default='cloudman-os',
             region_name='melbourne',
             region_endpoint='nova.rc.nectar.org.au',
             ec2_port=8773,
             ec2_conn_path='/services/Cloud',
             cidr_range='115.146.92.0/22',
             is_secure=True,
             s3_host='swift.rc.nectar.org.au',
             s3_port=8888,
             s3_conn_path='/')
         cls.cluster_name = 'Blend CloudMan'
         cls.ami_id = os.environ['BIOBLEND_AMI_ID']
         cls.instance_type = 'm1.small'
         cls.password = '******'
Example #4
0
def start_cloudman(name, pwd, cm_type, inst_type, ami, ak, sk):
    """
    Start an instance of CloudMan with the provided arguments.

    Returns a tuple: an instance of ``CloudManConfig`` pointing to the
    settings used to launch this instance of CloudMan; and an instance
    of ``CloudManInstance`` pointing to the given instance of CloudMan.
    """
    cloud = None  # If left as None, BioBlend will default to Amazon
    # Define properties for the NeCTAR cloud
    cloud = Bunch(id='-1',
                  name="NeCTAR",
                  cloud_type='openstack',
                  bucket_default='cloudman-os',
                  region_name='melbourne',
                  region_endpoint='nova.rc.nectar.org.au',
                  ec2_port=8773,
                  ec2_conn_path='/services/Cloud',
                  cidr_range='115.146.92.0/22',
                  is_secure=True,
                  s3_host='swift.rc.nectar.org.au',
                  s3_port=8888,
                  s3_conn_path='/')
    # Create an instance of the CloudManConfig class and launch a CloudMan instance
    cmc = CloudManConfig(ak,
                         sk,
                         name,
                         ami,
                         inst_type,
                         pwd,
                         cloud_metadata=cloud,
                         cloudman_type=cm_type,
                         initial_storage_size=2,
                         placement='melbourne-np')
    print("Configured an instance; waiting to launch and boot...")
    cmi = CloudManInstance.launch_instance(cmc)
    print("Done! CloudMan IP is {0}".format(cmi.cloudman_url))
    return cmc, cmi
import bioblend
from bioblend.util import Bunch
from bioblend.cloudman.launch import CloudManLauncher

import logging

logging.basicConfig(filename="bioblend.log", level=logging.DEBUG)

cloud = Bunch(id='1',
              name='climb',
              cloud_type="openstack",
              bucket_default="cloudman_os",
              region_name="nova",
              region_endpoint="147.188.173.10",
              ec2_port="8773",
              ec2_conn_path="/services/Cloud",
              cidr_range="147.188.173.0/24",
              is_secure=False,
              s3_host="swift.rc.nectar.org.au",
              s3_port="8888",
              s3_conn_path='/')

cml = CloudManLauncher('ACCESS_KEY', 'SECRET_KEY', cloud)

response = cml.launch(cluster_name='test',
                      image_id='ami-00000039',
                      instance_type='m1.large',
                      password='******',
                      placement='nova')

print response