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;
|
||||
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" ) {
|
||||
|
@ -325,9 +325,13 @@
|
||||
<div class="row">
|
||||
<div class="small-12 columns">
|
||||
<label>
|
||||
<input type="checkbox" class="pci-type-nic"/>
|
||||
{{tr "PCI passthrough"}}
|
||||
{{tr "Virtual NIC hardware mode"}}
|
||||
</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 class="row nic-model-row">
|
||||
@ -362,6 +366,14 @@
|
||||
</table>
|
||||
</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>
|
||||
<legend>{{tr "Security Groups"}}</legend>
|
||||
|
@ -45,6 +45,7 @@ define(function(require) {
|
||||
data : {},
|
||||
timeout: true,
|
||||
success: function (request, pciDevices){
|
||||
console.log(opts)
|
||||
var tr = opts.tr;
|
||||
|
||||
var html = "<select>";
|
||||
|
@ -94,17 +94,30 @@ define(function(require) {
|
||||
templateJSON.RDP = "YES";
|
||||
}
|
||||
|
||||
if($("#cb_attach_alias", context).prop("checked")) {
|
||||
templateJSON.PARENT = $("#parent").val();
|
||||
|
||||
var obj = {
|
||||
"NIC_ALIAS": templateJSON
|
||||
};
|
||||
} else {
|
||||
var obj = {
|
||||
"NIC": templateJSON
|
||||
var obj = undefined
|
||||
|
||||
if (['pci-auto','pci-manual'].includes($("select.pci-type-nic", context).val())){
|
||||
var pciObj = $.extend({
|
||||
'TYPE': 'NIC',
|
||||
}, templateJSON);
|
||||
|
||||
obj = {
|
||||
"PCI": pciObj
|
||||
};
|
||||
}
|
||||
else{
|
||||
if($("#cb_attach_alias", context).prop("checked")) {
|
||||
templateJSON.PARENT = $("#parent").val();
|
||||
|
||||
obj = {
|
||||
"NIC_ALIAS": templateJSON
|
||||
};
|
||||
} else {
|
||||
obj = {
|
||||
"NIC": templateJSON
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if(selectedNetwork){
|
||||
Sunstone.runAction("VM.attachnic", that.element.ID, obj);
|
||||
|
@ -313,29 +313,30 @@ define(function(require) {
|
||||
var is_pci = (nic.PCI_ID != undefined);
|
||||
|
||||
var actions = "";
|
||||
|
||||
// Attach / Detach
|
||||
if (!is_pci){
|
||||
if (
|
||||
that.element.STATE == OpenNebulaVM.STATES.ACTIVE && (
|
||||
that.element.LCM_STATE == OpenNebulaVM.LCM_STATES.HOTPLUG_NIC ||
|
||||
that.element.LCM_STATE == OpenNebulaVM.LCM_STATES.HOTPLUG_NIC_POWEROFF
|
||||
)
|
||||
) {
|
||||
actions = Locale.tr("attach/detach in progress");
|
||||
} else {
|
||||
if (
|
||||
that.element.STATE == OpenNebulaVM.STATES.ACTIVE && (
|
||||
that.element.LCM_STATE == OpenNebulaVM.LCM_STATES.HOTPLUG_NIC ||
|
||||
that.element.LCM_STATE == OpenNebulaVM.LCM_STATES.HOTPLUG_NIC_POWEROFF
|
||||
)
|
||||
) {
|
||||
actions = Locale.tr("attach/detach in progress");
|
||||
} else {
|
||||
|
||||
if(Config.isTabActionEnabled("vms-tab", "VM.detachnic")){
|
||||
var icon = $("<i/>",{class:"fas fa-times"});
|
||||
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>";
|
||||
actions += (validateAction(that,"VM.detachnic"))
|
||||
? (isFirecracker(that)
|
||||
? (isPowerOff(that) ? anchor.get(0).outerHTML : "")
|
||||
: anchor.get(0).outerHTML
|
||||
)
|
||||
: "";
|
||||
}
|
||||
if(Config.isTabActionEnabled("vms-tab", "VM.detachnic")){
|
||||
var icon = $("<i/>",{class:"fas fa-times"});
|
||||
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>";
|
||||
actions += (validateAction(that,"VM.detachnic"))
|
||||
? (isFirecracker(that)
|
||||
? (isPowerOff(that) ? anchor.get(0).outerHTML : "")
|
||||
: anchor.get(0).outerHTML
|
||||
)
|
||||
: "";
|
||||
}
|
||||
|
||||
if (!is_pci){
|
||||
if(Config.isTabActionEnabled("vms-tab", "VM.attachsg")){
|
||||
var icon = $("<i/>",{class:"fas fa-shield-alt"});
|
||||
var anchorAttributes = {class: "attachsg", style: "padding-left: 1em"};
|
||||
|
Loading…
Reference in New Issue
Block a user