2015-03-02 08:52:07 +00:00
{% extends "base.html" %}
{% load i18n %}
2021-06-15 06:42:55 +00:00
{% load static %}
2020-07-13 09:33:09 +00:00
{% load icons %}
2015-03-06 13:46:59 +00:00
{% block title %}{% trans "Create new instance" %}{% endblock %}
2020-10-15 14:18:45 +00:00
2015-03-06 13:46:59 +00:00
{% block style %}
< link href = "{% static " css / bootstrap-multiselect . css " % } " rel = "stylesheet" >
{% endblock %}
2020-10-15 14:18:45 +00:00
{% block page_heading %}
{% blocktrans with host=compute.name %}New instance on {{ host }} {% endblocktrans %}
{% endblock page_heading %}
2015-03-02 08:52:07 +00:00
{% block content %}
2018-10-24 13:14:14 +00:00
{% include 'pleasewaitdialog.html' %}
2015-03-02 08:52:07 +00:00
2018-11-16 13:08:35 +00:00
{% if form.errors %}
{% for field in form %}
{% for error in field.errors %}
< div class = "alert alert-danger" >
2022-08-22 12:12:33 +00:00
< strong > {{ field.label }}:< / strong > < span > {{ error|escape }}< / span >
2018-11-16 13:08:35 +00:00
< / div >
{% endfor %}
{% endfor %}
{% for error in form.non_field_errors %}
< div class = "alert alert-danger" >
< strong > {{ error|escape }}< / strong >
< / div >
{% endfor %}
2020-05-19 16:53:54 +00:00
{% endif %}
2018-11-16 13:08:35 +00:00
2021-07-07 11:12:38 +00:00
< div class = "row" >
2018-10-24 13:14:14 +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 float-end" data-bs-toggle = "tab" data-bs-target = "#" type = "button" role = "tab" aria-controls = "go_compute" onclick = "goto_compute()" >
2020-05-19 16:53:54 +00:00
< span class = "fa fa-arrow-left" > < / span >
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 active" data-bs-toggle = "tab" data-bs-target = "#flavor" type = "button" role = "tab" aria-controls = "flavor" aria-selected = "true" >
2018-10-24 13:14:14 +00:00
{% trans "Flavor" %}
2021-07-07 11:12:38 +00:00
< / button >
2018-10-24 13:14:14 +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 = "#addCustom" type = "button" role = "tab" aria-controls = "addCustom" aria-selected = "false" >
2015-03-10 09:15:36 +00:00
{% trans "Custom" %}
2021-07-07 11:12:38 +00:00
< / button >
2018-10-24 13:14:14 +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 = "#addFromTemp" type = "button" role = "tab" aria-controls = "addFromTemp" aria-selected = "false" >
2015-03-10 09:15:36 +00:00
{% trans "Template" %}
2021-07-07 11:12:38 +00:00
< / button >
2018-10-24 13:14:14 +00:00
< / li >
< / ul >
<!-- Tab panes -->
< div class = "tab-content" >
< div role = "tabpanel" class = "tab-pane tab-pane-bordered active" id = "flavor" >
2021-09-13 07:26:42 +00:00
{% include 'create_flav_block.html' %}
< h3 class = "page-header" > {% trans "Create from flavor" %}< / h3 >
2018-10-24 13:14:14 +00:00
{% if not flavors %}
< div class = "col-lg-12" >
2021-07-07 11:12:38 +00:00
< div class = "alert alert-warning shadow-sm" >
2020-05-19 16:53:54 +00:00
< i class = "fa fa-exclamation-triangle" > < / i > < strong > {% trans "Warning" %}:< / strong > {% trans "Hypervisor doesn't have any Flavors" %}
2015-03-10 09:15:36 +00:00
< / div >
< / div >
2018-10-24 13:14:14 +00:00
{% else %}
< div class = "table-responsive" >
2020-07-13 09:33:09 +00:00
< table class = "table table-hover" >
2018-10-24 13:14:14 +00:00
< thead >
< tr >
2020-05-26 10:52:52 +00:00
< th scope = "col" > #< / th >
< th scope = "col" > {% trans "Name" %}< / th >
< th scope = "col" > {% trans "VCPU" %}< / th >
< th scope = "col" > {% trans "RAM" %}< / th >
< th scope = "col" > {% trans "HDD" %}< / th >
< th scope = "colgroup" colspan = "2" > {% trans "Action" %}< / th >
2018-10-24 13:14:14 +00:00
< / tr >
< / thead >
< tbody >
{% for flavor in flavors %}
< tr >
< td > {{ forloop.counter }}< / td >
< td > {{ flavor.label }}< / td >
< td > {{ flavor.vcpu }}< / td >
< td > {{ flavor.memory }} {% trans "MB" %}< / td >
< td > {{ flavor.disk }} {% trans "GB" %}< / td >
< td style = "width:5px;" >
< div class = "modal fade" id = "addVMflavor{{ forloop.counter }}" tabindex = "-1" role = "dialog" aria-labelledby = "addVMFlavorLabel" aria-hidden = "true" >
< div class = "modal-dialog" >
< div class = "modal-content" >
< div class = "modal-header" >
2020-05-19 16:53:54 +00:00
< h5 class = "modal-title" > {% trans "Create Virtual Machine" %} ({{ flavor.label }})< / h5 >
2021-07-07 11:12:38 +00:00
< button type = "button" class = "btn-close" data-bs-dismiss = "modal" aria-label = "Close" > < / button >
2018-10-24 13:14:14 +00:00
< / div >
< div class = "modal-body" >
2020-05-26 13:18:38 +00:00
< form method = "post" role = "form" aria-label = "Create instance from flavor form" > {% csrf_token %}
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-06-12 11:46:17 +00:00
< label class = "col-sm-4 col-form-label" > {% trans "Name" %}< / label >
< div class = "col-sm-7" >
2018-10-24 13:14:14 +00:00
< input type = "text" class = "form-control" name = "name"
2019-11-08 17:07:02 +00:00
placeholder="{% trans "Name" %}" maxlength="64" required
2018-10-24 13:14:14 +00:00
pattern="[a-zA-Z0-9\.\-_]+">
< input type = "hidden" name = "vcpu" value = "{{ flavor.vcpu }}" >
< input type = "hidden" name = "memory" value = "{{ flavor.memory }}" >
< input type = "hidden" name = "hdd_size" value = "{{ flavor.disk }}" >
< / div >
< / div >
2020-05-21 22:13:39 +00:00
{% if firmwares %}
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-06-12 11:46:17 +00:00
< label class = "col-sm-4 col-form-label" > {% trans "Firmware" %}< / label >
< div class = "col-sm-7" >
2021-07-07 11:12:38 +00:00
< select class = "form-select" id = "select_firmware" name = "firmware" >
2019-12-13 13:47:51 +00:00
{% for frm in firmwares %}
2020-03-16 13:59:45 +00:00
< option value = "{{ frm }}" { % if frm in default_firmware % } selected { % endif % } > {{ frm }}< / option >
2019-12-13 13:47:51 +00:00
{% endfor %}
< / select >
< / div >
< / div >
{% endif %}
{% if dom_caps.cpu_modes %}
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-06-12 11:46:17 +00:00
< label class = "col-sm-4 col-form-label" > {% trans "VCPU Config" %}< / label >
< div class = "col-sm-7" >
2021-07-07 11:12:38 +00:00
< select class = "form-select" id = "vcpu_mode" name = "vcpu_mode" >
2020-05-21 13:11:28 +00:00
< option value = "" > {% trans 'no-mode' %}< / option >
{% for mode in dom_caps.cpu_modes %}
{% if mode == 'custom' %}
< optgroup label = "Custom CPU Models" >
{% for model in dom_caps.cpu_custom_models %}
< option value = "{{ model }}" > {% trans model %}< / option >
{% endfor %}
< / optgroup >
{% else %}
2020-06-04 12:40:57 +00:00
< option value = "{{ mode }}" { % if mode = = default_cpu_mode % } selected { % endif % } >
2020-05-21 13:11:28 +00:00
{% trans mode %}
< / option >
{% endif %}
{% endfor %}
< / select >
2019-12-13 13:47:51 +00:00
< / div >
< / div >
{% endif %}
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-06-12 11:46:17 +00:00
< label class = "col-sm-4 col-form-label" > {% trans "Storage" %}< / label >
< div class = "col-sm-7" >
2018-10-24 13:14:14 +00:00
< input type = "hidden" name = "cache_mode" value = "default" >
2021-07-07 11:12:38 +00:00
< select class = "form-select" name = "storage" >
2018-10-24 13:14:14 +00:00
{% if storages %}
{% for storage in storages %}
< option value = "{{ storage }}" > {{ storage }}< / option >
{% endfor %}
{% else %}
< option value = "" > {% trans "None" %}< / option >
{% endif %}
< / select >
< / div >
< / div >
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-06-12 11:46:17 +00:00
< label class = "col-sm-4 col-form-label" > {% trans "Network" %}< / label >
< div class = "col-sm-7" >
2021-07-07 11:12:38 +00:00
< select class = "form-select" name = "networks" >
2018-10-24 13:14:14 +00:00
{% for network in networks %}
< option value = "{{ network }}" > {{ network }}< / option >
{% endfor %}
< / select >
< / div >
< / div >
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-06-12 11:46:17 +00:00
< label class = "col-sm-4 col-form-label" > {% trans "Advanced" %}< / label >
2021-07-07 11:12:38 +00:00
< div class = "d-grid col-sm-7" >
< button class = "btn btn-outline-light" type = "button" data-bs-toggle = "collapse" data-bs-target = "#flavAddCollapse" aria-expanded = "false" aria-controls = "flavAddCollapse" >
2020-05-21 13:11:28 +00:00
< span class = "fa fa-caret-down" > < / span >
< / button >
< / div >
2018-10-24 13:14:14 +00:00
< / div >
2020-05-21 13:11:28 +00:00
< div class = "collapse" id = "flavAddCollapse" >
2021-12-03 13:41:50 +00:00
< div class = "row" >
< label class = "col-sm-4 col-form-label" > {% trans "MAC" %}< / label >
< div class = "col-sm-7" >
< input type = "text" class = "form-control" name = "mac" maxlength = "17" value = "{{ mac_auto }}" required pattern = "[a-zA-Z0-9:]+" >
< / div >
< / div >
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-06-12 11:46:17 +00:00
< label class = "col-sm-4 col-form-label" > {% trans "NWFilter" %}< / label >
< div class = "col-sm-7" >
2021-07-07 11:12:38 +00:00
< select class = "form-select" name = "nwfilter" >
2020-05-21 13:11:28 +00:00
< option value = "" > {% trans "None" %}< / option >
{% for nwfilter in nwfilters %}
< option value = "{{ nwfilter }}" > {{ nwfilter }}< / option >
{% endfor %}
< / select >
< / div >
2018-10-24 13:14:14 +00:00
< / div >
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-06-12 11:46:17 +00:00
< label class = "col-sm-4 col-form-label" > {% trans "HDD cache mode" %}< / label >
< div class = "col-sm-7" >
2021-07-07 11:12:38 +00:00
< select class = "form-select" id = "cache_mode" name = "cache_mode" >
2020-05-21 13:11:28 +00:00
{% for mode, name in cache_modes %}
2020-05-28 21:43:26 +00:00
< option value = "{{ mode }}" { % if mode = = default_cache % } selected { % endif % } >
2020-05-21 13:11:28 +00:00
{% trans name %}< / option >
{% endfor %}
< / select >
< / div >
2019-12-13 13:47:51 +00:00
< / div >
2020-05-21 13:11:28 +00:00
{% if dom_caps.graphics_support == 'yes' %}
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-06-12 11:46:17 +00:00
< label class = "col-sm-4 col-form-label" > {% trans "Graphics" %}< / label >
< div class = "col-sm-7" >
2021-07-07 11:12:38 +00:00
< select class = "form-select" name = "graphics" >
2020-05-21 13:11:28 +00:00
{% for graphics in dom_caps.graphics_types %}
< option value = "{{ graphics }}" { % if default_graphics = = graphics % } selected { % endif % } > {{ graphics }}< / option >
{% endfor %}
< / select >
< / div >
2018-10-24 13:14:14 +00:00
< / div >
2020-05-21 13:11:28 +00:00
{% endif %}
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-06-12 11:46:17 +00:00
< label class = "col-sm-4 col-form-label" > {% trans "Video" %}< / label >
< div class = "col-sm-7" >
2021-07-07 11:12:38 +00:00
< select class = "form-select" name = "video" >
2020-05-21 13:11:28 +00:00
{% if not videos %}
< option value = "vga" > vga< / option >
< option value = "cirrus" > cirrus< / option >
{% endif %}
{% for video in videos %}
< option value = "{{ video }}" > {{ video }}< / option >
{% endfor %}
< / select >
< / div >
2020-05-19 16:53:54 +00:00
< / div >
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-06-12 11:46:17 +00:00
< label class = "col-sm-4 col-form-label" > {% trans "Console Access" %}< / label >
< div class = "col-sm-7" >
2021-07-07 11:12:38 +00:00
< select class = "form-select" name = "listener_addr" >
2020-05-21 13:11:28 +00:00
{% for addr, label in listener_addr %}
< option value = "{{ addr }}" { % if addr = = " 0 . 0 . 0 . 0 " % } selected { % endif % } > {{ label }}< / option >
{% endfor %}
< / select >
< / div >
2018-11-26 12:40:02 +00:00
< / div >
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-06-12 11:46:17 +00:00
< label class = "col-sm-4 col-form-label" > {% trans "Console Password" %}< / label >
< div class = "col-sm-7" >
< input class = "form-control" type = "password" name = "console_pass" placeholder = "{% trans " Console Password " % } " maxlength = "64" >
2020-05-21 13:11:28 +00:00
< / div >
2018-10-24 13:14:14 +00:00
< / div >
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-06-12 11:46:17 +00:00
< label class = "col-sm-4 col-form-label" > {% trans "Guest Agent" %}< / label >
< div class = "col-sm-7" >
2020-05-21 13:11:28 +00:00
< input type = "checkbox" name = "qemu_ga" value = "true" checked >
< / div >
< / div >
{% if virtio_support %}
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-06-12 11:46:17 +00:00
< label class = "col-sm-4 col-form-label" > {% trans "VirtIO" %}< / label >
< div class = "col-sm-7" >
2020-05-21 13:11:28 +00:00
< input type = "checkbox" name = "virtio" value = "{{ virtio_support }}" checked >
< / div >
< / div >
{% endif %}
2018-10-24 13:14:14 +00:00
< / div >
< / div >
< div class = "modal-footer" >
2021-07-07 11:12:38 +00:00
< button type = "button" class = "btn btn-secondary" data-bs-dismiss = "modal" > {% trans "Close" %}< / button >
2018-10-24 13:14:14 +00:00
{% if storages %}
< button type = "submit" class = "btn btn-primary" name = "create" > {% trans "Create" %}< / button >
{% else %}
< button class = "btn btn-primary disabled" > {% trans "Create" %}< / button >
{% endif %}
< / div >
2020-05-21 13:11:28 +00:00
< / form >
2018-10-24 13:14:14 +00:00
< / div >
< / div >
< / div >
2021-07-07 11:12:38 +00:00
< a data-bs-toggle = "modal" href = "#addVMflavor{{ forloop.counter }}" class = "btn btn-sm btn-secondary" >
2020-05-19 16:53:54 +00:00
< span class = "fa fa-plus" > < / span >
2018-10-24 13:14:14 +00:00
< / a >
< / td >
< td style = "width:5px;" >
2020-07-13 09:33:09 +00:00
< form action = "{% url 'instances:flavor_delete' flavor.id %}" method = "post" role = "form" aria-label = "Delete flavor form" >
{% csrf_token %}
2020-05-19 16:53:54 +00:00
< button type = "submit" class = "btn btn-sm btn-secondary" name = "delete_flavor" onclick = "return confirm('{% trans " Are you sure ? " % } ' ) " >
2020-07-13 09:33:09 +00:00
{% icon 'trash' %}
2018-10-24 13:14:14 +00:00
< / button >
< / form >
< / td >
< / tr >
{% endfor %}
< / tbody >
< / table >
< / div >
2018-11-16 13:08:35 +00:00
{% endif %}
< div class = "clearfix" > < / div >
< / div >
2018-10-24 13:14:14 +00:00
< div role = "tabpanel" class = "tab-pane tab-pane-bordered" id = "addCustom" >
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 custom instance form" > {% csrf_token %}
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 16:53:54 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "Name" %}< / label >
2018-11-23 12:20:51 +00:00
< div class = "col-sm-7" >
2019-11-08 17:07:02 +00:00
< input type = "text" class = "form-control" name = "name" placeholder = "{% trans " Name " % } " maxlength = "64" required pattern = "[a-zA-Z0-9\.\-_]+" >
2018-10-24 13:14:14 +00:00
< / div >
< / div >
2019-12-13 13:47:51 +00:00
{% if firmwares %}
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 16:53:54 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "Firmware" %}< / label >
2019-12-13 13:47:51 +00:00
< div class = "col-sm-7" >
2021-07-07 11:12:38 +00:00
< select class = "form-select" id = "select_firmware" name = "firmware" >
2019-12-13 13:47:51 +00:00
{% for frm in firmwares %}
< option value = "{{ frm }}" { % if frm = = default_firmware % } selected { % endif % } > {{ frm }}< / option >
{% endfor %}
< / select >
< / div >
< / div >
{% endif %}
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 16:53:54 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "VCPU" %}< / label >
2018-11-23 12:20:51 +00:00
< div class = "col-sm-7" >
2018-11-16 13:08:35 +00:00
< input type = "text" class = "form-control" name = "vcpu" value = "1" maxlength = "2" required pattern = "[0-9]" >
2018-10-24 13:14:14 +00:00
< / div >
< / div >
2019-12-13 13:47:51 +00:00
{% if dom_caps.cpu_modes %}
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 16:53:54 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "VCPU Config" %}< / label >
2018-11-23 12:20:51 +00:00
< div class = "col-sm-7" >
2021-07-07 11:12:38 +00:00
< select class = "form-select" id = "vcpu_mode" name = "vcpu_mode" >
2019-12-13 13:47:51 +00:00
< option value = "" > {% trans 'no-mode' %}< / option >
{% for mode in dom_caps.cpu_modes %}
{% if mode == 'custom' %}
< optgroup label = "Custom CPU Models" >
{% for model in dom_caps.cpu_custom_models %}
< option value = "{{ model }}" > {% trans model %}< / option >
{% endfor %}
< / optgroup >
{% else %}
2020-06-04 12:40:57 +00:00
< option value = "{{ mode }}" { % if mode = = default_cpu_mode % } selected { % endif % } >
2019-12-13 13:47:51 +00:00
{% trans mode %}
< / option >
{% endif %}
{% endfor %}
< / select >
2018-10-24 13:14:14 +00:00
< / div >
< / div >
2019-12-13 13:47:51 +00:00
{% endif %}
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 16:53:54 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "RAM" %}< / label >
2018-11-23 12:20:51 +00:00
< div class = "col-sm-7" >
2018-10-24 13:14:14 +00:00
< input type = "text" class = "form-control" name = "memory" value = "512" maxlength = "5" required pattern = "[0-9]+" >
< / div >
2020-05-19 16:53:54 +00:00
< label class = "col-sm-1 col-form-label" > {% trans "MB" %}< / label >
2018-10-24 13:14:14 +00:00
< / div >
2021-07-07 11:12:38 +00:00
< div id = "disk_list_div" class = "row d-none" >
< label class = "col-sm-3 col-form-label" id = "added_disks" > {% trans "Added Disks" %}< / label >
2018-11-23 12:20:51 +00:00
< div class = "col-sm-7" >
2021-07-07 11:12:38 +00:00
< ul id = "img-list" class = "row" >
2018-11-16 13:08:35 +00:00
<!-- populated from javascript -->
< / ul >
< / div >
< / div >
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 16:53:54 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "HDD" %}< / label >
2018-11-16 13:08:35 +00:00
< input id = "images" name = "images" type = "hidden" value = "" / >
< div class = "col-sm-3" >
2021-07-07 11:12:38 +00:00
< select class = "form-select" id = "storage-control" name = "storage-control" onchange = "get_cust_vols({{ compute_id }}, value);" >
2018-11-16 13:08:35 +00:00
{% if storages %}
2020-05-21 22:13:39 +00:00
< option value disabled selected > {% trans "Select pool" %}...< / option >
2018-11-16 13:08:35 +00:00
{% for storage in storages %}
< option value = "{{ storage }}" > {{ storage }}< / option >
2018-10-24 13:14:14 +00:00
{% endfor %}
{% else %}
< option value = "" > {% trans "None" %}< / option >
{% endif %}
< / select >
< / div >
2018-11-23 12:20:51 +00:00
< div class = "col-sm-4" >
2021-07-07 11:12:38 +00:00
< select class = "form-select" id = "image-control" name = "image-control" multiple = "multiple" >
2018-11-16 13:08:35 +00:00
<!-- populated from javascript -->
< / select >
< / div >
2018-10-24 13:14:14 +00:00
< / div >
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 16:53:54 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "Network" %}< / label >
2018-11-23 12:20:51 +00:00
< div class = "col-sm-7" >
2018-10-24 13:14:14 +00:00
< ul id = "net-list" >
<!-- populated from javascript -->
< / ul >
< input id = "networks" type = "hidden" name = "networks" value = "" / >
2021-07-07 11:12:38 +00:00
< select class = "form-select" id = "network-control" name = "network-control" multiple = "multiple" >
2018-10-24 13:14:14 +00:00
{% for network in networks %}
< option value = "{{ network }}" > {{ network }}< / option >
{% endfor %}
< / select >
< / div >
2021-12-03 13:41:50 +00:00
< input id = "mac" type = "hidden" name = "mac" value = "" / >
2018-10-24 13:14:14 +00:00
< / div >
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 20:01:37 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "Advanced" %}< / label >
2021-07-07 11:12:38 +00:00
< div class = "d-grid col-sm-7" >
< button class = "btn btn-outline-light" type = "button" data-bs-toggle = "collapse" data-bs-target = "#custadvcollapse" aria-expanded = "false" aria-controls = "custadvcollapse" >
2020-05-19 20:01:37 +00:00
< span class = "fa fa-caret-down" > < / span >
< / button >
< / div >
2018-10-24 13:14:14 +00:00
< / div >
2021-07-07 11:12:38 +00:00
< div class = "collapse" id = "custadvcollapse" >
< div class = "row meta-prealloc" >
2020-05-19 20:01:37 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "Disk Metadata" %}< / label >
< div class = "col-sm-7" >
2020-06-10 08:15:14 +00:00
< input type = "checkbox" name = "meta_prealloc" title = "{% trans " Metadata preallocation " % } " value = "true" >
2020-05-19 20:01:37 +00:00
< / div >
< label class = "col-lg-1 col-form-label" > {% trans "Image" %}< / label >
< / div >
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 20:01:37 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "HDD Cache Mode" %}< / label >
2019-12-13 13:47:51 +00:00
< div class = "col-sm-7" >
2021-07-07 11:12:38 +00:00
< select class = "form-select" id = "cache_mode" name = "cache_mode" >
2020-05-19 20:01:37 +00:00
{% for mode, name in cache_modes %}
2020-05-28 21:43:26 +00:00
< option value = "{{ mode }}" { % if mode = = default_cache % } selected { % endif % } >
2020-05-19 20:01:37 +00:00
{% trans name %}< / option >
2019-12-13 13:47:51 +00:00
{% endfor %}
< / select >
< / div >
< / div >
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 20:01:37 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "NWFilter" %}< / label >
< div class = "col-sm-7" >
2021-07-07 11:12:38 +00:00
< select class = "form-select" name = "nwfilter" >
2020-05-19 20:01:37 +00:00
< option value = "" > {% trans "None" %}< / option >
{% for nwfilter in nwfilters %}
< option value = "{{ nwfilter }}" > {{ nwfilter }}< / option >
{% endfor %}
< / select >
< / div >
2018-10-24 13:14:14 +00:00
< / div >
2020-05-19 20:01:37 +00:00
{% if dom_caps.graphics_support == 'yes' %}
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 20:01:37 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "Graphics" %}< / label >
< div class = "col-sm-7" >
2021-07-07 11:12:38 +00:00
< select class = "form-select" name = "graphics" >
2020-05-19 20:01:37 +00:00
{% for graphics in dom_caps.graphics_types %}
< option value = "{{ graphics }}" { % if default_graphics = = graphics % } selected { % endif % } > {{ graphics }}< / option >
{% endfor %}
< / select >
< / div >
< / div >
{% endif %}
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 20:01:37 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "Video" %}< / label >
< div class = "col-sm-7" >
2021-07-07 11:12:38 +00:00
< select class = "form-select" name = "video" >
2020-05-19 20:01:37 +00:00
{% if not videos %}
< option value = "vga" > vga< / option >
< option value = "cirrus" > cirrus< / option >
{% endif %}
{% for video in videos %}
< option value = "{{ video }}" > {{ video }}< / option >
{% endfor %}
< / select >
< / div >
2018-10-24 13:14:14 +00:00
< / div >
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 20:01:37 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "Console Access" %}< / label >
< div class = "col-sm-7" >
2021-07-07 11:12:38 +00:00
< select class = "form-select" name = "listener_addr" >
2020-05-19 20:01:37 +00:00
{% for addr, label in listener_addr %}
< option value = "{{ addr }}" { % if addr = = " 0 . 0 . 0 . 0 " % } selected { % endif % } > {{ label }}< / option >
{% endfor %}
< / select >
< / div >
2020-05-19 16:53:54 +00:00
< / div >
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 20:01:37 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "Console Password" %}< / label >
< div class = "col-sm-7" >
< input type = "password" class = "form-control" name = "console_pass" placeholder = "{% trans " Console Password " % } " maxlength = "64" >
< / div >
2018-11-26 12:40:02 +00:00
< / div >
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 20:01:37 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "Guest Agent" %}< / label >
< div class = "col-sm-6" >
< input type = "checkbox" name = "qemu_ga" value = "true" checked >
< / div >
< / div >
{% if virtio_support %}
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 20:01:37 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "VirtIO" %}< / label >
< div class = "col-sm-6" >
< input type = "checkbox" name = "virtio" value = "{{ virtio_support }}" checked >
< / div >
2018-10-24 13:14:14 +00:00
< / div >
2020-05-19 20:01:37 +00:00
{% endif %}
2018-10-24 13:14:14 +00:00
< / div >
2021-07-07 11:12:38 +00:00
< div class = "row" >
< div class = "d-grid col-sm-7 offset-3" >
2020-05-19 20:01:37 +00:00
{% if storages %}
2021-07-07 11:12:38 +00:00
< button type = "submit" class = "btn btn-primary" name = "create" formnovalidate onclick = "showPleaseWaitDialog()" value = "1" >
2020-05-19 20:01:37 +00:00
{% trans "Create" %}
< / button >
{% else %}
2021-07-07 11:12:38 +00:00
< button class = "btn btn-primary disabled" >
2020-05-19 20:01:37 +00:00
{% trans "Create" %}
< / button >
{% endif %}
< / div >
2020-05-19 16:53:54 +00:00
< / div >
2018-10-24 13:14:14 +00:00
< / form >
< / div >
< div class = "clearfix" > < / div >
< / div >
< div role = "tabpanel" class = "tab-pane tab-pane-bordered" id = "addFromTemp" >
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 from template form" > {% csrf_token %}
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 16:53:54 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "Name" %}< / label >
2018-11-23 12:20:51 +00:00
< div class = "col-sm-7" >
2019-11-08 17:07:02 +00:00
< input type = "text" class = "form-control" name = "name" placeholder = "{% trans " Name " % } " maxlength = "64" required pattern = "[a-zA-Z0-9\.\-_]+" >
2015-03-10 09:15:36 +00:00
< / div >
2018-10-24 13:14:14 +00:00
< / div >
2019-12-13 13:47:51 +00:00
{% if firmwares %}
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 16:53:54 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "Firmware" %}< / label >
2019-12-13 13:47:51 +00:00
< div class = "col-sm-7" >
2021-07-07 11:12:38 +00:00
< select class = "form-select" id = "select_firmware" name = "firmware" >
2019-12-13 13:47:51 +00:00
{% for frm in firmwares %}
< option value = "{{ frm }}" { % if frm = = default_firmware % } selected { % endif % } > {{ frm }}< / option >
{% endfor %}
< / select >
< / div >
< / div >
{% endif %}
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 16:53:54 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "VCPU" %}< / label >
2018-11-23 12:20:51 +00:00
< div class = "col-sm-7" >
2018-11-16 13:08:35 +00:00
< input type = "text" class = "form-control" name = "vcpu" value = "1" maxlength = "2" required pattern = "[0-9]" >
2015-03-10 09:15:36 +00:00
< / div >
2018-10-24 13:14:14 +00:00
< / div >
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 16:53:54 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "VCPU Config" %}< / label >
2018-11-23 12:20:51 +00:00
< div class = "col-sm-7" >
2021-07-07 11:12:38 +00:00
< select class = "form-select" id = "vcpu_mode" name = "vcpu_mode" >
2019-12-13 13:47:51 +00:00
< option value = "" > {% trans 'no-mode' %}< / option >
{% for mode in dom_caps.cpu_modes %}
{% if mode == 'custom' %}
< optgroup label = "Custom CPU Models" >
{% for model in dom_caps.cpu_custom_models %}
< option value = "{{ model }}" > {% trans model %}< / option >
{% endfor %}
< / optgroup >
{% else %}
2020-06-04 12:40:57 +00:00
< option value = "{{ mode }}" { % if mode = = default_cpu_mode % } selected { % endif % } >
2019-12-13 13:47:51 +00:00
{% trans mode %}
< / option >
{% endif %}
{% endfor %}
< / select >
2015-03-10 09:15:36 +00:00
< / div >
2018-10-24 13:14:14 +00:00
< / div >
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 16:53:54 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "RAM" %}< / label >
2018-11-23 12:20:51 +00:00
< div class = "col-sm-7" >
2018-10-24 13:14:14 +00:00
< input type = "text" class = "form-control" name = "memory" value = "512" maxlength = "5" required pattern = "[0-9]+" >
2016-04-21 10:14:20 +00:00
< / div >
2020-05-19 16:53:54 +00:00
< label class = "col-sm-1 col-form-label" > {% trans "MB" %}< / label >
2018-10-24 13:14:14 +00:00
< / div >
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 16:53:54 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "Template Disk" %}< / label >
2018-11-16 13:08:35 +00:00
< input id = "images" name = "images" type = "hidden" value = "" / >
< div class = "col-sm-3" >
2021-07-07 11:12:38 +00:00
< select class = "form-select" onchange = "get_template_vols({{ compute_id }}, value);" >
2018-11-16 13:08:35 +00:00
{% if storages %}
< option value disabled selected > {% trans "Select pool" %}...< / option >
{% for storage in storages %}
< option value = "{{ storage }}" > {{ storage }}< / option >
2016-04-17 21:41:40 +00:00
{% endfor %}
2018-10-24 13:14:14 +00:00
{% else %}
< option value = "" > {% trans "None" %}< / option >
{% endif %}
< / select >
2016-04-17 21:41:40 +00:00
< / div >
2018-11-23 12:20:51 +00:00
< div class = "col-sm-4" >
2021-07-07 11:12:38 +00:00
< select class = "form-select" id = "template" name = "template" disabled >
2018-11-16 13:08:35 +00:00
<!-- populated from javascript -->
< / select >
< / div >
2018-10-24 13:14:14 +00:00
< / div >
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 16:53:54 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "Storage" %}< / label >
2019-01-09 11:16:51 +00:00
< div class = "col-sm-7" >
2021-07-07 11:12:38 +00:00
< select class = "form-select" id = "storage" name = "storage" disabled >
2019-01-09 11:16:51 +00:00
{% if storages %}
{% for storage in storages %}
< option value = "{{ storage }}" > {{ storage }}< / option >
{% endfor %}
{% else %}
< option value = "" > {% trans "None" %}< / option >
{% endif %}
< / select >
< / div >
< / div >
2021-07-07 11:12:38 +00:00
< div class = "row" >
2021-12-03 13:41:50 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "Network/MAC" %}< / label >
< div class = "col-sm-3" >
2021-07-07 11:12:38 +00:00
< select class = "form-select" name = "networks" >
2018-10-24 13:14:14 +00:00
{% for network in networks %}
< option value = "{{ network }}" > {{ network }}< / option >
{% endfor %}
< / select >
2018-09-17 07:55:05 +00:00
< / div >
2021-12-03 13:41:50 +00:00
< div class = "col-sm-4" >
< input type = "text" class = "form-control" name = "mac" maxlength = "17" value = "{{ mac_auto }}" required pattern = "[a-zA-Z0-9:]+" >
< / div >
2018-10-24 13:14:14 +00:00
< / div >
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 20:01:37 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "Advanced" %}< / label >
2021-07-07 11:12:38 +00:00
< div class = "d-grid col-sm-7" >
< button class = "btn btn-outline-light" type = "button" data-bs-toggle = "collapse" data-bs-target = "#tempAdvCollapse" aria-expanded = "false" aria-controls = "tempAdvCollapse" >
2020-05-19 20:01:37 +00:00
< span class = "fa fa-caret-down" > < / span >
< / button >
< / div >
< / div >
< div class = "collapse" id = "tempAdvCollapse" >
2021-07-07 11:12:38 +00:00
< div class = "row meta-prealloc" >
2020-05-19 20:01:37 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "Disk Metadata" %}< / label >
< div class = "col-sm-7" >
2020-05-20 13:18:27 +00:00
< input type = "checkbox" name = "meta_prealloc" title = "{% trans " Metadata preallocation " % } " value = "true" >
2020-05-19 20:01:37 +00:00
< / div >
< label class = "col-lg-1 col-form-label" > {% trans "Image" %}< / label >
2018-09-17 07:55:05 +00:00
< / div >
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 20:01:37 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "HDD cache mode" %}< / label >
< div class = "col-sm-7" >
2021-07-07 11:12:38 +00:00
< select class = "form-select" id = "cache_mode" name = "cache_mode" >
2020-05-19 20:01:37 +00:00
{% for mode, name in cache_modes %}
2020-05-28 21:43:26 +00:00
< option value = "{{ mode }}" { % if mode = = default_cache % } selected { % endif % } >
2020-05-19 20:01:37 +00:00
{% trans name %}< / option >
{% endfor %}
< / select >
< / div >
2019-12-13 13:47:51 +00:00
< / div >
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 20:01:37 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "NWFilter" %}< / label >
< div class = "col-sm-7" >
2021-07-07 11:12:38 +00:00
< select class = "form-select" name = "nwfilter" >
2020-05-19 20:01:37 +00:00
< option value = "" > {% trans "None" %}< / option >
{% for nwfilter in nwfilters %}
< option value = "{{ nwfilter }}" > {{ nwfilter }}< / option >
{% endfor %}
< / select >
< / div >
2015-03-10 09:15:36 +00:00
< / div >
2020-05-19 20:01:37 +00:00
{% if dom_caps.graphics_support == 'yes' %}
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 20:01:37 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "Graphics" %}< / label >
< div class = "col-sm-7" >
2021-07-07 11:12:38 +00:00
< select class = "form-select" name = "graphics" >
2020-05-19 20:01:37 +00:00
{% for graphics in dom_caps.graphics_types %}
< option value = "{{ graphics }}" { % if default_graphics = = graphics % } selected { % endif % } > {{ graphics }}< / option >
{% endfor %}
< / select >
< / div >
2018-10-24 13:14:14 +00:00
< / div >
2020-05-19 20:01:37 +00:00
{% endif %}
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 20:01:37 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "Video" %}< / label >
< div class = "col-sm-7" >
2021-07-07 11:12:38 +00:00
< select class = "form-select" name = "video" >
2020-05-19 20:01:37 +00:00
{% if not videos %}
< option value = "vga" > vga< / option >
< option value = "cirrus" > cirrus< / option >
{% endif %}
{% for video in videos %}
< option value = "{{ video }}" > {{ video }}< / option >
{% endfor %}
< / select >
< / div >
2020-05-19 16:53:54 +00:00
< / div >
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 20:01:37 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "Console Access" %}< / label >
< div class = "col-sm-7" >
2021-07-07 11:12:38 +00:00
< select class = "form-select" name = "listener_addr" >
2020-05-19 20:01:37 +00:00
{% for addr, label in listener_addr %}
< option value = "{{ addr }}" { % if addr = = " 0 . 0 . 0 . 0 " % } selected { % endif % } > {{ label }}< / option >
{% endfor %}
< / select >
< / div >
2018-11-26 12:40:02 +00:00
< / div >
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 20:01:37 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "Console Password" %}< / label >
< div class = "col-sm-7" >
< input type = "password" class = "form-control" name = "console_pass" placeholder = "{% trans " Console Password " % } " maxlength = "64" >
< / div >
2018-11-23 12:20:51 +00:00
< / div >
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 20:01:37 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "Guest Agent" %}< / label >
< div class = "col-sm-6" >
< input type = "checkbox" name = "qemu_ga" value = "true" checked >
< / div >
< / div >
{% if virtio_support %}
2021-07-07 11:12:38 +00:00
< div class = "row" >
2020-05-19 20:01:37 +00:00
< label class = "col-sm-3 col-form-label" > {% trans "VirtIO" %}< / label >
< div class = "col-sm-6" >
< input type = "checkbox" name = "virtio" value = "{{ virtio_support }}" checked >
< / div >
< / div >
{% endif %}
2018-11-23 12:20:51 +00:00
< / div >
2021-07-07 11:12:38 +00:00
< div class = "row" >
< div class = "d-grid col-sm-7 offset-3" >
2019-12-13 13:47:51 +00:00
{% if storages %}
2021-07-07 11:12:38 +00:00
< button type = "submit" class = "btn btn-primary" name = "create" value = "1" formnovalidate onclick = "showPleaseWaitDialog()" >
2019-12-13 13:47:51 +00:00
{% trans "Create" %}
< / button >
{% else %}
< button class = "btn btn-primary disabled" >
{% trans "Create" %}
< / button >
{% endif %}
< / div >
2015-03-06 13:46:59 +00:00
< / div >
2018-10-24 13:14:14 +00:00
< / form >
< / div >
< div class = "clearfix" > < / div >
2015-03-06 13:46:59 +00:00
< / div >
2019-07-31 08:03:48 +00:00
< / div > <!-- /Tab panes -->
2018-10-24 13:14:14 +00:00
< / div >
2015-03-06 13:46:59 +00:00
{% endblock %}
{% block script %}
2021-07-07 11:12:38 +00:00
< script src = "{% static 'js/bootstrap-multiselect.js' %}" > < / script >
2015-03-06 13:46:59 +00:00
< script >
function toggleValue(string, updated_value, checked) {
2019-12-13 13:47:51 +00:00
let result = '';
2015-03-06 13:46:59 +00:00
if (checked) {
result = string;
if (result != '') result += ',';
result += updated_value;
} else {
$.each(string.split(','), function (index, value) {
if (value == updated_value) return;
if (result != '') result += ',';
result += value;
});
}
return result;
}
$(document).ready(function () {
2018-11-16 13:08:35 +00:00
$('#image-control').multiselect({
disableIfEmpty: true,
2018-10-31 14:07:39 +00:00
enableCaseInsensitiveFiltering: true,
maxHeight: 400,
inheritClass: true,
2018-11-23 12:20:51 +00:00
buttonWidth:function (options, select) {
return '100%';
},
2015-03-06 13:46:59 +00:00
buttonText: function (options, select) {
2018-11-16 13:08:35 +00:00
return 'Add image...';
2015-03-06 13:46:59 +00:00
},
buttonTitle: function (options, select) {
return '';
},
onChange: function (element, checked) {
2019-12-13 13:47:51 +00:00
let input_value = toggleValue($('#images').val(), element.val(), checked);
2015-03-06 13:46:59 +00:00
$('#images').val(input_value);
2018-11-16 13:08:35 +00:00
2019-12-13 13:47:51 +00:00
let selected_list_html = '';
let counter = 0;
2015-03-06 13:46:59 +00:00
if (input_value != '') {
2020-05-19 16:53:54 +00:00
$('#disk_list_div').removeClass('d-none');
2018-11-16 13:08:35 +00:00
$.each(input_value.split(','), function (index, value) {
2020-05-19 16:53:54 +00:00
var li = '< li > hdd' + counter + ' - ' +
2018-11-23 12:20:51 +00:00
'< select name = "device' + counter + '" class = "image-format" onchange = "get_disk_bus_choices({{ compute_id }},' + counter + ', value);" > ' +
'{% for dev in disk_devices %}' +
'< option value = ' + ' " { { dev } } " > ' + '{% trans dev %}< / option > ' +
'{% endfor %}' +
'< / select > ' +
'< select id = "bus' + counter + '" name = "bus' + counter + '" class = "image-format" > ' +
'{% for bus in disk_buses %}' +
'< option value = ' + ' " { { bus } } " ' +
'{% if bus == default_bus %}selected{% endif %}>' +
'{% trans bus %}< / option > ' +
'{% endfor %}' +
'< / select > ' +
2015-03-06 13:46:59 +00:00
' -> ' + value + ' ' +
2021-07-07 11:12:38 +00:00
'< a class = "btn-link float-end" onclick = "javascript:$(\'#image-control\').multiselect(\'deselect\', \'' + value + '\', true)" > < i class = "fa fa-remove" > < / i > < / a > < / li > ';
2015-03-06 13:46:59 +00:00
selected_list_html += li;
counter++;
});
2018-11-16 13:08:35 +00:00
}else {
2020-05-19 16:53:54 +00:00
$('#disk_list_div').addClass('d-none');
2015-03-06 13:46:59 +00:00
}
$('#img-list').html(selected_list_html);
}
});
2015-03-02 08:52:07 +00:00
2018-11-16 13:08:35 +00:00
2015-03-06 13:46:59 +00:00
$('#network-control').multiselect({
2018-11-07 12:36:03 +00:00
inheritClass: true,
2015-03-06 13:46:59 +00:00
buttonText: function (options, select) {
2018-11-07 12:36:03 +00:00
return 'Add network';
2015-03-06 13:46:59 +00:00
},
buttonTitle: function (options, select) {
return '';
},
2018-11-23 12:20:51 +00:00
buttonWidth:function (options, select) {
return '100%';
},
2015-03-06 13:46:59 +00:00
onChange: function (element, checked) {
2019-12-13 13:47:51 +00:00
let input_value = toggleValue($('#networks').val(), element.val(), checked);
2015-03-06 13:46:59 +00:00
$('#networks').val(input_value);
2019-12-13 13:47:51 +00:00
let selected_list_html = '';
2021-12-03 13:41:50 +00:00
mac_array = [];
net_counter = 0;
2015-03-06 13:46:59 +00:00
if (input_value != '') {
$.each(input_value.split(','), function (index, value) {
2021-12-03 13:41:50 +00:00
let li = '< li > < input type = "text" class = "input-xs" name = "mac'+ net_counter +'" maxlength = "17" required pattern = "[a-zA-Z0-9:]+" onchange = "populate_mac(' + net_counter +')" > ' +
' eth' + net_counter +
2015-03-06 13:46:59 +00:00
' -> ' + value + ' ' +
2021-07-07 11:12:38 +00:00
'< a class = "btn-link float-end" onclick = "$(\'#network-control\').multiselect(\'deselect\', \'' + value + '\', true)" > < i class = "fa fa-remove" > < / i > < / a > < / li > ';
2021-12-03 13:41:50 +00:00
random_mac(net_counter);
2015-03-06 13:46:59 +00:00
selected_list_html += li;
2021-12-03 13:41:50 +00:00
net_counter++;
2015-03-06 13:46:59 +00:00
});
2021-12-03 13:41:50 +00:00
2015-03-06 13:46:59 +00:00
}
$('#net-list').html(selected_list_html);
}
});
});
2018-11-16 13:08:35 +00:00
2021-12-03 13:41:50 +00:00
var mac_array = [];
function random_mac(c) {
$.getJSON("{% url 'instances:random_mac_address' %}", function (data) {
mac_array[c] = data['mac'];
$('input[name="mac' + c + '"').val(data['mac']);
populate_mac(c);
});
}
function populate_mac(c){
mac_array[c] = $('input[name="mac' + c + '"').val();
$('input[name="mac"').val(mac_array.join(","));
}
2019-12-13 13:47:51 +00:00
$("id[vcpu_mode]").multiselect();
2018-11-16 13:08:35 +00:00
function get_cust_vols(compute_id, pool) {
get_vol_url = "/computes/" + compute_id + "/storage/" + pool + "/volumes";
$.getJSON(get_vol_url, function (data) {
$("#image-control").find('option').remove();
$.each(data['vols'], function(i, item) {
$("#image-control").append('< option value = ' + item +' > ' + item + '< / option > ');
});
$('#image-control').multiselect('rebuild');
});
}
function get_template_vols(compute_id, pool) {
get_vol_url = "/computes/" + compute_id + "/storage/" + pool + "/volumes";
$.getJSON(get_vol_url, function (data) {
$("#template").find('option').remove();
$.each(data['vols'], function(i, item) {
$("#template").append('< option value = ' + item +' > ' + item + '< / option > ');
});
});
$("#template").removeAttr("disabled");
2019-01-09 11:16:51 +00:00
$("#storage").val(pool).change();
$("#storage").removeAttr("disabled");
2018-11-16 13:08:35 +00:00
}
2018-11-23 12:20:51 +00:00
2019-06-24 11:26:25 +00:00
function get_disk_bus_choices(compute_id, dev_idx, disk_type){
2019-12-13 13:47:51 +00:00
let arch = $('select[name="arch"]').val();
let machine = $("select[id='machine-control']").val();
get_diskBus_url = "/computes/" + compute_id + "/archs/" + arch + "/machines/" + machine + "/disks/" + disk_type + "/buses";
2018-11-23 12:20:51 +00:00
$.getJSON(get_diskBus_url, function (data) {
$("#bus" + dev_idx).find('option').remove();
$.each(data['bus'], function(i, item) {
$("#bus" + dev_idx).append('< option value = ' + item +' > ' + item + '< / option > ');
});
});
}
2015-03-06 13:46:59 +00:00
< / script >
2019-12-13 13:47:51 +00:00
{% if request.user.is_superuser %}
< script >
function goto_compute() {
2021-12-03 13:41:50 +00:00
let compute = {{ compute.id }};
2020-07-13 09:33:09 +00:00
window.location.href = "{% url 'instances:create_instance_select_type' 1 %}".replace(1, compute);
2019-12-13 13:47:51 +00:00
}
< / script >
{% endif %}
2016-04-21 10:14:20 +00:00
{% endblock %}