From c354393685fac4ce98ada04ba18252c2f19581ab Mon Sep 17 00:00:00 2001 From: catborise Date: Fri, 3 Dec 2021 16:41:50 +0300 Subject: [PATCH] add MAC address inputs for instance create methods --- instances/templates/create_instance_w2.html | 46 +++++++++++++++------ static/css/webvirtcloud.css | 8 ++++ vrtManager/create.py | 6 ++- 3 files changed, 46 insertions(+), 14 deletions(-) diff --git a/instances/templates/create_instance_w2.html b/instances/templates/create_instance_w2.html index 2c314bf..499dd3e 100644 --- a/instances/templates/create_instance_w2.html +++ b/instances/templates/create_instance_w2.html @@ -178,6 +178,12 @@
+
+ +
+ +
+
@@ -200,12 +206,6 @@
-
- -
- -
-
{% if dom_caps.graphics_support == 'yes' %}
@@ -396,6 +396,7 @@ {% endfor %}
+
@@ -601,14 +602,17 @@
- -
+ +
+
+ +
@@ -810,21 +814,39 @@ let input_value = toggleValue($('#networks').val(), element.val(), checked); $('#networks').val(input_value); let selected_list_html = ''; - let counter = 0; + mac_array = []; + net_counter = 0; if (input_value != '') { $.each(input_value.split(','), function (index, value) { - let li = '
  • eth' + counter + + let li = '
  • ' + + ' eth' + net_counter + ' -> ' + value + ' ' + '
  • '; + random_mac(net_counter); selected_list_html += li; - counter++; + net_counter++; }); + } $('#net-list').html(selected_list_html); } }); }); + 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(",")); + } + $("id[vcpu_mode]").multiselect(); function get_cust_vols(compute_id, pool) { @@ -866,7 +888,7 @@ {% if request.user.is_superuser %} diff --git a/static/css/webvirtcloud.css b/static/css/webvirtcloud.css index d1fbdf7..5767098 100644 --- a/static/css/webvirtcloud.css +++ b/static/css/webvirtcloud.css @@ -173,3 +173,11 @@ p { a { outline: 0; } + +.input-xs { + height: 22px; + padding: 2px 5px; + font-size: 12px; + line-height: 1.5; /* If Placeholder of the input is moved up, rem/modify this. */ + border-radius: 2px; + } \ No newline at end of file diff --git a/vrtManager/create.py b/vrtManager/create.py index 9cdaca4..fcae692 100644 --- a/vrtManager/create.py +++ b/vrtManager/create.py @@ -338,10 +338,12 @@ class wvmCreate(wvmConnect): xml += """""" % (vd_disk_letters.pop(0), "virtio") xml += """""" - for net in networks.split(","): + if mac: + macs = mac.split(',') + for idx, net in enumerate(networks.split(",")): xml += """""" if mac: - xml += f"""""" + xml += f"""""" xml += f"""""" if nwfilter: xml += f""""""