mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-26 06:50:09 +03:00
Feature #4217: Add missing options to marketplace pools in a federation
Slaves do not use cache, and all write methods have an extra check to avoid writings in a slave DB
This commit is contained in:
parent
0dc66e8d6e
commit
fb14daee30
@ -24,7 +24,10 @@ class SqlDB;
|
||||
class MarketPlaceAppPool : public PoolSQL
|
||||
{
|
||||
public:
|
||||
MarketPlaceAppPool(SqlDB * db):PoolSQL(db,MarketPlaceApp::table,true,true){};
|
||||
MarketPlaceAppPool(
|
||||
SqlDB * db,
|
||||
bool is_federation_slave)
|
||||
:PoolSQL(db,MarketPlaceApp::table,!is_federation_slave,true){};
|
||||
|
||||
~MarketPlaceAppPool(){};
|
||||
|
||||
@ -60,6 +63,16 @@ public:
|
||||
const std::string& mp_data,
|
||||
int * oid,
|
||||
std::string& error_str);
|
||||
|
||||
/**
|
||||
* Drops the MarketPlaceApp from the data base. The object mutex SHOULD be
|
||||
* locked.
|
||||
* @param objsql a pointer to the MarketPlace object
|
||||
* @param error_msg Error reason, if any
|
||||
* @return 0 on success, -1 DB error
|
||||
*/
|
||||
int drop(PoolObjectSQL * objsql, std::string& error_msg);
|
||||
|
||||
/**
|
||||
* Imports an app into the marketplace, as reported by the monitor driver
|
||||
* @param template to generate app with the from_template64 function
|
||||
|
@ -27,7 +27,8 @@ class MarketPlaceApp;
|
||||
class MarketPlacePool : public PoolSQL
|
||||
{
|
||||
public:
|
||||
MarketPlacePool(SqlDB * db);
|
||||
MarketPlacePool(SqlDB * db,
|
||||
bool is_federation_slave);
|
||||
|
||||
~MarketPlacePool(){};
|
||||
|
||||
|
@ -43,6 +43,15 @@ int MarketPlaceAppPool:: allocate(
|
||||
|
||||
std::ostringstream oss;
|
||||
|
||||
if (Nebula::instance().is_federation_slave())
|
||||
{
|
||||
NebulaLog::log("ONE",Log::ERROR,
|
||||
"MarketPlaceAppPool::allocate called, but this "
|
||||
"OpenNebula is a federation slave");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
mp = new MarketPlaceApp(uid, gid, uname, gname, umask, apptemplate);
|
||||
|
||||
mp->market_id = mp_id;
|
||||
@ -106,6 +115,23 @@ error_name:
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int MarketPlaceAppPool::drop(PoolObjectSQL * objsql, std::string& error_msg)
|
||||
{
|
||||
if (Nebula::instance().is_federation_slave())
|
||||
{
|
||||
NebulaLog::log("ONE",Log::ERROR,
|
||||
"MarketPlaceAppPool::drop called, but this "
|
||||
"OpenNebula is a federation slave");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
return PoolSQL::drop(objsql, error_msg);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int MarketPlaceAppPool::import(const std::string& t64, int mp_id,
|
||||
const std::string& mp_name, std::string& error_str)
|
||||
{
|
||||
|
@ -20,9 +20,17 @@
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
MarketPlacePool::MarketPlacePool(SqlDB * db)
|
||||
:PoolSQL(db, MarketPlace::table, true, true)
|
||||
MarketPlacePool::MarketPlacePool(
|
||||
SqlDB * db,
|
||||
bool is_federation_slave)
|
||||
:PoolSQL(db, MarketPlace::table, !is_federation_slave, true)
|
||||
{
|
||||
//Federation slaves do not need to init the pool
|
||||
if (is_federation_slave)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//lastOID is set in PoolSQL::init_cb
|
||||
if (get_lastOID() == -1)
|
||||
{
|
||||
@ -92,6 +100,15 @@ int MarketPlacePool::allocate(
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
if (Nebula::instance().is_federation_slave())
|
||||
{
|
||||
NebulaLog::log("ONE",Log::ERROR,
|
||||
"MarketPlacePool::allocate called, but this "
|
||||
"OpenNebula is a federation slave");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
mp = new MarketPlace(uid, gid, uname, gname, umask, mp_template);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@ -132,6 +149,15 @@ error_name:
|
||||
|
||||
int MarketPlacePool::drop(PoolObjectSQL * objsql, std::string& error_msg)
|
||||
{
|
||||
if (Nebula::instance().is_federation_slave())
|
||||
{
|
||||
NebulaLog::log("ONE",Log::ERROR,
|
||||
"MarketPlacePool::drop called, but this "
|
||||
"OpenNebula is a federation slave");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
MarketPlace *mp = static_cast<MarketPlace *>(objsql);
|
||||
|
||||
if( mp->get_collection_size() > 0 )
|
||||
|
@ -589,8 +589,8 @@ void Nebula::start(bool bootstrap_only)
|
||||
|
||||
secgrouppool = new SecurityGroupPool(db);
|
||||
|
||||
marketpool = new MarketPlacePool(db);
|
||||
apppool = new MarketPlaceAppPool(db);
|
||||
marketpool = new MarketPlacePool(db, is_federation_slave());
|
||||
apppool = new MarketPlaceAppPool(db, is_federation_slave());
|
||||
}
|
||||
catch (exception&)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user