当前位置: 首页>>代码示例>>Python>>正文


Python CloudManLauncher.launch方法代码示例

本文整理汇总了Python中bioblend.cloudman.launch.CloudManLauncher.launch方法的典型用法代码示例。如果您正苦于以下问题:Python CloudManLauncher.launch方法的具体用法?Python CloudManLauncher.launch怎么用?Python CloudManLauncher.launch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bioblend.cloudman.launch.CloudManLauncher的用法示例。


在下文中一共展示了CloudManLauncher.launch方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: launch_instance

# 需要导入模块: from bioblend.cloudman.launch import CloudManLauncher [as 别名]
# 或者: from bioblend.cloudman.launch.CloudManLauncher import launch [as 别名]
    def launch_instance(cfg, **kwargs):
        """
        Launches a new instance of CloudMan on the specified cloud infrastructure.

        :type cfg: CloudManConfig
        :param cfg: A CloudManConfig object containing the initial parameters
                    for this launch.
        """
        validation_result = cfg.validate()
        if validation_result is not None:
            raise VMLaunchException(
                "Invalid CloudMan configuration provided: {0}"
                .format(validation_result))
        launcher = CloudManLauncher(cfg.access_key, cfg.secret_key, cfg.cloud_metadata)
        result = launcher.launch(
            cfg.cluster_name, cfg.image_id, cfg.instance_type, cfg.password,
            cfg.kernel_id, cfg.ramdisk_id, cfg.key_name, cfg.security_groups,
            cfg.placement)
        if result['error'] is not None:
            raise VMLaunchException("Error launching cloudman instance: {0}".format(result['error']))
        instance = CloudManInstance(None, None, launcher=launcher,
                                    launch_result=result, cloudman_config=cfg)
        if cfg.block_until_ready and cfg.cluster_type:
            instance.get_status()  # this will indirect result in initialize being invoked
        return instance
开发者ID:Intel-HSS,项目名称:bioblend,代码行数:27,代码来源:__init__.py

示例2: runinstance

# 需要导入模块: from bioblend.cloudman.launch import CloudManLauncher [as 别名]
# 或者: from bioblend.cloudman.launch.CloudManLauncher import launch [as 别名]
def runinstance(request):
    """Run a CloudBioLinux/CloudMan instance with current session credentials.
    """
    form = request.session["ec2data"]

    # Handle extra_user_data
    extra_user_data = form['extra_user_data']
    if extra_user_data:
        for key, value in yaml.load(extra_user_data).iteritems():
            form[key] = value
    del form['extra_user_data']

    rs = None
    instance_type = form['instance_type']
    # Create cloudman connection with provided creds
    cml = CloudManLauncher(form["access_key"], form["secret_key"], form['cloud'])
    form["freenxpass"] = form["password"]
    if form['image_id']:
        image = models.Image.objects.get(pk=form['image_id'])
    else:
        try:
            image = models.Image.objects.get(cloud=form['cloud'], default=True)
        except models.Image.DoesNotExist:
            log.error("Cannot find an image to launch for cloud {0}".format(form['cloud']))
            return False
    # Compose kwargs from form data making sure the named arguments are not included
    kwargs = copy.deepcopy(form)
    for key in form.iterkeys():
        if key in ['cluster_name', 'image_id', 'instance_type', 'password',
                   'placement', 'access_key', 'secret_key', 'cloud']:
            del kwargs[key]
    response = cml.launch(cluster_name=form['cluster_name'],
                        image_id=image.image_id,
                        instance_type=instance_type,
                        password=form["password"],
                        kernel_id=image.kernel_id if image.kernel_id != '' else None,
                        ramdisk_id=image.ramdisk_id if image.ramdisk_id != '' else None,
                        placement=form['placement'],
                        **kwargs)
    if response["error"]:
        return response
    elif response["rs"]:
        rs = response["rs"]
        request.session['ec2data']['instance_id'] = rs.instances[0].id
        request.session['ec2data']['public_ip'] = rs.instances[0].ip_address  # public_dns_name
        request.session['ec2data']['image_id'] = rs.instances[0].image_id
        request.session['ec2data']['kp_name'] = response['kp_name']
        request.session['ec2data']['kp_material'] = response['kp_material']
        request.session['ec2data']['sg_name'] = response['sg_names'][0]

        # Add an entry to the Usage table
        try:
            u = models.Usage(cloud_name=form["cloud_name"],
                             cloud_type=form["cloud_type"],
                             image_id=image.image_id,
                             instance_type=instance_type,
                             user_id=form["access_key"])
            u.save()
        except Exception, e:
            log.debug("Trouble saving Usage data: {0}".format(e))
开发者ID:jmchilton,项目名称:biocloudcentral,代码行数:62,代码来源:views.py

示例3: run_instance

# 需要导入模块: from bioblend.cloudman.launch import CloudManLauncher [as 别名]
# 或者: from bioblend.cloudman.launch.CloudManLauncher import launch [as 别名]
def run_instance(form):
    """
    Run a CloudBioLinux/CloudMan instance with current session credentials.
    """
    err_msg = None
    kernel_id = None
    ramdisk_id = None
    # Handle extra_user_data
    extra_user_data = form['extra_user_data']
    if extra_user_data:
        for key, value in yaml.load(extra_user_data).iteritems():
            form[key] = value
    del form['extra_user_data']
    instance_type = form['instance_type']
    # Create cloudman connection with provided creds
    cml = CloudManLauncher(form["access_key"], form["secret_key"], form['cloud'])
    form["freenxpass"] = form["password"]
    if form['image_id']:
        if form['image_id'] == '0':
            image_id = form['custom_image_id']
        else:
            image = models.Image.objects.get(pk=form['image_id'])
            image_id = image.image_id
            image.kernel_id if image.kernel_id != '' else None
            image.ramdisk_id if image.ramdisk_id != '' else None
    else:
        try:
            image = models.Image.objects.get(cloud=form['cloud'], default=True)
            image_id = image.image_id
            image.kernel_id if image.kernel_id != '' else None
            image.ramdisk_id if image.ramdisk_id != '' else None
        except models.Image.DoesNotExist:
            err_msg = "Cannot find an image to launch for cloud {0}".format(form['cloud'])
            log.error(err_msg)
            return False
    # Compose kwargs from form data making sure the named arguments are not included
    kwargs = copy.deepcopy(form)
    for key in form.iterkeys():
        if key in ['cluster_name', 'image_id', 'instance_type', 'password',
                   'placement', 'access_key', 'secret_key', 'cloud']:
            del kwargs[key]
    response = cml.launch(cluster_name=form['cluster_name'],
                        image_id=image_id,
                        instance_type=instance_type,
                        password=form["password"],
                        kernel_id=kernel_id,
                        ramdisk_id=ramdisk_id,
                        placement=form['placement'],
                        **kwargs)
    # Keep these parts of the form as part of the response
    response['cluster_name'] = form['cluster_name']
    response['password'] = form['password']
    response['cloud_name'] = form['cloud_name']
    response['cloud_type'] = form['cloud_type']
    response['access_key'] = form['access_key']
    response['instance_type'] = form['instance_type']
    response['image_id'] = image_id
    response['error'] = err_msg
    return response
开发者ID:kernytsky,项目名称:biocloudcentral,代码行数:61,代码来源:tasks.py

示例4:

# 需要导入模块: from bioblend.cloudman.launch import CloudManLauncher [as 别名]
# 或者: from bioblend.cloudman.launch.CloudManLauncher import launch [as 别名]
 if not err_msg:
     log.debug(
         "Launching cluster '{0}' on {1} cloud from image {2} on "
         "instance type {3}{4}.".format(
             form["cluster_name"],
             form["cloud_name"],
             image_id,
             instance_type,
             " in zone '{0}'".format(form["placement"]) if form["placement"] else "",
         )
     )
     response = cml.launch(
         cluster_name=form["cluster_name"],
         image_id=image_id,
         instance_type=instance_type,
         password=form["password"],
         kernel_id=kernel_id,
         ramdisk_id=ramdisk_id,
         placement=form["placement"],
         **kwargs
     )
 # Keep these parts of the form as part of the response
 response["cluster_name"] = form["cluster_name"]
 response["password"] = form["password"]
 response["cloud_name"] = form["cloud_name"]
 response["cloud_type"] = form["cloud_type"]
 response["access_key"] = form["access_key"]
 response["instance_type"] = instance_type
 response["cluster_type"] = form.get("initial_cluster_type", "")
 response["storage_type"] = form.get("storage_type", "")
 response["storage_size"] = form.get("storage_size", "")
 response["institutional_email"] = form.get("institutional_email", "")
开发者ID:pli888,项目名称:cloudlaunch,代码行数:34,代码来源:tasks.py

示例5:

# 需要导入模块: from bioblend.cloudman.launch import CloudManLauncher [as 别名]
# 或者: from bioblend.cloudman.launch.CloudManLauncher import launch [as 别名]
        if key in ['cluster_name', 'image_id', 'instance_type', 'password',
                   'placement', 'access_key', 'secret_key', 'cloud', 'key_pair',
                   'ebs_optimized', 'subnet_id']:
            del kwargs[key]

    response = {}
    if not err_msg:
        log.debug("Launching cluster '{0}' on {1} cloud from image {2} on "
                  "instance type {3}{4}."
                  .format(form['cluster_name'], form['cloud_name'], image_id, instance_type,
                          " in zone '{0}'".format(form['placement']) if form['placement'] else ""))
        response = cml.launch(cluster_name=form['cluster_name'],
                              image_id=image_id,
                              instance_type=instance_type,
                              password=form["password"],
                              kernel_id=kernel_id,
                              ramdisk_id=ramdisk_id,
                              placement=form['placement'],
                              ebs_optimized=ebs_optimized,
                              subnet_id=subnet_id,
                              **kwargs)
    # Keep these parts of the form as part of the response
    response['cluster_name'] = form['cluster_name']
    response['password'] = form['password']
    response['cloud_name'] = form['cloud_name']
    response['cloud_type'] = form['cloud_type']
    response['access_key'] = form['access_key']
    response['instance_type'] = instance_type
    response['cluster_type'] = form.get('initial_cluster_type', '')
    response['storage_type'] = form.get('storage_type', '')
    response['storage_size'] = form.get('storage_size', '')
    response['institutional_email'] = form.get('institutional_email', '')
开发者ID:nturaga,项目名称:biocloudcentral,代码行数:34,代码来源:tasks.py

示例6: Bunch

# 需要导入模块: from bioblend.cloudman.launch import CloudManLauncher [as 别名]
# 或者: from bioblend.cloudman.launch.CloudManLauncher import launch [as 别名]
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='test',
                              placement='nova')

print response
开发者ID:nickloman,项目名称:biocloudcentral,代码行数:21,代码来源:test_cloudmanlauncher.py

示例7: run_instance

# 需要导入模块: from bioblend.cloudman.launch import CloudManLauncher [as 别名]
# 或者: from bioblend.cloudman.launch.CloudManLauncher import launch [as 别名]
def run_instance(form):
    """
    Run a CloudBioLinux/CloudMan instance with current session credentials.
    """
    # Dev code only!
    # Useful when wanting to skip the instance launch process but contitnue the process
    # response = {}
    # response['cluster_name'] = form['cluster_name']
    # response['password'] = form['password']
    # response['cloud_name'] = form['cloud_name']
    # response['cloud_type'] = form['cloud_type']
    # response['access_key'] = form['access_key']
    # response['instance_type'] = form['instance_type']
    # response['image_id'] = models.Image.objects.get(pk=form['image_id']).image_id
    # response['error'] = None
    # response['sg_names'] = ['CloudMan']
    # response['kp_name'] = 'cm_kp'
    # response['kp_material'] = ''
    # response['instance_id'] = 'i-l0cal'
    # response['instance_ip'] = '127.0.0.1'
    # response['institutional_email'] = form['institutional_email']
    # return response
    # End dev code

    err_msg = None
    kernel_id = None
    ramdisk_id = None
    # Handle extra_user_data
    extra_user_data = form["extra_user_data"]
    if extra_user_data:
        for key, value in yaml.load(extra_user_data).iteritems():
            form[key] = value
    del form["extra_user_data"]
    instance_type = form["instance_type"]
    # Create cloudman connection with provided creds
    cml = CloudManLauncher(form["access_key"], form["secret_key"], form["cloud"])
    form["freenxpass"] = form["password"]
    if form["image_id"]:
        if form["image_id"] == "0":
            image_id = form["custom_image_id"]
        else:
            image = models.Image.objects.get(pk=form["image_id"])
            image_id = image.image_id
            image.kernel_id if image.kernel_id != "" else None
            image.ramdisk_id if image.ramdisk_id != "" else None
    else:
        try:
            image = models.Image.objects.get(cloud=form["cloud"], default=True)
            image_id = image.image_id
            image.kernel_id if image.kernel_id != "" else None
            image.ramdisk_id if image.ramdisk_id != "" else None
        except models.Image.DoesNotExist:
            err_msg = "Cannot find an image to launch for cloud {0}".format(form["cloud"])
            log.error(err_msg)
            return False
    # Compose kwargs from form data making sure the named arguments are not included
    kwargs = copy.deepcopy(form)
    # key_name is the parameter name for the key pair in the launch method so
    # ensure it's there as a kwqrg if provided in the form
    if form.get("key_pair", None):
        kwargs["key_name"] = form["key_pair"]
    for key in form.iterkeys():
        if key in [
            "cluster_name",
            "image_id",
            "instance_type",
            "password",
            "placement",
            "access_key",
            "secret_key",
            "cloud",
            "key_pair",
        ]:
            del kwargs[key]
    if not err_msg:
        response = cml.launch(
            cluster_name=form["cluster_name"],
            image_id=image_id,
            instance_type=instance_type,
            password=form["password"],
            kernel_id=kernel_id,
            ramdisk_id=ramdisk_id,
            placement=form["placement"],
            **kwargs
        )
    # Keep these parts of the form as part of the response
    response["cluster_name"] = form["cluster_name"]
    response["password"] = form["password"]
    response["cloud_name"] = form["cloud_name"]
    response["cloud_type"] = form["cloud_type"]
    response["access_key"] = form["access_key"]
    response["instance_type"] = form["instance_type"]
    response["institutional_email"] = form["institutional_email"]
    response["image_id"] = image_id
    response["error"] = err_msg
    return response
开发者ID:jrevote,项目名称:biocloudcentral,代码行数:98,代码来源:tasks.py


注:本文中的bioblend.cloudman.launch.CloudManLauncher.launch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。