diff --git a/include/DatastorePool.h b/include/DatastorePool.h index c01b35ad86..7dbf41913f 100644 --- a/include/DatastorePool.h +++ b/include/DatastorePool.h @@ -26,7 +26,9 @@ using namespace std; class DatastorePool : public PoolSQL { public: - DatastorePool(SqlDB * db); + DatastorePool(SqlDB * db, + const string& base_path, + const string& type); ~DatastorePool(){}; diff --git a/src/datastore/Datastore.cc b/src/datastore/Datastore.cc index d7d7628e31..d38fcb2731 100644 --- a/src/datastore/Datastore.cc +++ b/src/datastore/Datastore.cc @@ -14,12 +14,6 @@ /* limitations under the License. */ /* ------------------------------------------------------------------------ */ -#include -#include - -#include -#include - #include "Datastore.h" #include "GroupPool.h" #include "NebulaLog.h" diff --git a/src/datastore/DatastorePool.cc b/src/datastore/DatastorePool.cc index 2dcb64f1de..a3ac161634 100644 --- a/src/datastore/DatastorePool.cc +++ b/src/datastore/DatastorePool.cc @@ -32,7 +32,10 @@ const int DatastorePool::SYSTEM_DS_ID = 0; /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -DatastorePool::DatastorePool(SqlDB * db):PoolSQL(db, Datastore::table) +DatastorePool::DatastorePool(SqlDB * db, + const string& base_path, + const string& type): + PoolSQL(db, Datastore::table) { ostringstream oss; string error_str; @@ -43,9 +46,20 @@ DatastorePool::DatastorePool(SqlDB * db):PoolSQL(db, Datastore::table) Datastore * ds; // Build the default datastore - // TODO: create template with default name, type and base path -/* - ds = new Datastore(SYSTEM_DS_ID, SYSTEM_DS_NAME); + + oss << "NAME = " << SYSTEM_DS_ID << endl + << "BASE_PATH = " << base_path << endl + << "TYPE = " << type; + + DatastoreTemplate * ds_tmpl = new DatastoreTemplate; + rc = ds_tmpl->parse_str_or_xml(oss.str(), error_str); + + if( rc < 0 ) + { + goto error_bootstrap; + } + + ds = new Datastore(-1, ds_tmpl); rc = PoolSQL::allocate(ds, error_str); @@ -53,7 +67,7 @@ DatastorePool::DatastorePool(SqlDB * db):PoolSQL(db, Datastore::table) { goto error_bootstrap; } -*/ + set_update_lastOID(99); } diff --git a/src/nebula/Nebula.cc b/src/nebula/Nebula.cc index bb2f1f6ebc..7e2a72e468 100644 --- a/src/nebula/Nebula.cc +++ b/src/nebula/Nebula.cc @@ -275,6 +275,10 @@ void Nebula::start() string default_device_prefix; time_t expiration_time; + vector system_ds; + string ds_base_path; + string ds_type; + vector vm_hooks; vector host_hooks; vector vm_restricted_attrs; @@ -313,7 +317,23 @@ void Nebula::start() tpool = new VMTemplatePool(db); - dspool = new DatastorePool(db); + rc = nebula_configuration->get("SYSTEM_DS", system_ds); + + if ( rc != 0 ) + { + string value; + const VectorAttribute * ds_conf = + static_cast(system_ds[0]); + + ds_base_path = ds_conf->vector_value("BASE_PATH"); + ds_type = ds_conf->vector_value("TYPE"); + } + else + { + throw runtime_error("Missing SYSTEM_DS configuration from oned.conf"); + } + + dspool = new DatastorePool(db, ds_base_path, ds_type); } catch (exception&) {