def populate_anti_affinity_choices(self, request, context):
    sahara = saharaclient(request)
    plugin, version = whelpers.get_plugin_and_hadoop_version(request)

    version_details = sahara.plugins.get_version_details(plugin, version)
    process_choices = []
    for service, processes in version_details.node_processes.items():
        for process in processes:
            process_choices.append((process, process))

    cluster_template_id = request.REQUEST.get("cluster_template_id", None)
    if cluster_template_id is None:
        selected_processes = request.REQUEST.get("aa_groups", [])
    else:
        cluster_template = sahara.cluster_templates.get(cluster_template_id)
        selected_processes = cluster_template.anti_affinity

    checked_dict = dict()

    for process in selected_processes:
        checked_dict[process] = process

    self.fields['anti_affinity'].initial = checked_dict

    return process_choices
Example #2
0
    def handle(self, request, context):
        sahara = saharaclient(request)
        node_groups = None

        plugin, hadoop_version = (
            whelpers.get_plugin_and_hadoop_version(request))

        ct_id = context["cluster_general_cluster_template"] or None
        user_keypair = context["cluster_general_keypair"] or None

        cluster = sahara.clusters.create(
            context["cluster_general_cluster_name"],
            plugin, hadoop_version,
            cluster_template_id=ct_id,
            default_image_id=context["cluster_general_image"],
            description=context["cluster_general_description"],
            node_groups=node_groups,
            user_keypair_id=user_keypair,
            is_transient=not(context["cluster_general_persist_cluster"]),
            net_id=context.get("cluster_general_neutron_management_network",
                               None))

        sahara.job_executions.create(
            context["job_general_job"],
            cluster.id,
            context["job_general_job_input"],
            context["job_general_job_output"],
            context["job_config"])

        return True
Example #3
0
def populate_anti_affinity_choices(self, request, context):
    sahara = saharaclient(request)
    plugin, version = whelpers.get_plugin_and_hadoop_version(request)

    version_details = sahara.plugins.get_version_details(plugin, version)
    process_choices = []
    for service, processes in version_details.node_processes.items():
        for process in processes:
            process_choices.append((process, process))

    cluster_template_id = request.REQUEST.get("cluster_template_id", None)
    if cluster_template_id is None:
        selected_processes = request.REQUEST.get("aa_groups", [])
    else:
        cluster_template = sahara.cluster_templates.get(cluster_template_id)
        selected_processes = cluster_template.anti_affinity

    checked_dict = dict()

    for process in selected_processes:
        checked_dict[process] = process

    self.fields['anti_affinity'].initial = checked_dict

    return process_choices