mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-03 01:17:41 +03:00
(cherry picked from commit 3fd059c543
)
This commit is contained in:
parent
da30d27e45
commit
6ee3a5ef5b
@ -106,11 +106,11 @@ public:
|
|||||||
* -2 if the rule is malformed,
|
* -2 if the rule is malformed,
|
||||||
* -3 if the DB insert failed
|
* -3 if the DB insert failed
|
||||||
*/
|
*/
|
||||||
virtual int add_rule(long long user,
|
int add_rule(long long user,
|
||||||
long long resource,
|
long long resource,
|
||||||
long long rights,
|
long long rights,
|
||||||
long long zone,
|
long long zone,
|
||||||
std::string& error_str);
|
std::string& error_str);
|
||||||
/**
|
/**
|
||||||
* Deletes a rule from the ACL rule set
|
* Deletes a rule from the ACL rule set
|
||||||
*
|
*
|
||||||
@ -118,7 +118,7 @@ public:
|
|||||||
* @param error_str Returns the error reason, if any
|
* @param error_str Returns the error reason, if any
|
||||||
* @return 0 on success
|
* @return 0 on success
|
||||||
*/
|
*/
|
||||||
virtual int del_rule(int oid, std::string& error_str);
|
int del_rule(int oid, std::string& error_str);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a new rule from the ACL rule set
|
* Deletes a new rule from the ACL rule set
|
||||||
@ -131,11 +131,11 @@ public:
|
|||||||
* @param error_str Returns the error reason, if any
|
* @param error_str Returns the error reason, if any
|
||||||
* @return 0 on success
|
* @return 0 on success
|
||||||
*/
|
*/
|
||||||
virtual int del_rule(long long user,
|
int del_rule(long long user,
|
||||||
long long resource,
|
long long resource,
|
||||||
long long rights,
|
long long rights,
|
||||||
long long zone,
|
long long zone,
|
||||||
std::string& error_str);
|
std::string& error_str);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes rules that apply to this user id
|
* Deletes rules that apply to this user id
|
||||||
@ -212,7 +212,7 @@ public:
|
|||||||
* @param oss The output stream to dump the rule set contents
|
* @param oss The output stream to dump the rule set contents
|
||||||
* @return 0 on success
|
* @return 0 on success
|
||||||
*/
|
*/
|
||||||
virtual int dump(std::ostringstream& oss);
|
int dump(std::ostringstream& oss);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
|
@ -769,7 +769,7 @@ private:
|
|||||||
/**
|
/**
|
||||||
* The type of addresses defined in the range
|
* The type of addresses defined in the range
|
||||||
*/
|
*/
|
||||||
AddressType type;
|
AddressType type = NONE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ID for this range, unique within the Virtual Network
|
* ID for this range, unique within the Virtual Network
|
||||||
@ -779,12 +779,12 @@ private:
|
|||||||
/**
|
/**
|
||||||
* Number of addresses in the range
|
* Number of addresses in the range
|
||||||
*/
|
*/
|
||||||
unsigned long int size;
|
unsigned long int size = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* First IP4 in the range
|
* First IP4 in the range
|
||||||
*/
|
*/
|
||||||
unsigned int ip;
|
unsigned int ip = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* First MAC in the range
|
* First MAC in the range
|
||||||
@ -825,7 +825,7 @@ private:
|
|||||||
* The Address Range attributes as a Template VectorAttribute. This is
|
* The Address Range attributes as a Template VectorAttribute. This is
|
||||||
* used to generate XML or a template representation of the AR.
|
* used to generate XML or a template representation of the AR.
|
||||||
*/
|
*/
|
||||||
VectorAttribute * attr;
|
VectorAttribute * attr = nullptr;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
/* Restricted Attributes */
|
/* Restricted Attributes */
|
||||||
|
@ -36,10 +36,11 @@ public:
|
|||||||
|
|
||||||
AuthManager(
|
AuthManager(
|
||||||
time_t timer,
|
time_t timer,
|
||||||
const std::string& mads_location):
|
const std::string& mads_location)
|
||||||
DriverManager(mads_location),
|
: DriverManager(mads_location)
|
||||||
Listener("Authorization Manager"),
|
, Listener("Authorization Manager")
|
||||||
timer_thread(timer, [this](){timer_action();})
|
, timer_thread(timer, [this](){timer_action();})
|
||||||
|
, authz_enabled(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,13 +424,13 @@ private:
|
|||||||
* related to the DS defined in DS_MAD_CONF specified in the Datastore
|
* related to the DS defined in DS_MAD_CONF specified in the Datastore
|
||||||
* template
|
* template
|
||||||
*/
|
*/
|
||||||
int set_ds_mad(std::string &ds_mad, std::string &error_str);
|
int set_ds_mad(const std::string &ds_mad, std::string &error_str);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify the proper definition of the TM_MAD by checking the attributes
|
* Verify the proper definition of the TM_MAD by checking the attributes
|
||||||
* related to the TM defined in TM_MAD_CONF
|
* related to the TM defined in TM_MAD_CONF
|
||||||
*/
|
*/
|
||||||
int set_tm_mad(std::string &tm_mad, std::string &error_str);
|
int set_tm_mad(const std::string &tm_mad, std::string &error_str);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Child classes can process the new template set with replace_template or
|
* Child classes can process the new template set with replace_template or
|
||||||
|
@ -49,7 +49,6 @@ public:
|
|||||||
: cmd(c)
|
: cmd(c)
|
||||||
, arg(a)
|
, arg(a)
|
||||||
, concurrency(ct)
|
, concurrency(ct)
|
||||||
, pid(-1)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
~Driver()
|
~Driver()
|
||||||
@ -129,12 +128,12 @@ private:
|
|||||||
/**
|
/**
|
||||||
* Communication pipe file descriptor (daemon <- driver)
|
* Communication pipe file descriptor (daemon <- driver)
|
||||||
*/
|
*/
|
||||||
int from_drv;
|
int from_drv = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Communication pipe file descriptor (daemon -> driver)
|
* Communication pipe file descriptor (daemon -> driver)
|
||||||
*/
|
*/
|
||||||
int to_drv;
|
int to_drv = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Driver configuration: path and arguments
|
* Driver configuration: path and arguments
|
||||||
@ -143,12 +142,12 @@ private:
|
|||||||
|
|
||||||
std::string arg;
|
std::string arg;
|
||||||
|
|
||||||
int concurrency;
|
int concurrency = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process ID of the driver
|
* Process ID of the driver
|
||||||
*/
|
*/
|
||||||
pid_t pid;
|
pid_t pid = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to read lines from the stream
|
* Class to read lines from the stream
|
||||||
|
@ -50,14 +50,19 @@
|
|||||||
class HostShareNode : public Template
|
class HostShareNode : public Template
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HostShareNode() : Template(false, '=', "NODE"){};
|
HostShareNode()
|
||||||
|
: Template(false, '=', "NODE")
|
||||||
|
, node_id(std::numeric_limits<unsigned int>::max())
|
||||||
|
{}
|
||||||
|
|
||||||
HostShareNode(unsigned int i) : Template(false, '=', "NODE"), node_id(i)
|
HostShareNode(unsigned int i)
|
||||||
|
: Template(false, '=', "NODE")
|
||||||
|
, node_id(i)
|
||||||
{
|
{
|
||||||
replace("NODE_ID", i);
|
replace("NODE_ID", i);
|
||||||
};
|
}
|
||||||
|
|
||||||
virtual ~HostShareNode(){};
|
virtual ~HostShareNode() = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the node from its XML representation. This function is used when
|
* Builds the node from its XML representation. This function is used when
|
||||||
|
@ -53,7 +53,7 @@ public:
|
|||||||
|
|
||||||
virtual ~HostSharePCI()
|
virtual ~HostSharePCI()
|
||||||
{
|
{
|
||||||
clear();
|
HostSharePCI::clear();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -127,6 +127,8 @@ public:
|
|||||||
if ( new_ar == 0 )
|
if ( new_ar == 0 )
|
||||||
{
|
{
|
||||||
error = "AR not found in IPAM driver response";
|
error = "AR not found in IPAM driver response";
|
||||||
|
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
vattr->replace(new_ar->value());
|
vattr->replace(new_ar->value());
|
||||||
@ -148,6 +150,8 @@ public:
|
|||||||
if ( addr == 0 )
|
if ( addr == 0 )
|
||||||
{
|
{
|
||||||
error = "ADDRESS not found in IPAM driver response";
|
error = "ADDRESS not found in IPAM driver response";
|
||||||
|
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ip = addr->vector_value("IP");
|
ip = addr->vector_value("IP");
|
||||||
|
@ -597,30 +597,36 @@ public:
|
|||||||
//Constructors and = are private to only access the class through instance
|
//Constructors and = are private to only access the class through instance
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
Nebula():nebula_configuration(0),
|
Nebula()
|
||||||
default_user_quota( "DEFAULT_USER_QUOTAS",
|
: nebula_configuration(0)
|
||||||
"/DEFAULT_USER_QUOTAS/DATASTORE_QUOTA",
|
, federation_enabled(false)
|
||||||
"/DEFAULT_USER_QUOTAS/NETWORK_QUOTA",
|
, federation_master(false)
|
||||||
"/DEFAULT_USER_QUOTAS/IMAGE_QUOTA",
|
, cache(false)
|
||||||
"/DEFAULT_USER_QUOTAS/VM_QUOTA"),
|
, zone_id(0)
|
||||||
default_group_quota("DEFAULT_GROUP_QUOTAS",
|
, server_id(-1)
|
||||||
"/DEFAULT_GROUP_QUOTAS/DATASTORE_QUOTA",
|
, default_user_quota( "DEFAULT_USER_QUOTAS",
|
||||||
"/DEFAULT_GROUP_QUOTAS/NETWORK_QUOTA",
|
"/DEFAULT_USER_QUOTAS/DATASTORE_QUOTA",
|
||||||
"/DEFAULT_GROUP_QUOTAS/IMAGE_QUOTA",
|
"/DEFAULT_USER_QUOTAS/NETWORK_QUOTA",
|
||||||
"/DEFAULT_GROUP_QUOTAS/VM_QUOTA"),
|
"/DEFAULT_USER_QUOTAS/IMAGE_QUOTA",
|
||||||
system_db(0), db_backend_type("sqlite"), logdb(0), fed_logdb(0),
|
"/DEFAULT_USER_QUOTAS/VM_QUOTA")
|
||||||
vmpool(0), hpool(0), vnpool(0), upool(0), ipool(0), gpool(0), tpool(0),
|
, default_group_quota("DEFAULT_GROUP_QUOTAS",
|
||||||
dspool(0), clpool(0), docpool(0), zonepool(0), secgrouppool(0),
|
"/DEFAULT_GROUP_QUOTAS/DATASTORE_QUOTA",
|
||||||
vdcpool(0), vrouterpool(0), marketpool(0), apppool(0), vmgrouppool(0),
|
"/DEFAULT_GROUP_QUOTAS/NETWORK_QUOTA",
|
||||||
vntpool(0), hkpool(0), lcm(0), vmm(0), im(0), tm(0), dm(0), rm(0), hm(0),
|
"/DEFAULT_GROUP_QUOTAS/IMAGE_QUOTA",
|
||||||
hl(0), authm(0), aclm(0), imagem(0), marketm(0), ipamm(0), raftm(0), frm(0)
|
"/DEFAULT_GROUP_QUOTAS/VM_QUOTA")
|
||||||
|
, system_db(0), db_backend_type("sqlite"), logdb(0), fed_logdb(0)
|
||||||
|
, vmpool(0), hpool(0), vnpool(0), upool(0), ipool(0), gpool(0), tpool(0)
|
||||||
|
, dspool(0), clpool(0), docpool(0), zonepool(0), secgrouppool(0)
|
||||||
|
, vdcpool(0), vrouterpool(0), marketpool(0), apppool(0), vmgrouppool(0)
|
||||||
|
, vntpool(0), hkpool(0), lcm(0), vmm(0), im(0), tm(0), dm(0), rm(0), hm(0)
|
||||||
|
, hl(0), authm(0), aclm(0), imagem(0), marketm(0), ipamm(0), raftm(0), frm(0)
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
~Nebula();
|
~Nebula();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Nebula& operator=(Nebula const&){return *this;};
|
Nebula& operator=(Nebula const&) = delete;
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// Environment variables
|
// Environment variables
|
||||||
|
@ -37,7 +37,12 @@ public:
|
|||||||
|
|
||||||
// ---------------------- Constructors ------------------------------------
|
// ---------------------- Constructors ------------------------------------
|
||||||
|
|
||||||
ObjectXML():xml(0), ctx(0) {}
|
ObjectXML()
|
||||||
|
: paths(nullptr)
|
||||||
|
, num_paths(0)
|
||||||
|
, xml(nullptr)
|
||||||
|
, ctx(nullptr)
|
||||||
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an object using a XML document
|
* Constructs an object using a XML document
|
||||||
|
@ -30,23 +30,25 @@ class PoolObjectAuth
|
|||||||
public:
|
public:
|
||||||
/* ------------------- Constructor and Methods -------------------------- */
|
/* ------------------- Constructor and Methods -------------------------- */
|
||||||
|
|
||||||
PoolObjectAuth():
|
PoolObjectAuth()
|
||||||
oid(-1),
|
: obj_type(PoolObjectSQL::NONE)
|
||||||
uid(-1),
|
, oid(-1)
|
||||||
gid(-1),
|
, uid(-1)
|
||||||
owner_u(1),
|
, gid(-1)
|
||||||
owner_m(1),
|
, owner_u(1)
|
||||||
owner_a(0),
|
, owner_m(1)
|
||||||
group_u(0),
|
, owner_a(0)
|
||||||
group_m(0),
|
, group_u(0)
|
||||||
group_a(0),
|
, group_m(0)
|
||||||
other_u(0),
|
, group_a(0)
|
||||||
other_m(0),
|
, other_u(0)
|
||||||
other_a(0),
|
, other_m(0)
|
||||||
disable_all_acl(false),
|
, other_a(0)
|
||||||
disable_cluster_acl(false),
|
, disable_all_acl(false)
|
||||||
disable_group_acl(false),
|
, disable_cluster_acl(false)
|
||||||
locked(0) {};
|
, disable_group_acl(false)
|
||||||
|
, locked(0)
|
||||||
|
{}
|
||||||
|
|
||||||
void get_acl_rules(AclRule& owner_rule,
|
void get_acl_rules(AclRule& owner_rule,
|
||||||
AclRule& group_rule,
|
AclRule& group_rule,
|
||||||
|
@ -63,10 +63,16 @@ public:
|
|||||||
bool success; /**< True if the call was successfull false otherwise */
|
bool success; /**< True if the call was successfull false otherwise */
|
||||||
|
|
||||||
RequestAttributes(AuthRequest::Operation api_auth_op)
|
RequestAttributes(AuthRequest::Operation api_auth_op)
|
||||||
: resp_obj(PoolObjectSQL::NONE)
|
: uid(-1)
|
||||||
|
, gid(-1)
|
||||||
|
, req_id(-1)
|
||||||
|
, umask(0)
|
||||||
|
, retval(nullptr)
|
||||||
|
, resp_obj(PoolObjectSQL::NONE)
|
||||||
, resp_id(-1)
|
, resp_id(-1)
|
||||||
, replication_idx(UINT64_MAX)
|
, replication_idx(UINT64_MAX)
|
||||||
, auth_op(api_auth_op)
|
, auth_op(api_auth_op)
|
||||||
|
, success(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
RequestAttributes(const RequestAttributes& ra) = default;
|
RequestAttributes(const RequestAttributes& ra) = default;
|
||||||
@ -89,6 +95,7 @@ public:
|
|||||||
, resp_msg()
|
, resp_msg()
|
||||||
, replication_idx(UINT64_MAX)
|
, replication_idx(UINT64_MAX)
|
||||||
, auth_op(ra.auth_op)
|
, auth_op(ra.auth_op)
|
||||||
|
, success(ra.success)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool is_admin() const
|
bool is_admin() const
|
||||||
@ -257,7 +264,7 @@ protected:
|
|||||||
|
|
||||||
// Configuration for authentication level of the API call
|
// Configuration for authentication level of the API call
|
||||||
PoolObjectSQL::ObjectType auth_object = PoolObjectSQL::ObjectType::NONE;
|
PoolObjectSQL::ObjectType auth_object = PoolObjectSQL::ObjectType::NONE;
|
||||||
AuthRequest::Operation auth_op;
|
AuthRequest::Operation auth_op = AuthRequest::NONE;
|
||||||
|
|
||||||
VMActions::Action vm_action;
|
VMActions::Action vm_action;
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ private:
|
|||||||
|
|
||||||
std::condition_variable _cond;
|
std::condition_variable _cond;
|
||||||
|
|
||||||
int _concurrency;
|
int _concurrency = 0;
|
||||||
|
|
||||||
std::map<typename MSG::msg_enum, callback_t > actions;
|
std::map<typename MSG::msg_enum, callback_t > actions;
|
||||||
|
|
||||||
|
@ -81,7 +81,9 @@ public:
|
|||||||
* attributes
|
* attributes
|
||||||
* @param tmpl template with SERVER
|
* @param tmpl template with SERVER
|
||||||
*/
|
*/
|
||||||
ZoneServers(Template * tmpl):ExtendedAttributeSet(false), next_id(-1)
|
ZoneServers(Template * tmpl)
|
||||||
|
: ExtendedAttributeSet(false)
|
||||||
|
, next_id(-1)
|
||||||
{
|
{
|
||||||
std::vector<VectorAttribute *> vas;
|
std::vector<VectorAttribute *> vas;
|
||||||
|
|
||||||
@ -109,9 +111,12 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Creates an empty zone server set
|
* Creates an empty zone server set
|
||||||
*/
|
*/
|
||||||
ZoneServers():ExtendedAttributeSet(false){};
|
ZoneServers()
|
||||||
|
: ExtendedAttributeSet(false)
|
||||||
|
, next_id(-1)
|
||||||
|
{}
|
||||||
|
|
||||||
virtual ~ZoneServers(){};
|
virtual ~ZoneServers() = default;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
/* Iterators */
|
/* Iterators */
|
||||||
|
@ -1,9 +1,60 @@
|
|||||||
<suppressions>
|
<suppressions>
|
||||||
<!--
|
<!-- Global suppression, issues which we don't want to solve -->
|
||||||
<suppress>
|
<suppress>
|
||||||
<id>variableScope</id>
|
<id>variableScope</id>
|
||||||
<fileName>*</fileName>
|
<fileName>*</fileName>
|
||||||
</suppress>
|
</suppress>
|
||||||
|
<suppress>
|
||||||
|
<id>noExplicitConstructor</id>
|
||||||
|
<fileName>*</fileName>
|
||||||
|
</suppress>
|
||||||
|
<suppress>
|
||||||
|
<id>missingInclude</id>
|
||||||
|
<fileName>*</fileName>
|
||||||
|
</suppress>
|
||||||
|
<suppress>
|
||||||
|
<id>danglingLifetime</id>
|
||||||
|
<fileName>*</fileName>
|
||||||
|
</suppress>
|
||||||
|
<suppress>
|
||||||
|
<id>shadowFunction</id>
|
||||||
|
<fileName>*</fileName>
|
||||||
|
</suppress>
|
||||||
|
<!-- Suppresions specific per file, false positives -->
|
||||||
|
<suppress>
|
||||||
|
<id>containerOutOfBounds</id>
|
||||||
|
<fileName>src/hm/HookLog.cc</fileName>
|
||||||
|
<symbolName>query_output</symbolName>
|
||||||
|
</suppress>
|
||||||
|
<suppress>
|
||||||
|
<id>ctuuninitvar</id>
|
||||||
|
<fileName>src/sql/LogDB.cc</fileName>
|
||||||
|
</suppress>
|
||||||
|
<suppress>
|
||||||
|
<id>knownConditionTrueFalse</id>
|
||||||
|
<fileName>src/raft/ReplicaThread.cc</fileName>
|
||||||
|
</suppress>
|
||||||
|
<suppress>
|
||||||
|
<id>knownConditionTrueFalse</id>
|
||||||
|
<fileName>src/vmm/LibVirtDriverKVM.cc</fileName>
|
||||||
|
</suppress>
|
||||||
|
<suppress>
|
||||||
|
<id>knownConditionTrueFalse</id>
|
||||||
|
<fileName>src/sql/LogDB.cc</fileName>
|
||||||
|
</suppress>
|
||||||
|
<suppress>
|
||||||
|
<id>knownConditionTrueFalse</id>
|
||||||
|
<fileName>src/monitor/src/data_model/VMRPCPool.cc</fileName>
|
||||||
|
</suppress>
|
||||||
|
<suppress>
|
||||||
|
<id>nullPointer</id>
|
||||||
|
<fileName>src/scheduler/include/Scheduler.h</fileName>
|
||||||
|
</suppress>
|
||||||
|
<suppress>
|
||||||
|
<id>uninitMemberVar</id>
|
||||||
|
<fileName>include/Callbackable.h</fileName>
|
||||||
|
</suppress>
|
||||||
|
<!-- Temporary suppressions, we may want to solve them in the future -->
|
||||||
<suppress>
|
<suppress>
|
||||||
<id>unusedVariable</id>
|
<id>unusedVariable</id>
|
||||||
<fileName>*</fileName>
|
<fileName>*</fileName>
|
||||||
@ -12,10 +63,6 @@
|
|||||||
<id>noConstructor</id>
|
<id>noConstructor</id>
|
||||||
<fileName>*</fileName>
|
<fileName>*</fileName>
|
||||||
</suppress>
|
</suppress>
|
||||||
<suppress>
|
|
||||||
<id>noExplicitConstructor</id>
|
|
||||||
<fileName>*</fileName>
|
|
||||||
</suppress>
|
|
||||||
<suppress>
|
<suppress>
|
||||||
<id>constVariable</id>
|
<id>constVariable</id>
|
||||||
<fileName>*</fileName>
|
<fileName>*</fileName>
|
||||||
@ -32,23 +79,13 @@
|
|||||||
<id>unreadVariable</id>
|
<id>unreadVariable</id>
|
||||||
<fileName>*</fileName>
|
<fileName>*</fileName>
|
||||||
</suppress>
|
</suppress>
|
||||||
-->
|
|
||||||
<suppress>
|
<suppress>
|
||||||
<id>missingInclude</id>
|
<id>constParameter</id>
|
||||||
<fileName>*</fileName>
|
<fileName>*</fileName>
|
||||||
</suppress>
|
</suppress>
|
||||||
<suppress>
|
<suppress>
|
||||||
<id>danglingLifetime</id>
|
<id>useStlAlgorithm</id>
|
||||||
<fileName>*</fileName>
|
<fileName>*</fileName>
|
||||||
</suppress>
|
</suppress>
|
||||||
<suppress>
|
|
||||||
<id>containerOutOfBounds</id>
|
|
||||||
<fileName>src/hm/HookLog.cc</fileName>
|
|
||||||
<symbolName>query_output</symbolName>
|
|
||||||
</suppress>
|
|
||||||
<suppress>
|
|
||||||
<id>ctuuninitvar</id>
|
|
||||||
<fileName>src/sql/LogDB.cc</fileName>
|
|
||||||
</suppress>
|
|
||||||
</suppressions>
|
</suppressions>
|
||||||
|
|
||||||
|
@ -14,10 +14,10 @@
|
|||||||
# To disable specific error messages use cppcheck-suppressions.xml file
|
# To disable specific error messages use cppcheck-suppressions.xml file
|
||||||
|
|
||||||
SOURCES="src"
|
SOURCES="src"
|
||||||
INCLUDES="-I include"
|
INCLUDES="-I include -I src/monitor/include -I src/scheduler/include"
|
||||||
DEFINES="-DSQLITE_DB -DMYSQL_DB -DPOSTGRESQL_DB -DSYSTEMD"
|
DEFINES="-DSQLITE_DB -DMYSQL_DB -DPOSTGRESQL_DB -DSYSTEMD"
|
||||||
ENABLE="--enable=performance,information"
|
ENABLE="--enable=performance,information,warning,portability,style"
|
||||||
IGNORE="-i .xmlrpc_test/ -i src/sunstone/ -i src/svncterm_server/ -i src/fireedge"
|
IGNORE="-i .xmlrpc_test/ -i src/sunstone/ -i src/svncterm_server/ -i src/fireedge -i src/parsers"
|
||||||
SUPRESS="--suppress-xml=share/smoke_tests/config/cppcheck-suppressions.xml"
|
SUPRESS="--suppress-xml=share/smoke_tests/config/cppcheck-suppressions.xml"
|
||||||
OTHERS="--std=c++14 --error-exitcode=2 -q"
|
OTHERS="--std=c++14 --error-exitcode=2 -q"
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ static int check_tm_target_type(string& tm_tt)
|
|||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int Datastore::set_ds_mad(std::string &mad, std::string &error_str)
|
int Datastore::set_ds_mad(const std::string &mad, std::string &error_str)
|
||||||
{
|
{
|
||||||
const VectorAttribute* vatt;
|
const VectorAttribute* vatt;
|
||||||
std::vector <std::string> vrequired_attrs;
|
std::vector <std::string> vrequired_attrs;
|
||||||
@ -375,7 +375,7 @@ error_common:
|
|||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int Datastore::set_tm_mad(string &tm_mad, string &error_str)
|
int Datastore::set_tm_mad(const string &tm_mad, string &error_str)
|
||||||
{
|
{
|
||||||
const VectorAttribute* vatt;
|
const VectorAttribute* vatt;
|
||||||
|
|
||||||
@ -447,35 +447,35 @@ int Datastore::set_tm_mad(string &tm_mad, string &error_str)
|
|||||||
|
|
||||||
for (const auto &mode : modes)
|
for (const auto &mode : modes)
|
||||||
{
|
{
|
||||||
string tm_mad = one_util::trim(mode);
|
string tm = one_util::trim(mode);
|
||||||
one_util::toupper(tm_mad);
|
one_util::toupper(tm);
|
||||||
|
|
||||||
st = vatt->vector_value("LN_TARGET_" + tm_mad);
|
st = vatt->vector_value("LN_TARGET_" + tm);
|
||||||
|
|
||||||
if (check_tm_target_type(st) == -1)
|
if (check_tm_target_type(st) == -1)
|
||||||
{
|
{
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
replace_template_attribute("LN_TARGET_" + tm_mad, st);
|
replace_template_attribute("LN_TARGET_" + tm, st);
|
||||||
|
|
||||||
st = vatt->vector_value("CLONE_TARGET_" + tm_mad);
|
st = vatt->vector_value("CLONE_TARGET_" + tm);
|
||||||
|
|
||||||
if (check_tm_target_type(st) == -1)
|
if (check_tm_target_type(st) == -1)
|
||||||
{
|
{
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
replace_template_attribute("CLONE_TARGET_" + tm_mad, st);
|
replace_template_attribute("CLONE_TARGET_" + tm, st);
|
||||||
|
|
||||||
st = vatt->vector_value("DISK_TYPE_" + tm_mad);
|
st = vatt->vector_value("DISK_TYPE_" + tm);
|
||||||
|
|
||||||
if (st.empty())
|
if (st.empty())
|
||||||
{
|
{
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
replace_template_attribute("DISK_TYPE_" + tm_mad, st);
|
replace_template_attribute("DISK_TYPE_" + tm, st);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ ExecuteHook::ExecuteHook(const std::string& _name, const std::string& _cmd,
|
|||||||
c_args[i] = nullptr;
|
c_args[i] = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=1; iss >> args[i] && i < EXECUTE_HOOK_MAX_ARG - 1; ++i)
|
for (int i=1; i < EXECUTE_HOOK_MAX_ARG && iss >> args[i]; ++i)
|
||||||
{
|
{
|
||||||
c_args[i] = args[i].c_str();
|
c_args[i] = args[i].c_str();
|
||||||
}
|
}
|
||||||
|
@ -578,7 +578,7 @@ int Host::post_update_template(string& error)
|
|||||||
im_mad_name = new_im_mad;
|
im_mad_name = new_im_mad;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!new_im_mad.empty())
|
if (!new_vm_mad.empty())
|
||||||
{
|
{
|
||||||
vmm_mad_name = new_vm_mad;
|
vmm_mad_name = new_vm_mad;
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@ void HostShare::update_capacity(Template& ht, string& rcpu, string& rmem)
|
|||||||
|
|
||||||
if ( ht.get("VMS_THREAD", vthread) )
|
if ( ht.get("VMS_THREAD", vthread) )
|
||||||
{
|
{
|
||||||
if ( vthread <= 0 )
|
if ( vthread == 0 )
|
||||||
{
|
{
|
||||||
vthread = 1;
|
vthread = 1;
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ int VirtualMachineBase::init_attributes()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vm_template = 0;
|
vm_template = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
nodes.clear();
|
nodes.clear();
|
||||||
@ -116,21 +116,21 @@ int VirtualMachineBase::init_attributes()
|
|||||||
user_template->from_xml_node(nodes[0]);
|
user_template->from_xml_node(nodes[0]);
|
||||||
|
|
||||||
free_nodes(nodes);
|
free_nodes(nodes);
|
||||||
|
|
||||||
|
public_cloud = (user_template->get("PUBLIC_CLOUD", attrs) > 0);
|
||||||
|
|
||||||
|
if (public_cloud == false)
|
||||||
|
{
|
||||||
|
attrs.clear();
|
||||||
|
public_cloud = (user_template->get("EC2", attrs) > 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
user_template = 0;
|
user_template = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public_cloud = (user_template->get("PUBLIC_CLOUD", attrs) > 0);
|
if (vm_template != nullptr)
|
||||||
|
|
||||||
if (public_cloud == false)
|
|
||||||
{
|
|
||||||
attrs.clear();
|
|
||||||
public_cloud = (user_template->get("EC2", attrs) > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vm_template != 0)
|
|
||||||
{
|
{
|
||||||
init_storage_usage();
|
init_storage_usage();
|
||||||
}
|
}
|
||||||
@ -200,10 +200,7 @@ void VirtualMachineBase::init_storage_usage()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ds_usage.count(ds_id) == 0)
|
ds_usage.emplace(ds_id, 0); // no-op if element already exists
|
||||||
{
|
|
||||||
ds_usage[ds_id] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (disk->vector_value("CLONE", clone) != 0)
|
if (disk->vector_value("CLONE", clone) != 0)
|
||||||
{
|
{
|
||||||
|
@ -45,7 +45,10 @@ HostMonitorManager::HostMonitorManager(
|
|||||||
const std::string& driver_path,
|
const std::string& driver_path,
|
||||||
int timer_period,
|
int timer_period,
|
||||||
int monitor_interval_host)
|
int monitor_interval_host)
|
||||||
: hpool(hp)
|
: driver_manager(make_unique<driver_manager_t>(driver_path))
|
||||||
|
, udp_driver(make_unique<UDPMonitorDriver>(addr, port))
|
||||||
|
, tcp_driver(make_unique<TCPMonitorDriver>(addr, port))
|
||||||
|
, hpool(hp)
|
||||||
, vmpool(vmp)
|
, vmpool(vmp)
|
||||||
, threads(_threads)
|
, threads(_threads)
|
||||||
, timer_period(timer_period)
|
, timer_period(timer_period)
|
||||||
@ -53,10 +56,7 @@ HostMonitorManager::HostMonitorManager(
|
|||||||
, is_leader(false)
|
, is_leader(false)
|
||||||
{
|
{
|
||||||
oned_driver = make_unique<OneMonitorDriver>(this);
|
oned_driver = make_unique<OneMonitorDriver>(this);
|
||||||
udp_driver = make_unique<UDPMonitorDriver>(addr, port);
|
}
|
||||||
tcp_driver = make_unique<TCPMonitorDriver>(addr, port);
|
|
||||||
driver_manager = make_unique<driver_manager_t>(driver_path);
|
|
||||||
};
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
@ -284,18 +284,15 @@ void Nebula::start(bool bootstrap_only)
|
|||||||
// -----------------------------------------------------------
|
// -----------------------------------------------------------
|
||||||
const VectorAttribute * vatt = nebula_configuration->get("FEDERATION");
|
const VectorAttribute * vatt = nebula_configuration->get("FEDERATION");
|
||||||
|
|
||||||
federation_enabled = false;
|
string mode = "STANDALONE";
|
||||||
federation_master = false;
|
|
||||||
cache = false;
|
|
||||||
zone_id = 0;
|
|
||||||
server_id = -1;
|
|
||||||
master_oned = vatt->vector_value("MASTER_ONED");
|
|
||||||
string mode = vatt->vector_value("MODE");
|
|
||||||
|
|
||||||
one_util::toupper(mode);
|
|
||||||
|
|
||||||
if (vatt != 0)
|
if (vatt != 0)
|
||||||
{
|
{
|
||||||
|
master_oned = vatt->vector_value("MASTER_ONED");
|
||||||
|
mode = vatt->vector_value("MODE");
|
||||||
|
|
||||||
|
one_util::toupper(mode);
|
||||||
|
|
||||||
if (mode == "STANDALONE")
|
if (mode == "STANDALONE")
|
||||||
{
|
{
|
||||||
federation_enabled = false;
|
federation_enabled = false;
|
||||||
|
@ -175,7 +175,6 @@ void RequestManagerAllocate::request_execute(xmlrpc_c::paramList const& params,
|
|||||||
|
|
||||||
int rc, id;
|
int rc, id;
|
||||||
|
|
||||||
int cluster_id = ClusterPool::NONE_CLUSTER_ID;
|
|
||||||
string cluster_name = ClusterPool::NONE_CLUSTER_NAME;
|
string cluster_name = ClusterPool::NONE_CLUSTER_NAME;
|
||||||
PoolObjectAuth cluster_perms;
|
PoolObjectAuth cluster_perms;
|
||||||
|
|
||||||
@ -195,7 +194,7 @@ void RequestManagerAllocate::request_execute(xmlrpc_c::paramList const& params,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cluster_id = get_cluster_id(params);
|
int cluster_id = get_cluster_id(params);
|
||||||
|
|
||||||
if ( cluster_id != ClusterPool::NONE_CLUSTER_ID )
|
if ( cluster_id != ClusterPool::NONE_CLUSTER_ID )
|
||||||
{
|
{
|
||||||
|
@ -872,11 +872,12 @@ int MarketPlaceDelete::drop(std::unique_ptr<PoolObjectSQL> object, bool r, Reque
|
|||||||
|
|
||||||
{
|
{
|
||||||
unique_ptr<MarketPlace> mp(static_cast<MarketPlace *>(object.release()));
|
unique_ptr<MarketPlace> mp(static_cast<MarketPlace *>(object.release()));
|
||||||
bool can_del = mp->is_public() || apps.empty();
|
|
||||||
|
|
||||||
apps = mp->get_marketapp_ids();
|
apps = mp->get_marketapp_ids();
|
||||||
mp_id = mp->get_oid();
|
mp_id = mp->get_oid();
|
||||||
|
|
||||||
|
bool can_del = mp->is_public() || apps.empty();
|
||||||
|
|
||||||
if (!can_del)
|
if (!can_del)
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
|
@ -57,7 +57,7 @@ void GroupSetQuota::
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
group->quota.set("a_tmpl, att.resp_msg);
|
rc = group->quota.set("a_tmpl, att.resp_msg);
|
||||||
|
|
||||||
static_cast<GroupPool *>(pool)->update_quotas(group.get());
|
static_cast<GroupPool *>(pool)->update_quotas(group.get());
|
||||||
|
|
||||||
|
@ -39,30 +39,18 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
/* Re-implement DB public functions not used in scheduler */
|
/* Disable public methods not used in scheduler */
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
int start()
|
int start() = delete;
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int add_rule(long long user,
|
int add_rule(long long user,
|
||||||
long long resource,
|
long long resource,
|
||||||
long long rights,
|
long long rights,
|
||||||
std::string& error_str)
|
std::string& error_str) = delete;
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
};
|
|
||||||
|
|
||||||
int del_rule(int oid, std::string& error_str)
|
int del_rule(int oid, std::string& error_str) = delete;
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
};
|
|
||||||
|
|
||||||
int dump(std::ostringstream& oss)
|
int dump(std::ostringstream& oss) = delete;
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
};
|
|
||||||
|
|
||||||
Client * client;
|
Client * client;
|
||||||
|
|
||||||
|
@ -84,10 +84,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool test_ds_capacity(int dsid, long long vm_disk_mb)
|
bool test_ds_capacity(int dsid, long long vm_disk_mb)
|
||||||
{
|
{
|
||||||
if (ds_free_disk.count(dsid) == 0)
|
ds_free_disk.emplace(dsid, free_disk);
|
||||||
{
|
|
||||||
ds_free_disk[dsid] = free_disk;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (vm_disk_mb < ds_free_disk[dsid]);
|
return (vm_disk_mb < ds_free_disk[dsid]);
|
||||||
}
|
}
|
||||||
@ -100,10 +97,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
void add_ds_capacity(int dsid, long long vm_disk_mb)
|
void add_ds_capacity(int dsid, long long vm_disk_mb)
|
||||||
{
|
{
|
||||||
if (ds_free_disk.count(dsid) == 0)
|
ds_free_disk.emplace(dsid, free_disk);
|
||||||
{
|
|
||||||
ds_free_disk[dsid] = free_disk;
|
|
||||||
}
|
|
||||||
|
|
||||||
ds_free_disk[dsid] -= vm_disk_mb;
|
ds_free_disk[dsid] -= vm_disk_mb;
|
||||||
}
|
}
|
||||||
@ -117,19 +111,19 @@ private:
|
|||||||
friend class HostXML;
|
friend class HostXML;
|
||||||
|
|
||||||
// Host computing capacity and usage
|
// Host computing capacity and usage
|
||||||
long long mem_usage;
|
long long mem_usage = 0;
|
||||||
long long cpu_usage;
|
long long cpu_usage = 0;
|
||||||
|
|
||||||
long long max_mem;
|
long long max_mem = 0;
|
||||||
long long max_cpu;
|
long long max_cpu = 0;
|
||||||
|
|
||||||
long long running_vms;
|
long long running_vms = 0;
|
||||||
|
|
||||||
// PCI devices
|
// PCI devices
|
||||||
HostSharePCI pci;
|
HostSharePCI pci;
|
||||||
|
|
||||||
// System datastore
|
// System datastore
|
||||||
long long free_disk;
|
long long free_disk = 0;
|
||||||
std::map<int, long long> ds_free_disk;
|
std::map<int, long long> ds_free_disk;
|
||||||
|
|
||||||
//Numa Nodes
|
//Numa Nodes
|
||||||
|
@ -90,7 +90,7 @@ public:
|
|||||||
get_suitable_nodes(nodes);
|
get_suitable_nodes(nodes);
|
||||||
|
|
||||||
for (unsigned int i=0 ;
|
for (unsigned int i=0 ;
|
||||||
i < nodes.size() && ( pool_limit <= 0 || i < pool_limit ) ;
|
i < nodes.size() && ( pool_limit == 0 || i < pool_limit ) ;
|
||||||
i++)
|
i++)
|
||||||
{
|
{
|
||||||
add_object(nodes[i]);
|
add_object(nodes[i]);
|
||||||
|
@ -78,6 +78,7 @@ protected:
|
|||||||
machines_limit(0),
|
machines_limit(0),
|
||||||
dispatch_limit(0),
|
dispatch_limit(0),
|
||||||
host_dispatch_limit(0),
|
host_dispatch_limit(0),
|
||||||
|
zone_id(0),
|
||||||
mem_ds_scale(0),
|
mem_ds_scale(0),
|
||||||
diff_vnets(false)
|
diff_vnets(false)
|
||||||
{
|
{
|
||||||
|
@ -115,7 +115,7 @@ private:
|
|||||||
|
|
||||||
float weight;
|
float weight;
|
||||||
|
|
||||||
float max;
|
float max = 0;
|
||||||
} sw;
|
} sw;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ protected:
|
|||||||
|
|
||||||
oss << "/VM_POOL/VM[TEMPLATE/VMGROUP/ROLE]";
|
oss << "/VM_POOL/VM[TEMPLATE/VMGROUP/ROLE]";
|
||||||
|
|
||||||
return get_nodes(oss.str().c_str(), content);
|
return get_nodes(oss.str(), content);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif /* VM_POOL_XML_H_ */
|
#endif /* VM_POOL_XML_H_ */
|
||||||
|
@ -228,20 +228,20 @@ void VirtualMachineXML::init_attributes()
|
|||||||
user_template->from_xml_node(nodes[0]);
|
user_template->from_xml_node(nodes[0]);
|
||||||
|
|
||||||
free_nodes(nodes);
|
free_nodes(nodes);
|
||||||
|
|
||||||
|
public_cloud = (user_template->get("PUBLIC_CLOUD", attrs) > 0);
|
||||||
|
|
||||||
|
if (public_cloud == false)
|
||||||
|
{
|
||||||
|
attrs.clear();
|
||||||
|
public_cloud = (user_template->get("EC2", attrs) > 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
user_template = 0;
|
user_template = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public_cloud = (user_template->get("PUBLIC_CLOUD", attrs) > 0);
|
|
||||||
|
|
||||||
if (public_cloud == false)
|
|
||||||
{
|
|
||||||
attrs.clear();
|
|
||||||
public_cloud = (user_template->get("EC2", attrs) > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
only_public_cloud = false;
|
only_public_cloud = false;
|
||||||
|
|
||||||
if (vm_template != 0)
|
if (vm_template != 0)
|
||||||
@ -313,10 +313,7 @@ void VirtualMachineXML::init_storage_usage()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ds_usage.count(ds_id) == 0)
|
ds_usage.emplace(ds_id, 0);
|
||||||
{
|
|
||||||
ds_usage[ds_id] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (disk->vector_value("CLONE", clone) != 0)
|
if (disk->vector_value("CLONE", clone) != 0)
|
||||||
{
|
{
|
||||||
@ -455,7 +452,7 @@ bool VirtualMachineXML::test_image_datastore_capacity(
|
|||||||
{
|
{
|
||||||
ostringstream oss;
|
ostringstream oss;
|
||||||
|
|
||||||
oss << "Image Datastore " << ds->get_oid()
|
oss << "Image Datastore " << ds_it->first
|
||||||
<< " does not have enough capacity";
|
<< " does not have enough capacity";
|
||||||
|
|
||||||
error_msg = oss.str();
|
error_msg = oss.str();
|
||||||
|
@ -1331,7 +1331,7 @@ void Scheduler::dispatch()
|
|||||||
// Dispatch each VM till we reach the dispatch limit
|
// Dispatch each VM till we reach the dispatch limit
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
for (k = vm_rs.rbegin(); k != vm_rs.rend() &&
|
for (k = vm_rs.rbegin(); k != vm_rs.rend() &&
|
||||||
( dispatch_limit <= 0 || dispatched_vms < dispatch_limit ); ++k)
|
( dispatch_limit == 0 || dispatched_vms < dispatch_limit ); ++k)
|
||||||
{
|
{
|
||||||
dispatched = false;
|
dispatched = false;
|
||||||
|
|
||||||
|
@ -531,7 +531,7 @@ Attribute * Template::vector_xml_att(const xmlNode * node)
|
|||||||
attr = new VectorAttribute(
|
attr = new VectorAttribute(
|
||||||
reinterpret_cast<const char *>(node->name));
|
reinterpret_cast<const char *>(node->name));
|
||||||
|
|
||||||
for(child = child; child != 0; child = child->next)
|
for( ; child != 0; child = child->next)
|
||||||
{
|
{
|
||||||
grandchild = child->children;
|
grandchild = child->children;
|
||||||
|
|
||||||
|
@ -402,9 +402,9 @@ int UserPool::allocate(
|
|||||||
user = new User(-1, gid, uname, gname, upass, auth_driver, enabled);
|
user = new User(-1, gid, uname, gname, upass, auth_driver, enabled);
|
||||||
|
|
||||||
// Add the primary and secondary groups to the collection
|
// Add the primary and secondary groups to the collection
|
||||||
for (auto gid : gids)
|
for (auto group_id : gids)
|
||||||
{
|
{
|
||||||
user->add_group(gid);
|
user->add_group(group_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set a password for the OneGate tokens
|
// Set a password for the OneGate tokens
|
||||||
@ -419,9 +419,9 @@ int UserPool::allocate(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add the user to the main and secondary groups
|
// Add the user to the main and secondary groups
|
||||||
for (auto gid : gids)
|
for (auto group_id : gids)
|
||||||
{
|
{
|
||||||
auto group = gpool->get(gid);
|
auto group = gpool->get(group_id);
|
||||||
|
|
||||||
if (!group) //Secondary group no longer exists
|
if (!group) //Secondary group no longer exists
|
||||||
{
|
{
|
||||||
@ -443,9 +443,9 @@ int UserPool::allocate(
|
|||||||
if ( driver_managed_group_admin )
|
if ( driver_managed_group_admin )
|
||||||
{
|
{
|
||||||
// Set the user group admin
|
// Set the user group admin
|
||||||
for (auto gid : agids)
|
for (auto group_id : agids)
|
||||||
{
|
{
|
||||||
auto group = gpool->get(gid);
|
auto group = gpool->get(group_id);
|
||||||
|
|
||||||
if (!group) //Secondary group no longer exists
|
if (!group) //Secondary group no longer exists
|
||||||
{
|
{
|
||||||
@ -486,9 +486,9 @@ error_group:
|
|||||||
|
|
||||||
// Remove from all the groups, just in case the user id was added to a any
|
// Remove from all the groups, just in case the user id was added to a any
|
||||||
// of them before a non-existing group was found
|
// of them before a non-existing group was found
|
||||||
for (auto gid : gids)
|
for (auto group_id : gids)
|
||||||
{
|
{
|
||||||
if ( auto group = gpool->get(gid) )
|
if ( auto group = gpool->get(group_id) )
|
||||||
{
|
{
|
||||||
group->del_user(*oid);
|
group->del_user(*oid);
|
||||||
|
|
||||||
|
@ -534,9 +534,9 @@ int ResourceSet::add(const set<int>& groups, int zone_id, int id,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto id : del_ids)
|
for (auto del_id : del_ids)
|
||||||
{
|
{
|
||||||
this->del(groups, zone_id, id, error_aux);
|
this->del(groups, zone_id, del_id, error_aux);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2779,12 +2779,6 @@ int VirtualMachine::replace_template(
|
|||||||
auto new_tmpl =
|
auto new_tmpl =
|
||||||
make_unique<VirtualMachineTemplate>(false,'=',"USER_TEMPLATE");
|
make_unique<VirtualMachineTemplate>(false,'=',"USER_TEMPLATE");
|
||||||
|
|
||||||
if ( new_tmpl == 0 )
|
|
||||||
{
|
|
||||||
error = "Cannot allocate a new template";
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( new_tmpl->parse_str_or_xml(tmpl_str, error) != 0 )
|
if ( new_tmpl->parse_str_or_xml(tmpl_str, error) != 0 )
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
@ -2838,12 +2832,6 @@ int VirtualMachine::append_template(
|
|||||||
make_unique<VirtualMachineTemplate>(false,'=',"USER_TEMPLATE");
|
make_unique<VirtualMachineTemplate>(false,'=',"USER_TEMPLATE");
|
||||||
string rname;
|
string rname;
|
||||||
|
|
||||||
if ( new_tmpl == 0 )
|
|
||||||
{
|
|
||||||
error = "Cannot allocate a new template";
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( new_tmpl->parse_str_or_xml(tmpl_str, error) != 0 )
|
if ( new_tmpl->parse_str_or_xml(tmpl_str, error) != 0 )
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
@ -2852,31 +2840,18 @@ int VirtualMachine::append_template(
|
|||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
/* Append new_tmpl to the current user_template */
|
/* Append new_tmpl to the current user_template */
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
// Create a copy of actual user template
|
||||||
auto old_user_tmpl = make_unique<VirtualMachineTemplate>(*user_obj_template);
|
auto old_user_tmpl = make_unique<VirtualMachineTemplate>(*user_obj_template);
|
||||||
|
|
||||||
if (user_obj_template != 0)
|
if (keep_restricted &&
|
||||||
|
new_tmpl->check_restricted(rname, user_obj_template.get()))
|
||||||
{
|
{
|
||||||
if (keep_restricted &&
|
error ="User Template includes a restricted attribute " + rname;
|
||||||
new_tmpl->check_restricted(rname, user_obj_template.get()))
|
|
||||||
{
|
|
||||||
error ="User Template includes a restricted attribute " + rname;
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
user_obj_template->merge(new_tmpl.get());
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if (keep_restricted && new_tmpl->check_restricted(rname))
|
|
||||||
{
|
|
||||||
error ="User Template includes a restricted attribute " + rname;
|
|
||||||
|
|
||||||
return -1;
|
user_obj_template->merge(new_tmpl.get());
|
||||||
}
|
|
||||||
|
|
||||||
user_obj_template = move(new_tmpl);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (post_update_template(error) == -1)
|
if (post_update_template(error) == -1)
|
||||||
{
|
{
|
||||||
@ -3470,15 +3445,25 @@ int VirtualMachine::get_auto_network_leases(VirtualMachineTemplate * tmpl,
|
|||||||
|
|
||||||
VirtualMachineNic * nic = get_nic(nic_id);
|
VirtualMachineNic * nic = get_nic(nic_id);
|
||||||
|
|
||||||
|
if (!nic)
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
|
||||||
|
oss << "NIC_ID " << nic_id << " not found";
|
||||||
|
estr = oss.str();
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
net_mode = nic->vector_value("NETWORK_MODE");
|
net_mode = nic->vector_value("NETWORK_MODE");
|
||||||
|
|
||||||
string network_id = nic->vector_value("NETWORK_ID");
|
string network_id = nic->vector_value("NETWORK_ID");
|
||||||
|
|
||||||
if (nic == 0 || !one_util::icasecmp(net_mode, "AUTO") || !network_id.empty())
|
if (!one_util::icasecmp(net_mode, "AUTO") || !network_id.empty())
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
|
|
||||||
oss << "NIC_ID "<< nic_id << " not found or not AUTO";
|
oss << "NIC_ID " << nic_id << " not AUTO";
|
||||||
estr = oss.str();
|
estr = oss.str();
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -951,7 +951,7 @@ int VirtualMachine::parse_topology(Template * tmpl, std::string &error)
|
|||||||
(*it)->vector_value("TOTAL_CPUS", ncpu);
|
(*it)->vector_value("TOTAL_CPUS", ncpu);
|
||||||
(*it)->vector_value("MEMORY", nmem);
|
(*it)->vector_value("MEMORY", nmem);
|
||||||
|
|
||||||
if ( ncpu <= 0 || nmem <= 0)
|
if ( ncpu == 0 || nmem <= 0)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -970,7 +970,7 @@ int VirtualMachine::parse_topology(Template * tmpl, std::string &error)
|
|||||||
tmpl->erase("NUMA_NODE");
|
tmpl->erase("NUMA_NODE");
|
||||||
|
|
||||||
if (node_cpu != vcpu || node_mem != memory ||
|
if (node_cpu != vcpu || node_mem != memory ||
|
||||||
ncpu <= 0 || nmem <= 0)
|
ncpu == 0 || nmem <= 0)
|
||||||
{
|
{
|
||||||
for (auto it = new_nodes.begin(); it != new_nodes.end(); ++it)
|
for (auto it = new_nodes.begin(); it != new_nodes.end(); ++it)
|
||||||
{
|
{
|
||||||
@ -978,7 +978,7 @@ int VirtualMachine::parse_topology(Template * tmpl, std::string &error)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ncpu <= 0)
|
if (ncpu == 0)
|
||||||
{
|
{
|
||||||
error = "A NUMA_NODE must have TOTAL_CPUS greater than 0";
|
error = "A NUMA_NODE must have TOTAL_CPUS greater than 0";
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -707,7 +707,7 @@ int VirtualMachinePool::calculate_showback(
|
|||||||
|
|
||||||
std::string acct_str;
|
std::string acct_str;
|
||||||
|
|
||||||
rc = dump_acct(acct_str, start_time, end_time, start_index, chunk_size);
|
dump_acct(acct_str, start_time, end_time, start_index, chunk_size);
|
||||||
start_index += chunk_size;
|
start_index += chunk_size;
|
||||||
|
|
||||||
ObjectXML xml(acct_str);
|
ObjectXML xml(acct_str);
|
||||||
@ -717,7 +717,7 @@ int VirtualMachinePool::calculate_showback(
|
|||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
|
|
||||||
nodes.clear();
|
nodes.clear();
|
||||||
rc = xml.get_nodes("/HISTORY_RECORDS/HISTORY", nodes);
|
xml.get_nodes("/HISTORY_RECORDS/HISTORY", nodes);
|
||||||
|
|
||||||
for ( auto node : nodes )
|
for ( auto node : nodes )
|
||||||
{
|
{
|
||||||
@ -775,10 +775,7 @@ int VirtualMachinePool::calculate_showback(
|
|||||||
if( (et > t || et == 0) &&
|
if( (et > t || et == 0) &&
|
||||||
(st != 0 && st <= t_next) ) {
|
(st != 0 && st <= t_next) ) {
|
||||||
|
|
||||||
time_t stime = t;
|
time_t stime = max(t, st);
|
||||||
if(st != 0){
|
|
||||||
stime = max(t, st);
|
|
||||||
}
|
|
||||||
|
|
||||||
time_t etime = t_next;
|
time_t etime = t_next;
|
||||||
if(et != 0){
|
if(et != 0){
|
||||||
|
@ -31,7 +31,11 @@ using namespace std;
|
|||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
ObjectXML::ObjectXML(const std::string &xml_doc):paths(0),num_paths(0),xml(0),ctx(0)
|
ObjectXML::ObjectXML(const std::string &xml_doc)
|
||||||
|
: paths(nullptr)
|
||||||
|
, num_paths(0)
|
||||||
|
, xml(nullptr)
|
||||||
|
, ctx(nullptr)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user