mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-23 17:33:56 +03:00
F #3881: make Frontend Hostname configurable
co-authored-by: Alejandro Huertas <ahuertas@opennebula.io>
This commit is contained in:
parent
c54a93bb94
commit
6f0ec36f6f
@ -24,9 +24,6 @@
|
||||
# SCRIPTS_REMOTE_DIR: Remote path to store the monitoring and VM management
|
||||
# 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)
|
||||
# server : (mysql) host name or an IP address for the MySQL server
|
||||
@ -71,9 +68,6 @@ MONITORING_INTERVAL_DB_UPDATE = 0
|
||||
|
||||
SCRIPTS_REMOTE_DIR=/var/tmp/one
|
||||
|
||||
PORT = 2633
|
||||
|
||||
LISTEN_ADDRESS = "0.0.0.0"
|
||||
|
||||
DB = [ BACKEND = "sqlite" ]
|
||||
|
||||
@ -92,6 +86,23 @@ VNC_PORTS = [
|
||||
# RESERVED = "6800, 6801, 6810:6820, 9869"
|
||||
]
|
||||
|
||||
#*******************************************************************************
|
||||
# Server network and connection
|
||||
#-------------------------------------------------------------------------------
|
||||
# PORT: Port where oned will listen for xmlrpc calls.
|
||||
#
|
||||
# LISTEN_ADDRESS: Host IP to listen on for xmlrpc calls (default: all IPs).
|
||||
#
|
||||
# HOSTNAME: This Hostname is used by OpenNebula daemon to connect to the
|
||||
# frontend during drivers operations. If this variable is not set, OpenNebula
|
||||
# will auto detect it. It can be in FQDN format, hostname or an IP
|
||||
|
||||
PORT = 2633
|
||||
|
||||
LISTEN_ADDRESS = "0.0.0.0"
|
||||
|
||||
# HOSTNAME = "one-hostname"
|
||||
|
||||
#*******************************************************************************
|
||||
# API configuration attributes
|
||||
#-------------------------------------------------------------------------------
|
||||
|
@ -67,6 +67,8 @@
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/stat.h>
|
||||
#include <pthread.h>
|
||||
|
||||
@ -130,20 +132,12 @@ void Nebula::start(bool bootstrap_only)
|
||||
int fd;
|
||||
sigset_t mask;
|
||||
int signal;
|
||||
char hn[80];
|
||||
string scripts_remote_dir;
|
||||
SqlDB * db_backend;
|
||||
bool solo;
|
||||
|
||||
SqlDB * db_ptr;
|
||||
|
||||
if ( gethostname(hn,79) != 0 )
|
||||
{
|
||||
throw runtime_error("Error getting hostname");
|
||||
}
|
||||
|
||||
hostname = hn;
|
||||
|
||||
// -----------------------------------------------------------
|
||||
// Configuration
|
||||
// -----------------------------------------------------------
|
||||
@ -167,6 +161,44 @@ void Nebula::start(bool bootstrap_only)
|
||||
}
|
||||
|
||||
nebula_configuration->get("SCRIPTS_REMOTE_DIR", scripts_remote_dir);
|
||||
|
||||
// -----------------------------------------------------------
|
||||
// Get Hostname
|
||||
// -----------------------------------------------------------
|
||||
nebula_configuration->get("HOSTNAME", hostname);
|
||||
|
||||
if ( hostname.empty() )
|
||||
{
|
||||
char hn[1024];
|
||||
struct addrinfo hints = {}, *addrs;
|
||||
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_flags = AI_CANONNAME;
|
||||
|
||||
rc = gethostname(hn, 1023);
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
throw runtime_error("Error getting hostname" +
|
||||
std::string(strerror(rc)));
|
||||
}
|
||||
|
||||
rc = getaddrinfo(hn, nullptr, &hints, &addrs);
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
throw runtime_error("Error getting hostname: " +
|
||||
std::string(gai_strerror(rc)));
|
||||
}
|
||||
|
||||
if ( addrs != nullptr && addrs->ai_canonname != nullptr )
|
||||
{
|
||||
hostname = addrs->ai_canonname;
|
||||
}
|
||||
|
||||
freeaddrinfo(addrs);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------
|
||||
// Log system
|
||||
// -----------------------------------------------------------
|
||||
@ -228,6 +260,8 @@ void Nebula::start(bool bootstrap_only)
|
||||
throw;
|
||||
}
|
||||
|
||||
NebulaLog::log("ONE", Log::INFO, "Using hostname: " + hostname);
|
||||
|
||||
// -----------------------------------------------------------
|
||||
// Load the OpenNebula master key and keep it in memory
|
||||
// -----------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user