mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-22 13:33:52 +03:00
feature #3781: DISK_VIRTUAL/ACTUAL_SIZE first class element in VM
template
This commit is contained in:
parent
552e6a8f96
commit
3e6159f70f
@ -400,10 +400,12 @@ public:
|
||||
* @param _net_rx received bytes (total)
|
||||
*/
|
||||
void update_info(
|
||||
const int _memory,
|
||||
const int _cpu,
|
||||
const long long _net_tx,
|
||||
const long long _net_rx,
|
||||
int _memory,
|
||||
int _cpu,
|
||||
long long _net_tx,
|
||||
long long _net_rx,
|
||||
long long _disk_actual,
|
||||
long long _disk_virtual,
|
||||
const map<string, string> &custom);
|
||||
|
||||
/**
|
||||
@ -414,7 +416,7 @@ public:
|
||||
{
|
||||
map<string,string> empty;
|
||||
|
||||
update_info(0, 0, -1, -1, empty);
|
||||
update_info(0, 0, -1, -1, -1, -1, empty);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1702,6 +1704,16 @@ private:
|
||||
*/
|
||||
long long net_rx;
|
||||
|
||||
/**
|
||||
* Network usage, received bytes
|
||||
*/
|
||||
long long disk_actual;
|
||||
|
||||
/**
|
||||
* Network usage, received bytes
|
||||
*/
|
||||
long long disk_virtual;
|
||||
|
||||
/**
|
||||
* History record, for the current host
|
||||
*/
|
||||
|
@ -187,6 +187,13 @@
|
||||
|
||||
<!-- NET_RX: Received bytes from the network -->
|
||||
<xs:element name="NET_RX" type="xs:integer"/>
|
||||
|
||||
<!-- DISK_ACTUAL_SIZE: Real storage usage for the VM (mb) -->
|
||||
<xs:element name="DISK_ACTUAL_SIZE" type="xs:integer"/>
|
||||
|
||||
<!-- DISK_VIRTUAL_SIZE: Virtual storage usage for the VM (mb) -->
|
||||
<xs:element name="DISK_VIRTUAL_SIZE" type="xs:integer"/>
|
||||
|
||||
<xs:element name="TEMPLATE" type="xs:anyType"/>
|
||||
<xs:element name="USER_TEMPLATE" type="xs:anyType"/>
|
||||
<xs:element name="HISTORY_RECORDS">
|
||||
|
@ -120,6 +120,13 @@
|
||||
|
||||
<!-- NET_RX: Received bytes from the network -->
|
||||
<xs:element name="NET_RX" type="xs:integer"/>
|
||||
|
||||
<!-- DISK_ACTUAL_SIZE: Real storage usage for the VM (mb) -->
|
||||
<xs:element name="DISK_ACTUAL_SIZE" type="xs:integer"/>
|
||||
|
||||
<!-- DISK_VIRTUAL_SIZE: Virtual storage usage for the VM (mb) -->
|
||||
<xs:element name="DISK_VIRTUAL_SIZE" type="xs:integer"/>
|
||||
|
||||
<xs:element name="TEMPLATE" type="xs:anyType"/>
|
||||
<xs:element name="USER_TEMPLATE" type="xs:anyType"/>
|
||||
<xs:element name="HISTORY_RECORDS">
|
||||
|
@ -46,6 +46,14 @@
|
||||
:desc: Data sent to the network
|
||||
:size: 6
|
||||
|
||||
:DISK_ACTUAL:
|
||||
:desc: Total disk size
|
||||
:size: 6
|
||||
|
||||
:DISK_VIRTUAL:
|
||||
:desc: Total virtual disk size
|
||||
:size: 6
|
||||
|
||||
:default:
|
||||
- :VID
|
||||
- :HOSTNAME
|
||||
@ -55,4 +63,6 @@
|
||||
- :MEMORY
|
||||
- :CPU
|
||||
- :NET_RX
|
||||
- :NET_TX
|
||||
- :NET_TX
|
||||
- :DISK_ACTUAL
|
||||
- :DISK_VIRTUAL
|
@ -165,7 +165,16 @@ class AcctHelper < OpenNebulaHelper::OneHelper
|
||||
OpenNebulaHelper.unit_to_str(d["VM"]["NET_TX"].to_i / 1024.0, {})
|
||||
end
|
||||
|
||||
default :VID, :HOSTNAME, :ACTION, :REASON, :START_TIME, :END_TIME, :MEMORY, :CPU, :NET_RX, :NET_TX
|
||||
column :DISK_ACTUAL, "Total disk size used", :size=>6 do |d|
|
||||
# DISK size is measured in mb, unit_to_str expects KBytes
|
||||
OpenNebulaHelper.unit_to_str(d["VM"]["DISK_ACTUAL_SIZE"].to_i * 1024.0, {})
|
||||
end
|
||||
|
||||
column :DISK_VIRTUAL, "Total disk virtual size used", :size=>6 do |d|
|
||||
# DISK size is measured in mb, unit_to_str expects KBytes
|
||||
OpenNebulaHelper.unit_to_str(d["VM"]["DISK_VIRTUAL_SIZE"].to_i * 1024.0, {})
|
||||
end
|
||||
default :VID, :HOSTNAME, :ACTION, :REASON, :START_TIME, :END_TIME, :MEMORY, :CPU, :NET_RX, :NET_TX, :DISK_ACTUAL, :DISK_VIRTUAL
|
||||
end
|
||||
|
||||
SHOWBACK_TABLE = CLIHelper::ShowTable.new("oneshowback.yaml", nil) do
|
||||
|
@ -506,7 +506,9 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
||||
"USED MEMORY" => "MEMORY",
|
||||
"USED CPU" => "CPU",
|
||||
"NET_TX" => "NET_TX",
|
||||
"NET_RX" => "NET_RX"
|
||||
"NET_RX" => "NET_RX",
|
||||
"DISK SIZE (ACTUAL)" => "DISK_ACTUAL_SIZE",
|
||||
"DISK SIZE (VIRTUAL)" => "DISK_VIRTUAL_SIZE"
|
||||
}
|
||||
|
||||
poll_attrs.each { |k,v|
|
||||
@ -514,6 +516,8 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
||||
puts str % [k,vm[v]]
|
||||
elsif k == "USED MEMORY"
|
||||
puts str % [k, OpenNebulaHelper.unit_to_str(vm[v].to_i, {})]
|
||||
elsif k =~ /DISK/
|
||||
puts str % [k, OpenNebulaHelper.unit_to_str(vm[v].to_i*1024, {})]
|
||||
else
|
||||
puts str % [k, OpenNebulaHelper.unit_to_str(vm[v].to_i/1024, {})]
|
||||
end
|
||||
|
@ -51,11 +51,13 @@ class VirtualMachineDriver < OpenNebulaDriver
|
||||
}
|
||||
|
||||
POLL_ATTRIBUTE = {
|
||||
:usedmemory => "USEDMEMORY",
|
||||
:usedcpu => "USEDCPU",
|
||||
:nettx => "NETTX",
|
||||
:netrx => "NETRX",
|
||||
:state => "STATE"
|
||||
:usedmemory => "USEDMEMORY",
|
||||
:usedcpu => "USEDCPU",
|
||||
:nettx => "NETTX",
|
||||
:netrx => "NETRX",
|
||||
:state => "STATE",
|
||||
:disk_actual => "DISK_ACTUAL_SIZE",
|
||||
:disk_virtual=> "DISK_VIRTUAL_SIZE"
|
||||
}
|
||||
|
||||
VM_STATE = {
|
||||
|
@ -62,6 +62,8 @@ VirtualMachine::VirtualMachine(int id,
|
||||
cpu(0),
|
||||
net_tx(0),
|
||||
net_rx(0),
|
||||
disk_actual(0),
|
||||
disk_virtual(0),
|
||||
history(0),
|
||||
previous_history(0),
|
||||
_log(0)
|
||||
@ -3674,6 +3676,8 @@ string& VirtualMachine::to_xml_extended(string& xml, int n_history) const
|
||||
<< "<CPU>" << cpu << "</CPU>"
|
||||
<< "<NET_TX>" << net_tx << "</NET_TX>"
|
||||
<< "<NET_RX>" << net_rx << "</NET_RX>"
|
||||
<< "<DISK_ACTUAL_SIZE>" << disk_actual << "</DISK_ACTUAL_SIZE>"
|
||||
<< "<DISK_VIRTUAL_SIZE>"<< disk_virtual<< "</DISK_VIRTUAL_SIZE>"
|
||||
<< obj_template->to_xml(template_xml)
|
||||
<< user_obj_template->to_xml(user_template_xml);
|
||||
|
||||
@ -3748,6 +3752,8 @@ int VirtualMachine::from_xml(const string &xml_str)
|
||||
rc += xpath(cpu, "/VM/CPU", 0);
|
||||
rc += xpath(net_tx, "/VM/NET_TX", 0);
|
||||
rc += xpath(net_rx, "/VM/NET_RX", 0);
|
||||
rc += xpath(disk_actual, "/VM/DISK_ACTUAL_SIZE", 0);
|
||||
rc += xpath(disk_virtual,"/VM/DISK_VIRTUAL_SIZE", 0);
|
||||
|
||||
// Permissions
|
||||
rc += perms_from_xml();
|
||||
@ -3856,10 +3862,12 @@ string VirtualMachine::get_system_dir() const
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void VirtualMachine::update_info(
|
||||
const int _memory,
|
||||
const int _cpu,
|
||||
const long long _net_tx,
|
||||
const long long _net_rx,
|
||||
int _memory,
|
||||
int _cpu,
|
||||
long long _net_tx,
|
||||
long long _net_rx,
|
||||
long long _disk_actual,
|
||||
long long _disk_virtual,
|
||||
const map<string, string> &custom)
|
||||
{
|
||||
map<string, string>::const_iterator it;
|
||||
@ -3886,6 +3894,16 @@ void VirtualMachine::update_info(
|
||||
net_rx = _net_rx;
|
||||
}
|
||||
|
||||
if (_disk_actual != -1)
|
||||
{
|
||||
disk_actual = _disk_actual;
|
||||
}
|
||||
|
||||
if (_disk_virtual != -1)
|
||||
{
|
||||
disk_virtual = _disk_virtual;
|
||||
}
|
||||
|
||||
for (it = custom.begin(); it != custom.end(); it++)
|
||||
{
|
||||
replace_template_attribute(it->first, it->second);
|
||||
|
@ -647,7 +647,7 @@ void VirtualMachineManagerDriver::process_poll(
|
||||
|
||||
if (vm->get_state() == VirtualMachine::ACTIVE)
|
||||
{
|
||||
vm->update_info(memory, cpu, net_tx, net_rx, custom);
|
||||
vm->update_info(memory, cpu, net_tx, net_rx, dactual, dvirtual, custom);
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
|
@ -195,7 +195,9 @@ class DummyDriver < VirtualMachineDriver
|
||||
"#{POLL_ATTRIBUTE[:nettx]}=#{prev_nettx+(50*rand(3))} " \
|
||||
"#{POLL_ATTRIBUTE[:netrx]}=#{prev_netrx+(100*rand(4))} " \
|
||||
"#{POLL_ATTRIBUTE[:usedmemory]}=#{max_memory * (rand(80)+20)/100} " \
|
||||
"#{POLL_ATTRIBUTE[:usedcpu]}=#{max_cpu * (rand(95)+5)/100}"
|
||||
"#{POLL_ATTRIBUTE[:usedcpu]}=#{max_cpu * (rand(95)+5)/100} " \
|
||||
"#{POLL_ATTRIBUTE[:disk_actual]}=#{rand(1024)} " \
|
||||
"#{POLL_ATTRIBUTE[:disk_virtual]}=#{1024}"
|
||||
|
||||
send_message(ACTION[:poll],result,id,monitor_info)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user