mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-08 21:17:43 +03:00
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 <fborges@opennebula.io> (cherry picked from commit a3d5d61d4245a7936372e4a6c5dee4b6939f62f4)
This commit is contained in:
parent
5b2dc75474
commit
aafd5f3014
@ -113,9 +113,10 @@ define(function(require) {
|
|||||||
var that = this;
|
var that = this;
|
||||||
that.context = context;
|
that.context = context;
|
||||||
|
|
||||||
if (options != undefined && options.hide_pci == true){
|
//check
|
||||||
$("input.pci-type-nic", context).attr('disabled', 'disabled');
|
// if (options != undefined && options.hide_pci == true){
|
||||||
}
|
// $("select.pci-type-nic", context).attr('disabled', 'disabled');
|
||||||
|
// }
|
||||||
|
|
||||||
if (options != undefined && options.hide_auto == true){
|
if (options != undefined && options.hide_auto == true){
|
||||||
$(".only_create", context).hide();
|
$(".only_create", context).hide();
|
||||||
@ -223,29 +224,48 @@ define(function(require) {
|
|||||||
options.clustersTable.dataTable.children('tbody').on('click', 'tr', updateRowSelected)
|
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);
|
var tbody = $(".pci-row tbody", context);
|
||||||
|
|
||||||
if ($(this).prop('checked')){
|
switch (option) {
|
||||||
$("input[wizard_field=MODEL]", context).prop("disabled", true).prop('wizard_field_disabled', true);
|
case "emulated":
|
||||||
$(".nic-model-row", context).hide();
|
$("input[wizard_field=MODEL]", context).removeAttr('disabled').prop('wizard_field_disabled', false);
|
||||||
$(".pci-row", context).show();
|
$("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});
|
tbody.html( CreateUtils.pciRowHTML() );
|
||||||
} 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.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));
|
CreateUtils.setupPCIRows($(".pci-row", context));
|
||||||
|
|
||||||
$("input.pci-type-nic", context).change();
|
$("select.pci-type-nic", context).change();
|
||||||
|
|
||||||
if (!Config.isAdvancedEnabled("show_attach_nic_advanced")){
|
if (!Config.isAdvancedEnabled("show_attach_nic_advanced")){
|
||||||
$("#nic_values", context).hide();
|
$("#nic_values", context).hide();
|
||||||
@ -404,7 +424,7 @@ define(function(require) {
|
|||||||
nicJSON["SECURITY_GROUPS"] = secgroups.join(",");
|
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;
|
nicJSON["NIC_PCI"] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -497,7 +517,12 @@ define(function(require) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (templateJSON["TYPE"] == "NIC"){
|
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" ) {
|
if ( templateJSON["NETWORK_MODE"] && templateJSON["NETWORK_MODE"] === "auto" ) {
|
||||||
|
@ -325,9 +325,13 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="small-12 columns">
|
<div class="small-12 columns">
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" class="pci-type-nic"/>
|
{{tr "Virtual NIC hardware mode"}}
|
||||||
{{tr "PCI passthrough"}}
|
|
||||||
</label>
|
</label>
|
||||||
|
<select class="pci-type-nic">
|
||||||
|
<option value="emulated">{{tr "Emulated"}}</option>
|
||||||
|
<option value="pci-auto">{{tr "PCI passthrough - Automatic"}}</option>
|
||||||
|
<option value="pci-manual">{{tr "PCI passthrough - Manual"}}</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row nic-model-row">
|
<div class="row nic-model-row">
|
||||||
@ -362,6 +366,14 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row pci-manual-row">
|
||||||
|
<div class="medium-6 columns not_lxc">
|
||||||
|
<label for="SHORT_ADDRESS">
|
||||||
|
{{tr "Short address"}}
|
||||||
|
</label>
|
||||||
|
<input type="text" wizard_field="SHORT_ADDRESS" id="SHORT_ADDRESS" name="SHORT_ADDRESS" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>{{tr "Security Groups"}}</legend>
|
<legend>{{tr "Security Groups"}}</legend>
|
||||||
|
@ -45,6 +45,7 @@ define(function(require) {
|
|||||||
data : {},
|
data : {},
|
||||||
timeout: true,
|
timeout: true,
|
||||||
success: function (request, pciDevices){
|
success: function (request, pciDevices){
|
||||||
|
console.log(opts)
|
||||||
var tr = opts.tr;
|
var tr = opts.tr;
|
||||||
|
|
||||||
var html = "<select>";
|
var html = "<select>";
|
||||||
|
@ -94,17 +94,30 @@ define(function(require) {
|
|||||||
templateJSON.RDP = "YES";
|
templateJSON.RDP = "YES";
|
||||||
}
|
}
|
||||||
|
|
||||||
if($("#cb_attach_alias", context).prop("checked")) {
|
var obj = undefined
|
||||||
templateJSON.PARENT = $("#parent").val();
|
|
||||||
|
if (['pci-auto','pci-manual'].includes($("select.pci-type-nic", context).val())){
|
||||||
var obj = {
|
var pciObj = $.extend({
|
||||||
"NIC_ALIAS": templateJSON
|
'TYPE': 'NIC',
|
||||||
};
|
}, templateJSON);
|
||||||
} else {
|
|
||||||
var obj = {
|
obj = {
|
||||||
"NIC": templateJSON
|
"PCI": pciObj
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
if($("#cb_attach_alias", context).prop("checked")) {
|
||||||
|
templateJSON.PARENT = $("#parent").val();
|
||||||
|
|
||||||
|
obj = {
|
||||||
|
"NIC_ALIAS": templateJSON
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
obj = {
|
||||||
|
"NIC": templateJSON
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(selectedNetwork){
|
if(selectedNetwork){
|
||||||
Sunstone.runAction("VM.attachnic", that.element.ID, obj);
|
Sunstone.runAction("VM.attachnic", that.element.ID, obj);
|
||||||
|
@ -313,29 +313,30 @@ define(function(require) {
|
|||||||
var is_pci = (nic.PCI_ID != undefined);
|
var is_pci = (nic.PCI_ID != undefined);
|
||||||
|
|
||||||
var actions = "";
|
var actions = "";
|
||||||
|
|
||||||
// Attach / Detach
|
// Attach / Detach
|
||||||
if (!is_pci){
|
if (
|
||||||
if (
|
that.element.STATE == OpenNebulaVM.STATES.ACTIVE && (
|
||||||
that.element.STATE == OpenNebulaVM.STATES.ACTIVE && (
|
that.element.LCM_STATE == OpenNebulaVM.LCM_STATES.HOTPLUG_NIC ||
|
||||||
that.element.LCM_STATE == OpenNebulaVM.LCM_STATES.HOTPLUG_NIC ||
|
that.element.LCM_STATE == OpenNebulaVM.LCM_STATES.HOTPLUG_NIC_POWEROFF
|
||||||
that.element.LCM_STATE == OpenNebulaVM.LCM_STATES.HOTPLUG_NIC_POWEROFF
|
)
|
||||||
)
|
) {
|
||||||
) {
|
actions = Locale.tr("attach/detach in progress");
|
||||||
actions = Locale.tr("attach/detach in progress");
|
} else {
|
||||||
} else {
|
|
||||||
|
|
||||||
if(Config.isTabActionEnabled("vms-tab", "VM.detachnic")){
|
if(Config.isTabActionEnabled("vms-tab", "VM.detachnic")){
|
||||||
var icon = $("<i/>",{class:"fas fa-times"});
|
var icon = $("<i/>",{class:"fas fa-times"});
|
||||||
var anchorAttributes = {class: "detachnic", href: "VM.detachnic"};
|
var anchorAttributes = {class: "detachnic", href: "VM.detachnic"};
|
||||||
var anchor = $("<a/>",anchorAttributes).append(icon); //"<a href=\"VM.detachnic\" class=\"detachnic\" ><i class=\"fas fa-times\"/></a>";
|
var anchor = $("<a/>",anchorAttributes).append(icon); //"<a href=\"VM.detachnic\" class=\"detachnic\" ><i class=\"fas fa-times\"/></a>";
|
||||||
actions += (validateAction(that,"VM.detachnic"))
|
actions += (validateAction(that,"VM.detachnic"))
|
||||||
? (isFirecracker(that)
|
? (isFirecracker(that)
|
||||||
? (isPowerOff(that) ? anchor.get(0).outerHTML : "")
|
? (isPowerOff(that) ? anchor.get(0).outerHTML : "")
|
||||||
: anchor.get(0).outerHTML
|
: anchor.get(0).outerHTML
|
||||||
)
|
)
|
||||||
: "";
|
: "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!is_pci){
|
||||||
if(Config.isTabActionEnabled("vms-tab", "VM.attachsg")){
|
if(Config.isTabActionEnabled("vms-tab", "VM.attachsg")){
|
||||||
var icon = $("<i/>",{class:"fas fa-shield-alt"});
|
var icon = $("<i/>",{class:"fas fa-shield-alt"});
|
||||||
var anchorAttributes = {class: "attachsg", style: "padding-left: 1em"};
|
var anchorAttributes = {class: "attachsg", style: "padding-left: 1em"};
|
||||||
|
Loading…
Reference in New Issue
Block a user