{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Data Processing" %}{% endblock %}

{% block main %}

    <div class="guide">
        <ol>
            <li>
                <div>
                    <div>{% blocktrans trimmed %}The first step is to determine which type of
                    cluster you want to run.  You may have several choices
                    available depending on the configuration of your system.
                    Click on "choose plugin" to bring up the list of data
                    processing plugins.  There you will be able to choose the
                    data processing plugin along with the version number.
                    Choosing this up front will allow the rest of the cluster
                    creation steps to focus only on options that are pertinent
                    to your desired cluster type.{% endblocktrans %}
                    </div>
                    <a class="btn btn-default btn-small btn-create btn-inline ajax-modal" href="
                      {% url 'horizon:project:data_processing.clusters:plugin_select' %}">{% trans "Choose plugin" %}</a>
                    <div>{% trans "Current choice:" %}
                        {% if request.session.plugin_name and request.session.plugin_version %}
                            <span class="text-success">
                                {% trans "Plugin:" %}
                               {{ request.session.plugin_name }}
                                {% trans "Version:" %}
                               {{ request.session.plugin_version }}
                            </span>
                        {% else %}
                            <span class="text-danger">
                                {% trans "No plugin chosen" %}
                            </span>
                        {% endif %}
                    </div>
                </div>
            </li>
            <hr/>
            <li>
                <div>
                    <div>{% blocktrans trimmed %}You need to register an image to launch instances
                         of your cluster. Skip this step if you already have a registered image
                         for your plugin, otherwise click the link below. In the form you will
                         need to choose the image, input the username and add tags for the chosen plugin.
                         {% endblocktrans %}
                    </div>
                    <div>
                        <a class="btn btn-default btn-small btn-create btn-inline ajax-modal"
                            href="{% url 'horizon:project:data_processing.clusters:image_register'%}">
                            <span class="fa fa-plus"></span> {% trans "Register Image" %}</a>
                    </div>
                </div>
            </li>
            <hr/>
            <li>
                <div>
                    <div>{% blocktrans trimmed %}Next, you need to define the different
                        types of machines in your cluster.  This is done by
                        defining a Node Group Template for each type of
                        machine.  A very common case is where you
                        need to have one or more machines running a "master"
                        set of processes while another set of machines need
                        to be running the "worker" processes.  Here,
                        you will define the Node Group Template for your
                        "master" node(s).
                     {% endblocktrans %}
                    </div>
                    <div>
                          <a class="btn btn-default btn-small btn-create btn-inline ajax-modal
                            {% if not request.session.plugin_name or not request.session.plugin_version %} disabled {% endif %}"
                            href="{% if request.session.plugin_name and request.session.plugin_version %}{% url 'horizon:project:data_processing.clusters:configure-nodegroup-template'%}?plugin_name={{ request.session.plugin_name }}&hadoop_version={{ request.session.plugin_version }}&guide_template_type=master{% endif %}">
                            <span class="fa fa-plus"></span> {% trans "Create a Master Node Group Template" %}</a>
                          {% if view.show_existing_templates %}
                              {% trans " or " %}
                              <a class="btn btn-default btn-small btn-create btn-inline ajax-modal
                                {% if not request.session.plugin_name or not request.session.plugin_version %} disabled {% endif %}"
                                href="{% if request.session.plugin_name and request.session.plugin_version %}{% url 'horizon:project:data_processing.clusters:ngt_select'%}?plugin_name={{ request.session.plugin_name }}&hadoop_version={{ request.session.plugin_version }}&guide_template_type=master{% endif %}">
                                {% trans "Choose an existing Master Node Group Template" %}</a>
                          {% endif %}

                    </div>
                    <div>{% trans "Current choice:" %}
                        {% if request.session.master_name %}
                            <span class="text-success">
                                {% trans "Master Node Group Template:" %}
                               {{ request.session.master_name }}
                            </span>
                        {% else %}
                            <span class="text-danger">
                                {% trans "No Master Node Group Template Created" %}
                            </span>
                        {% endif %}
                    </div>
                </div>
            </li>
            <hr/>
            <li>
                <div>
                    <div>{% blocktrans trimmed %}Repeat the Node Group Template
                        creation process, but this time you are creating
                        your "worker" Node Group Template.{% endblocktrans %}
                    </div>
                    <div>
                        <a class="btn btn-default btn-small btn-create btn-inline ajax-modal
                            {% if not request.session.master_name %} disabled{% endif %}"
                            href="{% if request.session.plugin_name and request.session.plugin_version %}{% url 'horizon:project:data_processing.clusters:configure-nodegroup-template'%}?plugin_name={{ request.session.plugin_name }}&hadoop_version={{ request.session.plugin_version }}&guide_template_type=worker{% endif %}">
                            <span class="fa fa-plus"></span> {% trans "Create a Worker Node Group Template" %}</a>
                        {% if view.show_existing_templates %}
                            {% trans " or " %}
                            <a class="btn btn-default btn-small btn-create btn-inline ajax-modal
                                {% if not request.session.master_name %} disabled{% endif %}"
                                href="{% if request.session.plugin_name and request.session.plugin_version %}{% url 'horizon:project:data_processing.clusters:ngt_select'%}?plugin_name={{ request.session.plugin_name }}&hadoop_version={{ request.session.plugin_version }}&guide_template_type=worker{% endif %}">
                                {% trans "Choose an existing Worker Node Group Template" %}</a>
                        {% endif %}

                    </div>
                    <div>{% trans "Current choice:" %}
                        {% if request.session.worker_name %}
                            <span class="text-success">
                                {% trans "Worker Node Group Template:" %}
                               {{ request.session.worker_name }}
                            </span>
                        {% else %}
                            <span class="text-danger">
                                {% trans "No Worker Node Group Template Created" %}
                            </span>
                        {% endif %}
                    </div>
                </div>
            </li>
            <hr/>
            <li>
                <div>
                    <div>{% blocktrans trimmed %}Now you need to set the layout of your
                        cluster.  By
                        creating a Cluster Template, you will be choosing the
                        number of instances of each Node Group Template that
                        will appear in your cluster.  Additionally,
                        you will have a chance to set any cluster-specific
                        configuration items in the additional tabs on the
                        create Cluster Template form.{% endblocktrans %}
                    </div>
                    <div>
                        <a class="btn btn-default btn-small btn-create btn-inline ajax-modal
                            {% if not request.session.worker_name %} disabled{% endif %}"
                             href="{% url 'horizon:project:data_processing.clusters:configure-cluster-template' %}?plugin_name={{ request.session.plugin_name }}&hadoop_version={{ request.session.plugin_version }}&forms_ids=[0,1]&count_0=1&group_name_0={{ request.session.master_name }}&template_id_0={{ request.session.master_id }}&count_1=1&group_name_1={{ request.session.worker_name }}&template_id_1={{ request.session.worker_id }}&serialized_0=null&serialized_1=null">
                            <span class="fa fa-plus"></span> {% trans "Create a Cluster Template" %}</a>
                    </div>
                    <div>{% trans "Current choice:" %}
                        {% if request.session.guide_cluster_template_name %}
                            <span class="text-success">
                                {% trans "Worker Node Group Template:" %}
                               {{ request.session.guide_cluster_template_name }}
                            </span>
                        {% else %}
                            <span class="text-danger">
                                {% trans "No Cluster Template Created" %}
                            </span>
                        {% endif %}
                    </div>
                </div>
           </li>
            <hr/>
            <li>
                <div>
                    <div>{% blocktrans trimmed %}You are now ready to
                        launch your cluster.  When you click on the link
                        below, you will need to give your cluster a name,
                        choose the Cluster Template to use and choose which
                        image to use to build your instances.  After you
                        click on "Create", your instances will begin to
                        spawn.  Your cluster should be operational in a few
                        minutes.{% endblocktrans %}
                    </div>
                    <div>
                        <a class="btn btn-default btn-small btn-create btn-inline ajax-modal
                            {% if not request.session.guide_cluster_template_name %} disabled{% endif %}"
                            href="{% if request.session.guide_cluster_template_name %}{% url 'horizon:project:data_processing.clusters:configure-cluster'%}?plugin_name={{ request.session.plugin_name }}&hadoop_version={{ request.session.plugin_version }}&cluster_template_name={{ request.session.guide_cluster_template_name }}{% endif %}">
                            <span class="fa fa-plus"></span> {% trans "Launch a Cluster" %}</a>
                    </div>
                </div>
            </li>
        </ol>
        <div>
            <a id="reset_cluster_guide_btn"
               class=" btn btn-default btn-small btn-create btn-inline btn-danger"
               title="{% trans "Reset Cluster Guide" %}"
               href="{% url 'horizon:project:data_processing.clusters:reset_cluster_guide' True %}">
                {% trans "Reset Cluster Creation Guide" %}
            </a>
        </div>
    </div>

{% endblock %}
