mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-03 01:17:41 +03:00
feature #4215: drop logic for MarketPlace is now in
RequestManagerDelete.
This commit is contained in:
parent
60c20ba0ee
commit
2fe760218e
@ -42,7 +42,12 @@ public:
|
||||
/* Set the action in the set */
|
||||
void set(T action)
|
||||
{
|
||||
action_set += 1 << static_cast<int>(action);
|
||||
action_set |= 1 << static_cast<int>(action);
|
||||
};
|
||||
|
||||
void clear(T action)
|
||||
{
|
||||
action_set &= (~ (1 << static_cast<int>(action)));
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -106,8 +106,31 @@ public:
|
||||
return supported_actions.is_set(action);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if this is a public (external) marketplace
|
||||
*/
|
||||
bool is_public() const;
|
||||
|
||||
/**
|
||||
* Disbale de monitor action for this marketplace
|
||||
* @return true if the monitor was enabled
|
||||
*/
|
||||
bool disable_monitor()
|
||||
{
|
||||
bool enabled = supported_actions.is_set(MarketPlaceApp::MONITOR);
|
||||
|
||||
supported_actions.clear(MarketPlaceApp::MONITOR);
|
||||
|
||||
return enabled;
|
||||
}
|
||||
/**
|
||||
* Enable the monitor action
|
||||
*/
|
||||
void enable_monitor()
|
||||
{
|
||||
supported_actions.set(MarketPlaceApp::MONITOR);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
friend class MarketPlacePool;
|
||||
|
@ -161,7 +161,6 @@ int MarketPlaceAppPool::drop(PoolObjectSQL * objsql, std::string& error_msg)
|
||||
|
||||
std::ostringstream oss("Cannot drop marketapp at federation master: ",
|
||||
std::ios::ate);
|
||||
|
||||
try
|
||||
{
|
||||
client->call(client->get_endpoint(),
|
||||
|
@ -211,20 +211,6 @@ int MarketPlacePool::drop(PoolObjectSQL * objsql, std::string& error_msg)
|
||||
return -1;
|
||||
}
|
||||
|
||||
MarketPlace *mp = static_cast<MarketPlace *>(objsql);
|
||||
|
||||
if( !mp->is_public() && mp->marketapps.size() > 0 )
|
||||
{
|
||||
std::ostringstream oss;
|
||||
|
||||
oss << "MarketPlace " << mp->get_oid() << " is not empty.";
|
||||
error_msg = oss.str();
|
||||
|
||||
NebulaLog::log("MARKETPLACE", Log::ERROR, error_msg);
|
||||
|
||||
return -3;
|
||||
}
|
||||
|
||||
return PoolSQL::drop(objsql, error_msg);
|
||||
}
|
||||
|
||||
|
@ -576,18 +576,30 @@ int MarketPlaceAppDelete::drop(int oid, PoolObjectSQL * object, string& emsg)
|
||||
|
||||
int MarketPlaceDelete::drop(int oid, PoolObjectSQL * object, string& emsg)
|
||||
{
|
||||
MarketPlace * mp = static_cast<MarketPlace *>(object);
|
||||
set<int> apps = mp->get_marketapp_ids();
|
||||
MarketPlace * mp = static_cast<MarketPlace *>(object);
|
||||
std::set<int> apps = mp->get_marketapp_ids();
|
||||
bool can_del = mp->is_public() || apps.empty();
|
||||
int mp_id = mp->get_oid();
|
||||
|
||||
int rc = pool->drop(object, emsg);
|
||||
|
||||
object->unlock();
|
||||
|
||||
if ( rc != 0 || apps.empty() )
|
||||
if( !can_del )
|
||||
{
|
||||
return rc;
|
||||
std::ostringstream oss;
|
||||
|
||||
oss << object_name(PoolObjectSQL::MARKETPLACE) << " "
|
||||
<< mp->get_oid() << " is not empty.";
|
||||
emsg = oss.str();
|
||||
|
||||
mp->unlock();
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool old_monitor = mp->disable_monitor();
|
||||
|
||||
mp->unlock();
|
||||
|
||||
int rc = 0;
|
||||
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
||||
MarketPlaceApp * app;
|
||||
@ -619,6 +631,28 @@ int MarketPlaceDelete::drop(int oid, PoolObjectSQL * object, string& emsg)
|
||||
app->unlock();
|
||||
}
|
||||
|
||||
MarketPlacePool* mppool = static_cast<MarketPlacePool *>(pool);
|
||||
|
||||
mp = mppool->get(mp_id, true);
|
||||
|
||||
if (mp == 0)
|
||||
{
|
||||
emsg = "MarketPlace no longer exists";
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( rc == 0 )
|
||||
{
|
||||
mppool->drop(mp, emsg);
|
||||
}
|
||||
else if (old_monitor)
|
||||
{
|
||||
mp->enable_monitor();
|
||||
}
|
||||
|
||||
mp->unlock();
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user