2019-12-13 13:47:51 +00:00
|
|
|
{% extends "base.html" %}
|
|
|
|
{% load i18n %}
|
2021-06-15 06:42:55 +00:00
|
|
|
{% load static %}
|
2020-10-15 14:18:45 +00:00
|
|
|
|
2020-06-10 08:15:14 +00:00
|
|
|
{% block title %}{% trans "Create new instance" %} - {% trans "Select Type" %}{% endblock %}
|
2019-12-13 13:47:51 +00:00
|
|
|
|
2020-10-15 14:18:45 +00:00
|
|
|
{% block page_heading%}
|
|
|
|
{% blocktrans with host=compute.name %}New instance on {{ host }} {% endblocktrans %}
|
|
|
|
{% endblock page_heading %}
|
|
|
|
|
2019-12-13 13:47:51 +00:00
|
|
|
{% block content %}
|
|
|
|
{% include 'pleasewaitdialog.html' %}
|
|
|
|
|
|
|
|
{% if form.errors %}
|
|
|
|
{% for field in form %}
|
|
|
|
{% for error in field.errors %}
|
|
|
|
<div class="alert alert-danger">
|
|
|
|
<strong>{{ error|escape }}</strong>
|
|
|
|
</div>
|
|
|
|
{% endfor %}
|
|
|
|
{% endfor %}
|
|
|
|
{% for error in form.non_field_errors %}
|
|
|
|
<div class="alert alert-danger">
|
|
|
|
<strong>{{ error|escape }}</strong>
|
|
|
|
</div>
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
|
2021-07-07 11:12:38 +00:00
|
|
|
<div class="row">
|
2019-12-13 13:47:51 +00:00
|
|
|
<div class="col-lg-12">
|
|
|
|
<div role="tabpanel">
|
|
|
|
<!-- Nav tabs -->
|
2020-05-26 13:18:38 +00:00
|
|
|
<ul class="nav nav-tabs" role="tablist" aria-label="Instance create method">
|
2021-07-07 11:12:38 +00:00
|
|
|
<li class="nav-item" role="presentation">
|
|
|
|
<button class="nav-link active" data-bs-toggle="tab" data-bs-target="#select_architecture" type="button" role="tab" aria-controls="select_architecture" aria-selected="true">
|
2019-12-13 13:47:51 +00:00
|
|
|
{% trans "Architecture" %}
|
2021-07-07 11:12:38 +00:00
|
|
|
</button>
|
2019-12-13 13:47:51 +00:00
|
|
|
</li>
|
2021-07-07 11:12:38 +00:00
|
|
|
<li class="nav-item" role="presentation">
|
|
|
|
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#addFromXML" type="button" role="tab" aria-controls="addFromXML" aria-selected="false">
|
2019-12-13 13:47:51 +00:00
|
|
|
{% trans "XML" %}
|
2021-07-07 11:12:38 +00:00
|
|
|
</button>
|
2019-12-13 13:47:51 +00:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<!-- Tab panes -->
|
|
|
|
<div class="tab-content">
|
2021-07-07 11:12:38 +00:00
|
|
|
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="select_architecture">
|
|
|
|
<form method="post" role="form" aria-label="Select instance architecture form">{% csrf_token %}
|
|
|
|
<div class="row">
|
|
|
|
<label class="col-sm-3 col-form-label">{% trans "Architecture" %}</label>
|
|
|
|
<div class="col-sm-6">
|
|
|
|
<select class="form-select" id="select_archs" name="archs" onchange="get_machine_types({{ compute_id }}, value);">
|
|
|
|
{% for hpv in hypervisors %}
|
|
|
|
<option value="{{ hpv }}" {% if hpv == default_arch %}selected{% endif %}>{{ hpv }}</option>
|
|
|
|
{% endfor %}
|
|
|
|
</select>
|
2019-12-13 13:47:51 +00:00
|
|
|
</div>
|
2021-07-07 11:12:38 +00:00
|
|
|
</div>
|
|
|
|
<div class="row">
|
|
|
|
<label class="col-sm-3 col-form-label">{% trans "Chipset" %}</label>
|
|
|
|
<div class="col-sm-6">
|
|
|
|
<select class="form-select" id="select_chipset" name="chipset">
|
|
|
|
<!-- fill with script -->
|
|
|
|
</select>
|
2019-12-13 13:47:51 +00:00
|
|
|
</div>
|
2021-07-07 11:12:38 +00:00
|
|
|
</div>
|
|
|
|
<div class="row">
|
|
|
|
<div class="d-grid col-sm-6 offset-3 mt-3">
|
|
|
|
<button class="btn btn-primary" type="button" name="create_instance" onclick="goto_create()">
|
|
|
|
{% trans "Next" %}
|
|
|
|
</button>
|
2019-12-13 13:47:51 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-07-07 11:12:38 +00:00
|
|
|
</form>
|
2019-12-13 13:47:51 +00:00
|
|
|
<div class="clearfix"></div>
|
|
|
|
</div>
|
|
|
|
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="addFromXML">
|
2020-05-28 21:43:26 +00:00
|
|
|
<div>
|
2020-05-26 13:18:38 +00:00
|
|
|
<form method="post" role="form" aria-label="Create instance with XML form">{% csrf_token %}
|
2019-12-13 13:47:51 +00:00
|
|
|
<div class="col-sm-12" id="xmlheight">
|
|
|
|
<input type="hidden" name="dom_xml"/>
|
|
|
|
<textarea id="editor"></textarea>
|
|
|
|
</div>
|
2021-07-07 11:12:38 +00:00
|
|
|
<button type="submit" class="btn btn-primary float-end" name="create_xml" onclick="showPleaseWaitDialog()">
|
2019-12-13 13:47:51 +00:00
|
|
|
{% trans "Create" %}
|
|
|
|
</button>
|
|
|
|
</form>
|
|
|
|
</div>
|
2020-03-16 13:59:45 +00:00
|
|
|
<div class="clearfix"></div>
|
2019-12-13 13:47:51 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{% endblock %}
|
|
|
|
{% block script %}
|
|
|
|
<script>
|
|
|
|
$(document).ready(function () {
|
|
|
|
let arch = $("#select_archs").val();
|
|
|
|
get_machine_types({{ compute_id }}, arch);
|
|
|
|
});
|
|
|
|
|
|
|
|
function get_machine_types(compute_id, arch) {
|
|
|
|
get_machine_type_url = "/computes/" + compute_id + "/archs/" + arch + "/machines";
|
|
|
|
$.getJSON(get_machine_type_url, function (data) {
|
|
|
|
$("#select_chipset").find('option').remove();
|
|
|
|
$("#select_archs").val(arch);
|
|
|
|
$.each(data['machines'], function(i, item) {
|
|
|
|
if (item == '{{ default_machine }}') {
|
|
|
|
var selected = 'selected';
|
|
|
|
}else{
|
|
|
|
var selected = '';
|
|
|
|
}
|
|
|
|
$("#select_chipset").append('<option value="' + item + '"' + selected +'>' + item + '</option>');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2020-05-14 16:59:22 +00:00
|
|
|
<script src="{% static "js/ace/ace.js" %}"></script>
|
2019-12-13 13:47:51 +00:00
|
|
|
<script>
|
|
|
|
var editor = ace.edit("editor");
|
|
|
|
editor.getSession().setMode("ace/mode/xml");
|
|
|
|
|
|
|
|
var input = $('input[name="dom_xml"]');
|
|
|
|
editor.getSession().on("change",function () {
|
|
|
|
input.val(editor.getSession().getValue());
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
{% if request.user.is_superuser %}
|
|
|
|
<script>
|
|
|
|
function goto_create() {
|
|
|
|
let compute = '{{ compute.id }}';
|
|
|
|
let arch = $("#select_archs").val();
|
|
|
|
let machine = $("#select_chipset").val();
|
2020-07-13 09:33:09 +00:00
|
|
|
//create_machine_url = "/computes/" + compute + "/create/archs/" + arch + "/machines/" + machine;
|
|
|
|
url = "{% url 'instances:create_instance' compute.id 'x86_64' 'pc' %}".replace(/x86_64/, arch).replace(/pc/, machine);
|
|
|
|
window.location.href = url;//create_machine_url;
|
2019-12-13 13:47:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
{% endif %}
|
|
|
|
{% endblock %}
|