mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-24 21:34:01 +03:00
Feature #1112: Create default system datastore at bootstrap
This commit is contained in:
parent
174ba75d63
commit
0dfb521b9b
@ -26,7 +26,7 @@ using namespace std;
|
||||
class DatastorePool : public PoolSQL
|
||||
{
|
||||
public:
|
||||
DatastorePool(SqlDB * db):PoolSQL(db, Datastore::table){};
|
||||
DatastorePool(SqlDB * db);
|
||||
|
||||
~DatastorePool(){};
|
||||
|
||||
@ -34,6 +34,16 @@ public:
|
||||
/* Constants for DB management */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Default name for the oneadmin group
|
||||
*/
|
||||
static const string SYSTEM_DS_NAME;
|
||||
|
||||
/**
|
||||
* Identifier for the oneadmin group
|
||||
*/
|
||||
static const int SYSTEM_DS_ID;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Methods for DB management */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
@ -20,6 +20,50 @@
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* There is a default datastore boostrapped by the core: */
|
||||
/* The first 100 IDs are reserved for system datastores. Regular ones start */
|
||||
/* from ID 100 */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
const string DatastorePool::SYSTEM_DS_NAME = "default";
|
||||
const int DatastorePool::SYSTEM_DS_ID = 0;
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
DatastorePool::DatastorePool(SqlDB * db):PoolSQL(db, Datastore::table)
|
||||
{
|
||||
ostringstream oss;
|
||||
string error_str;
|
||||
|
||||
if (get_lastOID() == -1) //lastOID is set in PoolSQL::init_cb
|
||||
{
|
||||
int rc;
|
||||
Datastore * ds;
|
||||
|
||||
// Build the default datastore
|
||||
ds = new Datastore(SYSTEM_DS_ID, SYSTEM_DS_NAME);
|
||||
|
||||
rc = PoolSQL::allocate(ds, error_str);
|
||||
|
||||
if( rc < 0 )
|
||||
{
|
||||
goto error_bootstrap;
|
||||
}
|
||||
|
||||
set_update_lastOID(99);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
error_bootstrap:
|
||||
oss << "Error trying to create default datastore: " << error_str;
|
||||
NebulaLog::log("DATASTORE",Log::ERROR,oss);
|
||||
|
||||
throw runtime_error(oss.str());
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user