mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-22 13:33:52 +03:00
Feature #4217: Bootstrap the OpenNebula Systems Marketplace
This commit is contained in:
parent
e08d21cec8
commit
07fb60dd83
@ -27,7 +27,7 @@ class MarketPlaceApp;
|
||||
class MarketPlacePool : public PoolSQL
|
||||
{
|
||||
public:
|
||||
MarketPlacePool(SqlDB * db):PoolSQL(db, MarketPlace::table, true, true){};
|
||||
MarketPlacePool(SqlDB * db);
|
||||
|
||||
~MarketPlacePool(){};
|
||||
|
||||
|
@ -1080,6 +1080,11 @@ DS_MAD_CONF = [
|
||||
# template
|
||||
#*******************************************************************************
|
||||
|
||||
MARKET_MAD_CONF = [
|
||||
NAME = "one",
|
||||
REQUIRED_ATTRS = ""
|
||||
]
|
||||
|
||||
MARKET_MAD_CONF = [
|
||||
NAME = "http",
|
||||
REQUIRED_ATTRS = "BASE_URL,PUBLIC_DIR"
|
||||
|
@ -15,8 +15,63 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#include "MarketPlacePool.h"
|
||||
#include "User.h"
|
||||
#include "Nebula.h"
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
MarketPlacePool::MarketPlacePool(SqlDB * db)
|
||||
:PoolSQL(db, MarketPlace::table, true, true)
|
||||
{
|
||||
//lastOID is set in PoolSQL::init_cb
|
||||
if (get_lastOID() == -1)
|
||||
{
|
||||
// Build the default default security group
|
||||
string default_market =
|
||||
"NAME=\"OpenNebula Public\"\n"
|
||||
"MARKET_MAD=one\n"
|
||||
"DESCRIPTION=\"OpenNebula Systems MarketPlace\"";
|
||||
|
||||
Nebula& nd = Nebula::instance();
|
||||
UserPool * upool = nd.get_upool();
|
||||
User * oneadmin = upool->get(0, false);
|
||||
|
||||
string error;
|
||||
|
||||
MarketPlaceTemplate * default_tmpl = new MarketPlaceTemplate;
|
||||
char * error_parse;
|
||||
|
||||
default_tmpl->parse(default_market, &error_parse);
|
||||
|
||||
MarketPlace * marketplace = new MarketPlace(
|
||||
oneadmin->get_uid(),
|
||||
oneadmin->get_gid(),
|
||||
oneadmin->get_uname(),
|
||||
oneadmin->get_gname(),
|
||||
oneadmin->get_umask(),
|
||||
default_tmpl);
|
||||
|
||||
marketplace->set_permissions(1,1,1, 1,0,0, 1,0,0, error);
|
||||
|
||||
if (PoolSQL::allocate(marketplace, error) < 0)
|
||||
{
|
||||
ostringstream oss;
|
||||
oss << "Error trying to create default "
|
||||
<< "OpenNebula Systems MarketPlace: " << error;
|
||||
NebulaLog::log("MKP", Log::ERROR, oss);
|
||||
|
||||
throw runtime_error(oss.str());
|
||||
}
|
||||
|
||||
// The first 100 IDs are reserved for system MarketPlaces.
|
||||
// Regular ones start from ID 100
|
||||
|
||||
set_update_lastOID(99);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -488,9 +488,6 @@ void Nebula::start(bool bootstrap_only)
|
||||
zonepool= new ZonePool(db, is_federation_slave());
|
||||
vdcpool = new VdcPool(db, is_federation_slave());
|
||||
|
||||
marketpool = new MarketPlacePool(db);
|
||||
apppool = new MarketPlaceAppPool(db);
|
||||
|
||||
nebula_configuration->get("VM_HOOK", vm_hooks);
|
||||
nebula_configuration->get("HOST_HOOK", host_hooks);
|
||||
nebula_configuration->get("VROUTER_HOOK", vrouter_hooks);
|
||||
@ -608,6 +605,9 @@ void Nebula::start(bool bootstrap_only)
|
||||
default_group_quota.select();
|
||||
|
||||
secgrouppool = new SecurityGroupPool(db);
|
||||
|
||||
marketpool = new MarketPlacePool(db);
|
||||
apppool = new MarketPlaceAppPool(db);
|
||||
}
|
||||
catch (exception&)
|
||||
{
|
||||
|
@ -156,8 +156,9 @@ void OpenNebulaTemplate::set_multiple_conf_default()
|
||||
#******
|
||||
*/
|
||||
|
||||
set_conf_market("one", "");
|
||||
set_conf_market("http", "BASE_URL,PUBLIC_DIR");
|
||||
set_conf_market("s3", "ACCESS_KEY_ID,SECRET_ACCESS_KEY,REGION,BUCKET");
|
||||
set_conf_market("s3", "ACCESS_KEY_ID,SECRET_ACCESS_KEY,REGION,BUCKET");
|
||||
|
||||
register_multiple_conf_default("MARKET_MAD_CONF");
|
||||
}
|
||||
|
@ -83,7 +83,41 @@ module Migrator
|
||||
|
||||
log_time()
|
||||
|
||||
########################################################################
|
||||
# OpenNebula Systems MarketPlace
|
||||
########################################################################
|
||||
|
||||
oneadmin_uname = nil
|
||||
|
||||
@db.fetch("SELECT name FROM user_pool WHERE oid=0") do |row|
|
||||
oneadmin_uname = row[:name]
|
||||
end
|
||||
|
||||
if oneadmin_uname == nil
|
||||
puts "Error trying to read oneadmin's user name ('SELECT name FROM user_pool WHERE oid=0')"
|
||||
return false
|
||||
end
|
||||
|
||||
oneadmin_gname = nil
|
||||
|
||||
@db.fetch("SELECT name FROM group_pool WHERE oid=0") do |row|
|
||||
oneadmin_gname = row[:name]
|
||||
end
|
||||
|
||||
if oneadmin_gname == nil
|
||||
puts "Error trying to read oneadmin's group name ('SELECT name FROM group_pool WHERE oid=0')"
|
||||
return false
|
||||
end
|
||||
|
||||
@db.run "CREATE TABLE marketplace_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body MEDIUMTEXT, uid INTEGER, gid INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER);"
|
||||
|
||||
@db.run "INSERT INTO marketplace_pool VALUES(0,'OpenNebula Public','<MARKETPLACE><ID>0</ID><UID>0</UID><GID>0</GID><UNAME>#{oneadmin_uname}</UNAME><GNAME>#{oneadmin_gname}</GNAME><NAME>OpenNebula Public</NAME><MARKET_MAD><![CDATA[one]]></MARKET_MAD><TOTAL_MB>0</TOTAL_MB><FREE_MB>0</FREE_MB><USED_MB>0</USED_MB><MARKETPLACEAPPS></MARKETPLACEAPPS><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>1</OWNER_A><GROUP_U>1</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>1</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><TEMPLATE><DESCRIPTION><![CDATA[OpenNebula Systems MarketPlace]]></DESCRIPTION></TEMPLATE></MARKETPLACE>',0,0,1,1,1);"
|
||||
|
||||
@db.run "INSERT INTO pool_control VALUES('marketplace_pool',99);"
|
||||
|
||||
@db.run "CREATE TABLE marketplaceapp_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body MEDIUMTEXT, uid INTEGER, gid INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER, UNIQUE(name,uid));"
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user