F #1401: Configurable VM_*_OPERATIONS per group and user. Restructure of the API

authorization levels and initialization logic.

Co-authored-by: Pavel Czerny <pczerny@opennebula.systems>
This commit is contained in:
Ruben S. MonteroandPavel Czerny committed 2019-09-09 13:13:52 +02:00
1 parent 332560d38f
commit 500e45dbd6
58 files changed
+1442 -1130

No files matched your search

+35 -31
View File
@@ -248,6 +248,9 @@ string& Group::to_xml_extended(string& xml, bool extended) const
int Group::from_xml(const string& xml)
{
int rc = 0;
string error;
vector<xmlNodePtr> content;
vector<xmlNodePtr>::iterator it;
@@ -283,6 +286,8 @@ int Group::from_xml(const string& xml)
ObjectXML::free_nodes(content);
content.clear();
rc += vm_actions.set_auth_ops(*obj_template, error);
if (rc != 0)
{
return -1;
@@ -540,42 +545,41 @@ 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");
VectorAttribute * sunstone = obj_template->get("SUNSTONE");
if ( sunstone == 0 )
{
map<string,string> vvalue;
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));
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);
sunstone = new VectorAttribute("SUNSTONE", vvalue);
obj_template->set(sunstone);
}
else
{
if ( sunstone->vector_value("DEFAULT_VIEW").empty() )
{
sunstone->replace("DEFAULT_VIEW", user_default);
}
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("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_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);
}
}
if ( sunstone->vector_value("GROUP_ADMIN_VIEWS").empty() )
{
sunstone->replace("GROUP_ADMIN_VIEWS", admin_views);
}
}
}
+8 -4
View File
@@ -38,7 +38,8 @@ const int GroupPool::USERS_ID = 1;
/* -------------------------------------------------------------------------- */
GroupPool::GroupPool(SqlDB * db, vector<const VectorAttribute *> hook_mads,
const string& remotes_location, bool is_federation_slave) :
const string& remotes_location, bool is_federation_slave,
vector<const SingleAttribute *>& restricted_attrs) :
PoolSQL(db, Group::table)
{
ostringstream oss;
@@ -61,7 +62,7 @@ GroupPool::GroupPool(SqlDB * db, vector<const VectorAttribute *> hook_mads,
rc = PoolSQL::allocate(group, error_str);
if( rc < 0 )
if (rc < 0)
{
goto error_groups;
}
@@ -72,7 +73,7 @@ GroupPool::GroupPool(SqlDB * db, vector<const VectorAttribute *> hook_mads,
rc = PoolSQL::allocate(group, error_str);
if(rc < 0)
if (rc < 0)
{
goto error_groups;
}
@@ -82,6 +83,9 @@ GroupPool::GroupPool(SqlDB * db, vector<const VectorAttribute *> hook_mads,
register_hooks(hook_mads, remotes_location);
// Set restricted attributes
GroupTemplate::parse_restricted(restricted_attrs);
return;
error_groups:
@@ -222,7 +226,7 @@ int GroupPool::drop(PoolObjectSQL * objsql, string& error_msg)
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int GroupPool::dump(string& oss, const string& where,
int GroupPool::dump(string& oss, const string& where,
const string& limit, bool desc)
{
int rc;
+22
View File
@@ -0,0 +1,22 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2019, OpenNebula Project, OpenNebula Systems */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
#include "GroupTemplate.h"
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
std::map<std::string, std::set<std::string>> GroupTemplate::restricted;
+2 -1
View File
@@ -23,7 +23,8 @@ lib_name='nebula_group'
# Sources to generate the library
source_files=[
'GroupPool.cc',
'Group.cc'
'Group.cc',
'GroupTemplate.cc'
]
# Build library