mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
Merge remote-tracking branch 'origin/feature-2392'
This commit is contained in:
commit
bf850adffd
@ -232,6 +232,7 @@ public:
|
||||
int seq,
|
||||
int hid,
|
||||
const string& hostname,
|
||||
int cid,
|
||||
const string& vmm,
|
||||
const string& vnm,
|
||||
const string& tmm,
|
||||
@ -275,8 +276,9 @@ private:
|
||||
int oid;
|
||||
int seq;
|
||||
|
||||
string hostname;
|
||||
int hid;
|
||||
string hostname;
|
||||
int cid;
|
||||
|
||||
string vmm_mad_name;
|
||||
string vnm_mad_name;
|
||||
|
@ -96,6 +96,7 @@ protected:
|
||||
|
||||
int add_history(VirtualMachine * vm,
|
||||
int hid,
|
||||
int cid,
|
||||
const string& hostname,
|
||||
const string& vmm_mad,
|
||||
const string& vnm_mad,
|
||||
|
@ -408,6 +408,7 @@ public:
|
||||
*/
|
||||
void add_history(
|
||||
int hid,
|
||||
int cid,
|
||||
const string& hostname,
|
||||
const string& vmm_mad,
|
||||
const string& vnm_mad,
|
||||
|
@ -248,6 +248,9 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
||||
puts str % ["HOST",
|
||||
vm['/VM/HISTORY_RECORDS/HISTORY[last()]/HOSTNAME']] if
|
||||
%w{ACTIVE SUSPENDED POWEROFF}.include? vm.state_str
|
||||
puts str % ["CLUSTER ID",
|
||||
vm['/VM/HISTORY_RECORDS/HISTORY[last()]/CID'] ] if
|
||||
%w{ACTIVE SUSPENDED POWEROFF}.include? vm.state_str
|
||||
puts str % ["START TIME",
|
||||
OpenNebulaHelper.time_to_str(vm['/VM/STIME'])]
|
||||
puts str % ["END TIME",
|
||||
|
@ -123,6 +123,57 @@ module Migrator
|
||||
|
||||
@db.run "DROP TABLE old_datastore_pool;"
|
||||
|
||||
########################################################################
|
||||
# Feature #2392
|
||||
########################################################################
|
||||
|
||||
@db.run "ALTER TABLE vm_pool RENAME TO old_vm_pool;"
|
||||
@db.run "CREATE TABLE vm_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body MEDIUMTEXT, uid INTEGER, gid INTEGER, last_poll INTEGER, state INTEGER, lcm_state INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER);"
|
||||
|
||||
@db.fetch("SELECT * FROM old_vm_pool") do |row|
|
||||
doc = REXML::Document.new(row[:body])
|
||||
|
||||
doc.root.each_element("HISTORY_RECORDS/HISTORY") do |e|
|
||||
update_history(e)
|
||||
end
|
||||
|
||||
@db[:vm_pool].insert(
|
||||
:oid => row[:oid],
|
||||
:name => row[:name],
|
||||
:body => doc.root.to_s,
|
||||
:uid => row[:uid],
|
||||
:gid => row[:gid],
|
||||
:last_poll => row[:last_poll],
|
||||
:state => row[:state],
|
||||
:lcm_state => row[:lcm_state],
|
||||
:owner_u => row[:owner_u],
|
||||
:group_u => row[:group_u],
|
||||
:other_u => row[:other_u])
|
||||
end
|
||||
|
||||
@db.run "DROP TABLE old_vm_pool;"
|
||||
|
||||
@db.run "ALTER TABLE history RENAME TO old_history;"
|
||||
@db.run "CREATE TABLE history (vid INTEGER, seq INTEGER, body MEDIUMTEXT, stime INTEGER, etime INTEGER,PRIMARY KEY(vid,seq));"
|
||||
|
||||
@db.fetch("SELECT * FROM old_history") do |row|
|
||||
doc = REXML::Document.new(row[:body])
|
||||
|
||||
doc.root.each_element("/HISTORY") do |e|
|
||||
update_history(e)
|
||||
end
|
||||
|
||||
@db[:history].insert(
|
||||
:vid => row[:vid],
|
||||
:seq => row[:seq],
|
||||
:body => doc.root.to_s,
|
||||
:stime => row[:stime],
|
||||
:etime => row[:etime])
|
||||
end
|
||||
|
||||
@db.run "DROP TABLE old_history;"
|
||||
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
@ -202,4 +253,23 @@ module Migrator
|
||||
end
|
||||
end
|
||||
|
||||
def update_history(history_elem)
|
||||
hid = nil
|
||||
|
||||
history_elem.each_element("HID") do |e|
|
||||
hid = e.text
|
||||
end
|
||||
|
||||
new_elem = history_elem.add_element("CID")
|
||||
new_elem.text = "-1" # Cluster None
|
||||
|
||||
if hid.nil?
|
||||
return
|
||||
end
|
||||
|
||||
@db.fetch("SELECT cid FROM host_pool WHERE oid = #{hid}") do |row|
|
||||
new_elem.text = row[:cid].to_s
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -440,6 +440,7 @@ VirtualMachine * RequestManagerVirtualMachine::get_vm(int id,
|
||||
|
||||
int RequestManagerVirtualMachine::add_history(VirtualMachine * vm,
|
||||
int hid,
|
||||
int cid,
|
||||
const string& hostname,
|
||||
const string& vmm_mad,
|
||||
const string& vnm_mad,
|
||||
@ -453,7 +454,7 @@ int RequestManagerVirtualMachine::add_history(VirtualMachine * vm,
|
||||
|
||||
VirtualMachinePool * vmpool = static_cast<VirtualMachinePool *>(pool);
|
||||
|
||||
vm->add_history(hid, hostname, vmm_mad, vnm_mad, tm_mad, ds_location, ds_id);
|
||||
vm->add_history(hid, cid, hostname, vmm_mad, vnm_mad, tm_mad, ds_location, ds_id);
|
||||
|
||||
rc = vmpool->update_history(vm);
|
||||
|
||||
@ -766,6 +767,7 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
|
||||
if (add_history(vm,
|
||||
hid,
|
||||
cluster_id,
|
||||
hostname,
|
||||
vmm_mad,
|
||||
vnm_mad,
|
||||
@ -961,6 +963,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
|
||||
|
||||
if (add_history(vm,
|
||||
hid,
|
||||
cluster_id,
|
||||
hostname,
|
||||
vmm_mad,
|
||||
vnm_mad,
|
||||
|
@ -40,8 +40,9 @@ History::History(
|
||||
ObjectXML(),
|
||||
oid(_oid),
|
||||
seq(_seq),
|
||||
hostname(""),
|
||||
hid(-1),
|
||||
hostname(""),
|
||||
cid(-1),
|
||||
vmm_mad_name(""),
|
||||
vnm_mad_name(""),
|
||||
tm_mad_name(""),
|
||||
@ -66,6 +67,7 @@ History::History(
|
||||
int _seq,
|
||||
int _hid,
|
||||
const string& _hostname,
|
||||
int _cid,
|
||||
const string& _vmm,
|
||||
const string& _vnm,
|
||||
const string& _tmm,
|
||||
@ -74,8 +76,9 @@ History::History(
|
||||
const string& _vm_info):
|
||||
oid(_oid),
|
||||
seq(_seq),
|
||||
hostname(_hostname),
|
||||
hid(_hid),
|
||||
hostname(_hostname),
|
||||
cid(_cid),
|
||||
vmm_mad_name(_vmm),
|
||||
vnm_mad_name(_vnm),
|
||||
tm_mad_name(_tmm),
|
||||
@ -301,6 +304,7 @@ string& History::to_xml(string& xml, bool database) const
|
||||
"<SEQ>" << seq << "</SEQ>" <<
|
||||
"<HOSTNAME>" << hostname << "</HOSTNAME>"<<
|
||||
"<HID>" << hid << "</HID>" <<
|
||||
"<CID>" << cid << "</CID>" <<
|
||||
"<STIME>" << stime << "</STIME>" <<
|
||||
"<ETIME>" << etime << "</ETIME>" <<
|
||||
"<VMMMAD>" << vmm_mad_name << "</VMMMAD>"<<
|
||||
@ -341,6 +345,7 @@ int History::rebuild_attributes()
|
||||
rc += xpath(seq , "/HISTORY/SEQ", -1);
|
||||
rc += xpath(hostname , "/HISTORY/HOSTNAME", "not_found");
|
||||
rc += xpath(hid , "/HISTORY/HID", -1);
|
||||
rc += xpath(cid , "/HISTORY/CID", -1);
|
||||
rc += xpath(stime , "/HISTORY/STIME", 0);
|
||||
rc += xpath(etime , "/HISTORY/ETIME", 0);
|
||||
rc += xpath(vmm_mad_name , "/HISTORY/VMMMAD", "not_found");
|
||||
|
@ -1367,6 +1367,7 @@ error_common:
|
||||
|
||||
void VirtualMachine::add_history(
|
||||
int hid,
|
||||
int cid,
|
||||
const string& hostname,
|
||||
const string& vmm_mad,
|
||||
const string& vnm_mad,
|
||||
@ -1395,6 +1396,7 @@ void VirtualMachine::add_history(
|
||||
seq,
|
||||
hid,
|
||||
hostname,
|
||||
cid,
|
||||
vmm_mad,
|
||||
vnm_mad,
|
||||
tm_mad,
|
||||
@ -1424,6 +1426,7 @@ void VirtualMachine::cp_history()
|
||||
history->seq + 1,
|
||||
history->hid,
|
||||
history->hostname,
|
||||
history->cid,
|
||||
history->vmm_mad_name,
|
||||
history->vnm_mad_name,
|
||||
history->tm_mad_name,
|
||||
@ -1456,6 +1459,7 @@ void VirtualMachine::cp_previous_history()
|
||||
history->seq + 1,
|
||||
previous_history->hid,
|
||||
previous_history->hostname,
|
||||
previous_history->cid,
|
||||
previous_history->vmm_mad_name,
|
||||
previous_history->vnm_mad_name,
|
||||
previous_history->tm_mad_name,
|
||||
|
Loading…
x
Reference in New Issue
Block a user