From aafd5f3014a29266141cef9dd89d79a6323eda44 Mon Sep 17 00:00:00 2001 From: Frederick Borges Date: Mon, 12 Sep 2022 13:13:44 +0200 Subject: [PATCH] F #5940: Support PCI Network Devices on RSunstone (#2274) The "Hardware" profile of a network interface (NIC) of a VM can be of three types, now exposed in Sunstone: - "Emulated" it includes the hardware model emulated by Qemu - "PCI - Automatic" oned hw scheduler will pick the best PCI device for the NIC - "PCI - Manual" user can specify the PCI device by its short-address as shown in host information This commits also enables the attach/detach operations on PCI based NICs *Note*: only for KVM VMs Signed-off-by: Frederick Borges (cherry picked from commit a3d5d61d4245a7936372e4a6c5dee4b6939f62f4) --- .../create/wizard-tabs/network/nic-tab.js | 61 +++++++++++++------ .../wizard-tabs/network/nic-tab/html.hbs | 16 ++++- .../form-panels/create/wizard-tabs/utils.js | 1 + .../app/tabs/vms-tab/dialogs/attach-nic.js | 31 +++++++--- .../public/app/tabs/vms-tab/panels/network.js | 41 +++++++------ 5 files changed, 101 insertions(+), 49 deletions(-) diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/network/nic-tab.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/network/nic-tab.js index 87e91ac5d1..d5f3a379af 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/network/nic-tab.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/network/nic-tab.js @@ -113,9 +113,10 @@ define(function(require) { var that = this; that.context = context; - if (options != undefined && options.hide_pci == true){ - $("input.pci-type-nic", context).attr('disabled', 'disabled'); - } + //check + // if (options != undefined && options.hide_pci == true){ + // $("select.pci-type-nic", context).attr('disabled', 'disabled'); + // } if (options != undefined && options.hide_auto == true){ $(".only_create", context).hide(); @@ -223,29 +224,48 @@ define(function(require) { options.clustersTable.dataTable.children('tbody').on('click', 'tr', updateRowSelected) } - $("input.pci-type-nic", context).on("change", function(){ + $("select.pci-type-nic", context).on("change", function(){ + var option = $(this).val() var tbody = $(".pci-row tbody", context); - if ($(this).prop('checked')){ - $("input[wizard_field=MODEL]", context).prop("disabled", true).prop('wizard_field_disabled', true); - $(".nic-model-row", context).hide(); - $(".pci-row", context).show(); + switch (option) { + case "emulated": + $("input[wizard_field=MODEL]", context).removeAttr('disabled').prop('wizard_field_disabled', false); + $("input[wizard_field=SHORT_ADDRESS]", context).prop("disabled", true).prop('wizard_field_disabled', true); + $(".nic-model-row", context).show(); + $(".pci-row", context).hide(); + $(".pci-manual-row", context).hide(); - tbody.html( CreateUtils.pciRowHTML() ); + tbody.html(""); + break; + case "pci-auto": + $("input[wizard_field=MODEL]", context).prop("disabled", true).prop('wizard_field_disabled', true); + $("input[wizard_field=SHORT_ADDRESS]", context).prop("disabled", true).prop('wizard_field_disabled', true); + $(".nic-model-row", context).hide(); + $(".pci-row", context).show(); + $(".pci-manual-row", context).hide(); - CreateUtils.fillPCIRow({tr: $('tr', tbody), remove: false}); - } else { - $("input[wizard_field=MODEL]", context).removeAttr('disabled').prop('wizard_field_disabled', false); - $(".nic-model-row", context).show(); - $(".pci-row", context).hide(); + tbody.html( CreateUtils.pciRowHTML() ); - tbody.html(""); + CreateUtils.fillPCIRow({tr: $('tr', tbody), remove: false}); + break; + case "pci-manual": + $("input[wizard_field=MODEL]", context).prop("disabled", true).prop('wizard_field_disabled', true); + $("input[wizard_field=SHORT_ADDRESS]", context).removeAttr('disabled').prop('wizard_field_disabled', false); + $(".nic-model-row", context).hide(); + $(".pci-row", context).hide(); + $(".pci-manual-row", context).show(); + + tbody.html( CreateUtils.pciRowHTML() ); + + CreateUtils.fillPCIRow({tr: $('tr', tbody), remove: false}); + break; } }); CreateUtils.setupPCIRows($(".pci-row", context)); - $("input.pci-type-nic", context).change(); + $("select.pci-type-nic", context).change(); if (!Config.isAdvancedEnabled("show_attach_nic_advanced")){ $("#nic_values", context).hide(); @@ -404,7 +424,7 @@ define(function(require) { nicJSON["SECURITY_GROUPS"] = secgroups.join(","); } - if ($("input.pci-type-nic", context).prop("checked")){ + if (['pci-auto','pci-manual'].includes($("select.pci-type-nic", context).val())){ nicJSON["NIC_PCI"] = true; } @@ -497,7 +517,12 @@ define(function(require) { } if (templateJSON["TYPE"] == "NIC"){ - $("input.pci-type-nic", context).click(); + if (templateJSON["SHORT_ADDRESS"]){ + $("select.pci-type-nic", context).val('pci-manual').change(); + } + else { + $("select.pci-type-nic", context).val('pci-auto').change(); + } } if ( templateJSON["NETWORK_MODE"] && templateJSON["NETWORK_MODE"] === "auto" ) { diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/network/nic-tab/html.hbs b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/network/nic-tab/html.hbs index 88b0a7da55..9bc1acedb0 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/network/nic-tab/html.hbs +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/network/nic-tab/html.hbs @@ -325,9 +325,13 @@
+
@@ -362,6 +366,14 @@
+
+
+ + +
+
{{tr "Security Groups"}} diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/utils.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/utils.js index 6777ddf93a..c4a7c5d3c3 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/utils.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/utils.js @@ -45,6 +45,7 @@ define(function(require) { data : {}, timeout: true, success: function (request, pciDevices){ + console.log(opts) var tr = opts.tr; var html = "