1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-02-27 13:57:23 +03:00

Bug #1306: Add tm_mad to History elements

This commit is contained in:
Carlos Martín 2012-06-28 15:32:52 +02:00
parent 1130e37a2e
commit d5b40785f5
6 changed files with 49 additions and 8 deletions

View File

@ -46,6 +46,7 @@ public:
const string& hostname, const string& hostname,
const string& vmm, const string& vmm,
const string& vnm, const string& vnm,
const string& tmm,
const string& vm_info); const string& vm_info);
~History(){}; ~History(){};
@ -89,6 +90,7 @@ private:
string vmm_mad_name; string vmm_mad_name;
string vnm_mad_name; string vnm_mad_name;
string tm_mad_name;
time_t stime; time_t stime;
time_t etime; time_t etime;

View File

@ -57,13 +57,14 @@ protected:
AuthRequest::Operation op); AuthRequest::Operation op);
int get_host_information(int hid, string& name, string& vmm, string& vnm, int get_host_information(int hid, string& name, string& vmm, string& vnm,
RequestAttributes& att, PoolObjectAuth& host_perms); string& tm, RequestAttributes& att, PoolObjectAuth& host_perms);
int add_history(VirtualMachine * vm, int add_history(VirtualMachine * vm,
int hid, int hid,
const string& hostname, const string& hostname,
const string& vmm_mad, const string& vmm_mad,
const string& vnm_mad, const string& vnm_mad,
const string& tm_mad,
RequestAttributes& att); RequestAttributes& att);
VirtualMachine * get_vm(int id, RequestAttributes& att); VirtualMachine * get_vm(int id, RequestAttributes& att);

View File

@ -242,7 +242,8 @@ public:
int hid, int hid,
const string& hostname, const string& hostname,
const string& vmm_mad, const string& vmm_mad,
const string& vnm_mad); const string& vnm_mad,
const string& tm_mad);
/** /**
* Duplicates the last history record. Only the host related fields are * Duplicates the last history record. Only the host related fields are
@ -318,6 +319,26 @@ public:
return previous_history->vnm_mad_name; return previous_history->vnm_mad_name;
}; };
/**
* Returns the TM driver name for the current host. The hasHistory()
* function MUST be called before this one.
* @return the TM mad name
*/
const string & get_tm_mad() const
{
return history->tm_mad_name;
};
/**
* Returns the TM driver name for the previous host. The
* hasPreviousHistory() function MUST be called before this one.
* @return the TM mad name
*/
const string & get_previous_tm_mad() const
{
return previous_history->tm_mad_name;
};
/** /**
* Returns the transfer filename. The transfer file is in the form: * Returns the transfer filename. The transfer file is in the form:
* $ONE_LOCATION/var/$VM_ID/transfer.$SEQ * $ONE_LOCATION/var/$VM_ID/transfer.$SEQ

View File

@ -99,6 +99,7 @@ int RequestManagerVirtualMachine::get_host_information(int hid,
string& name, string& name,
string& vmm, string& vmm,
string& vnm, string& vnm,
string& tm,
RequestAttributes& att, RequestAttributes& att,
PoolObjectAuth& host_perms) PoolObjectAuth& host_perms)
{ {
@ -121,6 +122,7 @@ int RequestManagerVirtualMachine::get_host_information(int hid,
name = host->get_name(); name = host->get_name();
vmm = host->get_vmm_mad(); vmm = host->get_vmm_mad();
vnm = host->get_vnm_mad(); vnm = host->get_vnm_mad();
tm = ""; // TODO host->get_cluster_id, get DS from Cluster, get TM from DS
host->get_permissions(host_perms); host->get_permissions(host_perms);
@ -156,6 +158,7 @@ int RequestManagerVirtualMachine::add_history(VirtualMachine * vm,
const string& hostname, const string& hostname,
const string& vmm_mad, const string& vmm_mad,
const string& vnm_mad, const string& vnm_mad,
const string& tm_mad,
RequestAttributes& att) RequestAttributes& att)
{ {
string vmdir; string vmdir;
@ -163,7 +166,7 @@ int RequestManagerVirtualMachine::add_history(VirtualMachine * vm,
VirtualMachinePool * vmpool = static_cast<VirtualMachinePool *>(pool); VirtualMachinePool * vmpool = static_cast<VirtualMachinePool *>(pool);
vm->add_history(hid,hostname,vmm_mad,vnm_mad); vm->add_history(hid,hostname,vmm_mad,vnm_mad,tm_mad);
rc = vmpool->update_history(vm); rc = vmpool->update_history(vm);
@ -308,13 +311,14 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
string hostname; string hostname;
string vmm_mad; string vmm_mad;
string vnm_mad; string vnm_mad;
string tm_mad;
int id = xmlrpc_c::value_int(paramList.getInt(1)); int id = xmlrpc_c::value_int(paramList.getInt(1));
int hid = xmlrpc_c::value_int(paramList.getInt(2)); int hid = xmlrpc_c::value_int(paramList.getInt(2));
bool auth = false; bool auth = false;
if (get_host_information(hid,hostname,vmm_mad,vnm_mad,att, host_perms) != 0) if (get_host_information(hid,hostname,vmm_mad,vnm_mad,tm_mad,att, host_perms) != 0)
{ {
return; return;
} }
@ -341,7 +345,7 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
return; return;
} }
if ( add_history(vm,hid,hostname,vmm_mad,vnm_mad,att) != 0) if ( add_history(vm,hid,hostname,vmm_mad,vnm_mad,tm_mad,att) != 0)
{ {
vm->unlock(); vm->unlock();
return; return;
@ -369,6 +373,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
string hostname; string hostname;
string vmm_mad; string vmm_mad;
string vnm_mad; string vnm_mad;
string tm_mad;
int id = xmlrpc_c::value_int(paramList.getInt(1)); int id = xmlrpc_c::value_int(paramList.getInt(1));
int hid = xmlrpc_c::value_int(paramList.getInt(2)); int hid = xmlrpc_c::value_int(paramList.getInt(2));
@ -376,7 +381,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
bool auth = false; bool auth = false;
if (get_host_information(hid,hostname,vmm_mad,vnm_mad,att, host_perms) != 0) if (get_host_information(hid,hostname,vmm_mad,vnm_mad,tm_mad,att, host_perms) != 0)
{ {
return; return;
} }
@ -405,7 +410,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
return; return;
} }
if ( add_history(vm,hid,hostname,vmm_mad,vnm_mad,att) != 0) if ( add_history(vm,hid,hostname,vmm_mad,vnm_mad,tm_mad,att) != 0)
{ {
vm->unlock(); vm->unlock();
return; return;

View File

@ -44,6 +44,7 @@ History::History(
hid(-1), hid(-1),
vmm_mad_name(""), vmm_mad_name(""),
vnm_mad_name(""), vnm_mad_name(""),
tm_mad_name(""),
stime(0), stime(0),
etime(0), etime(0),
prolog_stime(0), prolog_stime(0),
@ -64,6 +65,7 @@ History::History(
const string& _hostname, const string& _hostname,
const string& _vmm, const string& _vmm,
const string& _vnm, const string& _vnm,
const string& _tmm,
const string& _vm_info): const string& _vm_info):
oid(_oid), oid(_oid),
seq(_seq), seq(_seq),
@ -71,6 +73,7 @@ History::History(
hid(_hid), hid(_hid),
vmm_mad_name(_vmm), vmm_mad_name(_vmm),
vnm_mad_name(_vnm), vnm_mad_name(_vnm),
tm_mad_name(_tmm),
stime(0), stime(0),
etime(0), etime(0),
prolog_stime(0), prolog_stime(0),
@ -292,6 +295,7 @@ string& History::to_xml(string& xml, bool database) const
"<ETIME>" << etime << "</ETIME>" << "<ETIME>" << etime << "</ETIME>" <<
"<VMMMAD>" << vmm_mad_name << "</VMMMAD>"<< "<VMMMAD>" << vmm_mad_name << "</VMMMAD>"<<
"<VNMMAD>" << vnm_mad_name << "</VNMMAD>"<< "<VNMMAD>" << vnm_mad_name << "</VNMMAD>"<<
"<TMMAD>" << tm_mad_name << "</TMMAD>" <<
"<PSTIME>" << prolog_stime << "</PSTIME>"<< "<PSTIME>" << prolog_stime << "</PSTIME>"<<
"<PETIME>" << prolog_etime << "</PETIME>"<< "<PETIME>" << prolog_etime << "</PETIME>"<<
"<RSTIME>" << running_stime << "</RSTIME>"<< "<RSTIME>" << running_stime << "</RSTIME>"<<
@ -328,6 +332,10 @@ int History::rebuild_attributes()
rc += xpath(etime , "/HISTORY/ETIME", 0); rc += xpath(etime , "/HISTORY/ETIME", 0);
rc += xpath(vmm_mad_name , "/HISTORY/VMMMAD", "not_found"); rc += xpath(vmm_mad_name , "/HISTORY/VMMMAD", "not_found");
xpath(vnm_mad_name , "/HISTORY/VNMMAD", "dummy"); xpath(vnm_mad_name , "/HISTORY/VNMMAD", "dummy");
// TODO: add TMMAD element in onedb migrator
rc += xpath(tm_mad_name , "/HISTORY/TMMAD", "not_found");
rc += xpath(prolog_stime , "/HISTORY/PSTIME", 0); rc += xpath(prolog_stime , "/HISTORY/PSTIME", 0);
rc += xpath(prolog_etime , "/HISTORY/PETIME", 0); rc += xpath(prolog_etime , "/HISTORY/PETIME", 0);
rc += xpath(running_stime , "/HISTORY/RSTIME", 0); rc += xpath(running_stime , "/HISTORY/RSTIME", 0);

View File

@ -826,7 +826,8 @@ void VirtualMachine::add_history(
int hid, int hid,
const string& hostname, const string& hostname,
const string& vmm_mad, const string& vmm_mad,
const string& vnm_mad) const string& vnm_mad,
const string& tm_mad)
{ {
ostringstream os; ostringstream os;
int seq; int seq;
@ -851,6 +852,7 @@ void VirtualMachine::add_history(
hostname, hostname,
vmm_mad, vmm_mad,
vnm_mad, vnm_mad,
tm_mad,
vm_xml); vm_xml);
history_records.push_back(history); history_records.push_back(history);
@ -877,6 +879,7 @@ void VirtualMachine::cp_history()
history->hostname, history->hostname,
history->vmm_mad_name, history->vmm_mad_name,
history->vnm_mad_name, history->vnm_mad_name,
history->tm_mad_name,
vm_xml); vm_xml);
previous_history = history; previous_history = history;
@ -906,6 +909,7 @@ void VirtualMachine::cp_previous_history()
previous_history->hostname, previous_history->hostname,
previous_history->vmm_mad_name, previous_history->vmm_mad_name,
previous_history->vnm_mad_name, previous_history->vnm_mad_name,
previous_history->tm_mad_name,
vm_xml); vm_xml);
previous_history = history; previous_history = history;