diff --git a/include/History.h b/include/History.h index 35e38a3569..0f46fc86f2 100644 --- a/include/History.h +++ b/include/History.h @@ -46,6 +46,7 @@ public: const string& hostname, const string& vm_dir, const string& vmm, + const string& vnm, const string& tm); ~History(){}; @@ -91,6 +92,7 @@ private: int hid; string vmm_mad_name; + string vnm_mad_name; string tm_mad_name; time_t stime; diff --git a/include/Host.h b/include/Host.h index f112532aa0..cb9403cdf4 100644 --- a/include/Host.h +++ b/include/Host.h @@ -130,6 +130,15 @@ public: return vmm_mad_name; }; + /** + * Retrives VNM mad name + * @return string vnm mad name + */ + const string& get_vnm_mad() const + { + return vnm_mad_name; + }; + /** * Retrives TM mad name * @return string tm mad name @@ -311,6 +320,11 @@ private: */ string vmm_mad_name; + /** + * Name of the VN driver used to manage networking in this host + */ + string vnm_mad_name; + /** * Name of the TM driver used to transfer file to and from this host */ @@ -338,6 +352,7 @@ private: const string& hostname="", const string& im_mad_name="", const string& vmm_mad_name="", + const string& vnm_mad_name="", const string& tm_mad_name=""); virtual ~Host(); diff --git a/include/HostPool.h b/include/HostPool.h index 89a516218e..50686a60fe 100644 --- a/include/HostPool.h +++ b/include/HostPool.h @@ -51,6 +51,7 @@ public: const string& hostname, const string& im_mad_name, const string& vmm_mad_name, + const string& vnm_mad_name, const string& tm_mad_name, string& error_str); diff --git a/include/RequestManagerVirtualMachine.h b/include/RequestManagerVirtualMachine.h index ea70ad35f5..0c06b4582b 100644 --- a/include/RequestManagerVirtualMachine.h +++ b/include/RequestManagerVirtualMachine.h @@ -51,13 +51,14 @@ protected: bool vm_authorization(int id, int hid, ImageTemplate *tmpl, RequestAttributes& att); - int get_host_information(int hid, string& name, string& vmm, string& tm, - RequestAttributes& att); + int get_host_information(int hid, string& name, string& vmm, string& vnm, + string& tm, RequestAttributes& att); int add_history(VirtualMachine * vm, int hid, const string& hostname, const string& vmm_mad, + const string& vnm_mad, const string& tm_mad, RequestAttributes& att); diff --git a/include/VirtualMachine.h b/include/VirtualMachine.h index 7d93020fd8..357ccb75a1 100644 --- a/include/VirtualMachine.h +++ b/include/VirtualMachine.h @@ -217,6 +217,7 @@ public: const string& hostname, const string& vm_dir, const string& vmm_mad, + const string& vnm_mad, const string& tm_mad); /** @@ -281,9 +282,7 @@ public: // const string & get_vnm_mad() const string get_vnm_mad() const { - string tmp = "TODO"; - return tmp; - //TODO return history->vnm_mad_name; + return history->vnm_mad_name; }; /** @@ -294,9 +293,7 @@ public: // const string & get_previous_vnm_mad() const string get_previous_vnm_mad() const { - string tmp = "TODO"; - return tmp; - //return previous_history->vnm_mad_name; + return previous_history->vnm_mad_name; }; /** diff --git a/src/host/Host.cc b/src/host/Host.cc index 52361a96ed..484a44953b 100644 --- a/src/host/Host.cc +++ b/src/host/Host.cc @@ -33,11 +33,13 @@ Host::Host( const string& _hostname, const string& _im_mad_name, const string& _vmm_mad_name, + const string& _vnm_mad_name, const string& _tm_mad_name): PoolObjectSQL(id,_hostname,-1,-1,"","",table), state(INIT), im_mad_name(_im_mad_name), vmm_mad_name(_vmm_mad_name), + vnm_mad_name(_vnm_mad_name), tm_mad_name(_tm_mad_name), last_monitored(0) { @@ -200,6 +202,7 @@ string& Host::to_xml(string& xml) const "<STATE>" << state << "</STATE>" << "<IM_MAD>" << im_mad_name << "</IM_MAD>" << "<VM_MAD>" << vmm_mad_name << "</VM_MAD>" << + "<VN_MAD>" << vnm_mad_name << "</VN_MAD>" << "<TM_MAD>" << tm_mad_name << "</TM_MAD>" << "<LAST_MON_TIME>" << last_monitored << "</LAST_MON_TIME>" << host_share.to_xml(share_xml) << @@ -231,6 +234,7 @@ int Host::from_xml(const string& xml) rc += xpath(im_mad_name, "/HOST/IM_MAD", "not_found"); rc += xpath(vmm_mad_name, "/HOST/VM_MAD", "not_found"); + rc += xpath(vnm_mad_name, "/HOST/VN_MAD", "not_found"); rc += xpath(tm_mad_name, "/HOST/TM_MAD", "not_found"); rc += xpath(last_monitored, "/HOST/LAST_MON_TIME", 0); diff --git a/src/host/HostPool.cc b/src/host/HostPool.cc index d33529cbad..b3d404a1a0 100644 --- a/src/host/HostPool.cc +++ b/src/host/HostPool.cc @@ -139,6 +139,7 @@ int HostPool::allocate ( const string& hostname, const string& im_mad_name, const string& vmm_mad_name, + const string& vnm_mad_name, const string& tm_mad_name, string& error_str) { @@ -165,6 +166,11 @@ int HostPool::allocate ( goto error_vmm; } + if ( vnm_mad_name.empty() ) + { + goto error_vnm; + } + if ( tm_mad_name.empty() ) { goto error_tm; @@ -179,7 +185,8 @@ int HostPool::allocate ( // Build a new Host object - host = new Host(-1, hostname, im_mad_name, vmm_mad_name, tm_mad_name); + host = new Host(-1, hostname, im_mad_name, vmm_mad_name, vnm_mad_name, + tm_mad_name); // Insert the Object in the pool @@ -204,6 +211,10 @@ error_vmm: oss << "VMM_MAD_NAME cannot be empty."; goto error_common; +error_vnm: + oss << "VNM_MAD_NAME cannot be empty."; + goto error_common; + error_tm: oss << "TM_MAD_NAME cannot be empty."; goto error_common; diff --git a/src/rm/RequestManagerAllocate.cc b/src/rm/RequestManagerAllocate.cc index eb60f27e08..6d0eded4cc 100644 --- a/src/rm/RequestManagerAllocate.cc +++ b/src/rm/RequestManagerAllocate.cc @@ -212,11 +212,13 @@ int HostAllocate::pool_allocate(xmlrpc_c::paramList const& paramList, string host = xmlrpc_c::value_string(paramList.getString(1)); string im_mad = xmlrpc_c::value_string(paramList.getString(2)); string vmm_mad = xmlrpc_c::value_string(paramList.getString(3)); - string tm_mad = xmlrpc_c::value_string(paramList.getString(4)); + string vnm_mad = xmlrpc_c::value_string(paramList.getString(4)); + string tm_mad = xmlrpc_c::value_string(paramList.getString(5)); HostPool * hpool = static_cast<HostPool *>(pool); - return hpool->allocate(&id, host, im_mad, vmm_mad, tm_mad, error_str); + return hpool->allocate(&id, host, im_mad, vmm_mad, vnm_mad, tm_mad, + error_str); } /* -------------------------------------------------------------------------- */ diff --git a/src/rm/RequestManagerVirtualMachine.cc b/src/rm/RequestManagerVirtualMachine.cc index 17dd537084..ff74188a51 100644 --- a/src/rm/RequestManagerVirtualMachine.cc +++ b/src/rm/RequestManagerVirtualMachine.cc @@ -88,7 +88,8 @@ bool RequestManagerVirtualMachine::vm_authorization(int oid, int RequestManagerVirtualMachine::get_host_information(int hid, string& name, - string& vmm, + string& vmm, + string& vnm, string& tm, RequestAttributes& att) { @@ -110,6 +111,7 @@ int RequestManagerVirtualMachine::get_host_information(int hid, name = host->get_name(); vmm = host->get_vmm_mad(); + vnm = host->get_vnm_mad(); tm = host->get_tm_mad(); host->unlock(); @@ -142,6 +144,7 @@ int RequestManagerVirtualMachine::add_history(VirtualMachine * vm, int hid, const string& hostname, const string& vmm_mad, + const string& vnm_mad, const string& tm_mad, RequestAttributes& att) { @@ -154,7 +157,7 @@ int RequestManagerVirtualMachine::add_history(VirtualMachine * vm, nd.get_configuration_attribute("VM_DIR",vmdir); - vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad); + vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad); rc = vmpool->update_history(vm); @@ -273,6 +276,7 @@ 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)); @@ -283,7 +287,7 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList, return; } - if (get_host_information(hid,hostname,vmm_mad,tm_mad, att) != 0) + if (get_host_information(hid,hostname,vmm_mad,vnm_mad,tm_mad, att) != 0) { return; } @@ -303,7 +307,7 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList, return; } - if ( add_history(vm,hid,hostname,vmm_mad,tm_mad,att) != 0) + if ( add_history(vm,hid,hostname,vmm_mad,vnm_mad,tm_mad,att) != 0) { vm->unlock(); return; @@ -329,6 +333,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)); @@ -340,7 +345,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList return; } - if (get_host_information(hid,hostname,vmm_mad,tm_mad,att) != 0) + if (get_host_information(hid,hostname,vmm_mad,vnm_mad,tm_mad,att) != 0) { return; } @@ -362,7 +367,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList return; } - if ( add_history(vm,hid,hostname,vmm_mad,tm_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 3bef2c4eb6..f2a52ccb3c 100644 --- a/src/vm/History.cc +++ b/src/vm/History.cc @@ -43,6 +43,7 @@ History::History( vm_dir(""), hid(-1), vmm_mad_name(""), + vnm_mad_name(""), tm_mad_name(""), stime(0), etime(0), @@ -63,6 +64,7 @@ History::History( const string& _hostname, const string& _vm_dir, const string& _vmm, + const string& _vnm, const string& _tm): oid(_oid), seq(_seq), @@ -70,6 +72,7 @@ History::History( vm_dir(_vm_dir), hid(_hid), vmm_mad_name(_vmm), + vnm_mad_name(_vnm), tm_mad_name(_tm), stime(0), etime(0), @@ -267,6 +270,7 @@ string& History::to_xml(string& xml) const "<STIME>" << stime << "</STIME>" << "<ETIME>" << etime << "</ETIME>" << "<VMMMAD>" << vmm_mad_name << "</VMMMAD>"<< + "<VNMMAD>" << vnm_mad_name << "</VNMMAD>"<< "<TMMAD>" << tm_mad_name << "</TMMAD>" << "<PSTIME>" << prolog_stime << "</PSTIME>"<< "<PETIME>" << prolog_etime << "</PETIME>"<< @@ -297,6 +301,7 @@ int History::rebuild_attributes() rc += xpath(stime , "/HISTORY/STIME", 0); rc += xpath(etime , "/HISTORY/ETIME", 0); rc += xpath(vmm_mad_name , "/HISTORY/VMMMAD", "not_found"); + rc += xpath(vnm_mad_name , "/HISTORY/VNMMAD", "not_found"); rc += xpath(tm_mad_name , "/HISTORY/TMMAD", "not_found"); rc += xpath(prolog_stime , "/HISTORY/PSTIME", 0); rc += xpath(prolog_etime , "/HISTORY/PETIME", 0); diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index 349f57b8ba..1ca014f8db 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -581,6 +581,7 @@ void VirtualMachine::add_history( const string& hostname, const string& vm_dir, const string& vmm_mad, + const string& vnm_mad, const string& tm_mad) { ostringstream os; @@ -597,7 +598,7 @@ void VirtualMachine::add_history( previous_history = history; } - history = new History(oid,seq,hid,hostname,vm_dir,vmm_mad,tm_mad); + history = new History(oid,seq,hid,hostname,vm_dir,vmm_mad,vnm_mad,tm_mad); history_records.push_back(history); }; @@ -620,6 +621,7 @@ void VirtualMachine::cp_history() history->hostname, history->vm_dir, history->vmm_mad_name, + history->vnm_mad_name, history->tm_mad_name); @@ -647,6 +649,7 @@ void VirtualMachine::cp_previous_history() previous_history->hostname, previous_history->vm_dir, previous_history->vmm_mad_name, + previous_history->vnm_mad_name, previous_history->tm_mad_name); previous_history = history;