mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-25 02:50:08 +03:00
Feature #2572: XML-RPC library element size can be defined in sched.conf
This commit is contained in:
parent
1abee8aafc
commit
99157ea06b
@ -20,7 +20,7 @@
|
||||
#include "Template.h"
|
||||
#include <map>
|
||||
|
||||
/**
|
||||
/**
|
||||
* This class provides the basic abstraction for OpenNebula configuration files
|
||||
*/
|
||||
class NebulaTemplate : public Template
|
||||
@ -33,7 +33,7 @@ public:
|
||||
{
|
||||
conf_file = etc_location + _conf_name;
|
||||
}
|
||||
|
||||
|
||||
virtual ~NebulaTemplate(){};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
@ -42,22 +42,22 @@ public:
|
||||
int get(const char * name, vector<const Attribute*>& values) const
|
||||
{
|
||||
string _name(name);
|
||||
|
||||
return Template::get(_name,values);
|
||||
|
||||
return Template::get(_name,values);
|
||||
};
|
||||
|
||||
|
||||
void get(const char * name, string& values) const
|
||||
{
|
||||
string _name(name);
|
||||
|
||||
Template::get(_name,values);
|
||||
|
||||
Template::get(_name,values);
|
||||
};
|
||||
|
||||
|
||||
void get(const char * name, int& values) const
|
||||
{
|
||||
string _name(name);
|
||||
|
||||
Template::get(_name,values);
|
||||
|
||||
Template::get(_name,values);
|
||||
};
|
||||
|
||||
void get(const char *name, unsigned int& values) const
|
||||
@ -68,32 +68,32 @@ public:
|
||||
|
||||
values = static_cast<unsigned int>(ival);
|
||||
};
|
||||
|
||||
|
||||
void get(const char * name, time_t& values) const
|
||||
{
|
||||
const SingleAttribute * sattr;
|
||||
vector<const Attribute *> attr;
|
||||
|
||||
|
||||
string _name(name);
|
||||
|
||||
|
||||
if ( Template::get(_name,attr) == 0 )
|
||||
{
|
||||
values = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
sattr = dynamic_cast<const SingleAttribute *>(attr[0]);
|
||||
|
||||
|
||||
if ( sattr != 0 )
|
||||
{
|
||||
istringstream is;
|
||||
|
||||
|
||||
is.str(sattr->value());
|
||||
is >> values;
|
||||
}
|
||||
else
|
||||
values = 0;
|
||||
};
|
||||
values = 0;
|
||||
};
|
||||
|
||||
void get(const char *name, float& value) const
|
||||
{
|
||||
@ -109,6 +109,13 @@ public:
|
||||
Template::get(_name,value);
|
||||
};
|
||||
|
||||
void get(const char *name, long long& value) const
|
||||
{
|
||||
string _name(name);
|
||||
|
||||
Template::get(_name,value);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
@ -119,10 +126,10 @@ public:
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Full path to the configuration file
|
||||
* Full path to the configuration file
|
||||
*/
|
||||
string conf_file;
|
||||
|
||||
|
||||
/**
|
||||
* Defaults for the configuration file
|
||||
*/
|
||||
@ -138,13 +145,13 @@ protected:
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
class OpenNebulaTemplate : public NebulaTemplate
|
||||
{
|
||||
{
|
||||
public:
|
||||
|
||||
OpenNebulaTemplate(const string& etc_location, const string& _var_location):
|
||||
NebulaTemplate(etc_location, conf_name), var_location(_var_location)
|
||||
{};
|
||||
|
||||
|
||||
~OpenNebulaTemplate(){};
|
||||
|
||||
private:
|
||||
@ -157,7 +164,7 @@ private:
|
||||
* Path for the var directory, for defaults
|
||||
*/
|
||||
string var_location;
|
||||
|
||||
|
||||
/**
|
||||
* Sets the defaults value for the template
|
||||
*/
|
||||
|
@ -5,6 +5,8 @@
|
||||
#*******************************************************************************
|
||||
# Daemon configuration attributes
|
||||
#-------------------------------------------------------------------------------
|
||||
# MESSAGE_SIZE: Buffer size in bytes for XML-RPC responses.
|
||||
#
|
||||
# ONED_PORT: Port to connect to the OpenNebula daemon (oned)
|
||||
#
|
||||
# SCHED_INTERVAL: Seconds between two scheduling actions
|
||||
@ -57,6 +59,8 @@
|
||||
# - debug_level: 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBU
|
||||
#*******************************************************************************
|
||||
|
||||
MESSAGE_SIZE = 1073741824
|
||||
|
||||
ONED_PORT = 2633
|
||||
|
||||
SCHED_INTERVAL = 30
|
||||
|
@ -55,15 +55,15 @@ public:
|
||||
* @param endpoint Where the rpc server is listening, must be something
|
||||
* like "http://localhost:2633/RPC2". If not set, the endpoint will be set
|
||||
* to $ONE_XMLRPC.
|
||||
* @param message_size for XML elements in the client library (in bytes)
|
||||
* @throws Exception if the authorization options are invalid
|
||||
*/
|
||||
Client( string secret = "",
|
||||
string endpoint = "")
|
||||
Client(const string& secret, const string& endpoint, size_t message_size)
|
||||
{
|
||||
set_one_auth(secret);
|
||||
set_one_endpoint(endpoint);
|
||||
|
||||
xmlrpc_limit_set(XMLRPC_XML_SIZE_LIMIT_ID, 1024*MESSAGE_SIZE);
|
||||
xmlrpc_limit_set(XMLRPC_XML_SIZE_LIMIT_ID, message_size);
|
||||
}
|
||||
|
||||
const string& get_oneauth()
|
||||
@ -76,17 +76,16 @@ public:
|
||||
return one_endpoint;
|
||||
}
|
||||
|
||||
size_t get_message_size()
|
||||
{
|
||||
return xmlrpc_limit_get(XMLRPC_XML_SIZE_LIMIT_ID);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// PRIVATE ATTRIBUTES AND METHODS
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Default message size for XML data off the network
|
||||
*/
|
||||
static const int MESSAGE_SIZE;
|
||||
|
||||
string one_auth;
|
||||
string one_endpoint;
|
||||
|
||||
|
@ -33,11 +33,6 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
const int Client::MESSAGE_SIZE = 51200;
|
||||
//
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void Client::set_one_auth(string secret)
|
||||
{
|
||||
if (secret.empty())
|
||||
|
@ -195,7 +195,18 @@ void Scheduler::start()
|
||||
|
||||
try
|
||||
{
|
||||
client = new Client("",url);
|
||||
long long message_size;
|
||||
|
||||
conf.get("MESSAGE_SIZE", message_size);
|
||||
|
||||
client = new Client("", url, message_size);
|
||||
|
||||
oss.str("");
|
||||
|
||||
oss << "XML-RPC client using " << client->get_message_size()
|
||||
<< " bytes for response buffer.\n";
|
||||
|
||||
NebulaLog::log("SCHED", Log::INFO, oss);
|
||||
}
|
||||
catch(runtime_error &)
|
||||
{
|
||||
|
@ -35,6 +35,7 @@ void SchedulerTemplate::set_conf_default()
|
||||
#*******************************************************************************
|
||||
# Daemon configuration attributes
|
||||
#-------------------------------------------------------------------------------
|
||||
# XML_RPC_MESSAGE_SIZE
|
||||
# ONED_PORT
|
||||
# SCHED_INTERVAL
|
||||
# MAX_VM
|
||||
@ -47,6 +48,12 @@ void SchedulerTemplate::set_conf_default()
|
||||
# LOG
|
||||
#-------------------------------------------------------------------------------
|
||||
*/
|
||||
// XML_RPC_MESSAGE_SIZE
|
||||
value = "1073741824";
|
||||
|
||||
attribute = new SingleAttribute("MESSAGE_SIZE",value);
|
||||
conf_default.insert(make_pair(attribute->name(),attribute));
|
||||
|
||||
// ONED_PORT
|
||||
value = "2633";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user