mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-25 06:03:36 +03:00
F #4952: Add IPv6 support for oned
This commit is contained in:
parent
7cbceb043b
commit
4429031117
@ -43,15 +43,15 @@ class RequestManager : public ActionListener
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
RequestManager(
|
RequestManager(
|
||||||
int _port,
|
const string& _port,
|
||||||
int _max_conn,
|
int _max_conn,
|
||||||
int _max_conn_backlog,
|
int _max_conn_backlog,
|
||||||
int _keepalive_timeout,
|
int _keepalive_timeout,
|
||||||
int _keepalive_max_conn,
|
int _keepalive_max_conn,
|
||||||
int _timeout,
|
int _timeout,
|
||||||
const string _xml_log_file,
|
const string& _xml_log_file,
|
||||||
const string call_log_format,
|
const string& call_log_format,
|
||||||
const string _listen_address,
|
const string& _listen_address,
|
||||||
int message_size);
|
int message_size);
|
||||||
|
|
||||||
~RequestManager(){};
|
~RequestManager(){};
|
||||||
@ -105,7 +105,7 @@ private:
|
|||||||
/**
|
/**
|
||||||
* Port number where the connection will be open
|
* Port number where the connection will be open
|
||||||
*/
|
*/
|
||||||
int port;
|
string port;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FD for the XML server socket
|
* FD for the XML server socket
|
||||||
|
@ -964,7 +964,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
void clear_template_monitor_error();
|
void clear_template_monitor_error();
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
// Timers & Requirements
|
// Timers & Requirements
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
@ -993,7 +992,7 @@ public:
|
|||||||
* @param disk
|
* @param disk
|
||||||
* @param pci_dev
|
* @param pci_dev
|
||||||
*/
|
*/
|
||||||
void get_requirements (int& cpu, int& memory, int& disk,
|
void get_requirements(int& cpu, int& memory, int& disk,
|
||||||
vector<VectorAttribute *>& pci_dev);
|
vector<VectorAttribute *>& pci_dev);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1013,7 +1012,7 @@ public:
|
|||||||
*
|
*
|
||||||
* @return 0 on success
|
* @return 0 on success
|
||||||
*/
|
*/
|
||||||
int check_resize (float cpu, int memory, int vcpu, string& error_str);
|
int check_resize(float cpu, int memory, int vcpu, string& error_str);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resize the VM capacity
|
* Resize the VM capacity
|
||||||
@ -1024,7 +1023,7 @@ public:
|
|||||||
*
|
*
|
||||||
* @return 0 on success
|
* @return 0 on success
|
||||||
*/
|
*/
|
||||||
int resize (float cpu, int memory, int vcpu, string& error_str);
|
int resize(float cpu, int memory, int vcpu, string& error_str);
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
// Virtual Machine Disks
|
// Virtual Machine Disks
|
||||||
@ -1132,7 +1131,7 @@ public:
|
|||||||
* @param password Password to encrypt the token, if it is set
|
* @param password Password to encrypt the token, if it is set
|
||||||
* @return -1 in case of error, 0 if the VM has no context, 1 on success
|
* @return -1 in case of error, 0 if the VM has no context, 1 on success
|
||||||
*/
|
*/
|
||||||
int generate_context(string &files, int &disk_id, const string& password);
|
int generate_context(string &files, int &disk_id, const string& password);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the CREATED_BY template attribute, or the uid if it does not exist
|
* Returns the CREATED_BY template attribute, or the uid if it does not exist
|
||||||
|
@ -370,8 +370,8 @@ void Nebula::start(bool bootstrap_only)
|
|||||||
//XML Library
|
//XML Library
|
||||||
xmlCleanupParser();
|
xmlCleanupParser();
|
||||||
|
|
||||||
NebulaLog::log("ONE", Log::INFO, "Database bootstrap finalized, exiting.\n");
|
NebulaLog::log("ONE", Log::INFO,
|
||||||
|
"Database bootstrap finalized, exiting.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -918,7 +918,7 @@ void Nebula::start(bool bootstrap_only)
|
|||||||
// ---- Request Manager ----
|
// ---- Request Manager ----
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int rm_port = 0;
|
string rm_port;
|
||||||
int max_conn;
|
int max_conn;
|
||||||
int max_conn_backlog;
|
int max_conn_backlog;
|
||||||
int keepalive_timeout;
|
int keepalive_timeout;
|
||||||
|
@ -54,9 +54,8 @@
|
|||||||
|
|
||||||
#include <sys/signal.h>
|
#include <sys/signal.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <sys/types.h>
|
||||||
#include <netinet/tcp.h>
|
#include <netdb.h>
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -64,15 +63,15 @@
|
|||||||
|
|
||||||
|
|
||||||
RequestManager::RequestManager(
|
RequestManager::RequestManager(
|
||||||
int _port,
|
const string& _port,
|
||||||
int _max_conn,
|
int _max_conn,
|
||||||
int _max_conn_backlog,
|
int _max_conn_backlog,
|
||||||
int _keepalive_timeout,
|
int _keepalive_timeout,
|
||||||
int _keepalive_max_conn,
|
int _keepalive_max_conn,
|
||||||
int _timeout,
|
int _timeout,
|
||||||
const string _xml_log_file,
|
const string& _xml_log_file,
|
||||||
const string call_log_format,
|
const string& call_log_format,
|
||||||
const string _listen_address,
|
const string& _listen_address,
|
||||||
int message_size):
|
int message_size):
|
||||||
port(_port),
|
port(_port),
|
||||||
socket_fd(-1),
|
socket_fd(-1),
|
||||||
@ -167,11 +166,29 @@ extern "C" void * rm_xml_server_loop(void *arg)
|
|||||||
|
|
||||||
int RequestManager::setup_socket()
|
int RequestManager::setup_socket()
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
int yes = 1;
|
int yes = 1;
|
||||||
struct sockaddr_in rm_addr;
|
|
||||||
|
|
||||||
socket_fd = socket(AF_INET, SOCK_STREAM, 0);
|
struct addrinfo hints = {0};
|
||||||
|
struct addrinfo * result;
|
||||||
|
|
||||||
|
hints.ai_family = AF_UNSPEC;
|
||||||
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
hints.ai_flags = AI_PASSIVE;
|
||||||
|
|
||||||
|
rc = getaddrinfo(listen_address.c_str(), port.c_str(), &hints, &result);
|
||||||
|
|
||||||
|
if ( rc != 0 )
|
||||||
|
{
|
||||||
|
ostringstream oss;
|
||||||
|
|
||||||
|
oss << "Cannot open server socket: " << gai_strerror(rc);
|
||||||
|
NebulaLog::log("ReM",Log::ERROR,oss);
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
socket_fd = socket(result->ai_family, result->ai_socktype, 0);
|
||||||
|
|
||||||
if ( socket_fd == -1 )
|
if ( socket_fd == -1 )
|
||||||
{
|
{
|
||||||
@ -180,6 +197,8 @@ int RequestManager::setup_socket()
|
|||||||
oss << "Cannot open server socket: " << strerror(errno);
|
oss << "Cannot open server socket: " << strerror(errno);
|
||||||
NebulaLog::log("ReM",Log::ERROR,oss);
|
NebulaLog::log("ReM",Log::ERROR,oss);
|
||||||
|
|
||||||
|
freeaddrinfo(result);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,35 +213,24 @@ int RequestManager::setup_socket()
|
|||||||
|
|
||||||
close(socket_fd);
|
close(socket_fd);
|
||||||
|
|
||||||
|
freeaddrinfo(result);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fcntl(socket_fd,F_SETFD,FD_CLOEXEC); // Close socket in MADs
|
fcntl(socket_fd,F_SETFD,FD_CLOEXEC); // Close socket in MADs
|
||||||
|
|
||||||
rm_addr.sin_family = AF_INET;
|
rc = bind(socket_fd, result->ai_addr, result->ai_addrlen);
|
||||||
rm_addr.sin_port = htons(port);
|
|
||||||
|
|
||||||
rc = inet_aton(listen_address.c_str(), &rm_addr.sin_addr);
|
freeaddrinfo(result);
|
||||||
|
|
||||||
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));
|
|
||||||
|
|
||||||
if ( rc == -1)
|
if ( rc == -1)
|
||||||
{
|
{
|
||||||
ostringstream oss;
|
ostringstream oss;
|
||||||
|
|
||||||
oss << "Cannot bind to " << listen_address << ":" << port << " : " << strerror(errno);
|
oss << "Cannot bind to " << listen_address << ":" << port << " : "
|
||||||
|
<< strerror(errno);
|
||||||
|
|
||||||
NebulaLog::log("ReM",Log::ERROR,oss);
|
NebulaLog::log("ReM",Log::ERROR,oss);
|
||||||
|
|
||||||
close(socket_fd);
|
close(socket_fd);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user