mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-25 02:50:08 +03:00
Feature #377: MySQL port is now defined in oned.conf
This commit is contained in:
parent
5f6b326c52
commit
33e01f53b1
@ -44,6 +44,7 @@ class MySqlDB : public SqlDB
|
||||
public:
|
||||
|
||||
MySqlDB(const string& server,
|
||||
const int& port,
|
||||
const string& user,
|
||||
const string& password,
|
||||
char * database);
|
||||
@ -109,6 +110,7 @@ public:
|
||||
|
||||
MySqlDB(
|
||||
string server,
|
||||
int port,
|
||||
string user,
|
||||
string password,
|
||||
char * database)
|
||||
|
@ -98,7 +98,7 @@ public:
|
||||
{
|
||||
if (mysql)
|
||||
{
|
||||
db = new MySqlDB("localhost","oneadmin","oneadmin",NULL);
|
||||
db = new MySqlDB("localhost",0,"oneadmin","oneadmin",NULL);
|
||||
|
||||
ostringstream oss1;
|
||||
oss1 << "DROP DATABASE IF EXISTS " << db_name;
|
||||
|
@ -19,6 +19,8 @@
|
||||
# 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
|
||||
# port : (mysql) port for the connection to the server.
|
||||
# If set to 0, the default port is used.
|
||||
# user : (mysql) user's MySQL login ID
|
||||
# passwd : (mysql) the password for user
|
||||
# db_name : (mysql) the database name
|
||||
@ -44,6 +46,7 @@ DB = [ backend = "sqlite" ]
|
||||
# Sample configuration for MySQL
|
||||
# DB = [ backend = "mysql",
|
||||
# server = "localhost",
|
||||
# port = 0,
|
||||
# user = "oneadmin",
|
||||
# passwd = "oneadmin",
|
||||
# db_name = "opennebula" ]
|
||||
|
@ -141,6 +141,8 @@ void Nebula::start()
|
||||
bool db_is_sqlite = true;
|
||||
|
||||
string server = "localhost";
|
||||
string port_str;
|
||||
int port = 0;
|
||||
string user = "oneadmin";
|
||||
string passwd = "oneadmin";
|
||||
string db_name = "opennebula";
|
||||
@ -164,6 +166,18 @@ void Nebula::start()
|
||||
server = value;
|
||||
}
|
||||
|
||||
istringstream is;
|
||||
|
||||
port_str = db->vector_value("PORT");
|
||||
|
||||
is.str(port_str);
|
||||
is >> port;
|
||||
|
||||
if( is.fail() )
|
||||
{
|
||||
port = 0;
|
||||
}
|
||||
|
||||
value = db->vector_value("USER");
|
||||
if (!value.empty())
|
||||
{
|
||||
@ -194,7 +208,7 @@ void Nebula::start()
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
db = new MySqlDB(server,user,passwd,0);
|
||||
db = new MySqlDB(server,port,user,passwd,0);
|
||||
|
||||
oss << "CREATE DATABASE IF NOT EXISTS " << db_name;
|
||||
rc = db->exec(oss);
|
||||
|
@ -72,7 +72,7 @@ public:
|
||||
|
||||
if (mysql)
|
||||
{
|
||||
db = new MySqlDB("localhost","oneadmin","oneadmin",NULL);
|
||||
db = new MySqlDB("localhost",0,"oneadmin","oneadmin",NULL);
|
||||
|
||||
ostringstream oss1;
|
||||
oss1 << "DROP DATABASE IF EXISTS " << db_name;
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
MySqlDB::MySqlDB(
|
||||
const string& server,
|
||||
const int& port,
|
||||
const string& user,
|
||||
const string& password,
|
||||
char * database)
|
||||
@ -37,7 +38,7 @@ MySqlDB::MySqlDB(
|
||||
|
||||
// Connect to the server
|
||||
if (!mysql_real_connect(db, server.c_str(), user.c_str(),
|
||||
password.c_str(), database, 0, NULL, 0))
|
||||
password.c_str(), database, port, NULL, 0))
|
||||
{
|
||||
throw runtime_error("Could not open database.");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user