mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-16 22:50:10 +03:00
feature #212: Some pending tasks, mostly log errors.
This commit is contained in:
parent
90597a8c07
commit
3debc8a318
@ -24,6 +24,8 @@
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
#include "NebulaLog.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// =============================================================================
|
||||
|
@ -18,6 +18,7 @@
|
||||
#ifndef POOL_XML_H_
|
||||
#define POOL_XML_H_
|
||||
|
||||
#include "NebulaLog.h"
|
||||
#include "ObjectXML.h"
|
||||
#include "Client.h"
|
||||
|
||||
@ -67,7 +68,8 @@ protected:
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
// TODO: log error
|
||||
NebulaLog::log("POOL",Log::ERROR,
|
||||
"Could not retrieve pool info from ONE");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -79,7 +81,12 @@ protected:
|
||||
|
||||
if( !success )
|
||||
{
|
||||
// TODO log error, in message
|
||||
ostringstream oss;
|
||||
|
||||
oss << "ONE returned error while retrieving pool info:" << endl;
|
||||
oss << message;
|
||||
|
||||
NebulaLog::log("POOL", Log::ERROR, oss);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -98,6 +105,28 @@ protected:
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets an object from the pool
|
||||
* @param oid the object unique identifier
|
||||
*
|
||||
* @return a pointer to the object, 0 in case of failure
|
||||
*/
|
||||
virtual ObjectXML * get(int oid) const
|
||||
{
|
||||
map<int, ObjectXML *>::const_iterator it;
|
||||
|
||||
it = objects.find(oid);
|
||||
|
||||
if ( it == objects.end() )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
@ -107,17 +136,6 @@ protected:
|
||||
return objects;
|
||||
};
|
||||
|
||||
protected:
|
||||
/**
|
||||
* XML-RPC client
|
||||
*/
|
||||
Client * client;
|
||||
|
||||
/**
|
||||
* Hash map contains the suitable [id, object] pairs.
|
||||
*/
|
||||
map<int, ObjectXML *> objects;
|
||||
|
||||
/**
|
||||
* Inserts a new ObjectXML into the objects map
|
||||
*/
|
||||
@ -133,27 +151,20 @@ protected:
|
||||
*/
|
||||
virtual int load_info(xmlrpc_c::value &result) = 0;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Attributes
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Gets an object from the pool
|
||||
* @param oid the object unique identifier
|
||||
*
|
||||
* @return a pointer to the object, 0 in case of failure
|
||||
* XML-RPC client
|
||||
*/
|
||||
virtual const ObjectXML * get(int oid) const
|
||||
{
|
||||
map<int, ObjectXML *>::const_iterator it;
|
||||
Client * client;
|
||||
|
||||
it = objects.find(oid);
|
||||
/**
|
||||
* Hash map contains the suitable [id, object] pairs.
|
||||
*/
|
||||
map<int, ObjectXML *> objects;
|
||||
|
||||
if ( it == objects.end() )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
/**
|
||||
|
@ -39,9 +39,9 @@ public:
|
||||
*
|
||||
* @return a pointer to the object, 0 in case of failure
|
||||
*/
|
||||
const VirtualMachineXML * get(int oid) const
|
||||
VirtualMachineXML * get(int oid) const
|
||||
{
|
||||
return static_cast<const VirtualMachineXML *>(PoolXML::get(oid));
|
||||
return static_cast<VirtualMachineXML *>(PoolXML::get(oid));
|
||||
};
|
||||
|
||||
protected:
|
||||
|
@ -18,13 +18,12 @@
|
||||
#ifndef VM_XML_H_
|
||||
#define VM_XML_H_
|
||||
|
||||
#include "ObjectXML.h"
|
||||
#include <sstream>
|
||||
|
||||
using namespace std;
|
||||
#include "ObjectXML.h"
|
||||
#include "HostPoolXML.h"
|
||||
|
||||
//TODO include the HostPool file...
|
||||
class HostPoolXML;
|
||||
using namespace std;
|
||||
|
||||
class VirtualMachineXML : public ObjectXML
|
||||
{
|
||||
|
@ -25,8 +25,6 @@ int VirtualMachinePoolXML::set_up()
|
||||
|
||||
if ( rc == 0 )
|
||||
{
|
||||
// TODO FIX LOG
|
||||
/*
|
||||
oss.str("");
|
||||
oss << "Pending virtual machines :";
|
||||
|
||||
@ -37,8 +35,7 @@ int VirtualMachinePoolXML::set_up()
|
||||
oss << " " << it->second;
|
||||
}
|
||||
|
||||
Scheduler::log("VM",Log::DEBUG,oss);
|
||||
//*/
|
||||
NebulaLog::log("VM",Log::DEBUG,oss);
|
||||
}
|
||||
|
||||
return rc;
|
||||
@ -51,7 +48,10 @@ void VirtualMachinePoolXML::add_object(xmlNodePtr node)
|
||||
{
|
||||
if ( node == 0 || node->children == 0 || node->children->next==0 )
|
||||
{
|
||||
//TODO Log error
|
||||
NebulaLog::log("VM",Log::ERROR,
|
||||
"XML Node does not represent a valid Virtual Machine");
|
||||
// TODO: if the xml node isn't valid, do nothing?
|
||||
return;
|
||||
}
|
||||
|
||||
xmlChar * str_ptr = xmlNodeGetContent(node->children->next);
|
||||
@ -78,7 +78,13 @@ void VirtualMachinePoolXML::add_object(xmlNodePtr node)
|
||||
|
||||
if( !success )
|
||||
{
|
||||
// TODO log error
|
||||
ostringstream oss;
|
||||
|
||||
oss << "ONE returned error while retrieving info for VM " << vid;
|
||||
oss << ":" << endl;
|
||||
oss << message;
|
||||
|
||||
NebulaLog::log("VM",Log::ERROR,oss);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -94,18 +100,22 @@ void VirtualMachinePoolXML::add_object(xmlNodePtr node)
|
||||
int VirtualMachinePoolXML::load_info(xmlrpc_c::value &result)
|
||||
{
|
||||
try
|
||||
{/*TODO make it compile
|
||||
{
|
||||
client->call(client->get_endpoint(), // serverUrl
|
||||
"one.vmpool.info", // methodName
|
||||
"si", // arguments format
|
||||
result, // resultP
|
||||
&result, // resultP
|
||||
client->get_oneauth().c_str(), // argument 0
|
||||
-2); // argument 1*/
|
||||
-2); // argument 1
|
||||
return 0;
|
||||
}
|
||||
catch (exception const& e)
|
||||
{
|
||||
// TODO log error, in e.what()
|
||||
ostringstream oss;
|
||||
oss << "Exception raised: " << e.what();
|
||||
|
||||
NebulaLog::log("VM", Log::ERROR, oss);
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "VirtualMachineXML.h"
|
||||
|
||||
VirtualMachineXML::VirtualMachineXML(const string &xml_doc):ObjectXML(xml_doc)
|
||||
@ -113,8 +114,7 @@ void VirtualMachineXML::set_priorities(vector<float>& total)
|
||||
{
|
||||
if ( hosts.size() != total.size() )
|
||||
{
|
||||
// TODO log error
|
||||
// Scheduler::log("VM",Log::ERROR,"Wrong size for priority vector");
|
||||
NebulaLog::log("VM",Log::ERROR,"Wrong size for priority vector");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -132,11 +132,10 @@ void VirtualMachineXML::set_priorities(vector<float>& total)
|
||||
|
||||
int VirtualMachineXML::get_host(int& hid, HostPoolXML * hpool)
|
||||
{
|
||||
/*TODO Uncomment for HostPool
|
||||
vector<VirtualMachineXML::Host *>::reverse_iterator i;
|
||||
|
||||
vector<int>::iterator j;
|
||||
HostXML * host;
|
||||
HostXML * host;
|
||||
|
||||
int cpu;
|
||||
int mem;
|
||||
@ -146,7 +145,7 @@ int VirtualMachineXML::get_host(int& hid, HostPoolXML * hpool)
|
||||
|
||||
for (i=hosts.rbegin();i!=hosts.rend();i++)
|
||||
{
|
||||
host = hpool->get( (*i)->hid ) );
|
||||
host = hpool->get( (*i)->hid );
|
||||
|
||||
if ( host == 0 )
|
||||
{
|
||||
@ -163,7 +162,7 @@ int VirtualMachineXML::get_host(int& hid, HostPoolXML * hpool)
|
||||
}
|
||||
|
||||
hid = -1;
|
||||
*/
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -57,13 +57,10 @@ void Client::set_one_auth(string secret)
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO NOTIFY ERROR
|
||||
/*
|
||||
NebulaLog::log("ONE",Log::ERROR,
|
||||
NebulaLog::log("XMLRPC",Log::ERROR,
|
||||
"ONE_AUTH wrong format, must be <username>:<password>");
|
||||
|
||||
throw;
|
||||
//*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -128,8 +125,7 @@ int Client::read_oneauth(string &secret)
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
// TODO NOTIFY ERROR
|
||||
// NebulaLog::log("ONE",Log::ERROR,oss);
|
||||
NebulaLog::log("XMLRPC",Log::ERROR,oss);
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
Loading…
x
Reference in New Issue
Block a user