mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-16 22:50:10 +03:00
feature #282: Scheduler now builds objects from the pool dump xmls, instead of querying the core for each one individually.
This commit is contained in:
parent
4f82f078b8
commit
7a6b9fc975
@ -25,12 +25,16 @@ using namespace std;
|
||||
class HostXML : public ObjectXML
|
||||
{
|
||||
public:
|
||||
|
||||
HostXML(const string &xml_doc):ObjectXML(xml_doc)
|
||||
{
|
||||
init_attributes();
|
||||
};
|
||||
|
||||
HostXML(const xmlNodePtr node):ObjectXML(node)
|
||||
{
|
||||
init_attributes();
|
||||
};
|
||||
|
||||
int get_hid() const
|
||||
{
|
||||
return oid;
|
||||
|
@ -28,8 +28,11 @@ using namespace std;
|
||||
class VirtualMachineXML : public ObjectXML
|
||||
{
|
||||
public:
|
||||
|
||||
VirtualMachineXML(const string &xml_doc);
|
||||
|
||||
VirtualMachineXML(const xmlNodePtr node);
|
||||
|
||||
~VirtualMachineXML();
|
||||
|
||||
|
||||
@ -94,6 +97,11 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* For constructors
|
||||
*/
|
||||
void init();
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------
|
||||
struct Host
|
||||
|
@ -55,44 +55,9 @@ void HostPoolXML::add_object(xmlNodePtr node)
|
||||
return;
|
||||
}
|
||||
|
||||
xmlChar * str_ptr = xmlNodeGetContent(node->children);
|
||||
istringstream iss(reinterpret_cast<char *>(str_ptr));
|
||||
HostXML* host = new HostXML( node );
|
||||
|
||||
int hid;
|
||||
xmlrpc_c::value result;
|
||||
|
||||
iss >> hid;
|
||||
xmlFree(str_ptr);
|
||||
|
||||
client->call(client->get_endpoint(), // serverUrl
|
||||
"one.host.info", // methodName
|
||||
"si", // arguments format
|
||||
&result, // resultP
|
||||
client->get_oneauth().c_str(), // argument 0
|
||||
hid); // argument 1
|
||||
|
||||
vector<xmlrpc_c::value> values =
|
||||
xmlrpc_c::value_array(result).vectorValueValue();
|
||||
|
||||
bool success = xmlrpc_c::value_boolean( values[0] );
|
||||
string message = xmlrpc_c::value_string( values[1] );
|
||||
|
||||
if( !success )
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
oss << "ONE returned error while retrieving info for Host " << hid;
|
||||
oss << ":" << endl;
|
||||
oss << message;
|
||||
|
||||
NebulaLog::log("HOST",Log::ERROR,oss);
|
||||
}
|
||||
else
|
||||
{
|
||||
HostXML* host = new HostXML( message );
|
||||
|
||||
objects.insert( pair<int,ObjectXML*>(hid, host) );
|
||||
}
|
||||
objects.insert( pair<int,ObjectXML*>(host->get_hid(), host) );
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -55,53 +55,18 @@ void VirtualMachinePoolXML::add_object(xmlNodePtr node)
|
||||
return;
|
||||
}
|
||||
|
||||
xmlChar * str_ptr = xmlNodeGetContent(node->children);
|
||||
istringstream iss(reinterpret_cast<char *>(str_ptr));
|
||||
|
||||
int vid;
|
||||
xmlrpc_c::value result;
|
||||
|
||||
iss >> vid;
|
||||
xmlFree(str_ptr);
|
||||
|
||||
client->call(client->get_endpoint(), // serverUrl
|
||||
"one.vm.info", // methodName
|
||||
"si", // arguments format
|
||||
&result, // resultP
|
||||
client->get_oneauth().c_str(), // argument 0
|
||||
vid); // argument 1
|
||||
|
||||
vector<xmlrpc_c::value> values =
|
||||
xmlrpc_c::value_array(result).vectorValueValue();
|
||||
|
||||
bool success = xmlrpc_c::value_boolean( values[0] );
|
||||
string message = xmlrpc_c::value_string( values[1] );
|
||||
|
||||
if( !success )
|
||||
try
|
||||
{
|
||||
ostringstream oss;
|
||||
VirtualMachineXML* vm = new VirtualMachineXML( node );
|
||||
|
||||
oss << "ONE returned error while retrieving info for VM " << vid;
|
||||
oss << ":" << endl;
|
||||
oss << message;
|
||||
|
||||
NebulaLog::log("VM",Log::ERROR,oss);
|
||||
objects.insert( pair<int,ObjectXML*>(vm->get_oid(), vm) );
|
||||
}
|
||||
else
|
||||
catch(runtime_error& re)
|
||||
{
|
||||
try
|
||||
{
|
||||
VirtualMachineXML* vm = new VirtualMachineXML( message );
|
||||
ostringstream oss_re;
|
||||
|
||||
objects.insert( pair<int,ObjectXML*>(vid, vm) );
|
||||
}
|
||||
catch(runtime_error& re)
|
||||
{
|
||||
ostringstream oss_re;
|
||||
|
||||
oss_re << re.what();
|
||||
NebulaLog::log("VM",Log::ERROR,oss_re);
|
||||
}
|
||||
oss_re << re.what();
|
||||
NebulaLog::log("VM",Log::ERROR,oss_re);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,16 @@
|
||||
#include "VirtualMachineXML.h"
|
||||
|
||||
VirtualMachineXML::VirtualMachineXML(const string &xml_doc):ObjectXML(xml_doc)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
VirtualMachineXML::VirtualMachineXML(const xmlNodePtr node):ObjectXML(node)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
void VirtualMachineXML::init()
|
||||
{
|
||||
vector<string> result;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user