1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

Merge branch 'feature-2921'

This commit is contained in:
Tino Vazquez 2016-11-11 13:21:15 +01:00
commit be09537a83
22 changed files with 277 additions and 109 deletions

View File

@ -241,7 +241,7 @@ class EC2QueryServer < CloudServer
private
def render_launch_time(vm)
return "<launchTime>#{Time.at(vm["STIME"].to_i).utc.xmlschema}</launchTime>"
return "<launchTime>#{Time.at(vm["STIME"].to_i).xmlschema}</launchTime>"
end
end

View File

@ -64,13 +64,7 @@ ARGV.each do |xpath|
values << ar.join(' ')
else
element = xml.elements[xpath.dup]
if !element.nil?
if element.class.method_defined?(:text)
values << element.text
else
values << element.to_s
end
end
values << element.text.to_s if !element.nil?
end
values << "\0"
end

View File

@ -2637,7 +2637,7 @@ EOT
# Params:
# +disk+:: Nokogiri::XML::Node describing a disk used by a template
def get_image_from_name(disk)
name = disk.at_xpath("IMAGE") && disk.at_xpath("IMAGE").content
name = disk.at_xpath("IMAGE").content # always defined
uid = disk.at_xpath("IMAGE_UID")
uname = disk.at_xpath("IMAGE_UNAME")

View File

@ -1,6 +1,5 @@
small_logo: images/opennebula-5.0.png
provision_logo: images/opennebula-5.0.png
confirm_vms: true
enabled_tabs:
- dashboard-tab
- instances-top-tab

View File

@ -1,5 +1,4 @@
provision_logo: images/opennebula-5.0.png
confirm_vms: true
enabled_tabs:
- provision-tab
- settings-tab

View File

@ -1,6 +1,5 @@
small_logo: images/opennebula-5.0.png
provision_logo: images/opennebula-5.0.png
confirm_vms: true
enabled_tabs:
- dashboard-tab
- instances-top-tab

View File

@ -612,6 +612,7 @@ define(function(require) {
"retrieveExternalIPs": retrieveExternalIPs,
"retrieveExternalNetworkAttrs": retrieveExternalNetworkAttrs,
"isNICGraphsSupported": isNICGraphsSupported,
"isDiskGraphsSupported": isDiskGraphsSupported,
"isNICAttachSupported": isNICAttachSupported,
"isVNCSupported": isVNCSupported,
"isSPICESupported": isSPICESupported,
@ -643,6 +644,15 @@ define(function(require) {
}
}
function isDiskGraphsSupported(element) {
var history = retrieveLastHistoryRecord(element)
if (history) {
return $.inArray(history.VM_MAD, ['ec2','az']) == -1;
} else {
return false;
}
}
function isNICAttachSupported(element) {
var history = retrieveLastHistoryRecord(element)
if (history) {

View File

@ -146,15 +146,10 @@ define(function(require) {
'vmLogos': (_config['vm_logos']),
'enabledTabs': _config['view']['enabled_tabs'],
'onedConf': _config['oned_conf'],
'confirmVMActions': _config['view']['confirm_vms'],
"allTabs": function() {
return Object.keys(_config['view']['tabs']);
}
/*"isConfirmVmsActionsEnable": function() {
Console.Log(_config['view']['confirm_vms']);
}*/
}
return Config;

View File

@ -77,8 +77,6 @@ define(function(require) {
var hostnameHTML = OpenNebula.VM.hostnameStrLink(this.element);
var vrouterHTML = '--';
var IP = OpenNebula.VM.ipsStr(this.element);
if (this.element.TEMPLATE.VROUTER_ID != undefined){
vrouterHTML = Navigation.link(
OpenNebula.VirtualRouter.getName(this.element.TEMPLATE.VROUTER_ID),
@ -124,7 +122,6 @@ define(function(require) {
'hostnameHTML': hostnameHTML,
'prettyStartTime': prettyStartTime,
'deployId': deployId,
'IP': IP,
'resched': resched,
'permissionsTableHTML': permissionsTableHTML,
'templateTableHTML': templateTableHTML,
@ -136,6 +133,7 @@ define(function(require) {
function _setup(context) {
RenameTr.setup(TAB_ID, RESOURCE, this.element.ID, context);
PermissionsTable.setup(TAB_ID, RESOURCE, this.element, context);
// Get rid of the unwanted (for show) SCHED_* keys
var that = this;
var strippedTemplate = {};

View File

@ -43,13 +43,6 @@
<td class="value_td">{{{hostnameHTML}}}</td>
<td></td>
</tr>
<tr>
<td class="key_td">{{tr "IP"}}</td>
<td class="value_td">{{{IP}}}</td>
<td></td>
</tr>
<tr>
<td class="key_td">{{tr "Start time"}}</td>
<td class="value_td">{{prettyStartTime}}</td>

View File

@ -29,6 +29,8 @@ define(function(require) {
var TemplateHtml = require('hbs!./storage/html');
var DiskDetailsHtml = require('hbs!./storage/disk-details');
var Navigation = require('utils/navigation');
var Notifier = require('utils/notifier');
var Graphs = require('utils/graphs');
/*
CONSTANTS
@ -62,6 +64,7 @@ define(function(require) {
Panel.prototype.setup = _setup;
Panel.prototype.getState = _getState;
Panel.prototype.setState = _setState;
Panel.prototype.onShow = _onShow;
return Panel;
@ -76,10 +79,82 @@ define(function(require) {
diskCost = Config.onedConf.DEFAULT_COST.DISK_COST;
}
return TemplateHtml({
var html = TemplateHtml({
element: this.element,
diskCost: diskCost
});
// Do not show statistics for not hypervisors that do not gather net data
//if (OpenNebulaVM.isNICGraphsSupported(that.element)) {
html += '\
<div class="row">\
<div class="medium-6 columns">\
<div class="row">\
<span>' + Locale.tr("Disk RD Bytes") + '</span3>\
</div>\
<div class="row">\
<div class="large-12 columns centered graph" id="vm_st_drb_graph" style="height: 100px;">\
<span id="provision_dashboard_total" style="font-size:80px">\
<i class="fa fa-spinner fa-spin"></i>\
</span>\
</div>\
</div>\
<div class="row graph_legend">\
<div class="large-12 columns centered" id="vm_net_rx_legend">\
</div>\
</div>\
</div>\
<div class="medium-6 columns">\
<div class="row">\
<span>' + Locale.tr("Disk WR Bytes") + '</span3>\
</div>\
<div class="row">\
<div class="large-12 columns centered graph" id="vm_st_dwb_graph" style="height: 100px;">\
<span id="provision_dashboard_total" style="font-size:80px">\
<i class="fa fa-spinner fa-spin"></i>\
</span>\
</div>\
</div>\
<div class="row graph_legend">\
<div class="large-12 columns centered" id="vm_net_tx_legend">\
</div>\
</div>\
</div>\
<div class="medium-6 columns">\
<div class="row">\
<span>' + Locale.tr("Disk RD IOPS") + '</span3>\
</div>\
<div class="row">\
<div class="large-12 columns centered graph" id="vm_st_drio_graph" style="height: 100px;">\
<span id="provision_dashboard_total" style="font-size:80px">\
<i class="fa fa-spinner fa-spin"></i>\
</span>\
</div>\
</div>\
<div class="row graph_legend">\
<div class="large-12 columns centered" id="vm_net_rx_speed_legend">\
</div>\
</div>\
</div>\
<div class="medium-6 columns">\
<div class="row">\
<span>' + Locale.tr("Disk WR IOPS") + '</span3>\
</div>\
<div class="row">\
<div class="large-12 columns centered graph" id="vm_st_dwio_graph" style="height: 100px;">\
<span id="provision_dashboard_total" style="font-size:80px">\
<i class="fa fa-spinner fa-spin"></i>\
</span>\
</div>\
</div>\
<div class="row graph_legend">\
<div class="large-12 columns centered" id="vm_net_tx_speed_legend">\
</div>\
</div>\
</div>\
</div>\
</form>';
// }
return html;
}
function _setup(context) {
@ -571,4 +646,61 @@ define(function(require) {
subTree : subTree
};
}
function _onShow(context) {
var that = this;
if (OpenNebulaVM.isDiskGraphsSupported(that.element)) {
OpenNebulaVM.monitor({
data: {
id: that.element.ID,
monitor: {
monitor_resources : "MONITORING/DISKRDBYTES,MONITORING/DISKWRBYTES,MONITORING/DISKRDIOPS,MONITORING/DISKWRIOPS"
}
},
success: function(req, response) {
var vmGraphs = [
{
labels : Locale.tr("Disk read bytes"),
monitor_resources : "MONITORING/DISKRDBYTES",
humanize_figures : true,
convert_from_bytes : true,
derivative : true,
div_graph : $("#vm_st_drb_graph")
},
{
labels : Locale.tr("Disk write bytes"),
monitor_resources : "MONITORING/DISKWRBYTES",
humanize_figures : true,
convert_from_bytes : true,
derivative : true,
div_graph : $("#vm_st_dwb_graph")
},
{
labels : Locale.tr("Disk Read IOPS"),
monitor_resources : "MONITORING/DISKRDIOPS",
//humanize_figures : true,
//convert_from_bytes : true,
y_sufix : "IOPS/s",
derivative : true,
div_graph : $("#vm_st_drio_graph")
},
{
labels : Locale.tr("Disk write IOPS"),
monitor_resources : "MONITORING/DISKWRIOPS",
//humanize_figures : true,
//convert_from_bytes : true,
y_sufix : "IOPS/s",
derivative : true,
div_graph : $("#vm_st_dwio_graph")
}
];
for (var i = 0; i < vmGraphs.length; i++) {
Graphs.plot(response, vmGraphs[i]);
}
},
error: Notifier.onError
});
}
}
});

View File

@ -130,7 +130,6 @@ define(function(require) {
];
}
function _emptyElementArray(vmId) {
return [
'<input class="check_item" type="checkbox" id="' + RESOURCE.toLowerCase() + '_' +

View File

@ -2,7 +2,6 @@
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OpenNebula Sunstone: Cloud Operations Center</title>
@ -61,7 +60,6 @@
<link href="css/app.css?v=<%= OpenNebula::VERSION %>" media="screen, projector, print" rel="stylesheet" type="text/css"></link>
<% else %>
<link href="css/app.min.css?v=<%= OpenNebula::VERSION %>" media="screen, projector, print" rel="stylesheet" type="text/css"></link>
<% end %>
</head>
<body class="antialiased">

View File

@ -1,9 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>OpenNebula Sunstone Login</title>
<!--[if IE]><link rel="shortcut icon" href="images/favicon.ico"><![endif]-->

View File

@ -25,8 +25,8 @@
# - template is the template of the VM in XML and base64 encoded
# - system_ds_mad flag if called by other SYSTEM_DS TM_MAD
SRC_HOST="$1"
DST_HOST="$2"
SRC="$1"
DST="$2"
DST_PATH="$3"
VM_ID="$4"
DS_ID="$5"

View File

@ -49,6 +49,7 @@ module KVM
:list => 'virsh --connect LIBVIRT_URI --readonly list',
:dumpxml => 'virsh --connect LIBVIRT_URI --readonly dumpxml',
:domifstat => 'virsh --connect LIBVIRT_URI --readonly domifstat',
:domblkstat => 'virsh --connect LIBVIRT_URI --readonly domblkstat',
:top => 'top -b -d2 -n 2 -p ',
'LIBVIRT_URI' => 'qemu:///system'
}
@ -154,6 +155,8 @@ module KVM
vm[:name] = uuid
end
values.merge!(get_diskio_statistics(name, xml))
vms_info[vm[:name]] = values
end
@ -322,6 +325,52 @@ module KVM
values
end
def self.get_disk_names(vmid, text = nil)
text = dump_xml(vmid) if !text
doc=REXML::Document.new(text)
disks = []
doc.elements.each('domain/devices/disk/target') do |ele|
disks << ele.attributes["dev"]
end
disks
end
def self.get_diskio_statistics(vmid, text = nil)
disks=get_disk_names(vmid, text)
if disks && !disks.empty?
values={}
values[:diskrdbytes]=0
values[:diskwrbytes]=0
values[:diskrdiops]=0
values[:diskwriops]=0
disks.each do |disk|
text=`#{virsh(:domblkstat)} #{vmid} #{disk}`
text.each_line do |line|
columns=line.split(/\s+/)
case columns[1]
when 'rd_bytes'
values[:diskrdbytes]+=columns[2].to_i
when 'wr_bytes'
values[:diskwrbytes]+=columns[2].to_i
when 'rd_req'
values[:diskrdiops]+=columns[2].to_i
when 'wr_req'
values[:diskwriops]+=columns[2].to_i
end
end
end
values
else
{}
end
end
# Translate libvirt state to Opennebula monitor state
# @param state [String] libvirt state
# @return [String] OpenNebula state

View File

@ -1454,6 +1454,11 @@ class VCenterVm
@netrx = 0
@nettx = 0
@diskrdbytes = 0
@diskwrbytes = 0
@diskrdiops = 0
@diskwriops = 0
end
############################################################################
@ -1862,6 +1867,10 @@ class VCenterVm
@netrx = 0
@nettx = 0
@diskrdbytes = 0
@diskwrbytes = 0
@diskrdiops = 0
@diskwriops = 0
return
end
@ -1893,7 +1902,7 @@ class VCenterVm
@guest_ip_addresses = guest_ip_addresses.join(',')
# Network metrics - Realtime retrieved by perfManager
# PerfManager metrics
pm = @client.vim.serviceInstance.content.perfManager
provider = pm.provider_summary [@vm].first
@ -1909,32 +1918,38 @@ class VCenterVm
if vmid < 0
@nettx = 0
@netrx = 0
id_not_found = "Could not retrieve VM ID from extra configuration for "\
"vCenter's VM UUID #{@vm.config.uuid}"
@diskrdbytes = 0
@diskwrbytes = 0
@diskrdiops = 0
@diskwriops = 0
else
one_vm = OpenNebula::VirtualMachine.new_with_id(vmid, OpenNebula::Client.new)
one_vm.info
stats = []
if(one_vm["LAST_POLL"] && one_vm["LAST_POLL"].to_i != 0 )
if(one_vm["MONITORING/LAST_MON"] && one_vm["MONITORING/LAST_MON"].to_i != 0 )
#Real time data stores max 1 hour. 1 minute has 3 samples
interval = (Time.now.to_i - one_vm["LAST_POLL"].to_i)
interval = (Time.now.to_i - one_vm["MONITORING/LAST_MON"].to_i)
#If last poll was more than hour ago get 3 minutes,
#else calculate how many samples since last poll
samples = interval > 3600 ? 9 : interval / refresh_rate
samples = interval > 3600 ? 9 : (interval / refresh_rate) + 1
max_samples = samples > 0 ? samples : 1
stats = pm.retrieve_stats(
[@vm],
['net.transmitted','net.bytesRx','net.bytesTx','net.received'],
['net.transmitted','net.bytesRx','net.bytesTx','net.received',
'virtualDisk.numberReadAveraged','virtualDisk.numberWriteAveraged',
'virtualDisk.read','virtualDisk.write'],
{interval:refresh_rate, max_samples: max_samples}
)
else
# First poll, get at least latest 3 minutes = 9 samples
stats = pm.retrieve_stats(
[@vm],
['net.transmitted','net.bytesRx'],
['net.transmitted','net.bytesRx','net.bytesTx','net.received',
'virtualDisk.numberReadAveraged','virtualDisk.numberWriteAveraged',
'virtualDisk.read','virtualDisk.write'],
{interval:refresh_rate, max_samples: 9}
)
end
@ -1942,21 +1957,63 @@ class VCenterVm
if stats.empty? || stats.first[1][:metrics].empty?
@nettx = 0
@netrx = 0
@diskrdbytes = 0
@diskwrbytes = 0
@diskrdiops = 0
@diskwriops = 0
else
metrics = stats.first[1][:metrics]
nettx_kbpersec = 0
metrics['net.transmitted'].each { |sample|
nettx_kbpersec += sample
}
if metrics['net.transmitted']
metrics['net.transmitted'].each { |sample|
nettx_kbpersec += sample
}
end
netrx_kbpersec = 0
metrics['net.bytesRx'].each { |sample|
netrx_kbpersec += sample
}
if metrics['net.bytesRx']
metrics['net.bytesRx'].each { |sample|
netrx_kbpersec += sample
}
end
read_kbpersec = 0
if metrics['virtualDisk.read']
metrics['virtualDisk.read'].each { |sample|
read_kbpersec += sample
}
end
read_iops = 0
if metrics['virtualDisk.numberReadAveraged']
metrics['virtualDisk.numberReadAveraged'].each { |sample|
read_iops += sample
}
end
write_kbpersec = 0
if metrics['virtualDisk.write']
metrics['virtualDisk.write'].each { |sample|
write_kbpersec += sample
}
end
write_iops = 0
if metrics['virtualDisk.numberWriteAveraged']
metrics['virtualDisk.numberWriteAveraged'].each { |sample|
write_iops += sample
}
end
@nettx = (nettx_kbpersec * 1024 * refresh_rate).to_i
@netrx = (netrx_kbpersec * 1024 * refresh_rate).to_i
@diskrdiops = read_iops
@diskwriops = write_iops
@diskrdbytes = (read_kbpersec * 1024 * refresh_rate).to_i
@diskwrbytes = (write_kbpersec * 1024 * refresh_rate).to_i
end
end
end
@ -1974,11 +2031,16 @@ class VCenterVm
str_info << "GUEST_IP_ADDRESSES=\\\"" <<
@guest_ip_addresses.to_s << "\\\" "
end
str_info << "LAST_MON=" << Time.now.to_i.to_s << " "
str_info << "#{POLL_ATTRIBUTE[:state]}=" << @state << " "
str_info << "#{POLL_ATTRIBUTE[:cpu]}=" << @used_cpu.to_s << " "
str_info << "#{POLL_ATTRIBUTE[:memory]}=" << @used_memory.to_s << " "
str_info << "#{POLL_ATTRIBUTE[:netrx]}=" << @netrx.to_s << " "
str_info << "#{POLL_ATTRIBUTE[:nettx]}=" << @nettx.to_s << " "
str_info << "DISKRDBYTES=" << @diskrdbytes.to_s << " "
str_info << "DISKWRBYTES=" << @diskwrbytes.to_s << " "
str_info << "DISKRDIOPS=" << @diskrdiops.to_s << " "
str_info << "DISKWRIOPS=" << @diskwriops.to_s << " "
str_info << "ESX_HOST=\\\"" << @esx_host.to_s << "\\\" "
str_info << "GUEST_STATE=" << @guest_state.to_s << " "
str_info << "VMWARETOOLS_RUNNING_STATUS=" << @vmware_tools.to_s << " "
@ -2589,7 +2651,8 @@ private
vm.config.hardware.device.each{ |dv|
if is_nic?(dv)
nics.each{|nic|
if nic.elements["MAC"].text == dv.macAddress
if nic.elements["MAC"].text == dv.macAddress and
nic.elements["BRIDGE"].text == dv.deviceInfo.summary
nics.delete(nic)
end
}

View File

@ -51,17 +51,4 @@ class VLANTagDriver < VNMMAD::VLANDriver
OpenNebula.exec_and_log("#{command(:ip)} link set #{@nic[:vlan_dev]} up")
end
def get_interface_vlan(name)
text = %x(#{command(:ip)} -d link show #{name})
return nil if $?.exitstatus != 0
text.each_line do |line|
m = line.match(/vlan protocol 802.1Q id (\d+)/)
return m[1] if m
end
nil
end
end

View File

@ -14,10 +14,6 @@
# limitations under the License. #
#--------------------------------------------------------------------------- #
# Set to true to check that no other vlans are connected to the bridge.
# Works with 802.1Q and VXLAN.
:validate_vlan_id: false
################################################################################
# Open vSwitch Options
################################################################################

View File

@ -46,9 +46,6 @@ module VNMMAD
# Create the bridge.
create_bridge
# Check that no other vlans are connected to this bridge
validate_vlan_id
# Return if vlan device is already in the bridge.
next if @bridges[@nic[:bridge]].include? @nic[:vlan_dev]
@ -94,9 +91,6 @@ module VNMMAD
# Get the name of the vlan device.
get_vlan_dev_name
# Return if the bridge doesn't exist because it was already deleted (handles last vm with multiple nics on the same vlan)
next if !@bridges.include? @nic[:bridge]
# Return if the vlan device is not the only left device in the bridge.
next if @bridges[@nic[:bridge]].length > 1 or !@bridges[@nic[:bridge]].include? @nic[:vlan_dev]
@ -155,27 +149,5 @@ module VNMMAD
bridges
end
def get_interface_vlan(name)
nil
end
def validate_vlan_id
@bridges[@nic[:bridge]].each do |interface|
vlan = get_interface_vlan(interface)
if vlan && vlan.to_s != @nic[:vlan_id]
OpenNebula.log_error("The interface #{interface} has "\
"vlan_id = #{vlan} but the network is configured "\
"with vlan_id = #{@nic[:vlan_id]}")
msg = "Interface with an incorrect vlan_id is already in "\
"the bridge"
OpenNebula.error_message(msg)
exit(-1)
end
end
end
end
end

View File

@ -32,7 +32,7 @@ require 'sg_driver'
require 'vlan'
require 'scripts_common'
Dir[File.expand_path('vnmmad-load.d', File.dirname(__FILE__)) + "/*.rb"].each{ |f| require f }
Dir["vnmmad-load.d/*.rb"].each{ |f| require f }
include OpenNebula

View File

@ -54,17 +54,4 @@ class VXLANDriver < VNMMAD::VLANDriver
OpenNebula.exec_and_log("#{command(:ip)} link set #{@nic[:vlan_dev]} up")
end
def get_interface_vlan(name)
text = %x(#{command(:ip)} -d link show #{name})
return nil if $?.exitstatus != 0
text.each_line do |line|
m = line.match(/^\s*vxlan id (\d+)/)
return m[1] if m
end
nil
end
end