From 09fe471af6616c5cfa1293b9ef1b91025d2708c4 Mon Sep 17 00:00:00 2001
From: "Ruben S. Montero" <rsmontero@opennebula.org>
Date: Wed, 9 Oct 2013 18:39:18 +0200
Subject: [PATCH] feature #1683: Renamed Nebula::init() to
 Nebula::bootstrap_db()

---
 include/Nebula.h     |  2 +-
 src/nebula/Nebula.cc |  2 +-
 src/nebula/oned.cc   | 74 ++++++++++++++++++++++----------------------
 3 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/include/Nebula.h b/include/Nebula.h
index 2db19d6725..d62a55ed94 100644
--- a/include/Nebula.h
+++ b/include/Nebula.h
@@ -346,7 +346,7 @@ public:
     /**
      *  Initialize the database
      */
-    void init();
+    void bootstrap_db();
 
     // -----------------------------------------------------------------------
     // Configuration attributes (read from oned.conf)
diff --git a/src/nebula/Nebula.cc b/src/nebula/Nebula.cc
index 7f78165fb7..66a03d9494 100644
--- a/src/nebula/Nebula.cc
+++ b/src/nebula/Nebula.cc
@@ -268,7 +268,7 @@ int SystemDB::select_sys_attribute(const string& attr_name, string& attr_xml)
 /* -------------------------------------------------------------------------- */
 /* -------------------------------------------------------------------------- */
 
-void Nebula::init()
+void Nebula::bootstrap_db()
 {
     start(true);
 }
diff --git a/src/nebula/oned.cc b/src/nebula/oned.cc
index 457ab7b71c..5cfeda178f 100644
--- a/src/nebula/oned.cc
+++ b/src/nebula/oned.cc
@@ -59,12 +59,12 @@ static void oned_init()
     try
     {
         Nebula& nd  = Nebula::instance();
-        nd.init();   
+        nd.bootstrap_db();
     }
     catch (exception &e)
     {
         cerr << e.what() << endl;
- 
+
         return;
     }
 }
@@ -77,19 +77,19 @@ static void oned_main()
     try
     {
         Nebula& nd  = Nebula::instance();
-        nd.start();    
+        nd.start();
     }
     catch (exception &e)
     {
         cerr << e.what() << endl;
- 
+
         return;
     }
 }
-    
+
 /* -------------------------------------------------------------------------- */
 /* -------------------------------------------------------------------------- */
-    
+
 int main(int argc, char **argv)
 {
     int             opt;
@@ -99,7 +99,7 @@ int main(int argc, char **argv)
     pid_t           pid,sid;
     string          wd;
     int             rc;
-            
+
     while((opt = getopt(argc,argv,"vhif")) != -1)
         switch(opt)
         {
@@ -117,7 +117,7 @@ int main(int argc, char **argv)
                 break;
             case 'f':
                 foreground = true;
-                break;        
+                break;
             default:
                 cerr << susage;
                 exit(-1);
@@ -125,24 +125,24 @@ int main(int argc, char **argv)
         }
 
     // ---------------------------------
-    //   Check if other oned is running  
-    // --------------------------------- 
-    
+    //   Check if other oned is running
+    // ---------------------------------
+
     string lockfile;
     string var_location;
-    
+
     nl = getenv("ONE_LOCATION");
 
     if (nl == 0) // OpenNebula in root of FSH
     {
-    	var_location = "/var/lib/one/"; 
+    	var_location = "/var/lib/one/";
     	lockfile 	 = "/var/lock/one/one";
     }
     else
     {
     	var_location = nl;
     	var_location += "/var/";
-    	
+
     	lockfile = var_location + ".lock";
     }
 
@@ -150,70 +150,70 @@ int main(int argc, char **argv)
 
     if( fd == -1)
     {
-        cerr<< "Error: Cannot start oned, opening lock file " << lockfile 
+        cerr<< "Error: Cannot start oned, opening lock file " << lockfile
             << endl;
-        
+
         exit(-1);
     }
 
     close(fd);
-    
-    // ---------------------------- 
-    //   Fork & exit main process   
-    // ---------------------------- 
-    
+
+    // ----------------------------
+    //   Fork & exit main process
+    // ----------------------------
+
     if (foreground == true)
     {
         pid = 0; //Do not fork
     }
     else
     {
-        pid = fork();    
+        pid = fork();
     }
-        
+
 
     switch (pid){
         case -1: // Error
-            cerr << "Error: Unable to fork.\n"; 
+            cerr << "Error: Unable to fork.\n";
             exit(-1);
-            
+
 
         case 0: // Child process
-        	
+
             rc  = chdir(var_location.c_str());
-                        
+
             if (rc != 0)
             {
                 goto error_chdir;
             }
-            
+
             if (foreground == false)
-            { 
+            {
                 sid = setsid();
-                
+
                 if (sid == -1)
                 {
                     goto error_sid;
                 }
             }
-                        
+
             oned_main();
-            
-            unlink(lockfile.c_str());            
+
+            unlink(lockfile.c_str());
             break;
 
         default: // Parent process
-            break;               
+            break;
     }
-    
+
     return 0;
-    
+
 error_chdir:
     cerr << "Error: cannot change to dir " << wd << "\n";
     unlink(lockfile.c_str());
     exit(-1);
 
-error_sid:    
+error_sid:
     cerr << "Error: creating new session\n";
     unlink(lockfile.c_str());
     exit(-1);