mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-26 06:50:09 +03:00
feature #4215: Remove public Marketplaces, even if they have images.
Associated apps are also removed.
This commit is contained in:
parent
fb14daee30
commit
a4dc856406
@ -98,6 +98,8 @@ public:
|
||||
return supported_actions.is_set(action);
|
||||
}
|
||||
|
||||
bool is_public() const;
|
||||
|
||||
private:
|
||||
|
||||
friend class MarketPlacePool;
|
||||
|
@ -138,7 +138,7 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
* Lists the Datastore ids
|
||||
* Lists the MarketPlace ids
|
||||
* @param oids a vector with the oids of the objects.
|
||||
*
|
||||
* @return 0 on success
|
||||
|
@ -407,6 +407,8 @@ public:
|
||||
};
|
||||
|
||||
~MarketPlaceDelete(){};
|
||||
|
||||
int drop(int oid, PoolObjectSQL * object, string& error_msg);
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
@ -1083,12 +1083,15 @@ DS_MAD_CONF = [
|
||||
# - monitor The apps of the marketplace will be monitored
|
||||
# - create, the app in the marketplace
|
||||
# - delete, the app from the marketplace
|
||||
# public: set to yes for external marketplaces. A public marketplace can be
|
||||
# removed even if it has registered apps.
|
||||
#*******************************************************************************
|
||||
|
||||
MARKET_MAD_CONF = [
|
||||
NAME = "one",
|
||||
REQUIRED_ATTRS = "",
|
||||
APP_ACTIONS = "create, monitor"
|
||||
APP_ACTIONS = "create, monitor",
|
||||
PUBLIC = "yes"
|
||||
]
|
||||
|
||||
MARKET_MAD_CONF = [
|
||||
|
@ -83,7 +83,7 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
|
||||
if d["IMAGES"]["ID"].nil?
|
||||
"0"
|
||||
else
|
||||
d["IMAGES"]["ID"].size
|
||||
[d["IMAGES"]["ID"]].flatten.size
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -74,7 +74,7 @@ class OneMarketPlaceHelper < OpenNebulaHelper::OneHelper
|
||||
if d["MARKETPLACEAPPS"]["ID"].nil?
|
||||
"0"
|
||||
else
|
||||
d["MARKETPLACEAPPS"]["ID"].size
|
||||
[d["MARKETPLACEAPPS"]["ID"]].flatten.size
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -432,3 +432,18 @@ void MarketPlace::update_monitor(const Template& data)
|
||||
data.get("USED_MB", used_mb);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
bool MarketPlace::is_public() const
|
||||
{
|
||||
const VectorAttribute* vatt;
|
||||
bool _public = false;
|
||||
|
||||
if (Nebula::instance().get_market_conf_attribute(market_mad, vatt) == 0)
|
||||
{
|
||||
vatt->vector_value("PUBLIC", _public);
|
||||
}
|
||||
|
||||
return _public;
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ int MarketPlacePool::drop(PoolObjectSQL * objsql, std::string& error_msg)
|
||||
|
||||
MarketPlace *mp = static_cast<MarketPlace *>(objsql);
|
||||
|
||||
if( mp->get_collection_size() > 0 )
|
||||
if( !mp->is_public() && mp->get_collection_size() > 0 )
|
||||
{
|
||||
std::ostringstream oss;
|
||||
|
||||
|
@ -536,3 +536,54 @@ 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();
|
||||
|
||||
int rc = pool->drop(object, emsg);
|
||||
|
||||
object->unlock();
|
||||
|
||||
if ( rc != 0 || apps.empty() )
|
||||
{
|
||||
return rc;
|
||||
}
|
||||
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
||||
MarketPlaceApp * app;
|
||||
MarketPlaceAppPool * apppool = nd.get_apppool();
|
||||
|
||||
string app_error;
|
||||
|
||||
for ( set<int>::iterator i = apps.begin(); i != apps.end(); ++i )
|
||||
{
|
||||
app = apppool->get(*i, true);
|
||||
|
||||
if ( app == 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( apppool->drop(app, app_error) != 0 )
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
oss << "Cannot remove " << object_name(PoolObjectSQL::MARKETPLACEAPP)
|
||||
<< " " << *i << ": " << app_error << ". ";
|
||||
|
||||
emsg = emsg + oss.str();
|
||||
|
||||
rc = -1;
|
||||
}
|
||||
|
||||
app->unlock();
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user