mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-25 02:50:08 +03:00
bug #4476: Add default views to users group at DB bootstraping
This commit is contained in:
parent
b82b1c06b9
commit
f45fe15bc5
@ -118,6 +118,18 @@ public:
|
||||
return new Template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets suntone views in the group template if they are not set. Adds
|
||||
* an attribute of the form:
|
||||
* SUNSTONE=[
|
||||
* DEFAULT_VIEW = "cloud",
|
||||
* GROUP_ADMIN_DEFAULT_VIEW = "groupadmin",
|
||||
* GROUP_ADMIN_VIEWS = "cloud,groupadmin",
|
||||
* VIEWS = "cloud" ]
|
||||
*/
|
||||
void sunstone_views(const string& user_default, const string& user_views,
|
||||
const string& admin_default, const string& admin_views);
|
||||
|
||||
private:
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
@ -89,9 +89,7 @@ int Group::drop(SqlDB * db)
|
||||
|
||||
int Group::insert(SqlDB *db, string& error_str)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = insert_replace(db, false, error_str);
|
||||
int rc = insert_replace(db, false, error_str);
|
||||
|
||||
if (rc == 0)
|
||||
{
|
||||
@ -493,3 +491,50 @@ void Group::del_admin_rules(int user_id)
|
||||
NebulaLog::log("GROUP",Log::ERROR,error_msg);
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
void Group::sunstone_views(const string& user_default, const string& user_views,
|
||||
const string& admin_default, const string& admin_views)
|
||||
{
|
||||
|
||||
VectorAttribute * sunstone = obj_template->get("SUNSTONE");
|
||||
|
||||
if ( sunstone == 0 )
|
||||
{
|
||||
map<string,string> vvalue;
|
||||
|
||||
vvalue.insert(make_pair("DEFAULT_VIEW", user_default));
|
||||
vvalue.insert(make_pair("VIEWS", user_views));
|
||||
vvalue.insert(make_pair("GROUP_ADMIN_DEFAULT_VIEW", admin_default));
|
||||
vvalue.insert(make_pair("GROUP_ADMIN_VIEWS", admin_views));
|
||||
|
||||
sunstone = new VectorAttribute("SUNSTONE", vvalue);
|
||||
|
||||
obj_template->set(sunstone);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( sunstone->vector_value("DEFAULT_VIEW").empty() )
|
||||
{
|
||||
sunstone->replace("DEFAULT_VIEW", user_default);
|
||||
}
|
||||
|
||||
if ( sunstone->vector_value("VIEWS").empty() )
|
||||
{
|
||||
sunstone->replace("VIEWS", user_views);
|
||||
}
|
||||
|
||||
if ( sunstone->vector_value("GROUP_ADMIN_DEFAULT_VIEW").empty() )
|
||||
{
|
||||
sunstone->replace("GROUP_ADMIN_DEFAULT_VIEW", admin_default);
|
||||
}
|
||||
|
||||
if ( sunstone->vector_value("GROUP_ADMIN_VIEWS").empty() )
|
||||
{
|
||||
sunstone->replace("GROUP_ADMIN_VIEWS", admin_views);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,6 +68,8 @@ GroupPool::GroupPool(SqlDB * db, vector<const VectorAttribute *> hook_mads,
|
||||
|
||||
group = new Group(USERS_ID, USERS_NAME);
|
||||
|
||||
group->sunstone_views("cloud","cloud","group_admin","group_admin,cloud");
|
||||
|
||||
rc = PoolSQL::allocate(group, error_str);
|
||||
|
||||
if(rc < 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user