mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-20 10:50:08 +03:00
Feature #1112: Use SYSTEM_DS values from oned.conf to create default DS
This commit is contained in:
parent
4e2bd36415
commit
d2ad28a909
@ -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(){};
|
||||
|
||||
|
@ -14,12 +14,6 @@
|
||||
/* limitations under the License. */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "Datastore.h"
|
||||
#include "GroupPool.h"
|
||||
#include "NebulaLog.h"
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -275,6 +275,10 @@ void Nebula::start()
|
||||
string default_device_prefix;
|
||||
time_t expiration_time;
|
||||
|
||||
vector<const Attribute *> system_ds;
|
||||
string ds_base_path;
|
||||
string ds_type;
|
||||
|
||||
vector<const Attribute *> vm_hooks;
|
||||
vector<const Attribute *> host_hooks;
|
||||
vector<const Attribute *> 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<const VectorAttribute *>(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&)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user