Feature #863: Add Virtual Network MAD to hosts

This commit is contained in:
Carlos Martín committed 2011-11-10 17:28:32 +01:00
1 parent 9b0f47068a
commit 665036efcf
11 files changed
+64 -18

No files matched your search

+4
View File
@@ -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);
+12 -1
View File
@@ -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;
+4 -2
View File
@@ -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);
}
/* -------------------------------------------------------------------------- */
+11 -6
View File
@@ -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;
+5
View File
@@ -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);
+4 -1
View File
@@ -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;