mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-11 05:17:41 +03:00
Feature #2562: Create a local zone on bootstrap
This commit is contained in:
parent
83a5a413ab
commit
87df948ee3
@ -130,6 +130,10 @@ public:
|
||||
return PoolSQL::dump(oss, "ZONE_POOL", Zone::table, where, limit);
|
||||
};
|
||||
|
||||
/**
|
||||
* ID for the special local zone in stand-alone mode
|
||||
*/
|
||||
static const int STANDALONE_ZONE_ID;
|
||||
private:
|
||||
|
||||
/**
|
||||
|
@ -17,14 +17,41 @@
|
||||
#include "ZonePool.h"
|
||||
#include "NebulaLog.h"
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
const int ZonePool::STANDALONE_ZONE_ID = 0;
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
ZonePool::ZonePool(SqlDB * db, bool cache)
|
||||
:PoolSQL(db, Zone::table, cache, true)
|
||||
{
|
||||
string error_str;
|
||||
|
||||
if (get_lastOID() == -1) //lastOID is set in PoolSQL::init_cb
|
||||
{
|
||||
int rc;
|
||||
Template * tmpl;
|
||||
|
||||
// Build the local zone
|
||||
tmpl = new Template;
|
||||
rc = tmpl->parse_str_or_xml(
|
||||
"NAME = OpenNebula\n"
|
||||
"ENDPOINT = -",
|
||||
error_str);
|
||||
|
||||
if( rc < 0 )
|
||||
{
|
||||
goto error_bootstrap;
|
||||
}
|
||||
|
||||
allocate(tmpl, &rc, error_str);
|
||||
|
||||
if( rc < 0 )
|
||||
{
|
||||
goto error_bootstrap;
|
||||
}
|
||||
|
||||
// The first 100 Zone IDs are reserved for system Zones.
|
||||
// Regular ones start from ID 100
|
||||
|
||||
@ -32,6 +59,13 @@ ZonePool::ZonePool(SqlDB * db, bool cache)
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
error_bootstrap:
|
||||
ostringstream oss;
|
||||
oss << "Error trying to create local zone: " << error_str;
|
||||
NebulaLog::log("ZONE",Log::ERROR,oss);
|
||||
|
||||
throw runtime_error(oss.str());
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
Loading…
Reference in New Issue
Block a user