mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
Feature #4620: Show PCI NICs in onevm show & sunstone panel
This commit is contained in:
parent
8917dd39aa
commit
5df05f624e
@ -472,6 +472,8 @@ in the frontend machine.
|
||||
|
||||
cluster = nil
|
||||
|
||||
vm_hash = vm.to_hash
|
||||
|
||||
if %w{ACTIVE SUSPENDED POWEROFF}.include? vm.state_str
|
||||
cluster_id = vm['/VM/HISTORY_RECORDS/HISTORY[last()]/CID']
|
||||
else
|
||||
@ -519,7 +521,7 @@ in the frontend machine.
|
||||
|
||||
CLIHelper.print_header(str_h1 % "VIRTUAL MACHINE MONITORING",false)
|
||||
|
||||
vm_monitoring = vm.to_hash['VM']['MONITORING']
|
||||
vm_monitoring = vm_hash['VM']['MONITORING']
|
||||
|
||||
# Find out if it is a hybrid VM to avoid showing local IPs
|
||||
isHybrid=false
|
||||
@ -573,11 +575,11 @@ in the frontend machine.
|
||||
vm_disks = []
|
||||
|
||||
if vm.has_elements?("/VM/TEMPLATE/DISK")
|
||||
vm_disks = [vm.to_hash['VM']['TEMPLATE']['DISK']].flatten
|
||||
vm_disks = [vm_hash['VM']['TEMPLATE']['DISK']].flatten
|
||||
end
|
||||
|
||||
if vm.has_elements?("/VM/TEMPLATE/CONTEXT")
|
||||
context_disk = vm.to_hash['VM']['TEMPLATE']['CONTEXT']
|
||||
context_disk = vm_hash['VM']['TEMPLATE']['CONTEXT']
|
||||
|
||||
context_disk["IMAGE"] = "CONTEXT"
|
||||
context_disk["DATASTORE"] = "-"
|
||||
@ -686,16 +688,21 @@ in the frontend machine.
|
||||
|
||||
sg_nics = []
|
||||
|
||||
if (vm.has_elements?("/VM/TEMPLATE/NIC/SECURITY_GROUPS"))
|
||||
sg_nics = [vm.to_hash['VM']['TEMPLATE']['NIC']].flatten
|
||||
if (vm.has_elements?("/VM/TEMPLATE/NIC/SECURITY_GROUPS") ||
|
||||
vm.has_elements?("/VM/TEMPLATE/PCI[NIC_ID>-1]/SECURITY_GROUPS"))
|
||||
|
||||
sg_nics.each do |nic|
|
||||
sg = nic["SECURITY_GROUPS"]
|
||||
sg_nics = [vm_hash['VM']['TEMPLATE']['NIC']]
|
||||
|
||||
if sg.nil?
|
||||
next
|
||||
sg_pcis = [vm_hash['VM']['TEMPLATE']['PCI']].flatten.compact
|
||||
|
||||
sg_pcis.each do |pci|
|
||||
if !pci['NIC_ID'].nil?
|
||||
sg_nics << pci
|
||||
end
|
||||
end
|
||||
|
||||
sg_nics.flatten!
|
||||
sg_nics.compact!
|
||||
end
|
||||
|
||||
# This variable holds the extra IP's got from monitoring. Right
|
||||
@ -714,7 +721,9 @@ in the frontend machine.
|
||||
|
||||
extra_ips.uniq!
|
||||
|
||||
if vm.has_elements?("/VM/TEMPLATE/NIC") || !extra_ips.empty?
|
||||
if vm.has_elements?("/VM/TEMPLATE/NIC") ||
|
||||
vm.has_elements?("/VM/TEMPLATE/PCI[NIC_ID>-1]") || !extra_ips.empty?
|
||||
|
||||
puts
|
||||
CLIHelper.print_header(str_h1 % "VM NICS",false)
|
||||
|
||||
@ -726,7 +735,19 @@ in the frontend machine.
|
||||
shown_ips = []
|
||||
|
||||
array_id = 0
|
||||
vm_nics = [vm.to_hash['VM']['TEMPLATE']['NIC']].flatten.compact
|
||||
vm_nics = [vm_hash['VM']['TEMPLATE']['NIC']]
|
||||
|
||||
vm_pcis = [vm_hash['VM']['TEMPLATE']['PCI']].flatten.compact
|
||||
|
||||
vm_pcis.each do |pci|
|
||||
if !pci['NIC_ID'].nil?
|
||||
vm_nics << pci
|
||||
end
|
||||
end
|
||||
|
||||
vm_nics.flatten!
|
||||
vm_nics.compact!
|
||||
|
||||
vm_nics.each {|nic|
|
||||
|
||||
next if nic.has_key?("CLI_DONE")
|
||||
@ -813,6 +834,14 @@ in the frontend machine.
|
||||
end
|
||||
end
|
||||
|
||||
column :PCI_ID, "", :left, :size=>8 do |d|
|
||||
if d["DOUBLE_ENTRY"]
|
||||
""
|
||||
else
|
||||
d["PCI_ID"]
|
||||
end
|
||||
end
|
||||
|
||||
end.show(vm_nics,{})
|
||||
|
||||
while vm.has_elements?("/VM/TEMPLATE/NIC")
|
||||
@ -895,7 +924,7 @@ in the frontend machine.
|
||||
d["RANGE"]
|
||||
end
|
||||
|
||||
end.show([vm.to_hash['VM']['TEMPLATE']['SECURITY_GROUP_RULE']].flatten, {})
|
||||
end.show([vm_hash['VM']['TEMPLATE']['SECURITY_GROUP_RULE']].flatten, {})
|
||||
|
||||
while vm.has_elements?("/VM/TEMPLATE/SECURITY_GROUP_RULE")
|
||||
vm.delete_element("/VM/TEMPLATE/SECURITY_GROUP_RULE")
|
||||
@ -924,7 +953,7 @@ in the frontend machine.
|
||||
d["HYPERVISOR_ID"] if !d.nil?
|
||||
end
|
||||
|
||||
end.show([vm.to_hash['VM']['TEMPLATE']['SNAPSHOT']].flatten, {})
|
||||
end.show([vm_hash['VM']['TEMPLATE']['SNAPSHOT']].flatten, {})
|
||||
|
||||
vm.delete_element("/VM/TEMPLATE/SNAPSHOT")
|
||||
end
|
||||
@ -961,7 +990,7 @@ in the frontend machine.
|
||||
column :"MESSAGE", "", :left, :donottruncate, :size=>35 do |d|
|
||||
d["MESSAGE"] if !d.nil?
|
||||
end
|
||||
end.show([vm.to_hash['VM']['USER_TEMPLATE']['SCHED_ACTION']].flatten, {})
|
||||
end.show([vm_hash['VM']['USER_TEMPLATE']['SCHED_ACTION']].flatten, {})
|
||||
end
|
||||
|
||||
if vm.has_elements?("/VM/USER_TEMPLATE")
|
||||
|
@ -80,6 +80,7 @@ define(function(require) {
|
||||
<th>' + Locale.tr("Network") + '</th>\
|
||||
<th>' + Locale.tr("IP") + '</th>\
|
||||
<th>' + Locale.tr("MAC") + '</th>\
|
||||
<th>' + Locale.tr("PCI address") + '</th>\
|
||||
<th>' + Locale.tr("IPv6 ULA") + '</th>\
|
||||
<th>' + Locale.tr("IPv6 Global") + '</th>\
|
||||
<th colspan="">' + Locale.tr("Actions") + '</th>\
|
||||
@ -207,15 +208,44 @@ define(function(require) {
|
||||
return html;
|
||||
}
|
||||
|
||||
function _ipTr(nic, attr){
|
||||
var v = "--";
|
||||
|
||||
if (nic[attr] != undefined){
|
||||
v = nic[attr];
|
||||
|
||||
if (nic["VROUTER_"+attr] != undefined){
|
||||
v += ("<br/>" + nic["VROUTER_"+attr] + Locale.tr(" (VRouter)"));
|
||||
}
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
function _setup(context) {
|
||||
var that = this;
|
||||
|
||||
var nics = []
|
||||
|
||||
if ($.isArray(that.element.TEMPLATE.NIC))
|
||||
nics = that.element.TEMPLATE.NIC
|
||||
else if (!$.isEmptyObject(that.element.TEMPLATE.NIC))
|
||||
nics = [that.element.TEMPLATE.NIC]
|
||||
if ($.isArray(that.element.TEMPLATE.NIC)){
|
||||
nics = that.element.TEMPLATE.NIC;
|
||||
} else if (!$.isEmptyObject(that.element.TEMPLATE.NIC)){
|
||||
nics = [that.element.TEMPLATE.NIC];
|
||||
}
|
||||
|
||||
var pcis = [];
|
||||
|
||||
if ($.isArray(that.element.TEMPLATE.PCI)){
|
||||
pcis = that.element.TEMPLATE.PCI;
|
||||
} else if (!$.isEmptyObject(that.element.TEMPLATE.PCI)){
|
||||
pcis = [that.element.TEMPLATE.PCI];
|
||||
}
|
||||
|
||||
$.each(pcis, function(){
|
||||
if(this.NIC_ID != undefined){
|
||||
nics.push(this);
|
||||
}
|
||||
});
|
||||
|
||||
var nic_dt_data = [];
|
||||
if (nics.length) {
|
||||
@ -224,22 +254,18 @@ define(function(require) {
|
||||
for (var i = 0; i < nics.length; i++) {
|
||||
var nic = nics[i];
|
||||
|
||||
var actions;
|
||||
// Attach / Detach
|
||||
if (
|
||||
(
|
||||
that.element.STATE == OpenNebulaVM.STATES.ACTIVE) &&
|
||||
(
|
||||
that.element.LCM_STATE == OpenNebulaVM.LCM_STATES.HOTPLUG_NIC) &&
|
||||
(
|
||||
nic.ATTACH == "YES")
|
||||
) {
|
||||
actions = Locale.tr("attach/detach in progress")
|
||||
} else {
|
||||
actions = '';
|
||||
var is_pci = (nic.PCI_ID != undefined);
|
||||
|
||||
if (Config.isTabActionEnabled("vms-tab", "VM.detachnic")) {
|
||||
if (StateActions.enabledStateAction("VM.detachnic", that.element.STATE, that.element.LCM_STATE)) {
|
||||
var actions = '';
|
||||
// Attach / Detach
|
||||
if (!is_pci){
|
||||
if ( (that.element.STATE == OpenNebulaVM.STATES.ACTIVE) &&
|
||||
(that.element.LCM_STATE == OpenNebulaVM.LCM_STATES.HOTPLUG_NIC) &&
|
||||
(nic.ATTACH == "YES") ) {
|
||||
actions = Locale.tr("attach/detach in progress")
|
||||
} else {
|
||||
if ( (Config.isTabActionEnabled("vms-tab", "VM.detachnic")) &&
|
||||
(StateActions.enabledStateAction("VM.detachnic", that.element.STATE, that.element.LCM_STATE))) {
|
||||
actions += '<a href="VM.detachnic" class="detachnic" ><i class="fa fa-times"/>' + Locale.tr("Detach") + '</a>'
|
||||
}
|
||||
}
|
||||
@ -268,27 +294,16 @@ define(function(require) {
|
||||
});
|
||||
}
|
||||
|
||||
function ipTr(attr){
|
||||
var v = "--";
|
||||
|
||||
if (nic[attr] != undefined){
|
||||
v = nic[attr];
|
||||
|
||||
if (nic["VROUTER_"+attr] != undefined){
|
||||
v += ("<br/>" + nic["VROUTER_"+attr] + Locale.tr(" (VRouter)"));
|
||||
}
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
var pci_address = is_pci ? nic.ADDRESS : '';
|
||||
|
||||
nic_dt_data.push({
|
||||
NIC_ID : nic.NIC_ID,
|
||||
NETWORK : nic.NETWORK,
|
||||
IP : ipTr("IP"),
|
||||
IP : _ipTr(nic, "IP"),
|
||||
MAC : nic.MAC,
|
||||
IP6_ULA : ipTr("IP6_ULA"),
|
||||
IP6_GLOBAL : ipTr("IP6_GLOBAL"),
|
||||
PCI_ADDRESS: pci_address,
|
||||
IP6_ULA : _ipTr(nic, "IP6_ULA"),
|
||||
IP6_GLOBAL : _ipTr(nic, "IP6_GLOBAL"),
|
||||
ACTIONS : actions,
|
||||
SECURITY_GROUP_RULES : secgroups
|
||||
});
|
||||
@ -309,6 +324,7 @@ define(function(require) {
|
||||
{"data": "NETWORK", "defaultContent": ""},
|
||||
{"data": "IP", "defaultContent": "", "class": "nowrap"},
|
||||
{"data": "MAC", "defaultContent": ""},
|
||||
{"data": "PCI_ADDRESS","defaultContent": ""},
|
||||
{"data": "IP6_ULA", "defaultContent": "", "class": "nowrap"},
|
||||
{"data": "IP6_GLOBAL", "defaultContent": "", "class": "nowrap"},
|
||||
{"data": "ACTIONS", "defaultContent": "", "orderable": false},
|
||||
|
Loading…
x
Reference in New Issue
Block a user