mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-09 22:14:13 +09:00
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:
1 parent
332560d38f
commit
500e45dbd6
58 files changed
+1442
-1130
No files matched your search
+22
-6
@@ -18,10 +18,12 @@
|
||||
#define GROUP_H_
|
||||
|
||||
#include "PoolSQL.h"
|
||||
#include "GroupTemplate.h"
|
||||
#include "ObjectCollection.h"
|
||||
#include "User.h"
|
||||
#include "QuotasSQL.h"
|
||||
#include "Template.h"
|
||||
#include "VMActions.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -115,14 +117,14 @@ public:
|
||||
int update_quotas(SqlDB *db)
|
||||
{
|
||||
return quota.update(oid, db->get_local_db());
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method for Group templates
|
||||
*/
|
||||
Template * get_new_template() const override
|
||||
{
|
||||
return new Template;
|
||||
return new GroupTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,6 +139,15 @@ public:
|
||||
void sunstone_views(const string& user_default, const string& user_views,
|
||||
const string& admin_default, const string& admin_views);
|
||||
|
||||
/**
|
||||
* @return the operation level (admin, manage or use) associated to the
|
||||
* given action for this group
|
||||
*/
|
||||
AuthRequest::Operation get_vm_auth_op(VMActions::Action action) const
|
||||
{
|
||||
return vm_actions.get_auth_op(action);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@@ -158,8 +169,8 @@ private:
|
||||
// Allow users in this group to see it
|
||||
group_u = 1;
|
||||
|
||||
obj_template = new Template;
|
||||
};
|
||||
obj_template = new GroupTemplate;
|
||||
}
|
||||
|
||||
virtual ~Group() = default;
|
||||
|
||||
@@ -180,6 +191,11 @@ private:
|
||||
void add_admin_rules(int user_id);
|
||||
void del_admin_rules(int user_id);
|
||||
|
||||
/**
|
||||
* List of VM actions and rights for this group
|
||||
*/
|
||||
VMActions vm_actions;
|
||||
|
||||
// *************************************************************************
|
||||
// DataBase implementation (Private)
|
||||
// *************************************************************************
|
||||
@@ -208,7 +224,7 @@ private:
|
||||
ostringstream oss_group(Group::db_bootstrap);
|
||||
|
||||
return db->exec_local_wr(oss_group);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the Group (identified with its OID) from the database.
|
||||
@@ -258,7 +274,7 @@ private:
|
||||
{
|
||||
string error_str;
|
||||
return insert_replace(db, true, error_str);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to print the Group object into a string in
|
||||
|
||||
+3
-2
@@ -27,9 +27,10 @@ class GroupPool : public PoolSQL
|
||||
{
|
||||
public:
|
||||
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);
|
||||
|
||||
~GroupPool(){};
|
||||
~GroupPool() = default;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Constants for DB management */
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* 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. */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef GROUP_TEMPLATE_H_
|
||||
#define GROUP_TEMPLATE_H_
|
||||
|
||||
#include "Template.h"
|
||||
|
||||
/**
|
||||
* User Template class, it represents the attributes of an user
|
||||
*/
|
||||
class GroupTemplate : public Template
|
||||
{
|
||||
public:
|
||||
GroupTemplate() : Template(false, '=', "TEMPLATE") {}
|
||||
|
||||
~GroupTemplate() = default;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Restricted attributes interface implementation
|
||||
// -------------------------------------------------------------------------
|
||||
bool check_restricted(string& rs_attr, const Template* base) override
|
||||
{
|
||||
return Template::check_restricted(rs_attr, base, restricted);
|
||||
}
|
||||
|
||||
bool check_restricted(string& rs_attr) override
|
||||
{
|
||||
return Template::check_restricted(rs_attr, restricted);
|
||||
}
|
||||
|
||||
static void parse_restricted(vector<const SingleAttribute *>& ra)
|
||||
{
|
||||
Template::parse_restricted(ra, restricted);
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* Restricted attribute list for GroupTemplate
|
||||
*/
|
||||
static std::map<std::string, std::set<std::string>> restricted;
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#endif /*GROUP_TEMPLATE_H_*/
|
||||
+2
-60
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "ObjectSQL.h"
|
||||
#include "ObjectXML.h"
|
||||
#include "VMActions.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -29,65 +30,6 @@ using namespace std;
|
||||
class History:public ObjectSQL, public ObjectXML
|
||||
{
|
||||
public:
|
||||
|
||||
enum VMAction
|
||||
{ //Associated XML-RPC API call
|
||||
NONE_ACTION = 0, // "one.vm.migrate"
|
||||
MIGRATE_ACTION = 1, // "one.vm.migrate"
|
||||
LIVE_MIGRATE_ACTION = 2,
|
||||
//SHUTDOWN_ACTION = 3,
|
||||
//SHUTDOWN_HARD_ACTION = 4,
|
||||
UNDEPLOY_ACTION = 5, // "one.vm.action"
|
||||
UNDEPLOY_HARD_ACTION = 6, // "one.vm.action"
|
||||
HOLD_ACTION = 7, // "one.vm.action"
|
||||
RELEASE_ACTION = 8, // "one.vm.action"
|
||||
STOP_ACTION = 9, // "one.vm.action"
|
||||
SUSPEND_ACTION = 10, // "one.vm.action"
|
||||
RESUME_ACTION = 11, // "one.vm.action"
|
||||
//BOOT_ACTION = 12,
|
||||
DELETE_ACTION = 13, // "one.vm.recover"
|
||||
DELETE_RECREATE_ACTION = 14, // "one.vm.recover"
|
||||
REBOOT_ACTION = 15, // "one.vm.action"
|
||||
REBOOT_HARD_ACTION = 16, // "one.vm.action"
|
||||
RESCHED_ACTION = 17, // "one.vm.action"
|
||||
UNRESCHED_ACTION = 18, // "one.vm.action"
|
||||
POWEROFF_ACTION = 19, // "one.vm.action"
|
||||
POWEROFF_HARD_ACTION = 20, // "one.vm.action"
|
||||
DISK_ATTACH_ACTION = 21, // "one.vm.attach"
|
||||
DISK_DETACH_ACTION = 22, // "one.vm.detach"
|
||||
NIC_ATTACH_ACTION = 23, // "one.vm.attachnic"
|
||||
NIC_DETACH_ACTION = 24, // "one.vm.detachnic"
|
||||
DISK_SNAPSHOT_CREATE_ACTION = 25, // "one.vm.disksnapshotcreate"
|
||||
DISK_SNAPSHOT_DELETE_ACTION = 26, // "one.vm.disksnapshotdelete"
|
||||
TERMINATE_ACTION = 27, // "one.vm.action"
|
||||
TERMINATE_HARD_ACTION = 28, // "one.vm.action"
|
||||
DISK_RESIZE_ACTION = 29, // "one.vm.diskresize"
|
||||
DEPLOY_ACTION = 30, // "one.vm.deploy"
|
||||
CHOWN_ACTION = 31, // "one.vm.chown"
|
||||
CHMOD_ACTION = 32, // "one.vm.chmod"
|
||||
UPDATECONF_ACTION = 33, // "one.vm.updateconf"
|
||||
RENAME_ACTION = 34, // "one.vm.rename"
|
||||
RESIZE_ACTION = 35, // "one.vm.resize"
|
||||
UPDATE_ACTION = 36, // "one.vm.update"
|
||||
SNAPSHOT_CREATE_ACTION = 37, // "one.vm.snapshotcreate"
|
||||
SNAPSHOT_DELETE_ACTION = 38, // "one.vm.snapshotdelete"
|
||||
SNAPSHOT_REVERT_ACTION = 39, // "one.vm.snapshotrevert"
|
||||
DISK_SAVEAS_ACTION = 40, // "one.vm.disksaveas"
|
||||
DISK_SNAPSHOT_REVERT_ACTION = 41, // "one.vm.disksnapshotrevert"
|
||||
RECOVER_ACTION = 42, // "one.vm.recover"
|
||||
RETRY_ACTION = 43, // "one.vm.recover"
|
||||
MONITOR_ACTION = 44, // internal, monitoring process
|
||||
DISK_SNAPSHOT_RENAME_ACTION = 45, // "one.vm.disksnapshotrename"
|
||||
ALIAS_ATTACH_ACTION = 46, // "one.vm.attachnic"
|
||||
ALIAS_DETACH_ACTION = 47, // "one.vm.detachnic"
|
||||
POFF_MIGRATE_ACTION = 48, // "one.vm.migrate"
|
||||
POFF_HARD_MIGRATE_ACTION = 49 // "one.vm.migrate"
|
||||
};
|
||||
|
||||
static string action_to_str(VMAction action);
|
||||
|
||||
static int action_from_str(const string& st, VMAction& action);
|
||||
|
||||
History(int oid, int _seq = -1);
|
||||
|
||||
History(
|
||||
@@ -170,7 +112,7 @@ private:
|
||||
time_t epilog_stime;
|
||||
time_t epilog_etime;
|
||||
|
||||
VMAction action;
|
||||
VMActions::Action action;
|
||||
|
||||
string vm_info;
|
||||
|
||||
|
||||
+1
-1
@@ -572,7 +572,7 @@ public:
|
||||
* Return the Authorization operation for a VM action
|
||||
*
|
||||
*/
|
||||
AuthRequest::Operation get_vm_auth_op(History::VMAction action)
|
||||
AuthRequest::Operation get_vm_auth_op(VMActions::Action action)
|
||||
{
|
||||
return nebula_configuration->get_vm_auth_op(action);
|
||||
}
|
||||
|
||||
+20
-20
@@ -20,7 +20,7 @@
|
||||
#include "Template.h"
|
||||
#include "ActionSet.h"
|
||||
#include "AuthRequest.h"
|
||||
#include "History.h"
|
||||
#include "VMActions.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
@@ -89,11 +89,27 @@ public:
|
||||
*/
|
||||
virtual int load_configuration();
|
||||
|
||||
/**
|
||||
* Returns action set from a string of actions seperated by commas
|
||||
*/
|
||||
static int set_vm_auth_ops(const std::string& ops_str,
|
||||
ActionSet<VMActions::Action>& ops_set, std::string& error);
|
||||
|
||||
/**
|
||||
* @param action
|
||||
* @return authorization operation configured for the given VM action
|
||||
*/
|
||||
AuthRequest::Operation get_vm_auth_op(History::VMAction action);
|
||||
AuthRequest::Operation get_vm_auth_op(VMActions::Action action)
|
||||
{
|
||||
AuthRequest::Operation aop = vm_actions.get_auth_op(action);
|
||||
|
||||
if (aop == AuthRequest::NONE)
|
||||
{
|
||||
aop = AuthRequest::MANAGE;
|
||||
}
|
||||
|
||||
return aop;
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
@@ -107,19 +123,9 @@ private:
|
||||
string var_location;
|
||||
|
||||
/**
|
||||
* Set of VM actions that require USE permission
|
||||
* Default set of VM action permissions
|
||||
*/
|
||||
ActionSet<History::VMAction> vm_use_actions;
|
||||
|
||||
/**
|
||||
* Set of VM actions that require MANAGE permission
|
||||
*/
|
||||
ActionSet<History::VMAction> vm_manage_actions;
|
||||
|
||||
/**
|
||||
* Set of VM actions that require ADMIN permission
|
||||
*/
|
||||
ActionSet<History::VMAction> vm_admin_actions;
|
||||
VMActions vm_actions;
|
||||
|
||||
/**
|
||||
* Sets the defaults value for the template
|
||||
@@ -177,12 +183,6 @@ private:
|
||||
*/
|
||||
void set_conf_vn(const std::string& name,
|
||||
const std::string& bridge_type);
|
||||
|
||||
/**
|
||||
* Sets auth permissions for vm operations
|
||||
*/
|
||||
int set_vm_auth_ops(std::string& error);
|
||||
};
|
||||
|
||||
|
||||
#endif /*NEBULA_TEMPLATE_H_*/
|
||||
+41
-36
@@ -24,6 +24,7 @@
|
||||
#include "AuthRequest.h"
|
||||
#include "PoolObjectSQL.h"
|
||||
#include "Quotas.h"
|
||||
#include "History.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -57,12 +58,15 @@ public:
|
||||
|
||||
uint64_t replication_idx;
|
||||
|
||||
RequestAttributes()
|
||||
AuthRequest::Operation auth_op; /**< Auth operation for the request */
|
||||
|
||||
RequestAttributes(AuthRequest::Operation api_auth_op)
|
||||
{
|
||||
resp_obj = PoolObjectSQL::NONE;
|
||||
resp_id = -1;
|
||||
resp_msg = "";
|
||||
replication_idx = UINT64_MAX;
|
||||
auth_op = api_auth_op;
|
||||
};
|
||||
|
||||
RequestAttributes(const RequestAttributes& ra)
|
||||
@@ -89,6 +93,8 @@ public:
|
||||
resp_msg = ra.resp_msg;
|
||||
|
||||
replication_idx = ra.replication_idx;
|
||||
|
||||
auth_op = ra.auth_op;
|
||||
};
|
||||
|
||||
RequestAttributes(int _uid, int _gid, const RequestAttributes& ra)
|
||||
@@ -117,6 +123,7 @@ public:
|
||||
resp_msg = "";
|
||||
|
||||
replication_idx = UINT64_MAX;
|
||||
auth_op = ra.auth_op;
|
||||
};
|
||||
|
||||
bool is_admin() const
|
||||
@@ -134,6 +141,14 @@ public:
|
||||
{
|
||||
return gid == GroupPool::ONEADMIN_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the operation level (admin, manage or use) associated to this
|
||||
* request. Precedence is: user > group > system.
|
||||
*
|
||||
* @param action perfomed on the VM object
|
||||
*/
|
||||
void set_auth_op(VMActions::Action action);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -189,39 +204,49 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Global configuration attributes por API calls */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
static string format_str;
|
||||
static const long long xmlrpc_timeout; //Timeout (ms) for request forwarding
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Static Request Attributes: shared among request of the same method */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
PoolSQL * pool; /**< Pool of objects */
|
||||
string method_name; /**< The name of the XML-RPC method */
|
||||
PoolSQL * pool;
|
||||
string method_name;
|
||||
|
||||
PoolObjectSQL::ObjectType auth_object;/**< Auth object for the request */
|
||||
AuthRequest::Operation auth_op; /**< Auth operation for the request */
|
||||
// Configuration for authentication level of the API call
|
||||
PoolObjectSQL::ObjectType auth_object;
|
||||
AuthRequest::Operation auth_op;
|
||||
|
||||
VMActions::Action vm_action;
|
||||
|
||||
// Logging configuration fot the API call
|
||||
set<int> hidden_params;
|
||||
bool log_method_call;
|
||||
|
||||
static string format_str;
|
||||
|
||||
bool log_method_call; //Write method call and result to the log
|
||||
|
||||
bool leader_only; //Method can be only execute by leaders or solo servers
|
||||
|
||||
static const long long xmlrpc_timeout; //Timeout (ms) for request forwarding
|
||||
//Method can be only execute by leaders or solo servers
|
||||
bool leader_only;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Class Constructors */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
Request(const string& mn, const string& signature, const string& help):
|
||||
pool(0),method_name(mn)
|
||||
Request(const string& mn, const string& signature, const string& help)
|
||||
{
|
||||
pool = nullptr;
|
||||
|
||||
method_name = mn;
|
||||
|
||||
_signature = signature;
|
||||
_help = help;
|
||||
|
||||
hidden_params.clear();
|
||||
|
||||
log_method_call = true;
|
||||
|
||||
leader_only = true;
|
||||
|
||||
vm_action = VMActions::NONE_ACTION;
|
||||
};
|
||||
|
||||
virtual ~Request() = default;
|
||||
@@ -336,25 +361,7 @@ protected:
|
||||
*
|
||||
* @return true if the user is authorized.
|
||||
*/
|
||||
bool basic_authorization(int oid, RequestAttributes& att)
|
||||
{
|
||||
return basic_authorization(oid, auth_op, att);
|
||||
};
|
||||
|
||||
/**
|
||||
* Performs a basic authorization for this request using the uid/gid
|
||||
* from the request. The function gets the object from the pool to get
|
||||
* the public attribute and its owner. The authorization is based on
|
||||
* object and type of operation for the request.
|
||||
* @param oid of the object, can be -1 for objects to be created, or
|
||||
* pools.
|
||||
* @param op operation of the request.
|
||||
* @param att the specific request attributes
|
||||
*
|
||||
* @return true if the user is authorized.
|
||||
*/
|
||||
bool basic_authorization(int oid, AuthRequest::Operation op,
|
||||
RequestAttributes& att);
|
||||
bool basic_authorization(int oid, RequestAttributes& att);
|
||||
|
||||
/**
|
||||
* Performs a basic authorization for this request using the uid/gid
|
||||
@@ -364,7 +371,6 @@ protected:
|
||||
* @param pool object pool
|
||||
* @param oid of the object, can be -1 for objects to be created, or
|
||||
* pools.
|
||||
* @param op operation of the request.
|
||||
* @param att the specific request attributes
|
||||
*
|
||||
* @return SUCCESS if the user is authorized.
|
||||
@@ -372,7 +378,6 @@ protected:
|
||||
static ErrorCode basic_authorization(
|
||||
PoolSQL* pool,
|
||||
int oid,
|
||||
AuthRequest::Operation op,
|
||||
PoolObjectSQL::ObjectType auth_object,
|
||||
RequestAttributes& att);
|
||||
|
||||
|
||||
@@ -117,11 +117,11 @@ protected:
|
||||
};
|
||||
|
||||
ErrorCode merge(Template * tmpl, const string &s_a, RequestAttributes& att) override
|
||||
{
|
||||
VMTemplateInstantiate vm_instantiate;
|
||||
{
|
||||
VMTemplateInstantiate vm_instantiate;
|
||||
|
||||
return vm_instantiate.merge(tmpl, s_a, att);
|
||||
};
|
||||
return vm_instantiate.merge(tmpl, s_a, att);
|
||||
};
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
@@ -59,8 +59,7 @@ protected:
|
||||
void request_execute(xmlrpc_c::paramList const& paramList,
|
||||
RequestAttributes& att) override;
|
||||
|
||||
ErrorCode delete_object(int oid, bool recursive,
|
||||
RequestAttributes& att, AuthRequest::Operation auth);
|
||||
ErrorCode delete_object(int oid, bool recursive, RequestAttributes& att);
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
@@ -105,7 +104,7 @@ public:
|
||||
|
||||
ErrorCode request_execute(int oid, bool recursive, RequestAttributes& att)
|
||||
{
|
||||
return delete_object(oid, recursive, att, auth_op);
|
||||
return delete_object(oid, recursive, att);
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -133,7 +132,7 @@ public:
|
||||
|
||||
ErrorCode request_execute(int oid, bool recursive, RequestAttributes& att)
|
||||
{
|
||||
return delete_object(oid, false, att, auth_op);
|
||||
return delete_object(oid, false, att);
|
||||
}
|
||||
|
||||
};
|
||||
@@ -188,7 +187,7 @@ public:
|
||||
|
||||
ErrorCode request_execute(int oid, RequestAttributes& att)
|
||||
{
|
||||
return delete_object(oid, false, att, auth_op);
|
||||
return delete_object(oid, false, att);
|
||||
};
|
||||
|
||||
void request_execute(xmlrpc_c::paramList const& paramList,
|
||||
@@ -327,6 +326,7 @@ public:
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_clpool();
|
||||
|
||||
auth_object = PoolObjectSQL::CLUSTER;
|
||||
auth_op = AuthRequest::ADMIN;
|
||||
};
|
||||
|
||||
@@ -69,7 +69,8 @@ public:
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
void to_xml(RequestAttributes& att, PoolObjectSQL * object, string& str) override
|
||||
void to_xml(RequestAttributes& att, PoolObjectSQL * object,
|
||||
string& str) override
|
||||
{
|
||||
static_cast<VirtualMachine *>(object)->to_xml_extended(str);
|
||||
};
|
||||
|
||||
@@ -27,8 +27,8 @@ class RequestManagerMarketPlaceApp: public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerMarketPlaceApp(const std::string& method_name,
|
||||
const std::string& help, const std::string& params) :
|
||||
Request(method_name, params, help)
|
||||
const std::string& help, const std::string& params) :
|
||||
Request(method_name, params, help)
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_apppool();
|
||||
@@ -42,7 +42,7 @@ protected:
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
virtual void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att) = 0;
|
||||
RequestAttributes& att) = 0;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@@ -52,12 +52,12 @@ class MarketPlaceAppEnable : public RequestManagerMarketPlaceApp
|
||||
{
|
||||
public:
|
||||
MarketPlaceAppEnable(): RequestManagerMarketPlaceApp("one.marketapp.enable",
|
||||
"Enables or disables a marketplace app", "A:sib"){};
|
||||
"Enables or disables a marketplace app", "A:sib"){};
|
||||
|
||||
~MarketPlaceAppEnable(){};
|
||||
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att) override;
|
||||
RequestAttributes& att) override;
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
@@ -122,18 +122,16 @@ public:
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_vmpool();
|
||||
auth_object = PoolObjectSQL::VM;
|
||||
vm_action = VMActions::RENAME_ACTION;
|
||||
}
|
||||
|
||||
auth_op = nd.get_vm_auth_op(History::RENAME_ACTION);
|
||||
};
|
||||
|
||||
~VirtualMachineRename(){};
|
||||
~VirtualMachineRename() = default;
|
||||
|
||||
int exist(const string& name, int uid) override
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int extra_updates(PoolObjectSQL * obj) override
|
||||
{
|
||||
VirtualMachine * vm;
|
||||
@@ -148,7 +146,7 @@ public:
|
||||
vm = static_cast<VirtualMachine *>(obj);
|
||||
|
||||
return vmpool->update_search(vm);
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
@@ -38,5 +38,4 @@ public:
|
||||
void request_execute(xmlrpc_c::paramList const& pl, RequestAttributes& att) override;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -30,7 +30,10 @@ class RequestManagerSystem: public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerSystem(const string& method_name, const string& help,
|
||||
const string& params) :Request(method_name,params,help) {};
|
||||
const string& params) :Request(method_name,params,help)
|
||||
{
|
||||
auth_op = AuthRequest::ADMIN;
|
||||
};
|
||||
|
||||
~RequestManagerSystem(){};
|
||||
|
||||
@@ -49,8 +52,7 @@ public:
|
||||
SystemVersion():
|
||||
RequestManagerSystem("one.system.version",
|
||||
"Returns the OpenNebula version",
|
||||
"A:s")
|
||||
{};
|
||||
"A:s") {}
|
||||
|
||||
~SystemVersion(){};
|
||||
|
||||
@@ -67,8 +69,7 @@ public:
|
||||
SystemConfig():
|
||||
RequestManagerSystem("one.system.config",
|
||||
"Returns the OpenNebula configuration",
|
||||
"A:s")
|
||||
{};
|
||||
"A:s") {}
|
||||
|
||||
~SystemConfig(){};
|
||||
|
||||
@@ -83,10 +84,7 @@ class SystemSql: public RequestManagerSystem
|
||||
{
|
||||
public:
|
||||
SystemSql():RequestManagerSystem("one.system.sql",
|
||||
"Executes and replicates SQL commands on the DB backend","A:ssb")
|
||||
{
|
||||
auth_op = AuthRequest::ADMIN;
|
||||
};
|
||||
"Executes and replicates SQL commands on the DB backend","A:ssb") {}
|
||||
|
||||
~SystemSql(){};
|
||||
|
||||
@@ -101,10 +99,7 @@ class SystemSqlQuery: public RequestManagerSystem
|
||||
{
|
||||
public:
|
||||
SystemSqlQuery():RequestManagerSystem("one.system.sqlquery",
|
||||
"Executes SQL queries on the DB backend","A:ss")
|
||||
{
|
||||
auth_op = AuthRequest::ADMIN;
|
||||
};
|
||||
"Executes SQL queries on the DB backend","A:ss") { }
|
||||
|
||||
~SystemSqlQuery(){};
|
||||
|
||||
@@ -144,10 +139,7 @@ public:
|
||||
UserQuotaInfo():
|
||||
RequestManagerSystem("one.userquota.info",
|
||||
"Returns the default user quota limits",
|
||||
"A:s")
|
||||
{
|
||||
auth_op = AuthRequest::ADMIN;
|
||||
};
|
||||
"A:s") { }
|
||||
|
||||
~UserQuotaInfo(){};
|
||||
|
||||
@@ -164,10 +156,7 @@ public:
|
||||
GroupQuotaInfo():
|
||||
RequestManagerSystem("one.groupquota.info",
|
||||
"Returns the default group quota limits",
|
||||
"A:s")
|
||||
{
|
||||
auth_op = AuthRequest::ADMIN;
|
||||
};
|
||||
"A:s") { }
|
||||
|
||||
~GroupQuotaInfo(){};
|
||||
|
||||
@@ -185,10 +174,7 @@ protected:
|
||||
const string& help):
|
||||
RequestManagerSystem(method_name,
|
||||
help,
|
||||
"A:ss")
|
||||
{
|
||||
auth_op = AuthRequest::ADMIN;
|
||||
};
|
||||
"A:ss") { }
|
||||
|
||||
~QuotaUpdate(){};
|
||||
|
||||
@@ -208,10 +194,7 @@ class UserQuotaUpdate : public QuotaUpdate
|
||||
public:
|
||||
UserQuotaUpdate():
|
||||
QuotaUpdate("one.userquota.update",
|
||||
"Updates the default user quota limits")
|
||||
{
|
||||
auth_op = AuthRequest::ADMIN;
|
||||
};
|
||||
"Updates the default user quota limits") { }
|
||||
|
||||
int set_default_quota(Template *tmpl, string& error) override;
|
||||
|
||||
@@ -226,10 +209,7 @@ class GroupQuotaUpdate : public QuotaUpdate
|
||||
public:
|
||||
GroupQuotaUpdate():
|
||||
QuotaUpdate("one.groupquota.update",
|
||||
"Updates the default group quota limits")
|
||||
{
|
||||
auth_op = AuthRequest::ADMIN;
|
||||
};
|
||||
"Updates the default group quota limits") { }
|
||||
|
||||
int set_default_quota(Template *tmpl, string& error) override;
|
||||
|
||||
|
||||
@@ -110,12 +110,12 @@ public:
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_vmpool();
|
||||
auth_object = PoolObjectSQL::VM;
|
||||
vm_action = VMActions::UPDATE_ACTION;
|
||||
}
|
||||
|
||||
auth_op = nd.get_vm_auth_op(History::UPDATE_ACTION);
|
||||
};
|
||||
|
||||
~VirtualMachineUpdateTemplate(){};
|
||||
~VirtualMachineUpdateTemplate() = default;
|
||||
|
||||
protected:
|
||||
int extra_updates(PoolObjectSQL * obj) override
|
||||
{
|
||||
VirtualMachine * vm;
|
||||
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
const string& s_uattr, Template* extra_attrs, int& vid,
|
||||
RequestAttributes& att);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Parse & merge user attributes (check if the request user is not oneadmin)
|
||||
* @param tmpl to merge the attributes to
|
||||
* @param s_uattr Template supplied by user to merge with the original
|
||||
|
||||
@@ -39,9 +39,9 @@ protected:
|
||||
|
||||
auth_object = PoolObjectSQL::VM;
|
||||
auth_op = AuthRequest::MANAGE;
|
||||
};
|
||||
}
|
||||
|
||||
~RequestManagerVirtualMachine(){};
|
||||
~RequestManagerVirtualMachine() = default;
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
@@ -54,8 +54,7 @@ protected:
|
||||
RequestAttributes& att,
|
||||
PoolObjectAuth * host_perms,
|
||||
PoolObjectAuth * ds_perm,
|
||||
PoolObjectAuth * img_perm,
|
||||
AuthRequest::Operation op);
|
||||
PoolObjectAuth * img_perm);
|
||||
|
||||
bool quota_resize_authorization(
|
||||
Template * deltas,
|
||||
@@ -114,14 +113,13 @@ protected:
|
||||
class VirtualMachineAction : public RequestManagerVirtualMachine
|
||||
{
|
||||
public:
|
||||
//auth_op is MANAGE for all actions but "resched" and "unresched"
|
||||
//this is dynamically set for each request in the execute method
|
||||
VirtualMachineAction():
|
||||
RequestManagerVirtualMachine("one.vm.action",
|
||||
"Performs an action on a virtual machine",
|
||||
"A:ssi"){};
|
||||
~VirtualMachineAction(){};
|
||||
"A:ssi") {}
|
||||
~VirtualMachineAction() = default;
|
||||
|
||||
protected:
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att) override;
|
||||
};
|
||||
@@ -137,11 +135,12 @@ public:
|
||||
"Deploys a virtual machine",
|
||||
"A:siibis")
|
||||
{
|
||||
auth_op = Nebula::instance().get_vm_auth_op(History::DEPLOY_ACTION);
|
||||
};
|
||||
vm_action = VMActions::DEPLOY_ACTION;
|
||||
}
|
||||
|
||||
~VirtualMachineDeploy(){};
|
||||
~VirtualMachineDeploy() = default;
|
||||
|
||||
protected:
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att) override;
|
||||
};
|
||||
@@ -155,12 +154,14 @@ public:
|
||||
VirtualMachineMigrate():
|
||||
RequestManagerVirtualMachine("one.vm.migrate",
|
||||
"Migrates a virtual machine",
|
||||
"A:siibbii"){
|
||||
auth_op = Nebula::instance().get_vm_auth_op(History::MIGRATE_ACTION);
|
||||
};
|
||||
"A:siibbii")
|
||||
{
|
||||
vm_action = VMActions::MIGRATE_ACTION;
|
||||
}
|
||||
|
||||
~VirtualMachineMigrate(){};
|
||||
~VirtualMachineMigrate() = default;
|
||||
|
||||
protected:
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att) override;
|
||||
};
|
||||
@@ -174,12 +175,14 @@ public:
|
||||
VirtualMachineDiskSaveas():
|
||||
RequestManagerVirtualMachine("one.vm.disksaveas",
|
||||
"Save a disk from virtual machine as a new image",
|
||||
"A:siissi"){
|
||||
auth_op= Nebula::instance().get_vm_auth_op(History::DISK_SAVEAS_ACTION);
|
||||
};
|
||||
"A:siissi")
|
||||
{
|
||||
vm_action = VMActions::DISK_SAVEAS_ACTION;
|
||||
}
|
||||
|
||||
~VirtualMachineDiskSaveas(){};
|
||||
~VirtualMachineDiskSaveas() = default;
|
||||
|
||||
protected:
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att) override;
|
||||
};
|
||||
@@ -190,22 +193,20 @@ public:
|
||||
class VirtualMachineMonitoring : public RequestManagerVirtualMachine
|
||||
{
|
||||
public:
|
||||
|
||||
VirtualMachineMonitoring():
|
||||
RequestManagerVirtualMachine("one.vm.monitoring",
|
||||
"Returns the virtual machine monitoring records",
|
||||
"A:si"){
|
||||
auth_op = AuthRequest::USE_NO_LCK;
|
||||
};
|
||||
"A:si")
|
||||
{
|
||||
auth_op = AuthRequest::USE_NO_LCK;
|
||||
vm_action = VMActions::MONITOR_ACTION;
|
||||
}
|
||||
|
||||
~VirtualMachineMonitoring(){};
|
||||
~VirtualMachineMonitoring() = default;
|
||||
|
||||
protected:
|
||||
void request_execute(xmlrpc_c::paramList const& paramList,
|
||||
RequestAttributes& att) override;
|
||||
|
||||
virtual bool is_locked(xmlrpc_c::paramList const& paramList, RequestAttributes& att){
|
||||
return false;
|
||||
};
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@@ -217,11 +218,13 @@ public:
|
||||
VirtualMachineAttach():
|
||||
RequestManagerVirtualMachine("one.vm.attach",
|
||||
"Attaches a new disk to the virtual machine",
|
||||
"A:sis"){
|
||||
auth_op= Nebula::instance().get_vm_auth_op(History::DISK_ATTACH_ACTION);
|
||||
};
|
||||
"A:sis")
|
||||
{
|
||||
auth_op = AuthRequest::USE_NO_LCK;
|
||||
vm_action = VMActions::DISK_ATTACH_ACTION;
|
||||
}
|
||||
|
||||
~VirtualMachineAttach(){};
|
||||
~VirtualMachineAttach() = default;
|
||||
|
||||
/**
|
||||
* Process a DISK attahment request to a Virtual Machine
|
||||
@@ -248,13 +251,15 @@ public:
|
||||
VirtualMachineDetach():
|
||||
RequestManagerVirtualMachine("one.vm.detach",
|
||||
"Detaches a disk from a virtual machine",
|
||||
"A:sii"){
|
||||
//Attach & detach are set to the same auth op in OpenNebulaTemplate
|
||||
auth_op= Nebula::instance().get_vm_auth_op(History::DISK_DETACH_ACTION);
|
||||
};
|
||||
"A:sii")
|
||||
{
|
||||
auth_op = AuthRequest::USE_NO_LCK;
|
||||
vm_action = VMActions::DISK_DETACH_ACTION;
|
||||
}
|
||||
|
||||
~VirtualMachineDetach(){};
|
||||
~VirtualMachineDetach() = default;
|
||||
|
||||
protected:
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att) override;
|
||||
};
|
||||
@@ -268,11 +273,12 @@ public:
|
||||
VirtualMachineAttachNic():
|
||||
RequestManagerVirtualMachine("one.vm.attachnic",
|
||||
"Attaches a new NIC to the virtual machine",
|
||||
"A:sis"){
|
||||
auth_op = Nebula::instance().get_vm_auth_op(History::NIC_ATTACH_ACTION);
|
||||
};
|
||||
"A:sis")
|
||||
{
|
||||
vm_action = VMActions::NIC_ATTACH_ACTION;
|
||||
}
|
||||
|
||||
~VirtualMachineAttachNic(){};
|
||||
~VirtualMachineAttachNic() = default;
|
||||
|
||||
/**
|
||||
* Process a NIC attahment request to a Virtual Machine
|
||||
@@ -285,10 +291,8 @@ public:
|
||||
RequestAttributes& att);
|
||||
|
||||
protected:
|
||||
|
||||
void request_execute(xmlrpc_c::paramList const& pl,
|
||||
RequestAttributes& ra) override;
|
||||
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@@ -300,12 +304,12 @@ public:
|
||||
VirtualMachineDetachNic():
|
||||
RequestManagerVirtualMachine("one.vm.detachnic",
|
||||
"Detaches a NIC from a virtual machine",
|
||||
"A:sii"){
|
||||
//Attach & detach are set to the same auth op in OpenNebulaTemplate
|
||||
auth_op = Nebula::instance().get_vm_auth_op(History::NIC_DETACH_ACTION);
|
||||
};
|
||||
"A:sii")
|
||||
{
|
||||
vm_action = VMActions::NIC_DETACH_ACTION;
|
||||
}
|
||||
|
||||
~VirtualMachineDetachNic(){};
|
||||
~VirtualMachineDetachNic() = default;
|
||||
|
||||
/**
|
||||
* Process a NIC detach request to a Virtual Machine
|
||||
@@ -330,12 +334,14 @@ public:
|
||||
VirtualMachineResize():
|
||||
RequestManagerVirtualMachine("one.vm.resize",
|
||||
"Changes the capacity of the virtual machine",
|
||||
"A:sisb"){
|
||||
auth_op = Nebula::instance().get_vm_auth_op(History::RESIZE_ACTION);
|
||||
};
|
||||
"A:sisb")
|
||||
{
|
||||
vm_action = VMActions::RESIZE_ACTION;
|
||||
}
|
||||
|
||||
~VirtualMachineResize(){};
|
||||
~VirtualMachineResize() = default;
|
||||
|
||||
protected:
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att) override;
|
||||
};
|
||||
@@ -349,15 +355,14 @@ public:
|
||||
VirtualMachineSnapshotCreate():
|
||||
RequestManagerVirtualMachine("one.vm.snapshotcreate",
|
||||
"Creates a new virtual machine snapshot",
|
||||
"A:sis"){
|
||||
Nebula& nd = Nebula::instance();
|
||||
"A:sis")
|
||||
{
|
||||
vm_action = VMActions::SNAPSHOT_CREATE_ACTION;
|
||||
}
|
||||
|
||||
//All VM snapshot operations are set to the same auth value
|
||||
auth_op = nd.get_vm_auth_op(History::SNAPSHOT_CREATE_ACTION);
|
||||
};
|
||||
|
||||
~VirtualMachineSnapshotCreate(){};
|
||||
~VirtualMachineSnapshotCreate() = default;
|
||||
|
||||
protected:
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att) override;
|
||||
};
|
||||
@@ -371,15 +376,14 @@ public:
|
||||
VirtualMachineSnapshotRevert():
|
||||
RequestManagerVirtualMachine("one.vm.snapshotrevert",
|
||||
"Reverts a virtual machine to a snapshot",
|
||||
"A:sii"){
|
||||
Nebula& nd = Nebula::instance();
|
||||
"A:sii")
|
||||
{
|
||||
vm_action = VMActions::SNAPSHOT_REVERT_ACTION;
|
||||
}
|
||||
|
||||
//All VM snapshot operations are set to the same auth value
|
||||
auth_op = nd.get_vm_auth_op(History::SNAPSHOT_REVERT_ACTION);
|
||||
};
|
||||
|
||||
~VirtualMachineSnapshotRevert(){};
|
||||
~VirtualMachineSnapshotRevert() = default;
|
||||
|
||||
protected:
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att) override;
|
||||
};
|
||||
@@ -393,15 +397,14 @@ public:
|
||||
VirtualMachineSnapshotDelete():
|
||||
RequestManagerVirtualMachine("one.vm.snapshotdelete",
|
||||
"Deletes a virtual machine snapshot",
|
||||
"A:sii"){
|
||||
Nebula& nd = Nebula::instance();
|
||||
"A:sii")
|
||||
{
|
||||
vm_action = VMActions::SNAPSHOT_DELETE_ACTION;
|
||||
}
|
||||
|
||||
//All VM snapshot operations are set to the same auth value
|
||||
auth_op = nd.get_vm_auth_op(History::SNAPSHOT_DELETE_ACTION);
|
||||
};
|
||||
|
||||
~VirtualMachineSnapshotDelete(){};
|
||||
~VirtualMachineSnapshotDelete() = default;
|
||||
|
||||
protected:
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att) override;
|
||||
};
|
||||
@@ -415,9 +418,14 @@ public:
|
||||
VirtualMachineRecover():
|
||||
RequestManagerVirtualMachine("one.vm.recover",
|
||||
"Recovers a virtual machine",
|
||||
"A:sii"){};
|
||||
~VirtualMachineRecover(){};
|
||||
"A:sii")
|
||||
{
|
||||
vm_action = VMActions::RECOVER_ACTION;
|
||||
}
|
||||
|
||||
~VirtualMachineRecover() = default;
|
||||
|
||||
protected:
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att) override;
|
||||
};
|
||||
@@ -428,22 +436,17 @@ public:
|
||||
class VirtualMachinePoolCalculateShowback : public RequestManagerVirtualMachine
|
||||
{
|
||||
public:
|
||||
|
||||
VirtualMachinePoolCalculateShowback():
|
||||
RequestManagerVirtualMachine("one.vmpool.calculateshowback",
|
||||
"Processes all the history records, and stores the monthly cost"
|
||||
" for each VM", "A:sii")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_vmpool();
|
||||
|
||||
auth_object = PoolObjectSQL::VM;
|
||||
};
|
||||
}
|
||||
|
||||
~VirtualMachinePoolCalculateShowback(){};
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
~VirtualMachinePoolCalculateShowback() = default;
|
||||
|
||||
protected:
|
||||
void request_execute(xmlrpc_c::paramList const& paramList,
|
||||
RequestAttributes& att) override;
|
||||
};
|
||||
@@ -457,16 +460,17 @@ public:
|
||||
VirtualMachineDiskSnapshotCreate():
|
||||
RequestManagerVirtualMachine("one.vm.disksnapshotcreate",
|
||||
"Creates a new virtual machine disk snapshot",
|
||||
"A:siis"){
|
||||
"A:siis")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
ipool = nd.get_ipool();
|
||||
|
||||
//All VM disk snapshot operations are set to the same auth value
|
||||
auth_op = nd.get_vm_auth_op(History::DISK_SNAPSHOT_CREATE_ACTION);
|
||||
};
|
||||
vm_action = VMActions::DISK_SNAPSHOT_CREATE_ACTION;
|
||||
}
|
||||
|
||||
~VirtualMachineDiskSnapshotCreate(){};
|
||||
~VirtualMachineDiskSnapshotCreate() = default;
|
||||
|
||||
protected:
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att) override;
|
||||
|
||||
@@ -483,15 +487,14 @@ public:
|
||||
VirtualMachineDiskSnapshotRevert():
|
||||
RequestManagerVirtualMachine("one.vm.disksnapshotrevert",
|
||||
"Reverts disk state to a snapshot",
|
||||
"A:siii"){
|
||||
Nebula& nd = Nebula::instance();
|
||||
"A:siii")
|
||||
{
|
||||
vm_action = VMActions::DISK_SNAPSHOT_REVERT_ACTION;
|
||||
}
|
||||
|
||||
//All VM disk snapshot operations are set to the same auth value
|
||||
auth_op = nd.get_vm_auth_op(History::DISK_SNAPSHOT_REVERT_ACTION);
|
||||
};
|
||||
|
||||
~VirtualMachineDiskSnapshotRevert(){};
|
||||
~VirtualMachineDiskSnapshotRevert() = default;
|
||||
|
||||
protected:
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att) override;
|
||||
};
|
||||
@@ -505,16 +508,17 @@ public:
|
||||
VirtualMachineDiskSnapshotDelete():
|
||||
RequestManagerVirtualMachine("one.vm.disksnapshotdelete",
|
||||
"Deletes a disk snapshot",
|
||||
"A:siii"){
|
||||
"A:siii")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
ipool = nd.get_ipool();
|
||||
|
||||
//All VM disk snapshot operations are set to the same auth value
|
||||
auth_op = nd.get_vm_auth_op(History::DISK_SNAPSHOT_DELETE_ACTION);
|
||||
};
|
||||
vm_action = VMActions::DISK_SNAPSHOT_DELETE_ACTION;
|
||||
}
|
||||
|
||||
~VirtualMachineDiskSnapshotDelete(){};
|
||||
~VirtualMachineDiskSnapshotDelete() = default;
|
||||
|
||||
protected:
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att) override;
|
||||
|
||||
@@ -531,15 +535,14 @@ public:
|
||||
VirtualMachineDiskSnapshotRename():
|
||||
RequestManagerVirtualMachine("one.vm.disksnapshotrename",
|
||||
"Rename a disk snapshot",
|
||||
"A:siiis"){
|
||||
Nebula& nd = Nebula::instance();
|
||||
"A:siiis")
|
||||
{
|
||||
vm_action = VMActions::DISK_SNAPSHOT_RENAME_ACTION;
|
||||
}
|
||||
|
||||
//All VM disk snapshot operations are set to the same auth value
|
||||
auth_op = nd.get_vm_auth_op(History::DISK_SNAPSHOT_RENAME_ACTION);
|
||||
};
|
||||
|
||||
~VirtualMachineDiskSnapshotRename(){};
|
||||
~VirtualMachineDiskSnapshotRename() = default;
|
||||
|
||||
protected:
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att) override;
|
||||
};
|
||||
@@ -553,33 +556,41 @@ public:
|
||||
VirtualMachineUpdateConf():
|
||||
RequestManagerVirtualMachine("one.vm.updateconf",
|
||||
"Updates several configuration attributes of a VM",
|
||||
"A:sis"){
|
||||
auth_op = Nebula::instance().get_vm_auth_op(History::UPDATECONF_ACTION);
|
||||
};
|
||||
"A:sis")
|
||||
{
|
||||
vm_action = VMActions::UPDATECONF_ACTION;
|
||||
}
|
||||
|
||||
~VirtualMachineUpdateConf(){};
|
||||
~VirtualMachineUpdateConf() = default;
|
||||
|
||||
protected:
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att) override;
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
class VirtualMachineDiskResize : public RequestManagerVirtualMachine
|
||||
{
|
||||
public:
|
||||
VirtualMachineDiskResize():
|
||||
RequestManagerVirtualMachine("one.vm.diskresize",
|
||||
"Resizes a disk from a virtual machine",
|
||||
"A:siis"){
|
||||
"A:siis")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
ipool = nd.get_ipool();
|
||||
|
||||
auth_op = nd.get_vm_auth_op(History::DISK_RESIZE_ACTION);
|
||||
};
|
||||
vm_action = VMActions::DISK_RESIZE_ACTION;
|
||||
}
|
||||
|
||||
~VirtualMachineDiskResize(){};
|
||||
~VirtualMachineDiskResize() = default;
|
||||
|
||||
protected:
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att) override;
|
||||
|
||||
private:
|
||||
ImagePool* ipool;
|
||||
};
|
||||
|
||||
@@ -38,6 +38,7 @@ protected:
|
||||
pool = nd.get_vrouterpool();
|
||||
|
||||
auth_object = PoolObjectSQL::VROUTER;
|
||||
auth_op = AuthRequest::MANAGE;
|
||||
};
|
||||
|
||||
~RequestManagerVirtualRouter(){};
|
||||
@@ -56,10 +57,7 @@ class VirtualRouterInstantiate : public RequestManagerVirtualRouter
|
||||
public:
|
||||
VirtualRouterInstantiate() : RequestManagerVirtualRouter(
|
||||
"one.vrouter.instantiate", "Instantiates a new virtual machine "
|
||||
"associated to a virtual router", "A:siiisbs")
|
||||
{
|
||||
auth_op = AuthRequest::MANAGE;
|
||||
};
|
||||
"associated to a virtual router", "A:siiisbs") { }
|
||||
|
||||
~VirtualRouterInstantiate(){};
|
||||
|
||||
@@ -76,10 +74,7 @@ class VirtualRouterAttachNic : public RequestManagerVirtualRouter
|
||||
public:
|
||||
VirtualRouterAttachNic():RequestManagerVirtualRouter("one.vrouter.attachnic",
|
||||
"Attaches a new NIC to the virtual router, and its virtual machines",
|
||||
"A:sis")
|
||||
{
|
||||
auth_op = AuthRequest::MANAGE;
|
||||
};
|
||||
"A:sis") { }
|
||||
|
||||
~VirtualRouterAttachNic(){};
|
||||
|
||||
@@ -95,10 +90,7 @@ class VirtualRouterDetachNic : public RequestManagerVirtualRouter
|
||||
{
|
||||
public:
|
||||
VirtualRouterDetachNic():RequestManagerVirtualRouter("one.vrouter.detachnic",
|
||||
"Detaches a NIC from a virtual router, and its virtual machines","A:sii")
|
||||
{
|
||||
auth_op = AuthRequest::MANAGE;
|
||||
};
|
||||
"Detaches a NIC from a virtual router, and its virtual machines","A:sii") { }
|
||||
|
||||
~VirtualRouterDetachNic(){};
|
||||
|
||||
|
||||
+20
-4
@@ -22,6 +22,8 @@
|
||||
#include "ObjectCollection.h"
|
||||
#include "QuotasSQL.h"
|
||||
#include "LoginToken.h"
|
||||
#include "VMActions.h"
|
||||
#include "AuthRequest.h"
|
||||
|
||||
class UserQuotas;
|
||||
|
||||
@@ -224,6 +226,15 @@ public:
|
||||
return groups.contains(_group_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the operation level (admin, manage or use) associated to the
|
||||
* given action for this group
|
||||
*/
|
||||
AuthRequest::Operation get_vm_auth_op(VMActions::Action action) const
|
||||
{
|
||||
return vm_actions.get_auth_op(action);
|
||||
}
|
||||
|
||||
// *************************************************************************
|
||||
// Quotas
|
||||
// *************************************************************************
|
||||
@@ -241,7 +252,7 @@ public:
|
||||
int update_quotas(SqlDB *db)
|
||||
{
|
||||
return quota.update(oid, db->get_local_db());
|
||||
};
|
||||
}
|
||||
|
||||
// *************************************************************************
|
||||
// Login tokens
|
||||
@@ -283,6 +294,11 @@ private:
|
||||
*/
|
||||
ObjectCollection groups;
|
||||
|
||||
/**
|
||||
* List of VM actions and rights for this user
|
||||
*/
|
||||
VMActions vm_actions;
|
||||
|
||||
// *************************************************************************
|
||||
// Authentication session used to cache authentication calls
|
||||
// *************************************************************************
|
||||
@@ -310,7 +326,7 @@ private:
|
||||
ostringstream oss_user(User::db_bootstrap);
|
||||
|
||||
return db->exec_local_wr(oss_user);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the User (identified with its OID) from the database.
|
||||
@@ -375,7 +391,7 @@ protected:
|
||||
session(0)
|
||||
{
|
||||
obj_template = new UserTemplate;
|
||||
};
|
||||
}
|
||||
|
||||
virtual ~User() = default;
|
||||
|
||||
@@ -406,7 +422,7 @@ protected:
|
||||
{
|
||||
string error_str;
|
||||
return insert_replace(db, true, error_str);
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
#endif /*USER_H_*/
|
||||
+8
-7
@@ -41,20 +41,21 @@ class UserPool : public PoolSQL
|
||||
{
|
||||
public:
|
||||
|
||||
UserPool(SqlDB * db,
|
||||
time_t __session_expiration_time,
|
||||
vector<const VectorAttribute *> hook_mads,
|
||||
const string& remotes_location,
|
||||
bool is_federation_slave);
|
||||
UserPool(SqlDB * db,
|
||||
time_t __session_expiration_time,
|
||||
vector<const VectorAttribute *> hook_mads,
|
||||
const string& remotes_location,
|
||||
bool is_federation_slave,
|
||||
vector<const SingleAttribute *>& restricted_attrs);
|
||||
|
||||
~UserPool(){};
|
||||
~UserPool() = default;
|
||||
|
||||
/**
|
||||
* Function to allocate a new User object
|
||||
* @param oid the id assigned to the User
|
||||
* @return the oid assigned to the object or -1 in case of failure
|
||||
*/
|
||||
int allocate (
|
||||
int allocate(
|
||||
int * oid,
|
||||
const string& uname,
|
||||
int gid,
|
||||
|
||||
+26
-4
@@ -19,17 +19,39 @@
|
||||
|
||||
#include "Template.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* User Template class, it represents the attributes of an user
|
||||
*/
|
||||
class UserTemplate : public Template
|
||||
{
|
||||
public:
|
||||
UserTemplate() : Template(true,'=',"TEMPLATE"){};
|
||||
UserTemplate() : Template(true,'=',"TEMPLATE") {}
|
||||
|
||||
~UserTemplate(){};
|
||||
~UserTemplate() = default;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Restricted attributes interface implementation
|
||||
// -------------------------------------------------------------------------
|
||||
bool check_restricted(string& rs_attr, const Template* base) override
|
||||
{
|
||||
return Template::check_restricted(rs_attr, base, restricted);
|
||||
}
|
||||
|
||||
bool check_restricted(string& rs_attr) override
|
||||
{
|
||||
return Template::check_restricted(rs_attr, restricted);
|
||||
}
|
||||
|
||||
static void parse_restricted(vector<const SingleAttribute *>& ra)
|
||||
{
|
||||
Template::parse_restricted(ra, restricted);
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* Restricted attribute list for UserTemplate
|
||||
*/
|
||||
static std::map<std::string, std::set<std::string>> restricted;
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* 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. */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef VMACTIONS_H
|
||||
#define VMACTIONS_H
|
||||
|
||||
#include "ActionSet.h"
|
||||
#include "AuthRequest.h"
|
||||
|
||||
class Template;
|
||||
|
||||
class VMActions
|
||||
{
|
||||
public:
|
||||
|
||||
enum Action
|
||||
{ //Associated XML-RPC API call
|
||||
NONE_ACTION = 0, // "one.vm.migrate"
|
||||
MIGRATE_ACTION = 1, // "one.vm.migrate"
|
||||
LIVE_MIGRATE_ACTION = 2,
|
||||
//SHUTDOWN_ACTION = 3,
|
||||
//SHUTDOWN_HARD_ACTION = 4,
|
||||
UNDEPLOY_ACTION = 5, // "one.vm.action"
|
||||
UNDEPLOY_HARD_ACTION = 6, // "one.vm.action"
|
||||
HOLD_ACTION = 7, // "one.vm.action"
|
||||
RELEASE_ACTION = 8, // "one.vm.action"
|
||||
STOP_ACTION = 9, // "one.vm.action"
|
||||
SUSPEND_ACTION = 10, // "one.vm.action"
|
||||
RESUME_ACTION = 11, // "one.vm.action"
|
||||
//BOOT_ACTION = 12,
|
||||
DELETE_ACTION = 13, // "one.vm.recover"
|
||||
DELETE_RECREATE_ACTION = 14, // "one.vm.recover"
|
||||
REBOOT_ACTION = 15, // "one.vm.action"
|
||||
REBOOT_HARD_ACTION = 16, // "one.vm.action"
|
||||
RESCHED_ACTION = 17, // "one.vm.action"
|
||||
UNRESCHED_ACTION = 18, // "one.vm.action"
|
||||
POWEROFF_ACTION = 19, // "one.vm.action"
|
||||
POWEROFF_HARD_ACTION = 20, // "one.vm.action"
|
||||
DISK_ATTACH_ACTION = 21, // "one.vm.attach"
|
||||
DISK_DETACH_ACTION = 22, // "one.vm.detach"
|
||||
NIC_ATTACH_ACTION = 23, // "one.vm.attachnic"
|
||||
NIC_DETACH_ACTION = 24, // "one.vm.detachnic"
|
||||
DISK_SNAPSHOT_CREATE_ACTION = 25, // "one.vm.disksnapshotcreate"
|
||||
DISK_SNAPSHOT_DELETE_ACTION = 26, // "one.vm.disksnapshotdelete"
|
||||
TERMINATE_ACTION = 27, // "one.vm.action"
|
||||
TERMINATE_HARD_ACTION = 28, // "one.vm.action"
|
||||
DISK_RESIZE_ACTION = 29, // "one.vm.diskresize"
|
||||
DEPLOY_ACTION = 30, // "one.vm.deploy"
|
||||
CHOWN_ACTION = 31, // "one.vm.chown"
|
||||
CHMOD_ACTION = 32, // "one.vm.chmod"
|
||||
UPDATECONF_ACTION = 33, // "one.vm.updateconf"
|
||||
RENAME_ACTION = 34, // "one.vm.rename"
|
||||
RESIZE_ACTION = 35, // "one.vm.resize"
|
||||
UPDATE_ACTION = 36, // "one.vm.update"
|
||||
SNAPSHOT_CREATE_ACTION = 37, // "one.vm.snapshotcreate"
|
||||
SNAPSHOT_DELETE_ACTION = 38, // "one.vm.snapshotdelete"
|
||||
SNAPSHOT_REVERT_ACTION = 39, // "one.vm.snapshotrevert"
|
||||
DISK_SAVEAS_ACTION = 40, // "one.vm.disksaveas"
|
||||
DISK_SNAPSHOT_REVERT_ACTION = 41, // "one.vm.disksnapshotrevert"
|
||||
RECOVER_ACTION = 42, // "one.vm.recover"
|
||||
RETRY_ACTION = 43, // "one.vm.recover"
|
||||
MONITOR_ACTION = 44, // internal, monitoring process
|
||||
DISK_SNAPSHOT_RENAME_ACTION = 45, // "one.vm.disksnapshotrename"
|
||||
ALIAS_ATTACH_ACTION = 46, // "one.vm.attachnic"
|
||||
ALIAS_DETACH_ACTION = 47, // "one.vm.detachnic"
|
||||
POFF_MIGRATE_ACTION = 48, // "one.vm.migrate"
|
||||
POFF_HARD_MIGRATE_ACTION = 49 // "one.vm.migrate"
|
||||
};
|
||||
|
||||
static string action_to_str(Action action);
|
||||
|
||||
static int action_from_str(const string& st, Action& action);
|
||||
|
||||
/**
|
||||
* @return true if action requires ADMIN right
|
||||
*/
|
||||
bool is_admin(Action action) const
|
||||
{
|
||||
return admin_actions.is_set(action);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if action requires ADMIN right
|
||||
*/
|
||||
bool is_use(Action action) const
|
||||
{
|
||||
return use_actions.is_set(action);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if action requires ADMIN right
|
||||
*/
|
||||
bool is_manage(Action action) const
|
||||
{
|
||||
return manage_actions.is_set(action);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the auth type for the given action
|
||||
*/
|
||||
AuthRequest::Operation get_auth_op(Action action) const;
|
||||
|
||||
/**
|
||||
* Sets the auth operations based on the provided template
|
||||
*/
|
||||
int set_auth_ops(const Template& tmpl, string& error);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Set of VM actions that require USE permission
|
||||
*/
|
||||
ActionSet<Action> use_actions;
|
||||
|
||||
/**
|
||||
* Set of VM actions that require MANAGE permission
|
||||
*/
|
||||
ActionSet<Action> manage_actions;
|
||||
|
||||
/**
|
||||
* Set of VM actions that require ADMIN permission
|
||||
*/
|
||||
ActionSet<Action> admin_actions;
|
||||
|
||||
/**
|
||||
* Returns action set from a string of actions seperated by commas
|
||||
*/
|
||||
int set_auth_ops(const std::string& ops_str,
|
||||
ActionSet<Action>& ops_set, std::string& error);
|
||||
};
|
||||
|
||||
#endif /*VMACTIONS_H*/
|
||||
@@ -653,7 +653,7 @@ public:
|
||||
* function MUST be called before this one.
|
||||
* @return the action that closed the current history record
|
||||
*/
|
||||
const History::VMAction get_action() const
|
||||
const VMActions::Action get_action() const
|
||||
{
|
||||
return history->action;
|
||||
};
|
||||
@@ -662,7 +662,7 @@ public:
|
||||
* Returns the action that closed the history record in the previous host
|
||||
* @return the action that closed the history record in the previous host
|
||||
*/
|
||||
const History::VMAction get_previous_action() const
|
||||
const VMActions::Action get_previous_action() const
|
||||
{
|
||||
return previous_history->action;
|
||||
};
|
||||
@@ -821,7 +821,7 @@ public:
|
||||
* Sets the action that closed the history record
|
||||
* @param action that closed the history record
|
||||
*/
|
||||
void set_action(History::VMAction action, int uid, int gid, int req_id)
|
||||
void set_action(VMActions::Action action, int uid, int gid, int req_id)
|
||||
{
|
||||
history->action = action;
|
||||
|
||||
@@ -831,7 +831,7 @@ public:
|
||||
history->req_id = req_id;
|
||||
};
|
||||
|
||||
void set_internal_action(History::VMAction action)
|
||||
void set_internal_action(VMActions::Action action)
|
||||
{
|
||||
history->action = action;
|
||||
|
||||
@@ -843,7 +843,7 @@ public:
|
||||
|
||||
void clear_action()
|
||||
{
|
||||
history->action = History::NONE_ACTION;
|
||||
history->action = VMActions::NONE_ACTION;
|
||||
|
||||
history->uid = -1;
|
||||
history->gid = -1;
|
||||
@@ -851,7 +851,7 @@ public:
|
||||
history->req_id = -1;
|
||||
}
|
||||
|
||||
void set_previous_action(History::VMAction action, int uid, int gid,int rid)
|
||||
void set_previous_action(VMActions::Action action, int uid, int gid,int rid)
|
||||
{
|
||||
previous_history->action = action;
|
||||
|
||||
@@ -1139,7 +1139,7 @@ public:
|
||||
* @param action VM action to check
|
||||
* @return true if the current VM MAD supports the given action for imported VMs
|
||||
*/
|
||||
bool is_imported_action_supported(History::VMAction action) const;
|
||||
bool is_imported_action_supported(VMActions::Action action) const;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Virtual Router related functions
|
||||
|
||||
@@ -153,7 +153,7 @@ public:
|
||||
* @param action
|
||||
* @return True if it is supported
|
||||
*/
|
||||
bool is_imported_action_supported(const string& mad,History::VMAction action)
|
||||
bool is_imported_action_supported(const string& mad, VMActions::Action action)
|
||||
{
|
||||
const VirtualMachineManagerDriver * vmd = get(mad);
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "Mad.h"
|
||||
#include "ActionSet.h"
|
||||
#include "VirtualMachinePool.h"
|
||||
#include "History.h"
|
||||
#include "VMActions.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
* @param action
|
||||
* @return True if it is supported
|
||||
*/
|
||||
bool is_imported_action_supported(History::VMAction action) const
|
||||
bool is_imported_action_supported(VMActions::Action action) const
|
||||
{
|
||||
return imported_actions.is_set(action);
|
||||
}
|
||||
@@ -159,7 +159,7 @@ private:
|
||||
* List of available actions for imported VMs. Each bit is an action
|
||||
* as defined in History.h, 1=supported and 0=not supported
|
||||
*/
|
||||
ActionSet<History::VMAction> imported_actions;
|
||||
ActionSet<VMActions::Action> imported_actions;
|
||||
|
||||
/**
|
||||
* Set to true if the hypervisor can keep system snapshots across
|
||||
|
||||
Reference in new issue
Block a user