From d5b40785f5a2e868675067d0aa9ce70d683e8156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Thu, 28 Jun 2012 15:32:52 +0200 Subject: [PATCH] Bug #1306: Add tm_mad to History elements --- include/History.h | 2 ++ include/RequestManagerVirtualMachine.h | 3 ++- include/VirtualMachine.h | 23 ++++++++++++++++++++++- src/rm/RequestManagerVirtualMachine.cc | 15 ++++++++++----- src/vm/History.cc | 8 ++++++++ src/vm/VirtualMachine.cc | 6 +++++- 6 files changed, 49 insertions(+), 8 deletions(-) diff --git a/include/History.h b/include/History.h index 952320e62c..7852cfed46 100644 --- a/include/History.h +++ b/include/History.h @@ -46,6 +46,7 @@ public: const string& hostname, const string& vmm, const string& vnm, + const string& tmm, const string& vm_info); ~History(){}; @@ -89,6 +90,7 @@ private: string vmm_mad_name; string vnm_mad_name; + string tm_mad_name; time_t stime; time_t etime; diff --git a/include/RequestManagerVirtualMachine.h b/include/RequestManagerVirtualMachine.h index 10b415352d..f4c8866cac 100644 --- a/include/RequestManagerVirtualMachine.h +++ b/include/RequestManagerVirtualMachine.h @@ -57,13 +57,14 @@ protected: AuthRequest::Operation op); 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 hid, const string& hostname, const string& vmm_mad, const string& vnm_mad, + const string& tm_mad, RequestAttributes& att); VirtualMachine * get_vm(int id, RequestAttributes& att); diff --git a/include/VirtualMachine.h b/include/VirtualMachine.h index 7a16a92e3a..36eeacea67 100644 --- a/include/VirtualMachine.h +++ b/include/VirtualMachine.h @@ -242,7 +242,8 @@ public: int hid, const string& hostname, 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 @@ -318,6 +319,26 @@ public: 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: * $ONE_LOCATION/var/$VM_ID/transfer.$SEQ diff --git a/src/rm/RequestManagerVirtualMachine.cc b/src/rm/RequestManagerVirtualMachine.cc index d4d7e7cd39..67e14dc50b 100644 --- a/src/rm/RequestManagerVirtualMachine.cc +++ b/src/rm/RequestManagerVirtualMachine.cc @@ -99,6 +99,7 @@ int RequestManagerVirtualMachine::get_host_information(int hid, string& name, string& vmm, string& vnm, + string& tm, RequestAttributes& att, PoolObjectAuth& host_perms) { @@ -121,6 +122,7 @@ int RequestManagerVirtualMachine::get_host_information(int hid, name = host->get_name(); vmm = host->get_vmm_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); @@ -156,6 +158,7 @@ int RequestManagerVirtualMachine::add_history(VirtualMachine * vm, const string& hostname, const string& vmm_mad, const string& vnm_mad, + const string& tm_mad, RequestAttributes& att) { string vmdir; @@ -163,7 +166,7 @@ int RequestManagerVirtualMachine::add_history(VirtualMachine * vm, VirtualMachinePool * vmpool = static_cast(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); @@ -308,13 +311,14 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList, string hostname; string vmm_mad; string vnm_mad; + string tm_mad; int id = xmlrpc_c::value_int(paramList.getInt(1)); int hid = xmlrpc_c::value_int(paramList.getInt(2)); 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; } @@ -341,7 +345,7 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList, 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(); return; @@ -369,6 +373,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList string hostname; string vmm_mad; string vnm_mad; + string tm_mad; int id = xmlrpc_c::value_int(paramList.getInt(1)); 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; - 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; } @@ -405,7 +410,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList 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(); return; diff --git a/src/vm/History.cc b/src/vm/History.cc index 4d7580aba9..415c990060 100644 --- a/src/vm/History.cc +++ b/src/vm/History.cc @@ -44,6 +44,7 @@ History::History( hid(-1), vmm_mad_name(""), vnm_mad_name(""), + tm_mad_name(""), stime(0), etime(0), prolog_stime(0), @@ -64,6 +65,7 @@ History::History( const string& _hostname, const string& _vmm, const string& _vnm, + const string& _tmm, const string& _vm_info): oid(_oid), seq(_seq), @@ -71,6 +73,7 @@ History::History( hid(_hid), vmm_mad_name(_vmm), vnm_mad_name(_vnm), + tm_mad_name(_tmm), stime(0), etime(0), prolog_stime(0), @@ -292,6 +295,7 @@ string& History::to_xml(string& xml, bool database) const "" << etime << "" << "" << vmm_mad_name << ""<< "" << vnm_mad_name << ""<< + "" << tm_mad_name << "" << "" << prolog_stime << ""<< "" << prolog_etime << ""<< "" << running_stime << ""<< @@ -328,6 +332,10 @@ int History::rebuild_attributes() rc += xpath(etime , "/HISTORY/ETIME", 0); rc += xpath(vmm_mad_name , "/HISTORY/VMMMAD", "not_found"); 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_etime , "/HISTORY/PETIME", 0); rc += xpath(running_stime , "/HISTORY/RSTIME", 0); diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index 54fa086a92..46ec12eb05 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -826,7 +826,8 @@ void VirtualMachine::add_history( int hid, const string& hostname, const string& vmm_mad, - const string& vnm_mad) + const string& vnm_mad, + const string& tm_mad) { ostringstream os; int seq; @@ -851,6 +852,7 @@ void VirtualMachine::add_history( hostname, vmm_mad, vnm_mad, + tm_mad, vm_xml); history_records.push_back(history); @@ -877,6 +879,7 @@ void VirtualMachine::cp_history() history->hostname, history->vmm_mad_name, history->vnm_mad_name, + history->tm_mad_name, vm_xml); previous_history = history; @@ -906,6 +909,7 @@ void VirtualMachine::cp_previous_history() previous_history->hostname, previous_history->vmm_mad_name, previous_history->vnm_mad_name, + previous_history->tm_mad_name, vm_xml); previous_history = history;