mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-23 17:33:56 +03:00
add LISTEN_ADDRESS config for oned XMLRPC
This commit is contained in:
parent
326ed81d1f
commit
ad351b12c0
@ -51,6 +51,7 @@ public:
|
||||
int _timeout,
|
||||
const string _xml_log_file,
|
||||
const string call_log_format,
|
||||
const string _listen_address,
|
||||
int message_size);
|
||||
|
||||
~RequestManager(){};
|
||||
@ -141,6 +142,11 @@ private:
|
||||
*/
|
||||
string xml_log_file;
|
||||
|
||||
/**
|
||||
* Specifies the address xmlrpc server will bind to
|
||||
*/
|
||||
string listen_address;
|
||||
|
||||
/**
|
||||
* Action engine for the Manager
|
||||
*/
|
||||
|
@ -28,6 +28,7 @@
|
||||
# scripts.
|
||||
#
|
||||
# PORT: Port where oned will listen for xmlrpc calls.
|
||||
# LISTEN_ADDRESS: Host IP to listen on for xmlrpc calls (default: all IPs).
|
||||
#
|
||||
# DB: Configuration attributes for the database backend
|
||||
# backend : can be sqlite or mysql (default is sqlite)
|
||||
@ -72,6 +73,8 @@ SCRIPTS_REMOTE_DIR=/var/tmp/one
|
||||
|
||||
PORT = 2633
|
||||
|
||||
LISTEN_ADDRESS = "0.0.0.0"
|
||||
|
||||
DB = [ backend = "sqlite" ]
|
||||
|
||||
# Sample configuration for MySQL
|
||||
|
@ -871,8 +871,10 @@ void Nebula::start(bool bootstrap_only)
|
||||
string log_call_format;
|
||||
string rpc_filename = "";
|
||||
int message_size;
|
||||
string rm_listen_address = "0.0.0.0";
|
||||
|
||||
nebula_configuration->get("PORT", rm_port);
|
||||
nebula_configuration->get("LISTEN_ADDRESS", rm_listen_address);
|
||||
nebula_configuration->get("MAX_CONN", max_conn);
|
||||
nebula_configuration->get("MAX_CONN_BACKLOG", max_conn_backlog);
|
||||
nebula_configuration->get("KEEPALIVE_TIMEOUT", keepalive_timeout);
|
||||
@ -889,7 +891,7 @@ void Nebula::start(bool bootstrap_only)
|
||||
|
||||
rm = new RequestManager(rm_port, max_conn, max_conn_backlog,
|
||||
keepalive_timeout, keepalive_max_conn, timeout, rpc_filename,
|
||||
log_call_format, message_size);
|
||||
log_call_format, rm_listen_address, message_size);
|
||||
}
|
||||
catch (bad_alloc&)
|
||||
{
|
||||
|
@ -105,6 +105,7 @@ void OpenNebulaTemplate::set_conf_default()
|
||||
# VM_INDIVIDUAL_MONITORING
|
||||
# VM_PER_INTERVAL
|
||||
# VM_MONITORING_EXPIRATION_TIME
|
||||
# LISTEN_ADDRESS
|
||||
# PORT
|
||||
# DB
|
||||
# VNC_BASE_PORT
|
||||
@ -160,6 +161,12 @@ void OpenNebulaTemplate::set_conf_default()
|
||||
attribute = new SingleAttribute("PORT",value);
|
||||
conf_default.insert(make_pair(attribute->name(),attribute));
|
||||
|
||||
//XML-RPC Server listen address
|
||||
value = "0.0.0.0";
|
||||
|
||||
attribute = new SingleAttribute("LISTEN_ADDRESS",value);
|
||||
conf_default.insert(make_pair(attribute->name(),attribute));
|
||||
|
||||
//DB CONFIGURATION
|
||||
vvalue.insert(make_pair("BACKEND","sqlite"));
|
||||
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
@ -65,6 +66,7 @@ RequestManager::RequestManager(
|
||||
int _timeout,
|
||||
const string _xml_log_file,
|
||||
const string call_log_format,
|
||||
const string _listen_address,
|
||||
int message_size):
|
||||
port(_port),
|
||||
socket_fd(-1),
|
||||
@ -73,7 +75,8 @@ RequestManager::RequestManager(
|
||||
keepalive_timeout(_keepalive_timeout),
|
||||
keepalive_max_conn(_keepalive_max_conn),
|
||||
timeout(_timeout),
|
||||
xml_log_file(_xml_log_file)
|
||||
xml_log_file(_xml_log_file),
|
||||
listen_address(_listen_address)
|
||||
{
|
||||
Request::set_call_log_format(call_log_format);
|
||||
|
||||
@ -192,7 +195,20 @@ int RequestManager::setup_socket()
|
||||
|
||||
rm_addr.sin_family = AF_INET;
|
||||
rm_addr.sin_port = htons(port);
|
||||
rm_addr.sin_addr.s_addr = INADDR_ANY;
|
||||
|
||||
rc = inet_aton(listen_address.c_str(), &rm_addr.sin_addr);
|
||||
|
||||
if ( rc == 0 )
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
oss << "Invalid listen address: " << listen_address;
|
||||
NebulaLog::log("ReM",Log::ERROR,oss);
|
||||
|
||||
close(socket_fd);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc = bind(socket_fd,(struct sockaddr *) &(rm_addr),sizeof(struct sockaddr));
|
||||
|
||||
@ -200,7 +216,7 @@ int RequestManager::setup_socket()
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
oss << "Cannot bind to port " << port << " : " << strerror(errno);
|
||||
oss << "Cannot bind to " << listen_address << ":" << port << " : " << strerror(errno);
|
||||
NebulaLog::log("ReM",Log::ERROR,oss);
|
||||
|
||||
close(socket_fd);
|
||||
|
Loading…
Reference in New Issue
Block a user