• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python context.spawn函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sahara.context.spawn函数的典型用法代码示例。如果您正苦于以下问题:Python spawn函数的具体用法?Python spawn怎么用?Python spawn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: create_cluster

def create_cluster(values):
    ctx = context.ctx()
    cluster = conductor.cluster_create(ctx, values)
    plugin = plugin_base.PLUGINS.get_plugin(cluster.plugin_name)

    # update nodegroup image usernames
    for nodegroup in cluster.node_groups:
        conductor.node_group_update(
            ctx, nodegroup,
            {"image_username": INFRA.get_node_group_image_username(nodegroup)})
    cluster = conductor.cluster_get(ctx, cluster)

    # validating cluster
    try:
        cluster = conductor.cluster_update(ctx, cluster,
                                           {"status": "Validating"})
        LOG.info(g.format_cluster_status(cluster))

        plugin.validate(cluster)
    except Exception as e:
        with excutils.save_and_reraise_exception():
            cluster = conductor.cluster_update(ctx, cluster,
                                               {"status": "Error",
                                                "status_description": str(e)})
            LOG.info(g.format_cluster_status(cluster))

    context.spawn("cluster-creating-%s" % cluster.id,
                  _provision_cluster, cluster.id)
    if CONF.use_identity_api_v3 and cluster.is_transient:
        trusts.create_trust(cluster)

    return conductor.cluster_get(ctx, cluster.id)
开发者ID:esala116,项目名称:sahara,代码行数:32,代码来源:api.py


示例2: execute_job

def execute_job(job_id, data):

    # Elements common to all job types
    cluster_id = data['cluster_id']
    configs = data.get('job_configs', {})

    ctx = context.current()
    cluster = conductor.cluster_get(ctx, cluster_id)
    plugin = plugin_base.PLUGINS.get_plugin(cluster.plugin_name)
    instance = plugin.get_oozie_server(cluster)

    extra = {}
    info = None
    if CONF.use_namespaces and not CONF.use_floating_ips:
        info = instance.remote().get_neutron_info()
        extra['neutron'] = info

    # Not in Java job types but present for all others
    input_id = data.get('input_id', None)
    output_id = data.get('output_id', None)

    # Since we will use a unified class in the database, we pass
    # a superset for all job types
    job_ex_dict = {'input_id': input_id, 'output_id': output_id,
                   'job_id': job_id, 'cluster_id': cluster_id,
                   'info': {'status': 'Pending'}, 'job_configs': configs,
                   'extra': extra}
    job_execution = conductor.job_execution_create(context.ctx(), job_ex_dict)

    context.spawn("Starting Job Execution %s" % job_execution.id,
                  manager.run_job, job_execution)
    return job_execution
开发者ID:esala116,项目名称:sahara,代码行数:32,代码来源:api.py


示例3: scale_cluster

def scale_cluster(id, data):
    ctx = context.ctx()

    cluster = conductor.cluster_get(ctx, id)
    plugin = plugin_base.PLUGINS.get_plugin(cluster.plugin_name)
    existing_node_groups = data.get('resize_node_groups', [])
    additional_node_groups = data.get('add_node_groups', [])

    #the next map is the main object we will work with
    #to_be_enlarged : {node_group_id: desired_amount_of_instances}
    to_be_enlarged = {}
    for ng in existing_node_groups:
        ng_id = g.find(cluster.node_groups, name=ng['name'])['id']
        to_be_enlarged.update({ng_id: ng['count']})

    additional = construct_ngs_for_scaling(cluster, additional_node_groups)
    cluster = conductor.cluster_get(ctx, cluster)

    # update nodegroup image usernames
    for nodegroup in cluster.node_groups:
        if additional.get(nodegroup.id):
            image_username = INFRA.get_node_group_image_username(nodegroup)
            conductor.node_group_update(
                ctx, nodegroup, {"image_username": image_username})
    cluster = conductor.cluster_get(ctx, cluster)

    try:
        cluster = conductor.cluster_update(ctx, cluster,
                                           {"status": "Validating"})
        LOG.info(g.format_cluster_status(cluster))
        plugin.validate_scaling(cluster, to_be_enlarged, additional)
    except Exception:
        with excutils.save_and_reraise_exception():
            g.clean_cluster_from_empty_ng(cluster)
            cluster = conductor.cluster_update(ctx, cluster,
                                               {"status": "Active"})
            LOG.info(g.format_cluster_status(cluster))

    # If we are here validation is successful.
    # So let's update to_be_enlarged map:
    to_be_enlarged.update(additional)

    for node_group in cluster.node_groups:
        if node_group.id not in to_be_enlarged:
            to_be_enlarged[node_group.id] = node_group.count

    context.spawn("cluster-scaling-%s" % id,
                  _provision_scaled_cluster, id, to_be_enlarged)
    return conductor.cluster_get(ctx, id)
开发者ID:esala116,项目名称:sahara,代码行数:49,代码来源:api.py


示例4: _spawn

 def _spawn(self, description, func, *args, **kwargs):
     context.spawn(description, func, *args, **kwargs)
开发者ID:JohannaMW,项目名称:sahara,代码行数:2,代码来源:ambariplugin.py


示例5: job_execution_suspend

 def job_execution_suspend(self, job_execution_id):
     context.spawn("Suspend Job Execution %s" % job_execution_id,
                   _suspend_job_execution, job_execution_id)
开发者ID:openstack,项目名称:sahara,代码行数:3,代码来源:ops.py


示例6: handle_verification

 def handle_verification(self, cluster_id, values):
     context.spawn('Handling Verification for cluster %s' % cluster_id,
                   _handle_verification, cluster_id, values)
开发者ID:openstack,项目名称:sahara,代码行数:3,代码来源:ops.py


示例7: delete_job_execution

 def delete_job_execution(self, job_execution_id):
     context.spawn("Deleting Job Execution %s" % job_execution_id,
                   _delete_job_execution, job_execution_id)
开发者ID:openstack,项目名称:sahara,代码行数:3,代码来源:ops.py


示例8: cancel_job_execution

 def cancel_job_execution(self, job_execution_id):
     context.spawn("Canceling Job Execution %s" % job_execution_id,
                   _cancel_job_execution, job_execution_id)
开发者ID:openstack,项目名称:sahara,代码行数:3,代码来源:ops.py


示例9: run_edp_job

 def run_edp_job(self, job_execution_id):
     context.spawn("Starting Job Execution %s" % job_execution_id,
                   _run_edp_job, job_execution_id)
开发者ID:openstack,项目名称:sahara,代码行数:3,代码来源:ops.py


示例10: terminate_cluster

 def terminate_cluster(self, cluster_id, force=False):
     context.spawn("cluster-terminating-%s" % cluster_id,
                   terminate_cluster, cluster_id, force)
开发者ID:openstack,项目名称:sahara,代码行数:3,代码来源:ops.py


示例11: provision_scaled_cluster

 def provision_scaled_cluster(self, cluster_id, node_group_id_map,
                              node_group_instance_map=None):
     context.spawn("cluster-scaling-%s" % cluster_id,
                   _provision_scaled_cluster, cluster_id, node_group_id_map,
                   node_group_instance_map)
开发者ID:openstack,项目名称:sahara,代码行数:5,代码来源:ops.py


示例12: provision_cluster

 def provision_cluster(self, cluster_id):
     context.spawn("cluster-creating-%s" % cluster_id,
                   _provision_cluster, cluster_id)
开发者ID:openstack,项目名称:sahara,代码行数:3,代码来源:ops.py


示例13: terminate_cluster

 def terminate_cluster(self, cluster_id):
     context.spawn("cluster-terminating-%s" % cluster_id,
                   _terminate_cluster, cluster_id)
开发者ID:B-Rich,项目名称:sahara,代码行数:3,代码来源:ops.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python api.set_conf函数代码示例发布时间:2022-05-27
下一篇:
Python context.sleep函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap