mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-03 01:17:41 +03:00
parent
16e902b679
commit
daaf132a43
@ -23,8 +23,6 @@
|
||||
#include "AclRule.h"
|
||||
#include "NebulaLog.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class PoolObjectAuth;
|
||||
class SqlDB;
|
||||
|
||||
@ -80,7 +78,7 @@ public:
|
||||
* @return true if the authorization is granted by any rule
|
||||
*/
|
||||
const bool authorize(int uid,
|
||||
const set<int>& user_groups,
|
||||
const std::set<int>& user_groups,
|
||||
const PoolObjectAuth& obj_perms,
|
||||
AuthRequest::Operation op);
|
||||
|
||||
@ -113,7 +111,7 @@ public:
|
||||
long long resource,
|
||||
long long rights,
|
||||
long long zone,
|
||||
string& error_str);
|
||||
std::string& error_str);
|
||||
/**
|
||||
* Deletes a rule from the ACL rule set
|
||||
*
|
||||
@ -121,7 +119,7 @@ public:
|
||||
* @param error_str Returns the error reason, if any
|
||||
* @return 0 on success
|
||||
*/
|
||||
virtual int del_rule(int oid, string& error_str);
|
||||
virtual int del_rule(int oid, std::string& error_str);
|
||||
|
||||
/**
|
||||
* Deletes a new rule from the ACL rule set
|
||||
@ -138,7 +136,7 @@ public:
|
||||
long long resource,
|
||||
long long rights,
|
||||
long long zone,
|
||||
string& error_str);
|
||||
std::string& error_str);
|
||||
|
||||
/**
|
||||
* Deletes rules that apply to this user id
|
||||
@ -190,16 +188,16 @@ public:
|
||||
* @param cids Set of object cluster IDs over which the user can operate
|
||||
*/
|
||||
void reverse_search(int uid,
|
||||
const set<int>& user_groups,
|
||||
const std::set<int>& user_groups,
|
||||
PoolObjectSQL::ObjectType obj_type,
|
||||
AuthRequest::Operation op,
|
||||
bool disable_all_acl,
|
||||
bool disable_cluster_acl,
|
||||
bool disable_group_acl,
|
||||
bool& all,
|
||||
vector<int>& oids,
|
||||
vector<int>& gids,
|
||||
vector<int>& cids);
|
||||
std::vector<int>& oids,
|
||||
std::vector<int>& gids,
|
||||
std::vector<int>& cids);
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* DB management */
|
||||
@ -215,7 +213,7 @@ public:
|
||||
* @param oss The output stream to dump the rule set contents
|
||||
* @return 0 on success
|
||||
*/
|
||||
virtual int dump(ostringstream& oss);
|
||||
virtual int dump(std::ostringstream& oss);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Refresh loop thread
|
||||
@ -249,12 +247,12 @@ protected:
|
||||
* ACL rules. Each rule is indexed by its 'user' long long attibute,
|
||||
* several rules can apply to the same user
|
||||
*/
|
||||
multimap<long long, AclRule*> acl_rules;
|
||||
std::multimap<long long, AclRule*> acl_rules;
|
||||
|
||||
/**
|
||||
* Rules indexed by oid. Stores the same rules as acl_rules
|
||||
*/
|
||||
map<int, AclRule *> acl_rules_oids;
|
||||
std::map<int, AclRule *> acl_rules_oids;
|
||||
|
||||
private:
|
||||
|
||||
@ -276,16 +274,16 @@ private:
|
||||
* @return true if any rule grants permission
|
||||
*/
|
||||
bool match_rules(
|
||||
long long user_req,
|
||||
long long resource_oid_req,
|
||||
long long resource_gid_req,
|
||||
const set<long long>& resource_cid_req,
|
||||
long long resource_all_req,
|
||||
long long rights_req,
|
||||
long long resource_oid_mask,
|
||||
long long resource_gid_mask,
|
||||
long long resource_cid_mask,
|
||||
const multimap<long long, AclRule*>& rules);
|
||||
long long user_req,
|
||||
long long resource_oid_req,
|
||||
long long resource_gid_req,
|
||||
const std::set<long long>& resource_cid_req,
|
||||
long long resource_all_req,
|
||||
long long rights_req,
|
||||
long long resource_oid_mask,
|
||||
long long resource_gid_mask,
|
||||
long long resource_cid_mask,
|
||||
const std::multimap<long long, AclRule*>& rules);
|
||||
/**
|
||||
* Wrapper for match_rules. It will check if any rules in the temporary
|
||||
* multimap or in the internal one grants permission.
|
||||
@ -304,16 +302,16 @@ private:
|
||||
* @return true if any rule grants permission
|
||||
*/
|
||||
bool match_rules_wrapper(
|
||||
long long user_req,
|
||||
long long resource_oid_req,
|
||||
long long resource_gid_req,
|
||||
const set<long long>& resource_cid_req,
|
||||
long long resource_all_req,
|
||||
long long rights_req,
|
||||
long long individual_obj_type,
|
||||
long long group_obj_type,
|
||||
long long cluster_obj_type,
|
||||
const multimap<long long, AclRule*> &tmp_rules);
|
||||
long long user_req,
|
||||
long long resource_oid_req,
|
||||
long long resource_gid_req,
|
||||
const std::set<long long>& resource_cid_req,
|
||||
long long resource_all_req,
|
||||
long long rights_req,
|
||||
long long individual_obj_type,
|
||||
long long group_obj_type,
|
||||
long long cluster_obj_type,
|
||||
const std::multimap<long long, AclRule*> &tmp_rules);
|
||||
/**
|
||||
* Deletes all rules that match the user mask
|
||||
*
|
||||
|
@ -17,14 +17,12 @@
|
||||
#ifndef ACL_RULE_H_
|
||||
#define ACL_RULE_H_
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#include "PoolObjectSQL.h"
|
||||
#include "AuthRequest.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* An ACL Rule is composed of three 64 bit numbers: user, resource and rights.
|
||||
@ -97,7 +95,7 @@ public:
|
||||
*
|
||||
* @return a human readable string for this rule
|
||||
*/
|
||||
const string& to_str() const
|
||||
const std::string& to_str() const
|
||||
{
|
||||
return str;
|
||||
};
|
||||
@ -108,7 +106,7 @@ public:
|
||||
* @param error_str Returns the error message, if any
|
||||
* @return true if the rule is wrong
|
||||
*/
|
||||
bool malformed(string& error_str) const;
|
||||
bool malformed(std::string& error_str) const;
|
||||
|
||||
/**
|
||||
* Function to print the object into a string in XML format
|
||||
@ -116,7 +114,7 @@ public:
|
||||
* @param xml the resulting XML string
|
||||
* @return a reference to the generated string
|
||||
*/
|
||||
string& to_xml(string& xml) const;
|
||||
std::string& to_xml(std::string& xml) const;
|
||||
|
||||
/**
|
||||
* Rebuilds the rule from an xml formatted string
|
||||
@ -247,7 +245,7 @@ private:
|
||||
/**
|
||||
* Human readable representation of the rule
|
||||
*/
|
||||
string str;
|
||||
std::string str;
|
||||
|
||||
/**
|
||||
* Builds the human representation of the ACL
|
||||
|
@ -24,8 +24,6 @@
|
||||
#include "PoolObjectSQL.h"
|
||||
#include "AddressRangePool.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class VectorAttribute;
|
||||
|
||||
/**
|
||||
@ -70,14 +68,14 @@ public:
|
||||
* @param ob the type
|
||||
* @return the string
|
||||
*/
|
||||
static string type_to_str(AddressType ob);
|
||||
static std::string type_to_str(AddressType ob);
|
||||
|
||||
/**
|
||||
* Return the string representation of an AddressType
|
||||
* @param ob the type
|
||||
* @return the string
|
||||
*/
|
||||
static AddressType str_to_type(string& str_type);
|
||||
static AddressType str_to_type(std::string& str_type);
|
||||
|
||||
/**
|
||||
* Return true if the address range includes IPv4 addresses
|
||||
@ -148,7 +146,7 @@ public:
|
||||
* implementation may contact an external IPAM to complete or validate
|
||||
* the AR allocation request.
|
||||
*/
|
||||
virtual int from_vattr(VectorAttribute * attr, string& error_msg) = 0;
|
||||
virtual int from_vattr(VectorAttribute * attr, std::string& error_msg) = 0;
|
||||
|
||||
/**
|
||||
* Builds an Address Range from a vector attribute stored in the DB
|
||||
@ -167,13 +165,13 @@ public:
|
||||
* @param vrs list of VRouter the user can access VNET usage info from.
|
||||
* A vector containing just -1 means all VRouters.
|
||||
*/
|
||||
void to_xml(ostringstream &oss, const vector<int>& vms,
|
||||
const vector<int>& vnets, const vector<int>& vrs) const;
|
||||
void to_xml(std::ostringstream &oss, const std::vector<int>& vms,
|
||||
const std::vector<int>& vnets, const std::vector<int>& vrs) const;
|
||||
|
||||
/**
|
||||
* Same as above but without the LEASES section
|
||||
*/
|
||||
void to_xml(ostringstream &oss) const;
|
||||
void to_xml(std::ostringstream &oss) const;
|
||||
|
||||
|
||||
// *************************************************************************
|
||||
@ -190,7 +188,7 @@ public:
|
||||
* @return 0 if success
|
||||
*/
|
||||
int allocate_addr(PoolObjectSQL::ObjectType ot, int obid,
|
||||
VectorAttribute * nic, const vector<string> &inherit);
|
||||
VectorAttribute * nic, const std::vector<std::string> &inherit);
|
||||
|
||||
/**
|
||||
* Returns the specific address by mac/ip if is not allocated. The NIC attr
|
||||
@ -202,25 +200,25 @@ public:
|
||||
* @param inherit attributes to be added to the NIC attribute
|
||||
* @return 0 if success
|
||||
*/
|
||||
int allocate_by_mac(const string& mac, PoolObjectSQL::ObjectType ot,
|
||||
int obid, VectorAttribute * nic, const vector<string> &inherit);
|
||||
int allocate_by_mac(const std::string& mac, PoolObjectSQL::ObjectType ot,
|
||||
int obid, VectorAttribute * nic, const std::vector<std::string> &inherit);
|
||||
|
||||
int allocate_by_ip(const string& ip, PoolObjectSQL::ObjectType ot,
|
||||
int obid, VectorAttribute * nic, const vector<string> &inherit);
|
||||
int allocate_by_ip(const std::string& ip, PoolObjectSQL::ObjectType ot,
|
||||
int obid, VectorAttribute * nic, const std::vector<std::string> &inherit);
|
||||
|
||||
int allocate_by_ip6(const string& ip6, PoolObjectSQL::ObjectType ot,
|
||||
int obid, VectorAttribute * nic, const vector<string> &inherit);
|
||||
int allocate_by_ip6(const std::string& ip6, PoolObjectSQL::ObjectType ot,
|
||||
int obid, VectorAttribute * nic, const std::vector<std::string> &inherit);
|
||||
|
||||
/**
|
||||
* Sets the given ip/mac on hold, the address is associated to a VM of
|
||||
* id -1.
|
||||
* @param ip/mac the ip to hold
|
||||
*/
|
||||
int hold_by_mac(const string& mac);
|
||||
int hold_by_mac(const std::string& mac);
|
||||
|
||||
int hold_by_ip(const string& ip);
|
||||
int hold_by_ip(const std::string& ip);
|
||||
|
||||
int hold_by_ip6(const string& ip);
|
||||
int hold_by_ip6(const std::string& ip);
|
||||
|
||||
/**
|
||||
* Frees a previous allocated address, referenced by its MAC/IP address
|
||||
@ -229,11 +227,11 @@ public:
|
||||
* @param mac/ip the MAC/IP address in string form
|
||||
* @return 0 if the address was freed
|
||||
*/
|
||||
int free_addr(PoolObjectSQL::ObjectType ot, int obid, const string& mac);
|
||||
int free_addr(PoolObjectSQL::ObjectType ot, int obid, const std::string& mac);
|
||||
|
||||
int free_addr_by_ip(PoolObjectSQL::ObjectType ot, int id, const string& ip);
|
||||
int free_addr_by_ip(PoolObjectSQL::ObjectType ot, int id, const std::string& ip);
|
||||
|
||||
int free_addr_by_ip6(PoolObjectSQL::ObjectType ot, int id,const string& ip);
|
||||
int free_addr_by_ip6(PoolObjectSQL::ObjectType ot, int id,const std::string& ip);
|
||||
|
||||
/**
|
||||
* Frees all previous allocated address to the given object
|
||||
@ -253,7 +251,7 @@ public:
|
||||
* @return the number of addresses freed
|
||||
*/
|
||||
int free_addr_by_range(PoolObjectSQL::ObjectType ot, int obid,
|
||||
const string& mac, unsigned int rsize);
|
||||
const std::string& mac, unsigned int rsize);
|
||||
|
||||
/**
|
||||
* Adds the relevant AR definition attributes to the Security Group rule
|
||||
@ -283,13 +281,13 @@ public:
|
||||
* @param ip/mac the firs ip in the Reservation
|
||||
* @return 0 on success
|
||||
*/
|
||||
int reserve_addr_by_mac(int vid, unsigned int rsize, const string& mac,
|
||||
int reserve_addr_by_mac(int vid, unsigned int rsize, const std::string& mac,
|
||||
AddressRange *rar);
|
||||
|
||||
int reserve_addr_by_ip(int vid, unsigned int rsize, const string& ip,
|
||||
int reserve_addr_by_ip(int vid, unsigned int rsize, const std::string& ip,
|
||||
AddressRange *rar);
|
||||
|
||||
int reserve_addr_by_ip6(int vid, unsigned int rsize, const string& ip,
|
||||
int reserve_addr_by_ip6(int vid, unsigned int rsize, const std::string& ip,
|
||||
AddressRange *rar);
|
||||
|
||||
// *************************************************************************
|
||||
@ -333,7 +331,7 @@ public:
|
||||
* @param name of the attribute
|
||||
* @return the value of the attribute if found, empty otherwise
|
||||
*/
|
||||
string get_attribute(const string& name) const
|
||||
std::string get_attribute(const std::string& name) const
|
||||
{
|
||||
return attr->vector_value(name);
|
||||
}
|
||||
@ -344,7 +342,7 @@ public:
|
||||
* @param value of the attribute
|
||||
* @return 0 on success
|
||||
*/
|
||||
int get_attribute(const string& name, int& value) const
|
||||
int get_attribute(const std::string& name, int& value) const
|
||||
{
|
||||
return attr->vector_value(name, value);
|
||||
}
|
||||
@ -361,18 +359,18 @@ public:
|
||||
int update_attributes(
|
||||
VectorAttribute * vup,
|
||||
bool keep_restricted,
|
||||
string& error_msg);
|
||||
std::string& error_msg);
|
||||
|
||||
/**
|
||||
* Helper function to initialize restricte attributes of an AddressRange
|
||||
*/
|
||||
static void set_restricted_attributes(vector<const SingleAttribute *>& ras);
|
||||
static void set_restricted_attributes(std::vector<const SingleAttribute *>& ras);
|
||||
|
||||
/**
|
||||
* Get the security groups for this AR.
|
||||
* @return a reference to the security group set
|
||||
*/
|
||||
const set<int>& get_security_groups() const
|
||||
const std::set<int>& get_security_groups() const
|
||||
{
|
||||
return security_groups;
|
||||
}
|
||||
@ -380,13 +378,11 @@ public:
|
||||
/**
|
||||
* Copy security groups into set
|
||||
*/
|
||||
void get_security_groups(set<int>& sgs)
|
||||
void get_security_groups(std::set<int>& sgs)
|
||||
{
|
||||
std::set<int>::const_iterator it;
|
||||
|
||||
for (it = security_groups.begin(); it != security_groups.end(); ++it)
|
||||
for (auto sg : security_groups)
|
||||
{
|
||||
sgs.insert(*it);
|
||||
sgs.insert(sg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -405,13 +401,14 @@ public:
|
||||
* rm_ar from AddressRangePool needs to access the internal representation
|
||||
* of the AR to remove it from the ARPool template.
|
||||
*/
|
||||
friend int AddressRangePool::rm_ar(unsigned int ar_id, bool force, string& error_msg);
|
||||
friend int AddressRangePool::rm_ar(unsigned int ar_id, bool force,
|
||||
std::string& error_msg);
|
||||
|
||||
/*
|
||||
* rm_ars from AddressRangePool needs to access the internal representation
|
||||
* of the AR to remove it from the ARPool template.
|
||||
*/
|
||||
friend int AddressRangePool::rm_ars(string& error_msg);
|
||||
friend int AddressRangePool::rm_ars(std::string& error_msg);
|
||||
|
||||
protected:
|
||||
/**
|
||||
@ -426,7 +423,7 @@ protected:
|
||||
/**
|
||||
* Builds the AddressRange from its vector attribute representation
|
||||
*/
|
||||
int from_attr(VectorAttribute * attr, string& error_msg);
|
||||
int from_attr(VectorAttribute * attr, std::string& error_msg);
|
||||
|
||||
/**
|
||||
* Builds an address request representation in XML form:
|
||||
@ -443,7 +440,7 @@ protected:
|
||||
* @param oss string stream to write the request to
|
||||
*/
|
||||
void addr_to_xml(unsigned int index, unsigned int size,
|
||||
ostringstream& oss) const;
|
||||
std::ostringstream& oss) const;
|
||||
|
||||
/**
|
||||
* Check if the given MAC is valid for this address range by verifying:
|
||||
@ -456,7 +453,8 @@ protected:
|
||||
*
|
||||
* @return true if the MAC is valid
|
||||
*/
|
||||
bool is_valid_mac(unsigned int& index, const string& mac_s, bool check_free);
|
||||
bool is_valid_mac(unsigned int& index, const std::string& mac_s,
|
||||
bool check_free);
|
||||
|
||||
/**
|
||||
* Check if the given IP is valid for this address range by verifying:
|
||||
@ -470,7 +468,8 @@ protected:
|
||||
*
|
||||
* @return true if the IP is valid
|
||||
*/
|
||||
bool is_valid_ip(unsigned int& index, const string& ip_s, bool check_free);
|
||||
bool is_valid_ip(unsigned int& index, const std::string& ip_s,
|
||||
bool check_free);
|
||||
|
||||
/**
|
||||
* Check if the given IP is valid for this address range by verifying:
|
||||
@ -484,7 +483,8 @@ protected:
|
||||
*
|
||||
* @return true if the IP is valid
|
||||
*/
|
||||
bool is_valid_ip6(unsigned int& index, const string& ip_s, bool check_free);
|
||||
bool is_valid_ip6(unsigned int& index, const std::string& ip_s,
|
||||
bool check_free);
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Implementation specific address management interface */
|
||||
@ -497,7 +497,8 @@ protected:
|
||||
*
|
||||
* @return 0 if success
|
||||
*/
|
||||
virtual int allocate_addr(unsigned int ix, unsigned int sz, string& mg) = 0;
|
||||
virtual int allocate_addr(unsigned int ix, unsigned int sz,
|
||||
std::string& mg) = 0;
|
||||
/**
|
||||
* Gets a range of free addresses
|
||||
* @param index the first address in the range
|
||||
@ -506,7 +507,8 @@ protected:
|
||||
*
|
||||
* @return 0 if success
|
||||
*/
|
||||
virtual int get_addr(unsigned int& index, unsigned int sz, string& msg) = 0;
|
||||
virtual int get_addr(unsigned int& index, unsigned int sz,
|
||||
std::string& msg) = 0;
|
||||
|
||||
/**
|
||||
* Sets the given address (by index) as free
|
||||
@ -515,7 +517,7 @@ protected:
|
||||
*
|
||||
* @return 0 if success
|
||||
*/
|
||||
virtual int free_addr(unsigned int index, string& msg) = 0;
|
||||
virtual int free_addr(unsigned int index, std::string& msg) = 0;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Allocated addresses */
|
||||
@ -531,7 +533,7 @@ protected:
|
||||
*
|
||||
* Address = First Address + index
|
||||
*/
|
||||
map<unsigned int, long long> allocated;
|
||||
std::map<unsigned int, long long> allocated;
|
||||
|
||||
private:
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -542,27 +544,27 @@ private:
|
||||
* @param mac in string form 00:02:01:02:03:04
|
||||
* @return 0 on success
|
||||
*/
|
||||
int mac_to_i(string mac, unsigned int i_mac[]) const;
|
||||
int mac_to_i(std::string mac, unsigned int i_mac[]) const;
|
||||
|
||||
/**
|
||||
* MAC to string
|
||||
* @param mac in array form
|
||||
*/
|
||||
string mac_to_s(const unsigned int mac[]) const;
|
||||
std::string mac_to_s(const unsigned int mac[]) const;
|
||||
|
||||
/**
|
||||
* IP version 4 to binary (32 bits)
|
||||
* @param ip in string form 192.168.0.2
|
||||
* @return 0 on success
|
||||
*/
|
||||
int ip_to_i(const string& _ip, unsigned int& i_ip) const;
|
||||
int ip_to_i(const std::string& _ip, unsigned int& i_ip) const;
|
||||
|
||||
/**
|
||||
* IP version 6 to binary (32 bits)
|
||||
* @param ip string form 2a00:1bc0:b001:A::3
|
||||
* @return 0 on success
|
||||
*/
|
||||
int ip6_to_i(const string& _ip, unsigned int i_ip[]) const;
|
||||
int ip6_to_i(const std::string& _ip, unsigned int i_ip[]) const;
|
||||
|
||||
/**
|
||||
* IP version 4 to dot notation
|
||||
@ -570,14 +572,14 @@ private:
|
||||
* @param i_ip Numeric (32 bits) IP
|
||||
* @return dot notation
|
||||
*/
|
||||
string ip_to_s(unsigned int i_ip) const;
|
||||
std::string ip_to_s(unsigned int i_ip) const;
|
||||
|
||||
/**
|
||||
* IPv6 64bits prefix conversion
|
||||
* @param prefix in string form 2a00:1bc0:b001:A::
|
||||
* @return 0 on success
|
||||
*/
|
||||
int prefix6_to_i(const string& prefix, unsigned int ip[]) const;
|
||||
int prefix6_to_i(const std::string& prefix, unsigned int ip[]) const;
|
||||
|
||||
/**
|
||||
* IPv6 to string
|
||||
@ -587,9 +589,9 @@ private:
|
||||
* @return 0 on success
|
||||
*/
|
||||
int ip6_to_s(const unsigned int prefix[], const unsigned int mac[],
|
||||
string& ip6_s) const;
|
||||
std::string& ip6_s) const;
|
||||
|
||||
int ip6_to_s(const unsigned int ip6_i[], string& ip6_s) const;
|
||||
int ip6_to_s(const unsigned int ip6_i[], std::string& ip6_s) const;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* NIC setup functions */
|
||||
@ -629,7 +631,8 @@ private:
|
||||
* @param addr_index internal index for the lease
|
||||
* @param nic attribute of a VMTemplate
|
||||
*/
|
||||
void set_vnet(VectorAttribute *nic, const vector<string> &inherit) const;
|
||||
void set_vnet(VectorAttribute *nic,
|
||||
const std::vector<std::string> &inherit) const;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Address index map helper functions */
|
||||
@ -647,7 +650,7 @@ private:
|
||||
* generated by allocated_to_attr()
|
||||
* @return 0 on success
|
||||
*/
|
||||
int attr_to_allocated(const string& allocated_s);
|
||||
int attr_to_allocated(const std::string& allocated_s);
|
||||
|
||||
/**
|
||||
* Adds a new allocated address to the map. Updates the ALLOCATED attribute
|
||||
@ -666,10 +669,10 @@ private:
|
||||
* @return 0 if success
|
||||
*/
|
||||
void allocate_by_index(unsigned int index,
|
||||
PoolObjectSQL::ObjectType ot,
|
||||
int obid,
|
||||
VectorAttribute* nic,
|
||||
const vector<string>& inherit);
|
||||
PoolObjectSQL::ObjectType ot,
|
||||
int obid,
|
||||
VectorAttribute* nic,
|
||||
const std::vector<std::string>& inherit);
|
||||
|
||||
/**
|
||||
* Frees an address from the map. Updates the ALLOCATED attribute
|
||||
@ -696,7 +699,7 @@ private:
|
||||
* @param error_msg if any
|
||||
* @return 0 on success
|
||||
*/
|
||||
int init_ipv4(string& error_msg);
|
||||
int init_ipv4(std::string& error_msg);
|
||||
|
||||
/**
|
||||
* Function to parse the IPv6 attributes ("GLOBAL_PREFIX" and "ULA_PREFIX")
|
||||
@ -704,7 +707,7 @@ private:
|
||||
* @param error_msg if any
|
||||
* @return 0 on success
|
||||
*/
|
||||
int init_ipv6(string& error_msg);
|
||||
int init_ipv6(std::string& error_msg);
|
||||
|
||||
/**
|
||||
* Function to parse the IPv6 attributes no slaac ("IP6") for IP6_STATIC
|
||||
@ -712,19 +715,19 @@ private:
|
||||
* @param error_msg if any
|
||||
* @return 0 on success
|
||||
*/
|
||||
int init_ipv6_static(string& error_msg);
|
||||
int init_ipv6_static(std::string& error_msg);
|
||||
|
||||
/**
|
||||
* Function to parse the MAC attributes ("MAC") for all AR types
|
||||
* @param error_msg if any
|
||||
* @return 0 on success
|
||||
*/
|
||||
int init_mac(string& error_msg);
|
||||
int init_mac(std::string& error_msg);
|
||||
|
||||
/**
|
||||
* Checks for restricted attributes, returns the first one found
|
||||
*/
|
||||
bool check(string& rs_attr) const;
|
||||
bool check(std::string& rs_attr) const;
|
||||
|
||||
/**
|
||||
* Deletes all restricted attributes
|
||||
@ -782,7 +785,7 @@ private:
|
||||
/**
|
||||
* Security Group IDs for this Address Range
|
||||
*/
|
||||
set<int> security_groups;
|
||||
std::set<int> security_groups;
|
||||
|
||||
/**
|
||||
* The Address Range attributes as a Template VectorAttribute. This is
|
||||
@ -801,7 +804,7 @@ private:
|
||||
/**
|
||||
* The restricted attributes from oned.conf
|
||||
*/
|
||||
static set<string> restricted_attributes;
|
||||
static std::set<std::string> restricted_attributes;
|
||||
|
||||
/**
|
||||
* Attributes to be process for Security Group rules
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include <string>
|
||||
|
||||
#include "AddressRange.h"
|
||||
#include "AddressRangePool.h"
|
||||
|
||||
class VectorAttribute;
|
||||
|
||||
@ -50,7 +49,8 @@ public:
|
||||
*
|
||||
* @return 0 if success
|
||||
*/
|
||||
int allocate_addr(unsigned int index, unsigned int rsize, string& error_msg);
|
||||
int allocate_addr(unsigned int index, unsigned int rsize,
|
||||
std::string& error_msg);
|
||||
|
||||
/**
|
||||
* Gets a range of free addresses
|
||||
@ -60,7 +60,8 @@ public:
|
||||
*
|
||||
* @return 0 if success
|
||||
*/
|
||||
int get_addr(unsigned int& index, unsigned int rsize, string& error_msg);
|
||||
int get_addr(unsigned int& index, unsigned int rsize,
|
||||
std::string& error_msg);
|
||||
|
||||
/**
|
||||
* Sets the given address (by index) as free
|
||||
@ -69,7 +70,7 @@ public:
|
||||
*
|
||||
* @return 0 if success
|
||||
*/
|
||||
int free_addr(unsigned int index, string& msg);
|
||||
int free_addr(unsigned int index, std::string& msg);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include <string>
|
||||
|
||||
#include "AddressRange.h"
|
||||
#include "AddressRangePool.h"
|
||||
|
||||
class VectorAttribute;
|
||||
|
||||
@ -53,7 +52,8 @@ public:
|
||||
*
|
||||
* @return 0 if success
|
||||
*/
|
||||
int allocate_addr(unsigned int index, unsigned int rsize, string& error_msg)
|
||||
int allocate_addr(unsigned int index, unsigned int rsize,
|
||||
std::string& error_msg)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -66,7 +66,8 @@ public:
|
||||
*
|
||||
* @return 0 if success
|
||||
*/
|
||||
int get_addr(unsigned int& index, unsigned int rsize, string& error_msg)
|
||||
int get_addr(unsigned int& index, unsigned int rsize,
|
||||
std::string& error_msg)
|
||||
{
|
||||
if ( rsize == 1 )
|
||||
{
|
||||
@ -83,7 +84,7 @@ public:
|
||||
*
|
||||
* @return 0 if success
|
||||
*/
|
||||
int free_addr(unsigned int index, string& msg)
|
||||
int free_addr(unsigned int index, std::string& msg)
|
||||
{
|
||||
return 0;
|
||||
};
|
||||
|
@ -22,15 +22,12 @@
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
#include <libxml/parser.h>
|
||||
|
||||
#include "VirtualNetworkTemplate.h"
|
||||
#include "PoolObjectSQL.h"
|
||||
|
||||
class VectorAttribute;
|
||||
class AddressRange;
|
||||
|
||||
using namespace std;
|
||||
|
||||
class AddressRangePool
|
||||
{
|
||||
@ -50,7 +47,7 @@ public:
|
||||
* @param error_msg describing the error
|
||||
* @return 0 on success
|
||||
*/
|
||||
int from_vattr(VectorAttribute * ar, string& error_msg);
|
||||
int from_vattr(VectorAttribute * ar, std::string& error_msg);
|
||||
|
||||
/**
|
||||
* Builds the address range set from its XML representation. This function
|
||||
@ -71,14 +68,14 @@ public:
|
||||
* @param force force remove, even if active leases exists
|
||||
* @return 0 on success, -1 if not exists or has used addresses
|
||||
*/
|
||||
int rm_ar(unsigned int ar_id, bool force, string& error_msg);
|
||||
int rm_ar(unsigned int ar_id, bool force, std::string& error_msg);
|
||||
|
||||
/**
|
||||
* Removes all address ranges from the pool if it does not contain any used
|
||||
* leases
|
||||
* @return 0 on success, -1 if not exists or has used addresses
|
||||
*/
|
||||
int rm_ars(string& error_msg);
|
||||
int rm_ars(std::string& error_msg);
|
||||
|
||||
/**
|
||||
* Updates the given address ranges
|
||||
@ -90,8 +87,8 @@ public:
|
||||
* the reason.
|
||||
* @return 0 on success
|
||||
*/
|
||||
int update_ar(vector<VectorAttribute *> ars, bool keep_restricted,
|
||||
string& error_msg);
|
||||
int update_ar(std::vector<VectorAttribute *> ars, bool keep_restricted,
|
||||
std::string& error_msg);
|
||||
/**
|
||||
* Allocates a new *empty* address range. It is not added to the pool as it
|
||||
* needs to be initialized. Only the AR_ID is set.
|
||||
@ -99,7 +96,7 @@ public:
|
||||
* IPAM...
|
||||
* @return the new address range.
|
||||
*/
|
||||
AddressRange * allocate_ar(const string& ipam_mad);
|
||||
AddressRange * allocate_ar(const std::string& ipam_mad);
|
||||
|
||||
/**
|
||||
* Adds a new address range to the pool. It should be allocated by the
|
||||
@ -122,7 +119,7 @@ public:
|
||||
* @return 0 if success
|
||||
*/
|
||||
int allocate_addr(PoolObjectSQL::ObjectType ot, int obid,
|
||||
VectorAttribute * nic, const vector<string> &inherit);
|
||||
VectorAttribute * nic, const std::vector<std::string> &inherit);
|
||||
|
||||
/**
|
||||
* Allocates an address in a suitable address range from the pool by mac/ip
|
||||
@ -133,14 +130,17 @@ public:
|
||||
* @param inherit attributes to be added to the NIC
|
||||
* @return 0 if success
|
||||
*/
|
||||
int allocate_by_mac(const string &mac, PoolObjectSQL::ObjectType ot, int obid,
|
||||
VectorAttribute * nic, const vector<string> &inherit);
|
||||
int allocate_by_mac(const std::string &mac, PoolObjectSQL::ObjectType ot,
|
||||
int obid, VectorAttribute * nic,
|
||||
const std::vector<std::string> &inherit);
|
||||
|
||||
int allocate_by_ip(const string &ip, PoolObjectSQL::ObjectType ot, int obid,
|
||||
VectorAttribute * nic, const vector<string> &inherit);
|
||||
int allocate_by_ip(const std::string &ip, PoolObjectSQL::ObjectType ot,
|
||||
int obid, VectorAttribute * nic,
|
||||
const std::vector<std::string> &inherit);
|
||||
|
||||
int allocate_by_ip6(const string &ip, PoolObjectSQL::ObjectType ot, int obid,
|
||||
VectorAttribute * nic, const vector<string> &inherit);
|
||||
int allocate_by_ip6(const std::string &ip, PoolObjectSQL::ObjectType ot,
|
||||
int obid, VectorAttribute * nic,
|
||||
const std::vector<std::string> &inherit);
|
||||
|
||||
/**
|
||||
* Holds an address from the specified address range.
|
||||
@ -148,22 +148,22 @@ public:
|
||||
* @param mac/ip the mac/ip to hold
|
||||
* @return 0 on success
|
||||
*/
|
||||
int hold_by_mac(unsigned int arid, const string& mac);
|
||||
int hold_by_mac(unsigned int arid, const std::string& mac);
|
||||
|
||||
int hold_by_ip(unsigned int arid, const string& ip);
|
||||
int hold_by_ip(unsigned int arid, const std::string& ip);
|
||||
|
||||
int hold_by_ip6(unsigned int arid, const string& ip);
|
||||
int hold_by_ip6(unsigned int arid, const std::string& ip);
|
||||
|
||||
/**
|
||||
* Holds an address from the first address range containing the MAC
|
||||
* @param mac/ip the mac/ip to hold
|
||||
* @return 0 on success
|
||||
*/
|
||||
int hold_by_mac(const string& mac);
|
||||
int hold_by_mac(const std::string& mac);
|
||||
|
||||
int hold_by_ip(const string& ip);
|
||||
int hold_by_ip(const std::string& ip);
|
||||
|
||||
int hold_by_ip6(const string& ip);
|
||||
int hold_by_ip6(const std::string& ip);
|
||||
|
||||
/**
|
||||
* Frees the given address by MAC/IP on the given address range
|
||||
@ -173,13 +173,13 @@ public:
|
||||
* @param mac/ip the specific MAC/IP address requested
|
||||
*/
|
||||
void free_addr(unsigned int arid, PoolObjectSQL::ObjectType ot, int obid,
|
||||
const string& mac);
|
||||
const std::string& mac);
|
||||
|
||||
void free_addr_by_ip(unsigned int arid, PoolObjectSQL::ObjectType ot,
|
||||
int obid, const string& ip);
|
||||
int obid, const std::string& ip);
|
||||
|
||||
void free_addr_by_ip6(unsigned int arid, PoolObjectSQL::ObjectType ot,
|
||||
int obid, const string& ip);
|
||||
int obid, const std::string& ip);
|
||||
|
||||
/**
|
||||
* Frees the given address by MAC/IP from all address ranges containing
|
||||
@ -188,11 +188,14 @@ public:
|
||||
* @param obid the id of the object requesting the address
|
||||
* @param mac/ip the specific MAC/IP address requested
|
||||
*/
|
||||
void free_addr(PoolObjectSQL::ObjectType ot, int obid, const string& mac);
|
||||
void free_addr(PoolObjectSQL::ObjectType ot, int obid,
|
||||
const std::string& mac);
|
||||
|
||||
void free_addr_by_ip(PoolObjectSQL::ObjectType ot, int id, const string& ip);
|
||||
void free_addr_by_ip(PoolObjectSQL::ObjectType ot, int id,
|
||||
const std::string& ip);
|
||||
|
||||
void free_addr_by_ip6(PoolObjectSQL::ObjectType ot, int id,const string& ip);
|
||||
void free_addr_by_ip6(PoolObjectSQL::ObjectType ot, int id,
|
||||
const std::string& ip);
|
||||
|
||||
/**
|
||||
* Frees all the addressed owned by the given object
|
||||
@ -211,7 +214,7 @@ public:
|
||||
* @param rsize size of the address range
|
||||
*/
|
||||
int free_addr_by_range(unsigned int arid, PoolObjectSQL::ObjectType ot,
|
||||
int obid, const string& mac, unsigned int rsize);
|
||||
int obid, const std::string& mac, unsigned int rsize);
|
||||
|
||||
/**
|
||||
* From a Security Group rule that uses this vnet, creates a new rule
|
||||
@ -222,8 +225,8 @@ public:
|
||||
* be deleted by the caller
|
||||
*/
|
||||
void process_security_rule(
|
||||
VectorAttribute * rule,
|
||||
vector<VectorAttribute*> &new_rules);
|
||||
VectorAttribute * rule,
|
||||
std::vector<VectorAttribute*> &new_rules);
|
||||
|
||||
// *************************************************************************
|
||||
// Address reservation
|
||||
@ -260,13 +263,13 @@ public:
|
||||
* @return 0 on success
|
||||
*/
|
||||
int reserve_addr_by_mac(int vid, unsigned int rsize, unsigned int ar_id,
|
||||
const string& mac, AddressRange *rar);
|
||||
const std::string& mac, AddressRange *rar);
|
||||
|
||||
int reserve_addr_by_ip(int vid, unsigned int rsize, unsigned int ar_id,
|
||||
const string& ip, AddressRange *rar);
|
||||
const std::string& ip, AddressRange *rar);
|
||||
|
||||
int reserve_addr_by_ip6(int vid, unsigned int rsize, unsigned int ar_id,
|
||||
const string& ip, AddressRange *rar);
|
||||
const std::string& ip, AddressRange *rar);
|
||||
|
||||
|
||||
// *************************************************************************
|
||||
@ -299,7 +302,7 @@ public:
|
||||
* @param value of the attribute
|
||||
* @param ar_id to get the attribute from
|
||||
*/
|
||||
void get_attribute(const string& name, string& value, int ar_id) const;
|
||||
void get_attribute(const std::string& name, std::string& value, int ar_id) const;
|
||||
|
||||
/**
|
||||
* Gets an attribute from the Address Range, int version
|
||||
@ -308,19 +311,19 @@ public:
|
||||
* @param ar_id to get the attribute from
|
||||
* @return 0 on success
|
||||
*/
|
||||
int get_attribute(const string& name, int& value, int ar_id) const;
|
||||
int get_attribute(const std::string& name, int& value, int ar_id) const;
|
||||
|
||||
/**
|
||||
* Gets a reference to a the security group set of an AR
|
||||
* @return a reference to the security group set or empty set if error
|
||||
*/
|
||||
const set<int>& get_security_groups(int ar_id) const;
|
||||
const std::set<int>& get_security_groups(int ar_id) const;
|
||||
|
||||
/**
|
||||
* Gets a the security group set of all ARs
|
||||
* @param sgs set with all the SG ids
|
||||
*/
|
||||
void get_all_security_groups(set<int>& sgs);
|
||||
void get_all_security_groups(std::set<int>& sgs);
|
||||
|
||||
/**
|
||||
* Generate a XML representation of the Address Range Pool
|
||||
@ -334,8 +337,11 @@ public:
|
||||
* A vector containing just -1 means all VRouters.
|
||||
* @return the string with the XML
|
||||
*/
|
||||
string& to_xml(string& sstream, bool extended, const vector<int>& vms,
|
||||
const vector<int>& vnets, const vector<int>& vrs) const;
|
||||
std::string& to_xml(std::string& sstream,
|
||||
bool extended,
|
||||
const std::vector<int>& vms,
|
||||
const std::vector<int>& vnets,
|
||||
const std::vector<int>& vrs) const;
|
||||
|
||||
/**
|
||||
* Encrypt all secret attributes
|
||||
@ -368,7 +374,7 @@ private:
|
||||
/**
|
||||
* Map to access each range
|
||||
*/
|
||||
map<unsigned int, AddressRange *> ar_pool;
|
||||
std::map<unsigned int, AddressRange *> ar_pool;
|
||||
|
||||
/**
|
||||
* Used addresses
|
||||
@ -383,7 +389,7 @@ private:
|
||||
* @param ar_id for the AddressRange
|
||||
* @return the new address range.
|
||||
*/
|
||||
AddressRange * allocate_ar(const string& ipam_mad, unsigned int ar_id);
|
||||
AddressRange * allocate_ar(const std::string& ipam_mad, unsigned int ar_id);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -24,8 +24,6 @@
|
||||
|
||||
#include "NebulaUtil.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* Attribute base class for name-value pairs. This class provides a generic
|
||||
* interface to implement
|
||||
@ -34,7 +32,7 @@ class Attribute
|
||||
{
|
||||
public:
|
||||
|
||||
Attribute(const string& aname):attribute_name(aname)
|
||||
Attribute(const std::string& aname):attribute_name(aname)
|
||||
{
|
||||
transform (
|
||||
attribute_name.begin(),
|
||||
@ -66,7 +64,7 @@ public:
|
||||
* Gets the name of the attribute.
|
||||
* @return the attribute name
|
||||
*/
|
||||
const string& name() const
|
||||
const std::string& name() const
|
||||
{
|
||||
return attribute_name;
|
||||
};
|
||||
@ -76,7 +74,7 @@ public:
|
||||
* by the calling function.
|
||||
* @return a string (allocated in the heap) holding the attribute value.
|
||||
*/
|
||||
virtual string * marshall(const char * _sep = 0) const = 0;
|
||||
virtual std::string * marshall(const char * _sep = 0) const = 0;
|
||||
|
||||
/**
|
||||
* Write the attribute using a simple XML format. The string MUST be freed
|
||||
@ -92,7 +90,7 @@ public:
|
||||
/**
|
||||
* Builds a new attribute from a string.
|
||||
*/
|
||||
virtual void unmarshall(const string& sattr, const char * _sep = 0) = 0;
|
||||
virtual void unmarshall(const std::string& sattr, const char * _sep = 0) = 0;
|
||||
|
||||
/**
|
||||
* Returns the attribute type
|
||||
@ -107,19 +105,19 @@ public:
|
||||
/**
|
||||
* Encrypt all secret attributes
|
||||
*/
|
||||
virtual void encrypt(const string& one_key, const set<string>& eas) {};
|
||||
virtual void encrypt(const std::string& one_key, const std::set<std::string>& eas) {};
|
||||
|
||||
/**
|
||||
* Decrypt all secret attributes
|
||||
*/
|
||||
virtual void decrypt(const string& one_key, const set<string>& eas) {};
|
||||
virtual void decrypt(const std::string& one_key, const std::set<std::string>& eas) {};
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* The attribute name.
|
||||
*/
|
||||
string attribute_name;
|
||||
std::string attribute_name;
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -134,9 +132,9 @@ class SingleAttribute : public Attribute
|
||||
{
|
||||
public:
|
||||
|
||||
SingleAttribute(const string& name):Attribute(name){};
|
||||
SingleAttribute(const std::string& name):Attribute(name){};
|
||||
|
||||
SingleAttribute(const string& name, const string& value):
|
||||
SingleAttribute(const std::string& name, const std::string& value):
|
||||
Attribute(name),attribute_value(value){};
|
||||
|
||||
SingleAttribute(const SingleAttribute& sa):Attribute(sa.attribute_name)
|
||||
@ -149,7 +147,7 @@ public:
|
||||
/**
|
||||
* Returns the attribute value, a string.
|
||||
*/
|
||||
const string& value() const
|
||||
const std::string& value() const
|
||||
{
|
||||
return attribute_value;
|
||||
};
|
||||
@ -159,9 +157,9 @@ public:
|
||||
* by the calling function.
|
||||
* @return a string (allocated in the heap) holding the attribute value.
|
||||
*/
|
||||
string * marshall(const char * _sep = 0) const override
|
||||
std::string * marshall(const char * _sep = 0) const override
|
||||
{
|
||||
string * rs = new string;
|
||||
auto rs = new std::string;
|
||||
|
||||
*rs = attribute_value;
|
||||
|
||||
@ -203,7 +201,7 @@ public:
|
||||
/**
|
||||
* Builds a new attribute from a string.
|
||||
*/
|
||||
void unmarshall(const string& sattr, const char * _sep = 0) override
|
||||
void unmarshall(const std::string& sattr, const char * _sep = 0) override
|
||||
{
|
||||
attribute_value = sattr;
|
||||
};
|
||||
@ -211,7 +209,7 @@ public:
|
||||
/**
|
||||
* Replaces the attribute value from a string.
|
||||
*/
|
||||
void replace(const string& sattr)
|
||||
void replace(const std::string& sattr)
|
||||
{
|
||||
attribute_value = sattr;
|
||||
};
|
||||
@ -235,16 +233,18 @@ public:
|
||||
/**
|
||||
* Encrypt all secret attributes
|
||||
*/
|
||||
virtual void encrypt(const string& one_key, const set<string>& eas) override;
|
||||
void encrypt(const std::string& one_key,
|
||||
const std::set<std::string>& eas) override;
|
||||
|
||||
/**
|
||||
* Decrypt all secret attributes
|
||||
*/
|
||||
virtual void decrypt(const string& one_key, const set<string>& eas) override;
|
||||
void decrypt(const std::string& one_key,
|
||||
const std::set<std::string>& eas) override;
|
||||
|
||||
private:
|
||||
|
||||
string attribute_value;
|
||||
std::string attribute_value;
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -259,9 +259,10 @@ class VectorAttribute : public Attribute
|
||||
{
|
||||
public:
|
||||
|
||||
VectorAttribute(const string& name):Attribute(name){};
|
||||
VectorAttribute(const std::string& name):Attribute(name){};
|
||||
|
||||
VectorAttribute(const string& name,const map<string,string>& value):
|
||||
VectorAttribute(const std::string& name,
|
||||
const std::map<std::string,std::string>& value):
|
||||
Attribute(name),attribute_value(value){};
|
||||
|
||||
VectorAttribute(const VectorAttribute& va):Attribute(va.attribute_name)
|
||||
@ -279,7 +280,7 @@ public:
|
||||
/**
|
||||
* Returns the attribute value, a string.
|
||||
*/
|
||||
const map<string,string>& value() const
|
||||
const std::map<std::string,std::string>& value() const
|
||||
{
|
||||
return attribute_value;
|
||||
};
|
||||
@ -290,7 +291,7 @@ public:
|
||||
*
|
||||
* @return the value of the attribute if found, empty otherwise
|
||||
*/
|
||||
string vector_value(const string& name) const;
|
||||
std::string vector_value(const std::string& name) const;
|
||||
|
||||
/**
|
||||
* Returns the value of the given element of the VectorAttribute
|
||||
@ -301,11 +302,9 @@ public:
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
template<typename T>
|
||||
int vector_value(const string& name, T& value) const
|
||||
int vector_value(const std::string& name, T& value) const
|
||||
{
|
||||
map<string,string>::const_iterator it;
|
||||
|
||||
it = attribute_value.find(name);
|
||||
auto it = attribute_value.find(name);
|
||||
|
||||
if ( it == attribute_value.end() )
|
||||
{
|
||||
@ -317,7 +316,7 @@ public:
|
||||
return -1;
|
||||
}
|
||||
|
||||
istringstream iss(it->second);
|
||||
std::istringstream iss(it->second);
|
||||
iss >> value;
|
||||
|
||||
if (iss.fail() || !iss.eof())
|
||||
@ -337,7 +336,9 @@ public:
|
||||
* @param default_value used if element is invalid
|
||||
*/
|
||||
template<typename T>
|
||||
void vector_value(const string& name, T& value, const T& default_value) const
|
||||
void vector_value(const std::string& name,
|
||||
T& value,
|
||||
const T& default_value) const
|
||||
{
|
||||
if (vector_value(name, value) != 0)
|
||||
{
|
||||
@ -345,9 +346,9 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
int vector_value(const string& name, string& value) const;
|
||||
int vector_value(const std::string& name, std::string& value) const;
|
||||
|
||||
int vector_value(const string& name, bool& value) const;
|
||||
int vector_value(const std::string& name, bool& value) const;
|
||||
|
||||
/**
|
||||
* Returns the value of the given element of the VectorAttribute
|
||||
@ -359,11 +360,9 @@ public:
|
||||
* @return the value in string form on success, "" otherwise
|
||||
*/
|
||||
template<typename T>
|
||||
string vector_value_str(const string& name, T& value) const
|
||||
std::string vector_value_str(const std::string& name, T& value) const
|
||||
{
|
||||
map<string,string>::const_iterator it;
|
||||
|
||||
it = attribute_value.find(name);
|
||||
auto it = attribute_value.find(name);
|
||||
|
||||
if ( it == attribute_value.end() )
|
||||
{
|
||||
@ -375,7 +374,7 @@ public:
|
||||
return "";
|
||||
}
|
||||
|
||||
istringstream iss(it->second);
|
||||
std::istringstream iss(it->second);
|
||||
iss >> value;
|
||||
|
||||
if (iss.fail() || !iss.eof())
|
||||
@ -392,7 +391,7 @@ public:
|
||||
* "VAL_NAME_1=VAL_VALUE_1,...,VAL_NAME_N=VAL_VALUE_N".
|
||||
* @return a string (allocated in the heap) holding the attribute value.
|
||||
*/
|
||||
string * marshall(const char * _sep = 0) const override;
|
||||
std::string * marshall(const char * _sep = 0) const override;
|
||||
|
||||
/**
|
||||
* Write the attribute using a simple XML format:
|
||||
@ -416,12 +415,12 @@ public:
|
||||
* Builds a new attribute from a string of the form:
|
||||
* "VAL_NAME_1=VAL_VALUE_1,...,VAL_NAME_N=VAL_VALUE_N".
|
||||
*/
|
||||
void unmarshall(const string& sattr, const char * _sep = 0) override;
|
||||
void unmarshall(const std::string& sattr, const char * _sep = 0) override;
|
||||
|
||||
/**
|
||||
* Replace the value of the given attribute with the provided map
|
||||
*/
|
||||
void replace(const map<string,string>& attr);
|
||||
void replace(const std::map<std::string,std::string>& attr);
|
||||
|
||||
/**
|
||||
* The attributes from vattr will be copied to this vector
|
||||
@ -435,16 +434,16 @@ public:
|
||||
* Replace the value of the given vector attribute
|
||||
*/
|
||||
template<typename T>
|
||||
void replace(const string& name, T value)
|
||||
void replace(const std::string& name, T value)
|
||||
{
|
||||
ostringstream oss;
|
||||
std::ostringstream oss;
|
||||
|
||||
oss << value;
|
||||
|
||||
replace(name, oss.str());
|
||||
}
|
||||
|
||||
void replace(const string& name, bool value)
|
||||
void replace(const std::string& name, bool value)
|
||||
{
|
||||
if (value == true)
|
||||
{
|
||||
@ -456,13 +455,13 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void replace(const string& name, const string& value);
|
||||
void replace(const std::string& name, const std::string& value);
|
||||
|
||||
/**
|
||||
* Removes given the vector attribute
|
||||
* @param name of the vector attribute
|
||||
*/
|
||||
void remove(const string& name);
|
||||
void remove(const std::string& name);
|
||||
|
||||
/**
|
||||
* Returns the attribute type
|
||||
@ -499,12 +498,14 @@ public:
|
||||
/**
|
||||
* Encrypt all secret attributes
|
||||
*/
|
||||
virtual void encrypt(const string& one_key, const set<string>& eas) override;
|
||||
void encrypt(const std::string& one_key,
|
||||
const std::set<std::string>& eas) override;
|
||||
|
||||
/**
|
||||
* Decrypt all secret attributes
|
||||
*/
|
||||
virtual void decrypt(const string& one_key, const set<string>& eas) override;
|
||||
void decrypt(const std::string& one_key,
|
||||
const std::set<std::string>& eas) override;
|
||||
|
||||
private:
|
||||
|
||||
@ -512,7 +513,7 @@ private:
|
||||
|
||||
static const int magic_sep_size;
|
||||
|
||||
map<string,string> attribute_value;
|
||||
std::map<std::string,std::string> attribute_value;
|
||||
};
|
||||
|
||||
#endif /*ATTRIBUTE_H_*/
|
||||
|
@ -175,7 +175,7 @@ private:
|
||||
* @return the Auth driver with attribute name equal to value
|
||||
* or 0 in not found
|
||||
*/
|
||||
const Driver<auth_msg_t> * get(const string& name)
|
||||
const Driver<auth_msg_t> * get(const std::string& name)
|
||||
{
|
||||
return DriverManager::get_driver(name);
|
||||
}
|
||||
@ -214,22 +214,22 @@ private:
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static void _undefined(unique_ptr<auth_msg_t> msg);
|
||||
static void _undefined(std::unique_ptr<auth_msg_t> msg);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void _authorize(unique_ptr<auth_msg_t> msg);
|
||||
void _authorize(std::unique_ptr<auth_msg_t> msg);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void _authenticate(unique_ptr<auth_msg_t> msg);
|
||||
void _authenticate(std::unique_ptr<auth_msg_t> msg);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static void _log(unique_ptr<auth_msg_t> msg);
|
||||
static void _log(std::unique_ptr<auth_msg_t> msg);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Action Listener interface
|
||||
|
@ -17,15 +17,9 @@
|
||||
#ifndef CACHE_POOL_H_
|
||||
#define CACHE_POOL_H_
|
||||
|
||||
#include <time.h>
|
||||
#include <sstream>
|
||||
#include <pthread.h>
|
||||
#include <map>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* The Cache Pool class. This class is used to store volatile pool data.
|
||||
@ -40,11 +34,9 @@ public:
|
||||
|
||||
~CachePool()
|
||||
{
|
||||
typename std::map<int, T *>::iterator it;
|
||||
|
||||
pthread_mutex_lock(&resource_lock);
|
||||
|
||||
for (it=resources.begin(); it != resources.end() ; ++it)
|
||||
for (auto it = resources.begin(); it != resources.end() ; ++it)
|
||||
{
|
||||
delete it->second;
|
||||
}
|
||||
@ -60,7 +52,7 @@ public:
|
||||
|
||||
pthread_mutex_lock(&resource_lock);
|
||||
|
||||
typename std::map<int, T *>::iterator it = resources.find(oid);
|
||||
auto it = resources.find(oid);
|
||||
|
||||
if ( it == resources.end() )
|
||||
{
|
||||
@ -83,7 +75,7 @@ public:
|
||||
{
|
||||
pthread_mutex_lock(&resource_lock);
|
||||
|
||||
typename std::map<int, T *>::iterator it = resources.find(oid);
|
||||
auto it = resources.find(oid);
|
||||
|
||||
if ( it != resources.end() )
|
||||
{
|
||||
|
@ -24,8 +24,6 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* This class represents a SQL callback
|
||||
*/
|
||||
@ -233,7 +231,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
set<T> * ids;
|
||||
std::set<T> * ids;
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -243,7 +241,7 @@ template<class T>
|
||||
class vector_cb : public Callbackable
|
||||
{
|
||||
public:
|
||||
void set_callback(vector<T> * _oids)
|
||||
void set_callback(std::vector<T> * _oids)
|
||||
{
|
||||
oids = _oids;
|
||||
|
||||
@ -271,7 +269,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
vector<T> * oids;
|
||||
std::vector<T> * oids;
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -322,7 +320,7 @@ class stream_cb : public Callbackable
|
||||
public:
|
||||
stream_cb(int _total): total_values(_total){};
|
||||
|
||||
void set_callback(ostringstream * _oss)
|
||||
void set_callback(std::ostringstream * _oss)
|
||||
{
|
||||
oss = _oss;
|
||||
|
||||
@ -352,7 +350,7 @@ private:
|
||||
|
||||
int total_values;
|
||||
|
||||
ostringstream * oss;
|
||||
std::ostringstream * oss;
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -23,8 +23,6 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
// =============================================================================
|
||||
// Doc:
|
||||
// http://xmlrpc-c.sourceforge.net/doc/#clientexamplepp
|
||||
@ -118,11 +116,11 @@ private:
|
||||
* @param message_size for XML elements in the client library (in bytes)
|
||||
* @throws Exception if the authorization options are invalid
|
||||
*/
|
||||
Client(const string& secret, const string& endpoint, size_t message_size,
|
||||
Client(const std::string& secret, const std::string& endpoint, size_t message_size,
|
||||
unsigned int tout);
|
||||
|
||||
string one_auth;
|
||||
string one_endpoint;
|
||||
std::string one_auth;
|
||||
std::string one_endpoint;
|
||||
|
||||
unsigned int timeout;
|
||||
|
||||
|
@ -18,11 +18,10 @@
|
||||
#define CLUSTER_H_
|
||||
|
||||
#include "PoolObjectSQL.h"
|
||||
#include "DatastorePool.h"
|
||||
#include "ClusterTemplate.h"
|
||||
#include "BitMap.h"
|
||||
#include "ObjectCollection.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* The Cluster class.
|
||||
@ -37,7 +36,7 @@ public:
|
||||
/**
|
||||
* Returns a copy of the datastore IDs set
|
||||
*/
|
||||
set<int> get_datastores()
|
||||
std::set<int> get_datastores()
|
||||
{
|
||||
return datastores.clone();
|
||||
};
|
||||
@ -46,12 +45,12 @@ public:
|
||||
* Returns a system DS for the cluster when none is set at the API level
|
||||
* @return the ID of the System
|
||||
*/
|
||||
static int get_default_system_ds(const set<int>& ds_collection);
|
||||
static int get_default_system_ds(const std::set<int>& ds_collection);
|
||||
|
||||
/**
|
||||
* Returns a copy of the host IDs set
|
||||
*/
|
||||
set<int> get_host_ids()
|
||||
std::set<int> get_host_ids()
|
||||
{
|
||||
return hosts.clone();
|
||||
}
|
||||
@ -59,7 +58,7 @@ public:
|
||||
/**
|
||||
* Returns a copy of the datastore IDs set
|
||||
*/
|
||||
set<int> get_datastore_ids()
|
||||
std::set<int> get_datastore_ids()
|
||||
{
|
||||
return datastores.clone();
|
||||
}
|
||||
@ -67,7 +66,7 @@ public:
|
||||
/**
|
||||
* Returns a copy of the vnet IDs set
|
||||
*/
|
||||
set<int> get_vnet_ids()
|
||||
std::set<int> get_vnet_ids()
|
||||
{
|
||||
return vnets.clone();
|
||||
}
|
||||
@ -78,7 +77,7 @@ public:
|
||||
* @param cpu reserved cpu (percentage, or absolute)
|
||||
* @param mem reserved mem (in KB)
|
||||
*/
|
||||
void get_reserved_capacity(string& cpu, string& mem) const
|
||||
void get_reserved_capacity(std::string& cpu, std::string& mem) const
|
||||
{
|
||||
get_template_attribute("RESERVED_CPU", cpu);
|
||||
|
||||
@ -93,7 +92,7 @@ public:
|
||||
* @param xml the resulting XML string
|
||||
* @return a reference to the generated string
|
||||
*/
|
||||
string& to_xml(string& xml) const override;
|
||||
std::string& to_xml(std::string& xml) const override;
|
||||
|
||||
/**
|
||||
* Rebuilds the object from an xml formatted string
|
||||
@ -101,7 +100,7 @@ public:
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int from_xml(const string &xml_str) override;
|
||||
int from_xml(const std::string &xml_str) override;
|
||||
|
||||
private:
|
||||
|
||||
@ -143,7 +142,7 @@ private:
|
||||
// *************************************************************************
|
||||
// Constructor
|
||||
// *************************************************************************
|
||||
Cluster(int id, const string& name, ClusterTemplate* cl_template,
|
||||
Cluster(int id, const std::string& name, ClusterTemplate* cl_template,
|
||||
const VectorAttribute& vnc_conf);
|
||||
|
||||
virtual ~Cluster() = default;
|
||||
@ -168,7 +167,7 @@ private:
|
||||
* @param error_str Returns the error reason, if any
|
||||
* @return 0 one success
|
||||
*/
|
||||
int insert_replace(SqlDB *db, bool replace, string& error_str);
|
||||
int insert_replace(SqlDB *db, bool replace, std::string& error_str);
|
||||
|
||||
/**
|
||||
* Bootstraps the database table(s) associated to the Cluster
|
||||
@ -181,7 +180,7 @@ private:
|
||||
* @param db pointer to the db
|
||||
* @return 0 on success
|
||||
*/
|
||||
int insert(SqlDB *db, string& error_str) override
|
||||
int insert(SqlDB *db, std::string& error_str) override
|
||||
{
|
||||
int rc;
|
||||
|
||||
@ -202,7 +201,7 @@ private:
|
||||
*/
|
||||
int update(SqlDB *db) override
|
||||
{
|
||||
string error_str;
|
||||
std::string error_str;
|
||||
|
||||
return insert_replace(db, true, error_str);
|
||||
}
|
||||
@ -239,7 +238,7 @@ private:
|
||||
* @param db pointer to the db
|
||||
* @return 0 on success
|
||||
*/
|
||||
int select(SqlDB *db, const string& _name, int _uid) override
|
||||
int select(SqlDB *db, const std::string& _name, int _uid) override
|
||||
{
|
||||
int rc = PoolObjectSQL::select(db, _name, _uid);
|
||||
|
||||
@ -258,7 +257,7 @@ private:
|
||||
* @param error_msg Error message, if any.
|
||||
* @return 0 if cluster can be dropped, -1 otherwise
|
||||
*/
|
||||
int check_drop(string& error_msg);
|
||||
int check_drop(std::string& error_msg);
|
||||
|
||||
/**
|
||||
* Factory method for cluster templates
|
||||
@ -272,9 +271,10 @@ private:
|
||||
* Add a resource to the corresponding set.
|
||||
* @return 0 on success
|
||||
*/
|
||||
int add_resource(PoolObjectSQL::ObjectType type, int resource_id, string& error_msg)
|
||||
int add_resource(PoolObjectSQL::ObjectType type, int resource_id,
|
||||
std::string& error_msg)
|
||||
{
|
||||
ostringstream oss;
|
||||
std::ostringstream oss;
|
||||
|
||||
int rc;
|
||||
|
||||
@ -308,7 +308,8 @@ private:
|
||||
* Remove a resource from the corresponding set.
|
||||
* @return 0 on success
|
||||
*/
|
||||
int del_resource(PoolObjectSQL::ObjectType type, int resource_id, string& error_msg)
|
||||
int del_resource(PoolObjectSQL::ObjectType type, int resource_id,
|
||||
std::string& error_msg)
|
||||
{
|
||||
int rc;
|
||||
|
||||
|
@ -21,15 +21,13 @@
|
||||
#include "PoolSQL.h"
|
||||
#include "OneDB.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
class ClusterPool : public PoolSQL
|
||||
{
|
||||
public:
|
||||
ClusterPool(SqlDB * db,
|
||||
const VectorAttribute * vnc_conf,
|
||||
vector<const SingleAttribute *>& encrypted_attrs);
|
||||
std::vector<const SingleAttribute *>& encrypted_attrs);
|
||||
|
||||
~ClusterPool(){};
|
||||
|
||||
@ -40,7 +38,7 @@ public:
|
||||
/**
|
||||
* Name for the "none" cluster
|
||||
*/
|
||||
static const string NONE_CLUSTER_NAME;
|
||||
static const std::string NONE_CLUSTER_NAME;
|
||||
|
||||
/**
|
||||
* Identifier for the "none" cluster
|
||||
@ -50,7 +48,7 @@ public:
|
||||
/**
|
||||
* Name for the default cluster
|
||||
*/
|
||||
static const string DEFAULT_CLUSTER_NAME;
|
||||
static const std::string DEFAULT_CLUSTER_NAME;
|
||||
|
||||
/**
|
||||
* Identifier for the default cluster
|
||||
@ -141,7 +139,7 @@ public:
|
||||
*
|
||||
* @return the oid assigned to the object, -1 in case of failure
|
||||
*/
|
||||
int allocate(string name, int * oid, string& error_str);
|
||||
int allocate(std::string name, int * oid, std::string& error_str);
|
||||
|
||||
/**
|
||||
* Function to get a cluster from the pool, if the object is not in memory
|
||||
@ -178,7 +176,7 @@ public:
|
||||
* -2 object is a system cluster (ID < 100)
|
||||
* -3 Cluster's User IDs set is not empty
|
||||
*/
|
||||
int drop(PoolObjectSQL * objsql, string& error_msg);
|
||||
int drop(PoolObjectSQL * objsql, std::string& error_msg);
|
||||
|
||||
/**
|
||||
* Bootstraps the database table(s) associated to the Cluster pool
|
||||
@ -186,7 +184,7 @@ public:
|
||||
*/
|
||||
static int bootstrap(SqlDB * _db)
|
||||
{
|
||||
ostringstream oss_bitmap;
|
||||
std::ostringstream oss_bitmap;
|
||||
int rc;
|
||||
|
||||
rc = Cluster::bootstrap(_db);
|
||||
@ -222,8 +220,8 @@ public:
|
||||
* @param auth_object to generate the filter for
|
||||
* @param cids vector of cluster ids
|
||||
*/
|
||||
static void cluster_acl_filter(ostringstream& filter,
|
||||
PoolObjectSQL::ObjectType auth_object, const vector<int>& cids);
|
||||
static void cluster_acl_filter(std::ostringstream& filter,
|
||||
PoolObjectSQL::ObjectType auth_object, const std::vector<int>& cids);
|
||||
|
||||
/**
|
||||
* Returns the Datastore Clusters performing a DB query
|
||||
@ -231,7 +229,7 @@ public:
|
||||
* @param cluster_ids Will contain the Cluster IDs
|
||||
* @return 0 on success
|
||||
*/
|
||||
int query_datastore_clusters(int oid, set<int> &cluster_ids);
|
||||
int query_datastore_clusters(int oid, std::set<int> &cluster_ids);
|
||||
|
||||
/**
|
||||
* Returns the VNet Clusters performing a DB query
|
||||
@ -239,7 +237,7 @@ public:
|
||||
* @param cluster_ids Will contain the Cluster IDs
|
||||
* @return 0 on success
|
||||
*/
|
||||
int query_vnet_clusters(int oid, set<int> &cluster_ids);
|
||||
int query_vnet_clusters(int oid, std::set<int> &cluster_ids);
|
||||
|
||||
/**
|
||||
* Adds a resource to the specifyed cluster and update the clusters body.
|
||||
@ -250,7 +248,7 @@ public:
|
||||
* @return 0 on success
|
||||
*/
|
||||
int add_to_cluster(PoolObjectSQL::ObjectType type, Cluster* cluster,
|
||||
int resource_id, string& error_msg);
|
||||
int resource_id, std::string& error_msg);
|
||||
|
||||
/**
|
||||
* Removes a resource from the specifyed cluster and update the clusters body.
|
||||
@ -261,7 +259,7 @@ public:
|
||||
* @return 0 on success
|
||||
*/
|
||||
int del_from_cluster(PoolObjectSQL::ObjectType type, Cluster* cluster,
|
||||
int resource_id, string& error_msg);
|
||||
int resource_id, std::string& error_msg);
|
||||
|
||||
/**
|
||||
* Updates the cluster vnc bitmap.
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
#include "Template.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* Cluster Template class
|
||||
@ -47,7 +46,7 @@ public:
|
||||
Template::decrypt(one_key, encrypted);
|
||||
}
|
||||
|
||||
static void parse_encrypted(vector<const SingleAttribute *>& ea)
|
||||
static void parse_encrypted(std::vector<const SingleAttribute *>& ea)
|
||||
{
|
||||
Template::parse_encrypted(ea, encrypted);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
* @param ob the type
|
||||
* @return the string
|
||||
*/
|
||||
static string type_to_str(DatastoreType ob)
|
||||
static std::string type_to_str(DatastoreType ob)
|
||||
{
|
||||
switch (ob)
|
||||
{
|
||||
@ -62,7 +62,7 @@ public:
|
||||
* @param str_type string representing the DatastoreTypr
|
||||
* @return the DatastoreType (defaults to IMAGE_DS)
|
||||
*/
|
||||
static DatastoreType str_to_type(string& str_type);
|
||||
static DatastoreType str_to_type(std::string& str_type);
|
||||
|
||||
/**
|
||||
* Datastore State
|
||||
@ -78,7 +78,7 @@ public:
|
||||
* @param state The state
|
||||
* @return the string representation
|
||||
*/
|
||||
static string state_to_str(DatastoreState state)
|
||||
static std::string state_to_str(DatastoreState state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
@ -93,7 +93,7 @@ public:
|
||||
* @param xml the resulting XML string
|
||||
* @return a reference to the generated string
|
||||
*/
|
||||
string& to_xml(string& xml) const override;
|
||||
std::string& to_xml(std::string& xml) const override;
|
||||
|
||||
/**
|
||||
* Rebuilds the object from an xml formatted string
|
||||
@ -101,7 +101,7 @@ public:
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int from_xml(const string &xml_str) override;
|
||||
int from_xml(const std::string &xml_str) override;
|
||||
|
||||
/**
|
||||
* Adds this image's ID to the set.
|
||||
@ -126,7 +126,7 @@ public:
|
||||
/**
|
||||
* Returns a copy of the Image IDs set
|
||||
*/
|
||||
set<int> get_image_ids()
|
||||
std::set<int> get_image_ids()
|
||||
{
|
||||
return images.clone();
|
||||
}
|
||||
@ -143,7 +143,7 @@ public:
|
||||
* Retrieves TM mad name
|
||||
* @return string tm mad name
|
||||
*/
|
||||
const string& get_tm_mad() const
|
||||
const std::string& get_tm_mad() const
|
||||
{
|
||||
return tm_mad;
|
||||
};
|
||||
@ -152,7 +152,7 @@ public:
|
||||
* Retrieves DS mad name
|
||||
* @return string ds mad name
|
||||
*/
|
||||
const string& get_ds_mad() const
|
||||
const std::string& get_ds_mad() const
|
||||
{
|
||||
return ds_mad;
|
||||
};
|
||||
@ -161,7 +161,7 @@ public:
|
||||
* Retrieves the base path
|
||||
* @return base path string
|
||||
*/
|
||||
const string& get_base_path() const
|
||||
const std::string& get_base_path() const
|
||||
{
|
||||
return base_path;
|
||||
};
|
||||
@ -193,8 +193,8 @@ public:
|
||||
* into the disk
|
||||
*/
|
||||
void disk_attribute(
|
||||
VirtualMachineDisk * disk,
|
||||
const vector<string>& inherit_attrs);
|
||||
VirtualMachineDisk * disk,
|
||||
const std::vector<std::string>& inherit_attrs);
|
||||
|
||||
/**
|
||||
* Set monitor information for the Datastore
|
||||
@ -246,14 +246,14 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int enable(bool enable, string& error_str);
|
||||
int enable(bool enable, std::string& error_str);
|
||||
|
||||
/**
|
||||
* Return a set with compatible system ds for an image ds
|
||||
*/
|
||||
void get_compatible_system_ds(set<int> &compatible_sys_ds)
|
||||
void get_compatible_system_ds(std::set<int> &compatible_sys_ds)
|
||||
{
|
||||
string compatible_sys_ds_str;
|
||||
std::string compatible_sys_ds_str;
|
||||
|
||||
get_template_attribute("COMPATIBLE_SYS_DS", compatible_sys_ds_str);
|
||||
|
||||
@ -264,7 +264,10 @@ public:
|
||||
* Verify the proper definition of the TM_MAD by checking the attributes
|
||||
* related to the TM defined in TM_MAD_CONF
|
||||
*/
|
||||
int get_tm_mad_targets(const string &tm_mad, string& ln_target, string& clone_target, string& disk_type);
|
||||
int get_tm_mad_targets(const std::string &tm_mad,
|
||||
std::string& ln_target,
|
||||
std::string& clone_target,
|
||||
std::string& disk_type);
|
||||
|
||||
private:
|
||||
|
||||
@ -281,17 +284,17 @@ private:
|
||||
/**
|
||||
* Name of the datastore driver used to register new images
|
||||
*/
|
||||
string ds_mad;
|
||||
std::string ds_mad;
|
||||
|
||||
/**
|
||||
* Name of the TM driver used to transfer file to and from the hosts
|
||||
*/
|
||||
string tm_mad;
|
||||
std::string tm_mad;
|
||||
|
||||
/**
|
||||
* Base path for the storage
|
||||
*/
|
||||
string base_path;
|
||||
std::string base_path;
|
||||
|
||||
/**
|
||||
* The datastore type
|
||||
@ -335,11 +338,11 @@ private:
|
||||
Datastore(
|
||||
int uid,
|
||||
int gid,
|
||||
const string& uname,
|
||||
const string& gname,
|
||||
const std::string& uname,
|
||||
const std::string& gname,
|
||||
int umask,
|
||||
DatastoreTemplate* ds_template,
|
||||
const set<int> &cluster_ids);
|
||||
const std::set<int> &cluster_ids);
|
||||
|
||||
virtual ~Datastore() = default;
|
||||
|
||||
@ -353,7 +356,7 @@ private:
|
||||
* @return -1 if an inconsistent assigment is found
|
||||
*
|
||||
*/
|
||||
int set_ds_disk_type(string& s_dt, string& error);
|
||||
int set_ds_disk_type(std::string& s_dt, std::string& error);
|
||||
|
||||
// *************************************************************************
|
||||
// DataBase implementation (Private)
|
||||
@ -366,7 +369,7 @@ private:
|
||||
* @param error_str Returns the error reason, if any
|
||||
* @return 0 one success
|
||||
*/
|
||||
int insert_replace(SqlDB *db, bool replace, string& error_str);
|
||||
int insert_replace(SqlDB *db, bool replace, std::string& error_str);
|
||||
|
||||
/**
|
||||
* Bootstraps the database table(s) associated to the Datastore
|
||||
@ -379,7 +382,7 @@ private:
|
||||
* @param db pointer to the db
|
||||
* @return 0 on success
|
||||
*/
|
||||
int insert(SqlDB *db, string& error_str) override;
|
||||
int insert(SqlDB *db, std::string& error_str) override;
|
||||
|
||||
/**
|
||||
* Writes/updates the Datastore's data fields in the database.
|
||||
@ -388,7 +391,7 @@ private:
|
||||
*/
|
||||
int update(SqlDB *db) override
|
||||
{
|
||||
string error_str;
|
||||
std::string error_str;
|
||||
return insert_replace(db, true, error_str);
|
||||
}
|
||||
|
||||
@ -405,13 +408,13 @@ private:
|
||||
* related to the DS defined in DS_MAD_CONF specified in the Datastore
|
||||
* template
|
||||
*/
|
||||
int set_ds_mad(string &ds_mad, string &error_str);
|
||||
int set_ds_mad(std::string &ds_mad, std::string &error_str);
|
||||
|
||||
/**
|
||||
* Verify the proper definition of the TM_MAD by checking the attributes
|
||||
* related to the TM defined in TM_MAD_CONF
|
||||
*/
|
||||
int set_tm_mad(string &tm_mad, string &error_str);
|
||||
int set_tm_mad(std::string &tm_mad, std::string &error_str);
|
||||
|
||||
/**
|
||||
* Child classes can process the new template set with replace_template or
|
||||
@ -420,7 +423,7 @@ private:
|
||||
* @return 0 on success
|
||||
* - encrypt secret attributes.
|
||||
*/
|
||||
int post_update_template(string& error) override;
|
||||
int post_update_template(std::string& error) override;
|
||||
};
|
||||
|
||||
#endif /*DATASTORE_H_*/
|
||||
|
@ -21,15 +21,13 @@
|
||||
#include "PoolSQL.h"
|
||||
#include "OneDB.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
class DatastorePool : public PoolSQL
|
||||
{
|
||||
public:
|
||||
DatastorePool(SqlDB * db,
|
||||
const vector<const SingleAttribute *>& _inherit_attrs,
|
||||
vector<const SingleAttribute *>& encrypted_attrs);
|
||||
const std::vector<const SingleAttribute *>& _inherit_attrs,
|
||||
std::vector<const SingleAttribute *>& encrypted_attrs);
|
||||
|
||||
~DatastorePool(){};
|
||||
|
||||
@ -40,7 +38,7 @@ public:
|
||||
/**
|
||||
* Name for the system datastore
|
||||
*/
|
||||
static const string SYSTEM_DS_NAME;
|
||||
static const std::string SYSTEM_DS_NAME;
|
||||
|
||||
/**
|
||||
* Identifier for the system datastore
|
||||
@ -50,7 +48,7 @@ public:
|
||||
/**
|
||||
* Name for the default datastore
|
||||
*/
|
||||
static const string DEFAULT_DS_NAME;
|
||||
static const std::string DEFAULT_DS_NAME;
|
||||
|
||||
/**
|
||||
* Identifier for the default datastore
|
||||
@ -60,7 +58,7 @@ public:
|
||||
/**
|
||||
* Name for the file datastore
|
||||
*/
|
||||
static const string FILE_DS_NAME;
|
||||
static const std::string FILE_DS_NAME;
|
||||
|
||||
/**
|
||||
* Identifier for the file datastore
|
||||
@ -87,15 +85,15 @@ public:
|
||||
* @return the oid assigned to the object, -1 in case of failure
|
||||
*/
|
||||
int allocate(
|
||||
int uid,
|
||||
int gid,
|
||||
const string& uname,
|
||||
const string& gname,
|
||||
int umask,
|
||||
DatastoreTemplate * ds_template,
|
||||
int * oid,
|
||||
const set<int> &cluster_ids,
|
||||
string& error_str);
|
||||
int uid,
|
||||
int gid,
|
||||
const std::string& uname,
|
||||
const std::string& gname,
|
||||
int umask,
|
||||
DatastoreTemplate * ds_template,
|
||||
int * oid,
|
||||
const std::set<int>& cluster_ids,
|
||||
std::string& error_str);
|
||||
|
||||
/**
|
||||
* Function to get a Datastore from the pool, if the object is not in memory
|
||||
@ -128,7 +126,7 @@ public:
|
||||
* @return 0 on success, -1 DB error
|
||||
* -3 Datastore's Image IDs set is not empty
|
||||
*/
|
||||
int drop(PoolObjectSQL * objsql, string& error_msg);
|
||||
int drop(PoolObjectSQL * objsql, std::string& error_msg);
|
||||
|
||||
/**
|
||||
* Bootstraps the database table(s) associated to the Datastore pool
|
||||
@ -163,7 +161,7 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int list(vector<int>& oids)
|
||||
int list(std::vector<int>& oids)
|
||||
{
|
||||
return PoolSQL::list(oids, one_db::ds_table);
|
||||
}
|
||||
@ -181,7 +179,7 @@ private:
|
||||
/**
|
||||
* Datastore attributes to be inherited into the VM disk
|
||||
*/
|
||||
vector<string> inherit_attrs;
|
||||
std::vector<std::string> inherit_attrs;
|
||||
|
||||
/**
|
||||
* Factory method to produce objects
|
||||
@ -189,7 +187,7 @@ private:
|
||||
*/
|
||||
PoolObjectSQL * create()
|
||||
{
|
||||
set<int> empty;
|
||||
std::set<int> empty;
|
||||
|
||||
return new Datastore(-1,-1,"","", 0, 0, empty);
|
||||
};
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
#include "Template.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* Datastore Template class
|
||||
@ -47,7 +46,7 @@ public:
|
||||
Template::decrypt(one_key, encrypted);
|
||||
}
|
||||
|
||||
static void parse_encrypted(vector<const SingleAttribute *>& ea)
|
||||
static void parse_encrypted(std::vector<const SingleAttribute *>& ea)
|
||||
{
|
||||
Template::parse_encrypted(ea, encrypted);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
* @param xml the string to store the XML
|
||||
* @return the same xml string to use it in << compounds
|
||||
*/
|
||||
string& to_xml(string& xml) const;
|
||||
std::string& to_xml(std::string& xml) const;
|
||||
|
||||
/**
|
||||
* Writes the quotas in the database.
|
||||
@ -73,7 +73,7 @@ private:
|
||||
* @param xml The xml-formatted string
|
||||
* @return 0 on success
|
||||
*/
|
||||
int from_xml(const string& xml);
|
||||
int from_xml(const std::string& xml);
|
||||
};
|
||||
|
||||
#endif /*DEFAULT_QUOTAS_H_*/
|
||||
|
@ -18,13 +18,8 @@
|
||||
#define DISPATCH_MANAGER_H_
|
||||
|
||||
#include "ActionManager.h"
|
||||
#include "HostPool.h"
|
||||
#include "VirtualMachinePool.h"
|
||||
#include "VirtualRouterPool.h"
|
||||
#include "ClusterPool.h"
|
||||
#include "UserPool.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
extern "C" void * dm_action_loop(void *arg);
|
||||
|
||||
@ -33,6 +28,10 @@ class TransferManager;
|
||||
class LifeCycleManager;
|
||||
class VirtualMachineManager;
|
||||
class ImageManager;
|
||||
class ClusterPool;
|
||||
class HostPool;
|
||||
class VirtualRouterPool;
|
||||
class UserPool;
|
||||
|
||||
struct RequestAttributes;
|
||||
|
||||
@ -192,7 +191,7 @@ public:
|
||||
* in a wrong a state
|
||||
*/
|
||||
int terminate(int vid, bool hard, const RequestAttributes& request,
|
||||
string& error_str);
|
||||
std::string& error_str);
|
||||
|
||||
/**
|
||||
* Shuts down a VM, but it is saved in the system DS instead of destroyed.
|
||||
@ -203,7 +202,7 @@ public:
|
||||
* in a wrong a state
|
||||
*/
|
||||
int undeploy(int vid, bool hard, const RequestAttributes& ra,
|
||||
string& error_str);
|
||||
std::string& error_str);
|
||||
|
||||
/**
|
||||
* Powers off a VM.
|
||||
@ -214,7 +213,7 @@ public:
|
||||
* in a wrong a state
|
||||
*/
|
||||
int poweroff(int vid, bool hard, const RequestAttributes& ra,
|
||||
string& error_str);
|
||||
std::string& error_str);
|
||||
|
||||
/**
|
||||
* Holds a VM.
|
||||
@ -223,7 +222,7 @@ public:
|
||||
* @return 0 on success, -1 if the VM does not exits or -2 if the VM is
|
||||
* in a wrong a state
|
||||
*/
|
||||
int hold(int vid, const RequestAttributes& ra, string& error_str);
|
||||
int hold(int vid, const RequestAttributes& ra, std::string& error_str);
|
||||
|
||||
/**
|
||||
* Releases a VM.
|
||||
@ -232,7 +231,7 @@ public:
|
||||
* @return 0 on success, -1 if the VM does not exits or -2 if the VM is
|
||||
* in a wrong a state
|
||||
*/
|
||||
int release(int vid, const RequestAttributes& ra, string& error_str);
|
||||
int release(int vid, const RequestAttributes& ra, std::string& error_str);
|
||||
|
||||
/**
|
||||
* Stops a VM.
|
||||
@ -241,7 +240,7 @@ public:
|
||||
* @return 0 on success, -1 if the VM does not exits or -2 if the VM is
|
||||
* in a wrong a state
|
||||
*/
|
||||
int stop(int vid, const RequestAttributes& ra, string& error_str);
|
||||
int stop(int vid, const RequestAttributes& ra, std::string& error_str);
|
||||
|
||||
/**
|
||||
* Suspends a VM.
|
||||
@ -250,7 +249,7 @@ public:
|
||||
* @return 0 on success, -1 if the VM does not exits or -2 if the VM is
|
||||
* in a wrong a state
|
||||
*/
|
||||
int suspend(int vid, const RequestAttributes& ra, string& error_str);
|
||||
int suspend(int vid, const RequestAttributes& ra, std::string& error_str);
|
||||
|
||||
/**
|
||||
* Resumes a VM.
|
||||
@ -259,7 +258,7 @@ public:
|
||||
* @return 0 on success, -1 if the VM does not exits or -2 if the VM is
|
||||
* in a wrong a state
|
||||
*/
|
||||
int resume(int vid, const RequestAttributes& ra, string& error_str);
|
||||
int resume(int vid, const RequestAttributes& ra, std::string& error_str);
|
||||
|
||||
/**
|
||||
* Ends a VM life cycle inside ONE.
|
||||
@ -268,12 +267,12 @@ public:
|
||||
* @return 0 on success, the VM mutex is unlocked
|
||||
*/
|
||||
int delete_vm(VirtualMachine * vm, const RequestAttributes& ra,
|
||||
string& error_str);
|
||||
std::string& error_str);
|
||||
|
||||
/**
|
||||
* VM ID interface
|
||||
*/
|
||||
int delete_vm(int vid, const RequestAttributes& ra, string& error_str)
|
||||
int delete_vm(int vid, const RequestAttributes& ra, std::string& error_str)
|
||||
{
|
||||
VirtualMachine * vm;
|
||||
|
||||
@ -295,7 +294,7 @@ public:
|
||||
* @return 0 on success
|
||||
*/
|
||||
int delete_recreate(VirtualMachine * vm, const RequestAttributes& ra,
|
||||
string& error_str);
|
||||
std::string& error_str);
|
||||
|
||||
/**
|
||||
* Ends a VM life cycle inside ONE but let the VM running at the Hipervisor.
|
||||
@ -304,7 +303,7 @@ public:
|
||||
* @return 0 on success, the VM mutex is unlocked
|
||||
*/
|
||||
int delete_vm_db(VirtualMachine * vm, const RequestAttributes& ra,
|
||||
string& error_str);
|
||||
std::string& error_str);
|
||||
|
||||
/**
|
||||
* Recover the last operation on the VM
|
||||
@ -314,7 +313,7 @@ public:
|
||||
* @return 0 on success
|
||||
*/
|
||||
int recover(VirtualMachine * vm, bool success, const RequestAttributes& ra,
|
||||
string& error_str);
|
||||
std::string& error_str);
|
||||
|
||||
/**
|
||||
* Retry the last operation on the VM
|
||||
@ -323,7 +322,7 @@ public:
|
||||
* @return 0 on success
|
||||
*/
|
||||
int retry(VirtualMachine * vm, const RequestAttributes& ra,
|
||||
string& error_str);
|
||||
std::string& error_str);
|
||||
|
||||
/**
|
||||
* Reboots a VM preserving any resource and RUNNING state
|
||||
@ -334,7 +333,7 @@ public:
|
||||
* in a wrong a state
|
||||
*/
|
||||
int reboot(int vid, bool hard, const RequestAttributes& ra,
|
||||
string& error_str);
|
||||
std::string& error_str);
|
||||
|
||||
/**
|
||||
* Set the re-scheduling flag for the VM (must be in RUNNING state)
|
||||
@ -346,7 +345,7 @@ public:
|
||||
* in a wrong a state
|
||||
*/
|
||||
int resched(int vid, bool do_resched, const RequestAttributes& ra,
|
||||
string& error_str);
|
||||
std::string& error_str);
|
||||
|
||||
/**
|
||||
* Starts the attach disk action.
|
||||
@ -358,7 +357,7 @@ public:
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int attach(int vid, VirtualMachineTemplate * tmpl,
|
||||
const RequestAttributes& ra, string& error_str);
|
||||
const RequestAttributes& ra, std::string& error_str);
|
||||
|
||||
/**
|
||||
* Starts the detach disk action.
|
||||
@ -370,7 +369,7 @@ public:
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int detach(int id, int disk_id, const RequestAttributes& ra,
|
||||
string& error_str);
|
||||
std::string& error_str);
|
||||
|
||||
/**
|
||||
* Starts the attach NIC action.
|
||||
@ -382,7 +381,7 @@ public:
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int attach_nic(int vid, VirtualMachineTemplate * tmpl,
|
||||
const RequestAttributes& ra, string& error_str);
|
||||
const RequestAttributes& ra, std::string& error_str);
|
||||
|
||||
/**
|
||||
* Starts the detach NIC action.
|
||||
@ -394,7 +393,7 @@ public:
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int detach_nic(int id, int nic_id, const RequestAttributes& ra,
|
||||
string& error_str);
|
||||
std::string& error_str);
|
||||
|
||||
/**
|
||||
* Starts the snapshot create action
|
||||
@ -407,8 +406,8 @@ public:
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int snapshot_create(int vid, string& name, int& snap_id,
|
||||
const RequestAttributes& ra, string& error_str);
|
||||
int snapshot_create(int vid, std::string& name, int& snap_id,
|
||||
const RequestAttributes& ra, std::string& error_str);
|
||||
|
||||
/**
|
||||
* Starts the snapshot revert action
|
||||
@ -421,7 +420,7 @@ public:
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int snapshot_revert(int vid, int snap_id, const RequestAttributes& ra,
|
||||
string& error_str);
|
||||
std::string& error_str);
|
||||
|
||||
/**
|
||||
* Starts the snapshot delete action
|
||||
@ -434,7 +433,7 @@ public:
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int snapshot_delete(int vid, int snap_id, const RequestAttributes& ra,
|
||||
string& error_str);
|
||||
std::string& error_str);
|
||||
|
||||
/**
|
||||
* Starts the disk snapshot create action
|
||||
@ -448,8 +447,8 @@ public:
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int disk_snapshot_create(int vid, int did, const string& name, int& snap_id,
|
||||
const RequestAttributes& ra, string& error_str);
|
||||
int disk_snapshot_create(int vid, int did, const std::string& name,
|
||||
int& snap_id, const RequestAttributes& ra, std::string& error_str);
|
||||
|
||||
/**
|
||||
* Reverts the disk state to a previous snapshot
|
||||
@ -463,7 +462,7 @@ public:
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int disk_snapshot_revert(int vid, int did, int snap_id,
|
||||
const RequestAttributes& ra, string& error_str);
|
||||
const RequestAttributes& ra, std::string& error_str);
|
||||
|
||||
/**
|
||||
* Deletes a disk snapshot
|
||||
@ -477,7 +476,7 @@ public:
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int disk_snapshot_delete(int vid, int did, int snap_id,
|
||||
const RequestAttributes& ra, string& error_str);
|
||||
const RequestAttributes& ra, std::string& error_str);
|
||||
|
||||
/**
|
||||
* Starts the disk resize create action
|
||||
@ -491,7 +490,7 @@ public:
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int disk_resize(int vid, int did, long long new_size,
|
||||
const RequestAttributes& ra, string& error_str);
|
||||
const RequestAttributes& ra, std::string& error_str);
|
||||
|
||||
/**
|
||||
* Update virtual machine context
|
||||
@ -502,7 +501,8 @@ public:
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int live_updateconf(int vid, const RequestAttributes& ra, string& error_str);
|
||||
int live_updateconf(int vid, const RequestAttributes& ra,
|
||||
std::string& error_str);
|
||||
|
||||
private:
|
||||
/**
|
||||
@ -528,7 +528,7 @@ private:
|
||||
/**
|
||||
* Pointer to the Cluster Pool
|
||||
*/
|
||||
ClusterPool * clpool;
|
||||
ClusterPool * clpool;
|
||||
|
||||
/**
|
||||
* Pointer to the Virtual Router Pool
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
* @param xml the resulting XML string
|
||||
* @return a reference to the generated string
|
||||
*/
|
||||
string& to_xml(string& xml) const override;
|
||||
std::string& to_xml(std::string& xml) const override;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Template Contents
|
||||
@ -97,7 +97,7 @@ private:
|
||||
* @param error_str Returns the error reason, if any
|
||||
* @return 0 one success
|
||||
*/
|
||||
int insert_replace(SqlDB *db, bool replace, string& error_str);
|
||||
int insert_replace(SqlDB *db, bool replace, std::string& error_str);
|
||||
|
||||
/**
|
||||
* Bootstraps the database table(s) associated to the Document
|
||||
@ -111,7 +111,7 @@ private:
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int from_xml(const string &xml_str) override;
|
||||
int from_xml(const std::string &xml_str) override;
|
||||
|
||||
protected:
|
||||
|
||||
@ -121,8 +121,8 @@ protected:
|
||||
Document( int id,
|
||||
int uid,
|
||||
int gid,
|
||||
const string& uname,
|
||||
const string& gname,
|
||||
const std::string& uname,
|
||||
const std::string& gname,
|
||||
int umask,
|
||||
int type,
|
||||
Template * _template_contents);
|
||||
@ -139,7 +139,7 @@ protected:
|
||||
* @param error_str Returns the error reason, if any
|
||||
* @return 0 on success
|
||||
*/
|
||||
int insert(SqlDB *db, string& error_str) override;
|
||||
int insert(SqlDB *db, std::string& error_str) override;
|
||||
|
||||
/**
|
||||
* Writes/updates the Document data fields in the database.
|
||||
@ -148,7 +148,7 @@ protected:
|
||||
*/
|
||||
int update(SqlDB *db) override
|
||||
{
|
||||
string err;
|
||||
std::string err;
|
||||
return insert_replace(db, true, err);
|
||||
};
|
||||
};
|
||||
|
@ -49,13 +49,13 @@ public:
|
||||
*/
|
||||
int allocate(int uid,
|
||||
int gid,
|
||||
const string& uname,
|
||||
const string& gname,
|
||||
const std::string& uname,
|
||||
const std::string& gname,
|
||||
int umask,
|
||||
int type,
|
||||
Template * template_contents,
|
||||
int * oid,
|
||||
string& error_str)
|
||||
std::string& error_str)
|
||||
{
|
||||
*oid = PoolSQL::allocate(
|
||||
new Document(-1, uid, gid, uname, gname, umask, type, template_contents),
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
|
||||
int load_driver(const VectorAttribute* mad_config);
|
||||
|
||||
int load_drivers(const vector<const VectorAttribute*>& mads_config);
|
||||
int load_drivers(const std::vector<const VectorAttribute*>& mads_config);
|
||||
|
||||
D * get_driver(const std::string& name) const;
|
||||
|
||||
@ -156,7 +156,7 @@ int DriverManager<D>::load_driver(const VectorAttribute* mad_config)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
template<typename D>
|
||||
int DriverManager<D>::load_drivers(const vector<const VectorAttribute*>& mads_config)
|
||||
int DriverManager<D>::load_drivers(const std::vector<const VectorAttribute*>& mads_config)
|
||||
{
|
||||
NebulaLog::info("DrM", "Loading drivers.");
|
||||
|
||||
@ -224,12 +224,12 @@ int DriverManager<D>::start(std::string& error)
|
||||
template<typename D>
|
||||
void DriverManager<D>::stop(int secs)
|
||||
{
|
||||
vector<thread> threads;
|
||||
std::vector<std::thread> threads;
|
||||
|
||||
for (auto& driver : drivers)
|
||||
{
|
||||
int _secs = secs;
|
||||
threads.push_back(thread([_secs, &driver] () {
|
||||
threads.push_back(std::thread([_secs, &driver] () {
|
||||
driver.second->stop(_secs);
|
||||
}));
|
||||
}
|
||||
@ -300,7 +300,7 @@ void DriverManager<D>::add_request(SyncRequest *ar)
|
||||
|
||||
ar->id = request_id++;
|
||||
|
||||
sync_requests.insert(sync_requests.end(),make_pair(ar->id,ar));
|
||||
sync_requests.insert(sync_requests.end(),std::make_pair(ar->id,ar));
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -48,7 +48,7 @@ public:
|
||||
return va->vector_value(name, value);
|
||||
}
|
||||
|
||||
string vector_value(const std::string& name) const
|
||||
std::string vector_value(const std::string& name) const
|
||||
{
|
||||
return va->vector_value(name);
|
||||
}
|
||||
@ -87,7 +87,7 @@ protected:
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Attribute Interface */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
string * marshall(const char * _sep = 0) const
|
||||
std::string * marshall(const char * _sep = 0) const
|
||||
{
|
||||
return va->marshall(_sep);
|
||||
};
|
||||
@ -234,7 +234,7 @@ protected:
|
||||
*/
|
||||
void add_attribute(ExtendedAttribute * a, int id)
|
||||
{
|
||||
a_set.insert(make_pair(id, a));
|
||||
a_set.insert(std::make_pair(id, a));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,10 +21,8 @@
|
||||
#include "GroupTemplate.h"
|
||||
#include "ObjectCollection.h"
|
||||
#include "QuotasSQL.h"
|
||||
#include "Template.h"
|
||||
#include "VMActions.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* The Group class.
|
||||
@ -38,7 +36,7 @@ public:
|
||||
* @param xml the resulting XML string
|
||||
* @return a reference to the generated string
|
||||
*/
|
||||
string& to_xml(string& xml) const override;
|
||||
std::string& to_xml(std::string& xml) const override;
|
||||
|
||||
/**
|
||||
* Function to print the Group object into a string in
|
||||
@ -46,7 +44,7 @@ public:
|
||||
* @param xml the resulting XML string
|
||||
* @return a reference to the generated string
|
||||
*/
|
||||
string& to_xml_extended(string& xml) const;
|
||||
std::string& to_xml_extended(std::string& xml) const;
|
||||
|
||||
/**
|
||||
* Rebuilds the object from an xml formatted string
|
||||
@ -54,7 +52,7 @@ public:
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int from_xml(const string &xml_str) override;
|
||||
int from_xml(const std::string &xml_str) override;
|
||||
|
||||
/**
|
||||
* Adds this user's ID to the set.
|
||||
@ -75,7 +73,7 @@ public:
|
||||
{
|
||||
if (admins.contains(id))
|
||||
{
|
||||
string error;
|
||||
std::string error;
|
||||
|
||||
del_admin(id, error);
|
||||
}
|
||||
@ -91,7 +89,7 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int add_admin(int user_id, string& error_msg);
|
||||
int add_admin(int user_id, std::string& error_msg);
|
||||
|
||||
/**
|
||||
* Deletes a User from the admin set. ACL Rules are updated only for this user.
|
||||
@ -101,7 +99,7 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int del_admin(int user_id, string& error_msg);
|
||||
int del_admin(int user_id, std::string& error_msg);
|
||||
|
||||
/**
|
||||
* Retrun true if User is an admin member of the group
|
||||
@ -146,8 +144,10 @@ public:
|
||||
* GROUP_ADMIN_VIEWS = "cloud,groupadmin",
|
||||
* VIEWS = "cloud" ]
|
||||
*/
|
||||
void sunstone_views(const string& user_default, const string& user_views,
|
||||
const string& admin_default, const string& admin_views);
|
||||
void sunstone_views(const std::string& user_default,
|
||||
const std::string& user_views,
|
||||
const std::string& admin_default,
|
||||
const std::string& admin_views);
|
||||
|
||||
/**
|
||||
* @return the operation level (admin, manage or use) associated to the
|
||||
@ -163,7 +163,7 @@ protected:
|
||||
* @param error string describing the error if any
|
||||
* @return 0 on success
|
||||
*/
|
||||
int post_update_template(string& error) override;
|
||||
int post_update_template(std::string& error) override;
|
||||
|
||||
private:
|
||||
|
||||
@ -177,7 +177,7 @@ private:
|
||||
// Constructor
|
||||
// *************************************************************************
|
||||
|
||||
Group(int id, const string& name);
|
||||
Group(int id, const std::string& name);
|
||||
|
||||
virtual ~Group() = default;
|
||||
|
||||
@ -214,7 +214,7 @@ private:
|
||||
* @param error_str Returns the error reason, if any
|
||||
* @return 0 one success
|
||||
*/
|
||||
int insert_replace(SqlDB *db, bool replace, string& error_str);
|
||||
int insert_replace(SqlDB *db, bool replace, std::string& error_str);
|
||||
|
||||
/**
|
||||
* Bootstraps the database table(s) associated to the Group
|
||||
@ -237,7 +237,7 @@ private:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int select(SqlDB * db, const string& name, int uid) override;
|
||||
int select(SqlDB * db, const std::string& name, int uid) override;
|
||||
|
||||
/**
|
||||
* Reads the Group quotas from the database.
|
||||
@ -258,7 +258,7 @@ private:
|
||||
* @param db pointer to the db
|
||||
* @return 0 on success
|
||||
*/
|
||||
int insert(SqlDB *db, string& error_str) override;
|
||||
int insert(SqlDB *db, std::string& error_str) override;
|
||||
|
||||
/**
|
||||
* Writes/updates the Group's data fields in the database. This method does
|
||||
@ -268,7 +268,7 @@ private:
|
||||
*/
|
||||
int update(SqlDB *db) override
|
||||
{
|
||||
string error_str;
|
||||
std::string error_str;
|
||||
return insert_replace(db, true, error_str);
|
||||
}
|
||||
|
||||
@ -279,7 +279,7 @@ private:
|
||||
* @param extended If true, default quotas are included
|
||||
* @return a reference to the generated string
|
||||
*/
|
||||
string& to_xml_extended(string& xml, bool extended) const;
|
||||
std::string& to_xml_extended(std::string& xml, bool extended) const;
|
||||
};
|
||||
|
||||
#endif /*GROUP_H_*/
|
||||
|
@ -20,15 +20,13 @@
|
||||
#include "Group.h"
|
||||
#include "PoolSQL.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
class GroupPool : public PoolSQL
|
||||
{
|
||||
public:
|
||||
|
||||
GroupPool(SqlDB * db, bool is_federation_slave,
|
||||
vector<const SingleAttribute *>& restricted_attrs);
|
||||
std::vector<const SingleAttribute *>& restricted_attrs);
|
||||
|
||||
~GroupPool() = default;
|
||||
|
||||
@ -39,7 +37,7 @@ public:
|
||||
/**
|
||||
* Default name for the oneadmin group
|
||||
*/
|
||||
static const string ONEADMIN_NAME;
|
||||
static const std::string ONEADMIN_NAME;
|
||||
|
||||
/**
|
||||
* Identifier for the oneadmin group
|
||||
@ -49,7 +47,7 @@ public:
|
||||
/**
|
||||
* Default name for the users group
|
||||
*/
|
||||
static const string USERS_NAME;
|
||||
static const std::string USERS_NAME;
|
||||
|
||||
/**
|
||||
* Identifier for the user group
|
||||
@ -69,9 +67,9 @@ public:
|
||||
*
|
||||
* @return the oid assigned to the object, -1 in case of failure
|
||||
*/
|
||||
int allocate(string name,
|
||||
int allocate(std::string name,
|
||||
int * oid,
|
||||
string& error_str);
|
||||
std::string& error_str);
|
||||
|
||||
/**
|
||||
* Function to get a group from the pool, if the object is not in memory
|
||||
@ -102,9 +100,9 @@ public:
|
||||
* @param id of the group
|
||||
* @return name of the group
|
||||
*/
|
||||
const string get_name(int gid)
|
||||
const std::string get_name(int gid)
|
||||
{
|
||||
static string error_str = "";
|
||||
static std::string error_str = "";
|
||||
|
||||
Group * group = get_ro(gid);
|
||||
|
||||
@ -113,7 +111,7 @@ public:
|
||||
return error_str;
|
||||
}
|
||||
|
||||
const string gname = group->get_name();
|
||||
const std::string gname = group->get_name();
|
||||
|
||||
group->unlock();
|
||||
|
||||
@ -144,7 +142,7 @@ public:
|
||||
* -2 object is a system group (ID < 100)
|
||||
* -3 Group's User IDs set is not empty
|
||||
*/
|
||||
int drop(PoolObjectSQL * objsql, string& error_msg);
|
||||
int drop(PoolObjectSQL * objsql, std::string& error_msg);
|
||||
|
||||
/**
|
||||
* Bootstraps the database table(s) associated to the Group pool
|
||||
@ -166,7 +164,8 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump(string& oss, const string& where, int sid, int eid, bool desc);
|
||||
int dump(std::string& oss, const std::string& where,
|
||||
int sid, int eid, bool desc);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -32,17 +32,17 @@ public:
|
||||
// -------------------------------------------------------------------------
|
||||
// Restricted attributes interface implementation
|
||||
// -------------------------------------------------------------------------
|
||||
bool check_restricted(string& rs_attr, const Template* base) override
|
||||
bool check_restricted(std::string& rs_attr, const Template* base) override
|
||||
{
|
||||
return Template::check_restricted(rs_attr, base, restricted);
|
||||
}
|
||||
|
||||
bool check_restricted(string& rs_attr) override
|
||||
bool check_restricted(std::string& rs_attr) override
|
||||
{
|
||||
return Template::check_restricted(rs_attr, restricted);
|
||||
}
|
||||
|
||||
static void parse_restricted(vector<const SingleAttribute *>& ra)
|
||||
static void parse_restricted(std::vector<const SingleAttribute *>& ra)
|
||||
{
|
||||
Template::parse_restricted(ra, restricted);
|
||||
}
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "ObjectXML.h"
|
||||
#include "VMActions.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* The History class, it represents an execution record of a Virtual Machine.
|
||||
@ -36,19 +35,19 @@ public:
|
||||
int oid,
|
||||
int seq,
|
||||
int hid,
|
||||
const string& hostname,
|
||||
const std::string& hostname,
|
||||
int cid,
|
||||
const string& vmm,
|
||||
const string& tmm,
|
||||
const std::string& vmm,
|
||||
const std::string& tmm,
|
||||
int ds_id,
|
||||
const string& vm_info);
|
||||
const std::string& vm_info);
|
||||
|
||||
~History(){};
|
||||
|
||||
/**
|
||||
* Function to write the History Record in an output stream
|
||||
*/
|
||||
friend ostream& operator<<(ostream& os, const History& history);
|
||||
friend std::ostream& operator<<(std::ostream& os, const History& history);
|
||||
|
||||
/**
|
||||
* Function to print the History object into a string in
|
||||
@ -56,7 +55,7 @@ public:
|
||||
* @param xml the resulting XML string
|
||||
* @return a reference to the generated string
|
||||
*/
|
||||
string& to_xml(string& xml) const;
|
||||
std::string& to_xml(std::string& xml) const;
|
||||
|
||||
/**
|
||||
* Function to print the History object into a string in
|
||||
@ -64,7 +63,7 @@ public:
|
||||
* @param xml the resulting XML string
|
||||
* @return a reference to the generated string
|
||||
*/
|
||||
string& to_xml_short(string& xml) const;
|
||||
std::string& to_xml_short(std::string& xml) const;
|
||||
|
||||
private:
|
||||
friend class VirtualMachine;
|
||||
@ -75,58 +74,58 @@ private:
|
||||
// ----------------------------------------
|
||||
// History fields
|
||||
// ----------------------------------------
|
||||
int oid;
|
||||
int seq;
|
||||
int oid;
|
||||
int seq;
|
||||
|
||||
int uid;
|
||||
int gid;
|
||||
int req_id;
|
||||
int uid;
|
||||
int gid;
|
||||
int req_id;
|
||||
|
||||
int hid;
|
||||
string hostname;
|
||||
int cid;
|
||||
int hid;
|
||||
std::string hostname;
|
||||
int cid;
|
||||
|
||||
string vmm_mad_name;
|
||||
string tm_mad_name;
|
||||
std::string vmm_mad_name;
|
||||
std::string tm_mad_name;
|
||||
|
||||
int ds_id;
|
||||
int ds_id;
|
||||
|
||||
time_t stime;
|
||||
time_t etime;
|
||||
time_t stime;
|
||||
time_t etime;
|
||||
|
||||
time_t prolog_stime;
|
||||
time_t prolog_etime;
|
||||
time_t prolog_stime;
|
||||
time_t prolog_etime;
|
||||
|
||||
time_t running_stime;
|
||||
time_t running_etime;
|
||||
time_t running_stime;
|
||||
time_t running_etime;
|
||||
|
||||
time_t epilog_stime;
|
||||
time_t epilog_etime;
|
||||
time_t epilog_stime;
|
||||
time_t epilog_etime;
|
||||
|
||||
VMActions::Action action;
|
||||
|
||||
string vm_info;
|
||||
std::string vm_info;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Non-persistent history fields
|
||||
// -------------------------------------------------------------------------
|
||||
// Local paths
|
||||
string transfer_file;
|
||||
string deployment_file;
|
||||
string context_file;
|
||||
string token_file;
|
||||
std::string transfer_file;
|
||||
std::string deployment_file;
|
||||
std::string context_file;
|
||||
std::string token_file;
|
||||
|
||||
// Remote paths
|
||||
string checkpoint_file;
|
||||
string rdeployment_file;
|
||||
string system_dir;
|
||||
std::string checkpoint_file;
|
||||
std::string rdeployment_file;
|
||||
std::string system_dir;
|
||||
|
||||
/**
|
||||
* Writes the history record in the DB
|
||||
* @param db pointer to the database.
|
||||
* @return 0 on success.
|
||||
*/
|
||||
int insert(SqlDB * db, string& error_str)
|
||||
int insert(SqlDB * db, std::string& error_str)
|
||||
{
|
||||
error_str.clear();
|
||||
|
||||
@ -180,7 +179,7 @@ private:
|
||||
* @param xml the resulting XML string
|
||||
* @return a reference to the generated string
|
||||
*/
|
||||
string& to_db_xml(string& xml) const;
|
||||
std::string& to_db_xml(std::string& xml) const;
|
||||
|
||||
/**
|
||||
* Function to print the History object into a string in
|
||||
@ -189,11 +188,11 @@ private:
|
||||
* @param database If it is true, the TEMPLATE element will be included
|
||||
* @return a reference to the generated string
|
||||
*/
|
||||
string& to_xml(string& xml, bool database) const;
|
||||
std::string& to_xml(std::string& xml, bool database) const;
|
||||
|
||||
string& to_json(string& json) const;
|
||||
std::string& to_json(std::string& json) const;
|
||||
|
||||
string& to_token(string& text) const;
|
||||
std::string& to_token(std::string& text) const;
|
||||
|
||||
/**
|
||||
* Rebuilds the object from an xml node
|
||||
@ -214,7 +213,7 @@ private:
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int from_xml(const string &xml_str)
|
||||
int from_xml(const std::string &xml_str)
|
||||
{
|
||||
ObjectXML::update_from_str(xml_str);
|
||||
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
UNDEFINED = 0x04
|
||||
};
|
||||
|
||||
static string hook_type_to_str(HookType ht)
|
||||
static std::string hook_type_to_str(HookType ht)
|
||||
{
|
||||
switch(ht)
|
||||
{
|
||||
@ -137,7 +137,7 @@ private:
|
||||
/**
|
||||
* The command to be executed
|
||||
*/
|
||||
string cmd;
|
||||
std::string cmd;
|
||||
|
||||
/**
|
||||
* True if the command is to be executed remotely
|
||||
@ -175,7 +175,7 @@ private:
|
||||
*/
|
||||
int update(SqlDB *db) override
|
||||
{
|
||||
string error_str;
|
||||
std::string error_str;
|
||||
return insert_replace(db, true, error_str);
|
||||
};
|
||||
|
||||
@ -184,7 +184,7 @@ private:
|
||||
* @param db pointer to the db
|
||||
* @return 0 on success
|
||||
*/
|
||||
int insert(SqlDB *db, string& error_str) override;
|
||||
int insert(SqlDB *db, std::string& error_str) override;
|
||||
|
||||
/**
|
||||
* Execute an INSERT or REPLACE Sql query.
|
||||
@ -193,7 +193,7 @@ private:
|
||||
* @param error_str Returns the error reason, if any
|
||||
* @return 0 one success
|
||||
*/
|
||||
int insert_replace(SqlDB *db, bool replace, string& error_str);
|
||||
int insert_replace(SqlDB *db, bool replace, std::string& error_str);
|
||||
|
||||
/**
|
||||
* Drops object from the database
|
||||
|
@ -135,7 +135,8 @@ public:
|
||||
return DriverManager::get_driver(hook_driver_name);
|
||||
}
|
||||
|
||||
static std::string * format_message(const string& args, const string&remote_host,
|
||||
static std::string * format_message(const std::string& args,
|
||||
const std::string& remote_host,
|
||||
int hook_id);
|
||||
|
||||
private:
|
||||
@ -178,22 +179,22 @@ private:
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static void _undefined(unique_ptr<hook_msg_t> msg);
|
||||
static void _undefined(std::unique_ptr<hook_msg_t> msg);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void _execute(unique_ptr<hook_msg_t> msg);
|
||||
void _execute(std::unique_ptr<hook_msg_t> msg);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void _retry(unique_ptr<hook_msg_t> msg);
|
||||
void _retry(std::unique_ptr<hook_msg_t> msg);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static void _log(unique_ptr<hook_msg_t> msg);
|
||||
static void _log(std::unique_ptr<hook_msg_t> msg);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Action Listener interface
|
||||
|
@ -22,7 +22,8 @@
|
||||
#include "HookAPI.h"
|
||||
#include "OneDB.h"
|
||||
|
||||
using namespace std;
|
||||
class SqlDB;
|
||||
|
||||
|
||||
class HookPool : public PoolSQL
|
||||
{
|
||||
@ -37,7 +38,7 @@ public:
|
||||
* @param oid the id assigned to the Hook
|
||||
* @return the oid assigned to the object or -1 in case of failure
|
||||
*/
|
||||
int allocate (Template * tmpl, string& error_str);
|
||||
int allocate (Template * tmpl, std::string& error_str);
|
||||
|
||||
/**
|
||||
* Function to get a Hook from the pool, if the object is not in memory
|
||||
|
@ -86,9 +86,9 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static string state_to_str(HostState state)
|
||||
static std::string state_to_str(HostState state)
|
||||
{
|
||||
string st = "";
|
||||
std::string st = "";
|
||||
|
||||
switch (state)
|
||||
{
|
||||
@ -117,7 +117,7 @@ public:
|
||||
* @param xml the resulting XML string
|
||||
* @return a reference to the generated string
|
||||
*/
|
||||
std::string& to_xml(string& xml) const override;
|
||||
std::string& to_xml(std::string& xml) const override;
|
||||
|
||||
/**
|
||||
* Rebuilds the object from an xml formatted string
|
||||
@ -206,7 +206,7 @@ public:
|
||||
* Retrieves VMM mad name
|
||||
* @return string vmm mad name
|
||||
*/
|
||||
const string& get_vmm_mad() const
|
||||
const std::string& get_vmm_mad() const
|
||||
{
|
||||
return vmm_mad_name;
|
||||
};
|
||||
@ -215,7 +215,7 @@ public:
|
||||
* Retrieves IM mad name
|
||||
* @return string im mad name
|
||||
*/
|
||||
const string& get_im_mad() const
|
||||
const std::string& get_im_mad() const
|
||||
{
|
||||
return im_mad_name;
|
||||
};
|
||||
@ -276,7 +276,7 @@ public:
|
||||
*
|
||||
* @return true if the share can host the VM
|
||||
*/
|
||||
bool test_capacity(HostShareCapacity &sr, string& error)
|
||||
bool test_capacity(HostShareCapacity &sr, std::string& error)
|
||||
{
|
||||
return host_share.test(sr, error);
|
||||
}
|
||||
@ -289,12 +289,12 @@ public:
|
||||
* @return true capacity was updated,
|
||||
* false if host has its own reservations
|
||||
*/
|
||||
bool update_reserved_capacity(const string& ccpu, const string& cmem);
|
||||
bool update_reserved_capacity(const std::string& ccpu, const std::string& cmem);
|
||||
|
||||
/**
|
||||
* Returns a copy of the VM IDs set
|
||||
*/
|
||||
set<int> get_vm_ids()
|
||||
std::set<int> get_vm_ids()
|
||||
{
|
||||
return vm_collection.clone();
|
||||
}
|
||||
@ -332,8 +332,8 @@ private:
|
||||
/**
|
||||
* Name of the IM and VMM drivers
|
||||
*/
|
||||
string im_mad_name;
|
||||
string vmm_mad_name;
|
||||
std::string im_mad_name;
|
||||
std::string vmm_mad_name;
|
||||
|
||||
/**
|
||||
* The Share represents the logical capacity associated with the host
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "HostMonitoringTemplate.h"
|
||||
#include "OneDB.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <sstream>
|
||||
|
||||
#include <vector>
|
||||
@ -43,13 +42,13 @@ public:
|
||||
* @return the oid assigned to the object or -1 in case of failure
|
||||
*/
|
||||
int allocate (
|
||||
int * oid,
|
||||
const string& hostname,
|
||||
const string& im_mad_name,
|
||||
const string& vmm_mad_name,
|
||||
int cluster_id,
|
||||
const string& cluster_name,
|
||||
string& error_str);
|
||||
int * oid,
|
||||
const std::string& hostname,
|
||||
const std::string& im_mad_name,
|
||||
const std::string& vmm_mad_name,
|
||||
int cluster_id,
|
||||
const std::string& cluster_name,
|
||||
std::string& error_str);
|
||||
|
||||
/**
|
||||
* Updates a Host in the data base. It also updates the previous state
|
||||
@ -90,7 +89,7 @@ public:
|
||||
* @param lock locks the Host mutex
|
||||
* @return a pointer to the Host, 0 if the Host could not be loaded
|
||||
*/
|
||||
Host * get(string name)
|
||||
Host * get(std::string name)
|
||||
{
|
||||
// The owner is set to -1, because it is not used in the key() method
|
||||
return static_cast<Host *>(PoolSQL::get(name,-1));
|
||||
@ -103,7 +102,7 @@ public:
|
||||
* @param lock locks the Host mutex
|
||||
* @return a pointer to the Host, 0 if the Host could not be loaded
|
||||
*/
|
||||
Host * get_ro(string name)
|
||||
Host * get_ro(std::string name)
|
||||
{
|
||||
// The owner is set to -1, because it is not used in the key() method
|
||||
return static_cast<Host *>(PoolSQL::get_ro(name,-1));
|
||||
@ -116,7 +115,7 @@ public:
|
||||
*
|
||||
* @return the key, a string
|
||||
*/
|
||||
string key(const string& name, int uid)
|
||||
std::string key(const std::string& name, int uid)
|
||||
{
|
||||
// Name is enough key because Hosts can't repeat names.
|
||||
return name;
|
||||
@ -130,8 +129,8 @@ public:
|
||||
{
|
||||
int rc;
|
||||
|
||||
ostringstream oss_host(one_db::host_db_bootstrap);
|
||||
ostringstream oss_monitor(one_db::host_monitor_db_bootstrap);
|
||||
std::ostringstream oss_host(one_db::host_db_bootstrap);
|
||||
std::ostringstream oss_monitor(one_db::host_monitor_db_bootstrap);
|
||||
|
||||
rc = _db->exec_local_wr(oss_host);
|
||||
rc += _db->exec_local_wr(oss_monitor);
|
||||
@ -194,7 +193,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int drop(PoolObjectSQL * objsql, string& error_msg)
|
||||
int drop(PoolObjectSQL * objsql, std::string& error_msg)
|
||||
{
|
||||
Host * host = static_cast<Host *>(objsql);
|
||||
|
||||
@ -233,7 +232,7 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int search(vector<int>& oids, const string& where)
|
||||
int search(std::vector<int>& oids, const std::string& where)
|
||||
{
|
||||
return PoolSQL::search(oids, one_db::host_table, where);
|
||||
};
|
||||
@ -247,7 +246,7 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump_monitoring(string& oss, const string& where);
|
||||
int dump_monitoring(std::string& oss, const std::string& where);
|
||||
|
||||
/**
|
||||
* Dumps the HOST monitoring information for a single HOST
|
||||
@ -257,9 +256,9 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump_monitoring(string& oss, int hostid)
|
||||
int dump_monitoring(std::string& oss, int hostid)
|
||||
{
|
||||
ostringstream filter;
|
||||
std::ostringstream filter;
|
||||
|
||||
filter << "oid = " << hostid;
|
||||
|
||||
|
@ -19,9 +19,6 @@
|
||||
|
||||
#include "ObjectXML.h"
|
||||
#include "Template.h"
|
||||
#include <time.h>
|
||||
#include <set>
|
||||
#include <map>
|
||||
|
||||
#include "HostSharePCI.h"
|
||||
#include "HostShareNUMA.h"
|
||||
@ -85,12 +82,12 @@ public:
|
||||
* @return true if the share can host the VM or it is the only one
|
||||
* configured
|
||||
*/
|
||||
bool test(HostShareCapacity& sr, string& error) const;
|
||||
bool test(HostShareCapacity& sr, std::string& error) const;
|
||||
|
||||
/**
|
||||
* Function to write a HostShare to an output stream
|
||||
*/
|
||||
friend ostream& operator<<(ostream& os, const HostShare& hs);
|
||||
friend std::ostream& operator<<(std::ostream& os, const HostShare& hs);
|
||||
|
||||
/**
|
||||
* Function to print the HostShare object into a string in
|
||||
@ -98,7 +95,7 @@ public:
|
||||
* @param xml the resulting XML string
|
||||
* @return a reference to the generated string
|
||||
*/
|
||||
string& to_xml(string& xml) const;
|
||||
std::string& to_xml(std::string& xml) const;
|
||||
|
||||
/**
|
||||
* Set the capacity attributes of the share. CPU and Memory may reserve some
|
||||
@ -116,7 +113,7 @@ public:
|
||||
*
|
||||
* NOTE: reserved strings will be modified
|
||||
*/
|
||||
void set_monitorization(Template& ht, string& rcpu, string& rmem);
|
||||
void set_monitorization(Template& ht, std::string& rcpu, std::string& rmem);
|
||||
|
||||
|
||||
/**
|
||||
@ -146,7 +143,7 @@ public:
|
||||
*
|
||||
* NOTE: reserved strings will be modified
|
||||
*/
|
||||
void update_capacity(Template& ht, string& rcpu, string& rmem);
|
||||
void update_capacity(Template& ht, std::string& rcpu, std::string& rmem);
|
||||
|
||||
/**
|
||||
* Return the number of running VMs in this host
|
||||
@ -193,9 +190,9 @@ private:
|
||||
*/
|
||||
bool test_compute(int cpu, long long mem, std::string &error) const;
|
||||
|
||||
bool test_pci(vector<VectorAttribute *>& pci_devs, string& error) const;
|
||||
bool test_pci(std::vector<VectorAttribute *>& pci_devs, std::string& error) const;
|
||||
|
||||
bool test_numa(HostShareCapacity &sr, string& error) const;
|
||||
bool test_numa(HostShareCapacity &sr, std::string& error) const;
|
||||
};
|
||||
|
||||
#endif /*HOST_SHARE_H_*/
|
||||
|
@ -48,11 +48,11 @@ struct HostShareCapacity
|
||||
long long mem;
|
||||
long long disk;
|
||||
|
||||
vector<VectorAttribute *> pci;
|
||||
std::vector<VectorAttribute *> pci;
|
||||
|
||||
VectorAttribute * topology;
|
||||
|
||||
vector<VectorAttribute *> nodes;
|
||||
std::vector<VectorAttribute *> nodes;
|
||||
};
|
||||
|
||||
#endif /*HOST_SHARE_CAPACITY_H_*/
|
||||
|
@ -122,7 +122,7 @@ public:
|
||||
/**
|
||||
* Prints the NUMA node to an output stream.
|
||||
*/
|
||||
friend ostream& operator<<(ostream& o, const HostShareNode& n);
|
||||
friend std::ostream& operator<<(std::ostream& o, const HostShareNode& n);
|
||||
|
||||
private:
|
||||
friend class HostShareNUMA;
|
||||
@ -337,7 +337,7 @@ public:
|
||||
* @param _vt vms_thread
|
||||
* @return 0 on success
|
||||
*/
|
||||
int from_xml_node(const vector<xmlNodePtr> &ns, unsigned int _vt);
|
||||
int from_xml_node(const std::vector<xmlNodePtr> &ns, unsigned int _vt);
|
||||
|
||||
/**
|
||||
* Updates the NUMA node information with monitor data
|
||||
@ -358,7 +358,7 @@ public:
|
||||
* @param xml the resulting XML string
|
||||
* @return a reference to the generated string
|
||||
*/
|
||||
string& to_xml(string& xml) const;
|
||||
std::string& to_xml(std::string& xml) const;
|
||||
|
||||
/**
|
||||
* Test if the virtual nodes and topology request fits in the host.
|
||||
@ -418,7 +418,7 @@ public:
|
||||
/**
|
||||
* Prints the NUMA nodes to an output stream.
|
||||
*/
|
||||
friend ostream& operator<<(ostream& o, const HostShareNUMA& n);
|
||||
friend std::ostream& operator<<(std::ostream& o, const HostShareNUMA& n);
|
||||
|
||||
HostShareNUMA& operator=(const HostShareNUMA& other);
|
||||
|
||||
|
@ -69,7 +69,7 @@ public:
|
||||
* @param devs list of requested devices by the VM.
|
||||
* @return true if all the devices are available.
|
||||
*/
|
||||
bool test(const vector<VectorAttribute *> &devs) const;
|
||||
bool test(const std::vector<VectorAttribute *> &devs) const;
|
||||
|
||||
/**
|
||||
* Assign the requested devices to the given VM. The assigned devices will
|
||||
@ -79,12 +79,12 @@ public:
|
||||
* assigned devices.
|
||||
* @param vmid of the VM
|
||||
*/
|
||||
void add(vector<VectorAttribute *> &devs, int vmid);
|
||||
void add(std::vector<VectorAttribute *> &devs, int vmid);
|
||||
|
||||
/**
|
||||
* Remove the VM assignment from the PCI device list
|
||||
*/
|
||||
void del(const vector<VectorAttribute *> &devs);
|
||||
void del(const std::vector<VectorAttribute *> &devs);
|
||||
|
||||
/**
|
||||
* Updates the PCI list with monitor data, it will create or
|
||||
@ -98,7 +98,7 @@ public:
|
||||
* Prints the PCI device list to an output stream. This function is used
|
||||
* for logging purposes and *not* for generating DB content.
|
||||
*/
|
||||
friend ostream& operator<<(ostream& o, const HostSharePCI& p);
|
||||
friend std::ostream& operator<<(std::ostream& o, const HostSharePCI& p);
|
||||
|
||||
HostSharePCI& operator=(const HostSharePCI& other);
|
||||
|
||||
@ -125,7 +125,7 @@ public:
|
||||
* in oned.conf)
|
||||
* @return -1 if wrong bus 0 on success
|
||||
*/
|
||||
static int set_pci_address(VectorAttribute * pci_device, const string& dbus);
|
||||
static int set_pci_address(VectorAttribute * pci_device, const std::string& dbus);
|
||||
|
||||
private:
|
||||
/**
|
||||
@ -151,12 +151,12 @@ private:
|
||||
|
||||
int vmid;
|
||||
|
||||
string address;
|
||||
std::string address;
|
||||
|
||||
VectorAttribute * attrs;
|
||||
};
|
||||
|
||||
map <string, PCIDevice *> pci_devices;
|
||||
std::map<std::string, PCIDevice *> pci_devices;
|
||||
};
|
||||
|
||||
#endif /*HOST_SHARE_PCI_H_*/
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
#include "Template.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* Host Template class, it represents the attributes of a Host
|
||||
@ -46,7 +45,7 @@ public:
|
||||
Template::decrypt(one_key, encrypted);
|
||||
}
|
||||
|
||||
static void parse_encrypted(vector<const SingleAttribute *>& ea)
|
||||
static void parse_encrypted(std::vector<const SingleAttribute *>& ea)
|
||||
{
|
||||
Template::parse_encrypted(ea, encrypted);
|
||||
}
|
||||
|
@ -210,17 +210,17 @@ private:
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static void _undefined(unique_ptr<ipam_msg_t> msg);
|
||||
static void _undefined(std::unique_ptr<ipam_msg_t> msg);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void _notify_request(unique_ptr<ipam_msg_t> msg);
|
||||
void _notify_request(std::unique_ptr<ipam_msg_t> msg);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static void _log(unique_ptr<ipam_msg_t> msg);
|
||||
static void _log(std::unique_ptr<ipam_msg_t> msg);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Action Listener interface
|
||||
|
@ -163,12 +163,12 @@ private:
|
||||
/**
|
||||
* XML representation for this request <AR>...</AR>
|
||||
*/
|
||||
string ar_xml;
|
||||
std::string ar_xml;
|
||||
|
||||
/**
|
||||
* Address request representation
|
||||
*/
|
||||
string address_xml;
|
||||
std::string address_xml;
|
||||
|
||||
/**
|
||||
* Parse a response from an IPAM driver OpenNebula template or XML
|
||||
|
@ -19,12 +19,9 @@
|
||||
|
||||
#include "PoolSQL.h"
|
||||
#include "ImageTemplate.h"
|
||||
#include "NebulaLog.h"
|
||||
#include "ObjectCollection.h"
|
||||
#include "Snapshots.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class VirtualMachineDisk;
|
||||
|
||||
/**
|
||||
@ -51,7 +48,7 @@ public:
|
||||
* @param ob the type
|
||||
* @return the string
|
||||
*/
|
||||
static string type_to_str(ImageType ob)
|
||||
static std::string type_to_str(ImageType ob)
|
||||
{
|
||||
switch (ob)
|
||||
{
|
||||
@ -70,7 +67,7 @@ public:
|
||||
* @param ob the type
|
||||
* @return the string
|
||||
*/
|
||||
static ImageType str_to_type(string& str_type);
|
||||
static ImageType str_to_type(std::string& str_type);
|
||||
|
||||
/**
|
||||
* Type of Disks (used by the VMM_MAD). Values: BLOCK, CDROM or
|
||||
@ -96,7 +93,7 @@ public:
|
||||
* @param ob the type
|
||||
* @return the string
|
||||
*/
|
||||
static string disk_type_to_str(DiskType ob)
|
||||
static std::string disk_type_to_str(DiskType ob)
|
||||
{
|
||||
switch (ob)
|
||||
{
|
||||
@ -119,7 +116,7 @@ public:
|
||||
* @param s_disk_type string representing the DiskTypr
|
||||
* @return the DiskType (defaults to FILE)
|
||||
*/
|
||||
static DiskType str_to_disk_type(string& s_disk_type);
|
||||
static DiskType str_to_disk_type(std::string& s_disk_type);
|
||||
|
||||
/**
|
||||
* Image State
|
||||
@ -144,7 +141,7 @@ public:
|
||||
* @param state The state
|
||||
* @return the string representation
|
||||
*/
|
||||
static string state_to_str(ImageState state)
|
||||
static std::string state_to_str(ImageState state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
@ -172,7 +169,7 @@ public:
|
||||
* @param xml the resulting XML string
|
||||
* @return a reference to the generated string
|
||||
*/
|
||||
string& to_xml(string& xml) const override;
|
||||
std::string& to_xml(std::string& xml) const override;
|
||||
|
||||
/**
|
||||
* Rebuilds the object from an xml formatted string
|
||||
@ -180,7 +177,7 @@ public:
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int from_xml(const string &xml_str) override;
|
||||
int from_xml(const std::string &xml_str) override;
|
||||
|
||||
/**
|
||||
* Returns true if the image is persistent
|
||||
@ -215,7 +212,7 @@ public:
|
||||
* Returns the source path of the image
|
||||
* @return source of image
|
||||
*/
|
||||
const string& get_source() const
|
||||
const std::string& get_source() const
|
||||
{
|
||||
return source;
|
||||
}
|
||||
@ -224,7 +221,7 @@ public:
|
||||
* Returns the original path of the image
|
||||
* @return path of image
|
||||
*/
|
||||
const string& get_path() const
|
||||
const std::string& get_path() const
|
||||
{
|
||||
return path;
|
||||
}
|
||||
@ -233,7 +230,7 @@ public:
|
||||
* Returns the fs_type for the image (defined for datablocks)
|
||||
* @return fs_type
|
||||
*/
|
||||
const string& get_fstype() const
|
||||
const std::string& get_fstype() const
|
||||
{
|
||||
return fs_type;
|
||||
}
|
||||
@ -251,7 +248,7 @@ public:
|
||||
/**
|
||||
* Sets the source path of the image
|
||||
*/
|
||||
void set_source(const string& _source)
|
||||
void set_source(const std::string& _source)
|
||||
{
|
||||
source = _source;
|
||||
}
|
||||
@ -345,7 +342,7 @@ public:
|
||||
return running_vms;
|
||||
}
|
||||
|
||||
set<int> get_running_ids() const
|
||||
std::set<int> get_running_ids() const
|
||||
{
|
||||
return vm_collection.clone();
|
||||
}
|
||||
@ -403,7 +400,7 @@ public:
|
||||
* @param _type the new type. It will be transformed to upper case
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int set_type(string& _type, string& error);
|
||||
int set_type(std::string& _type, std::string& error);
|
||||
|
||||
/**
|
||||
* Check if the image is used for saving_as a current one
|
||||
@ -421,9 +418,9 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int persistent(bool persis, string& error_str)
|
||||
int persistent(bool persis, std::string& error_str)
|
||||
{
|
||||
ostringstream oss;
|
||||
std::ostringstream oss;
|
||||
|
||||
if ((snapshots.size() > 0) && !persis)
|
||||
{
|
||||
@ -476,10 +473,10 @@ public:
|
||||
* into the disk
|
||||
*
|
||||
*/
|
||||
void disk_attribute(VirtualMachineDisk * disk,
|
||||
ImageType& img_type,
|
||||
string& dev_prefix,
|
||||
const vector<string>& inherit_attrs);
|
||||
void disk_attribute(VirtualMachineDisk * disk,
|
||||
ImageType& img_type,
|
||||
std::string& dev_prefix,
|
||||
const std::vector<std::string>& inherit_attrs);
|
||||
/**
|
||||
* Factory method for image templates
|
||||
*/
|
||||
@ -499,7 +496,7 @@ public:
|
||||
/**
|
||||
* Returns the Datastore name
|
||||
*/
|
||||
const string& get_ds_name() const
|
||||
const std::string& get_ds_name() const
|
||||
{
|
||||
return ds_name;
|
||||
};
|
||||
@ -507,7 +504,7 @@ public:
|
||||
/**
|
||||
* Updates the Datastore name
|
||||
*/
|
||||
void set_ds_name(const string& name)
|
||||
void set_ds_name(const std::string& name)
|
||||
{
|
||||
ds_name = name;
|
||||
};
|
||||
@ -518,7 +515,7 @@ public:
|
||||
* @param new_name Value for the NAME attribute
|
||||
* @return Pointer to the new tempalte 0 in case of success
|
||||
*/
|
||||
ImageTemplate * clone_template(const string& new_name) const;
|
||||
ImageTemplate * clone_template(const std::string& new_name) const;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Snapshots functions */
|
||||
@ -609,17 +606,17 @@ private:
|
||||
/**
|
||||
* Path to the image
|
||||
*/
|
||||
string source;
|
||||
std::string source;
|
||||
|
||||
/**
|
||||
* Original Path to the image (optional if source is given or datablock)
|
||||
*/
|
||||
string path;
|
||||
std::string path;
|
||||
|
||||
/**
|
||||
* File system type for the image (mandatory for datablocks)
|
||||
*/
|
||||
string fs_type;
|
||||
std::string fs_type;
|
||||
|
||||
/**
|
||||
* Size of the image in MB
|
||||
@ -655,7 +652,7 @@ private:
|
||||
/**
|
||||
* Datastore name
|
||||
*/
|
||||
string ds_name;
|
||||
std::string ds_name;
|
||||
|
||||
/**
|
||||
* Stores a collection with the VMs using the image
|
||||
@ -693,7 +690,7 @@ private:
|
||||
* @param error_str Returns the error reason, if any
|
||||
* @return 0 on success
|
||||
*/
|
||||
int insert_replace(SqlDB *db, bool replace, string& error_str);
|
||||
int insert_replace(SqlDB *db, bool replace, std::string& error_str);
|
||||
|
||||
/**
|
||||
* Bootstraps the database table(s) associated to the Image
|
||||
@ -706,7 +703,7 @@ private:
|
||||
* @param password
|
||||
* @return sha256 encrypted password
|
||||
*/
|
||||
static string sha256_digest(const string& pass);
|
||||
static std::string sha256_digest(const std::string& pass);
|
||||
|
||||
protected:
|
||||
|
||||
@ -714,12 +711,12 @@ protected:
|
||||
// Constructor
|
||||
// *************************************************************************
|
||||
|
||||
Image(int uid,
|
||||
int gid,
|
||||
const string& uname,
|
||||
const string& gname,
|
||||
int umask,
|
||||
ImageTemplate* img_template);
|
||||
Image(int uid,
|
||||
int gid,
|
||||
const std::string& uname,
|
||||
const std::string& gname,
|
||||
int umask,
|
||||
ImageTemplate* img_template);
|
||||
|
||||
virtual ~Image() = default;
|
||||
|
||||
@ -732,7 +729,7 @@ protected:
|
||||
* @param db pointer to the db
|
||||
* @return 0 on success
|
||||
*/
|
||||
int insert(SqlDB *db, string& error_str) override;
|
||||
int insert(SqlDB *db, std::string& error_str) override;
|
||||
|
||||
/**
|
||||
* Writes/updates the Images data fields in the database.
|
||||
|
@ -405,57 +405,57 @@ private:
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static void _undefined(unique_ptr<image_msg_t> msg);
|
||||
static void _undefined(std::unique_ptr<image_msg_t> msg);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void _stat(unique_ptr<image_msg_t> msg);
|
||||
void _stat(std::unique_ptr<image_msg_t> msg);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void _cp(unique_ptr<image_msg_t> msg);
|
||||
void _cp(std::unique_ptr<image_msg_t> msg);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void _clone(unique_ptr<image_msg_t> msg);
|
||||
void _clone(std::unique_ptr<image_msg_t> msg);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void _mkfs(unique_ptr<image_msg_t> msg);
|
||||
void _mkfs(std::unique_ptr<image_msg_t> msg);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void _rm(unique_ptr<image_msg_t> msg);
|
||||
void _rm(std::unique_ptr<image_msg_t> msg);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void _monitor(unique_ptr<image_msg_t> msg);
|
||||
void _monitor(std::unique_ptr<image_msg_t> msg);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void _snap_delete(unique_ptr<image_msg_t> msg);
|
||||
void _snap_delete(std::unique_ptr<image_msg_t> msg);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void _snap_revert(unique_ptr<image_msg_t> msg);
|
||||
void _snap_revert(std::unique_ptr<image_msg_t> msg);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void _snap_flatten(unique_ptr<image_msg_t> msg);
|
||||
void _snap_flatten(std::unique_ptr<image_msg_t> msg);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static void _log(unique_ptr<image_msg_t> msg);
|
||||
static void _log(std::unique_ptr<image_msg_t> msg);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Action Listener interface
|
||||
|
@ -23,16 +23,11 @@
|
||||
#include "Datastore.h"
|
||||
#include "OneDB.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <sstream>
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
class AuthRequest;
|
||||
class Snapshots;
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* The Image Pool class.
|
||||
@ -43,11 +38,11 @@ public:
|
||||
|
||||
ImagePool(
|
||||
SqlDB * db,
|
||||
const string& __default_type,
|
||||
const string& __default_dev_prefix,
|
||||
const string& __default_cdrom_dev_prefix,
|
||||
vector<const SingleAttribute *>& restricted_attrs,
|
||||
const vector<const SingleAttribute *>& _inherit_image_attrs);
|
||||
const std::string& __default_type,
|
||||
const std::string& __default_dev_prefix,
|
||||
const std::string& __default_cdrom_dev_prefix,
|
||||
std::vector<const SingleAttribute *>& restricted_attrs,
|
||||
const std::vector<const SingleAttribute *>& _inherit_image_attrs);
|
||||
|
||||
~ImagePool(){};
|
||||
|
||||
@ -76,21 +71,21 @@ public:
|
||||
int allocate (
|
||||
int uid,
|
||||
int gid,
|
||||
const string& uname,
|
||||
const string& gname,
|
||||
const std::string& uname,
|
||||
const std::string& gname,
|
||||
int umask,
|
||||
ImageTemplate * img_template,
|
||||
int ds_id,
|
||||
const string& ds_name,
|
||||
const std::string& ds_name,
|
||||
Image::DiskType disk_type,
|
||||
const string& ds_data,
|
||||
const std::string& ds_data,
|
||||
Datastore::DatastoreType ds_type,
|
||||
const string& ds_mad,
|
||||
const string& tm_mad,
|
||||
const string& extra_data,
|
||||
const std::string& ds_mad,
|
||||
const std::string& tm_mad,
|
||||
const std::string& extra_data,
|
||||
int source_img_id,
|
||||
int * oid,
|
||||
string& error_str);
|
||||
std::string& error_str);
|
||||
|
||||
/**
|
||||
** Function to get a Image from the pool, if the object is not in memory
|
||||
@ -124,7 +119,7 @@ public:
|
||||
*
|
||||
* @return a pointer to the object, 0 in case of failure
|
||||
*/
|
||||
Image * get(const string& name, int uid)
|
||||
Image * get(const std::string& name, int uid)
|
||||
{
|
||||
return static_cast<Image *>(PoolSQL::get(name,uid));
|
||||
};
|
||||
@ -137,7 +132,7 @@ public:
|
||||
*
|
||||
* @return a pointer to the object, 0 in case of failure
|
||||
*/
|
||||
Image * get_ro(const string& name, int uid)
|
||||
Image * get_ro(const std::string& name, int uid)
|
||||
{
|
||||
return static_cast<Image *>(PoolSQL::get_ro(name,uid));
|
||||
};
|
||||
@ -190,12 +185,12 @@ public:
|
||||
VirtualMachineDisk * disk,
|
||||
int disk_id,
|
||||
Image::ImageType& img_type,
|
||||
string& dev_prefix,
|
||||
std::string& dev_prefix,
|
||||
int uid,
|
||||
int& image_id,
|
||||
Snapshots ** snaps,
|
||||
bool attach,
|
||||
string& error_str);
|
||||
std::string& error_str);
|
||||
/**
|
||||
* Generates a DISK attribute for VM templates using the Image metadata
|
||||
*
|
||||
@ -208,17 +203,17 @@ public:
|
||||
int disk_id,
|
||||
int uid);
|
||||
|
||||
static const string& default_type()
|
||||
static const std::string& default_type()
|
||||
{
|
||||
return _default_type;
|
||||
};
|
||||
|
||||
static const string& default_dev_prefix()
|
||||
static const std::string& default_dev_prefix()
|
||||
{
|
||||
return _default_dev_prefix;
|
||||
};
|
||||
|
||||
static const string& default_cdrom_dev_prefix()
|
||||
static const std::string& default_cdrom_dev_prefix()
|
||||
{
|
||||
return _default_cdrom_dev_prefix;
|
||||
};
|
||||
@ -231,22 +226,22 @@ private:
|
||||
/**
|
||||
* Default image type
|
||||
**/
|
||||
static string _default_type;
|
||||
static std::string _default_type;
|
||||
|
||||
/**
|
||||
* Default device prefix
|
||||
**/
|
||||
static string _default_dev_prefix;
|
||||
static std::string _default_dev_prefix;
|
||||
|
||||
/**
|
||||
* Default device prefix for cdrom disks
|
||||
**/
|
||||
static string _default_cdrom_dev_prefix;
|
||||
static std::string _default_cdrom_dev_prefix;
|
||||
|
||||
/**
|
||||
* Image attributes to be inherited into the VM disk
|
||||
*/
|
||||
vector<string> inherit_attrs;
|
||||
std::vector<std::string> inherit_attrs;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Pool Attributes
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
#include "Template.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* Image Template class, it represents the attributes of an Image
|
||||
*/
|
||||
@ -50,17 +48,17 @@ public:
|
||||
// -------------------------------------------------------------------------
|
||||
// Restricted attributes interface implementation
|
||||
// -------------------------------------------------------------------------
|
||||
virtual bool check_restricted(string& rs_attr, const Template* base)
|
||||
virtual bool check_restricted(std::string& rs_attr, const Template* base)
|
||||
{
|
||||
return Template::check_restricted(rs_attr, base, restricted);
|
||||
}
|
||||
|
||||
virtual bool check_restricted(string& rs_attr)
|
||||
virtual bool check_restricted(std::string& rs_attr)
|
||||
{
|
||||
return Template::check_restricted(rs_attr, restricted);
|
||||
}
|
||||
|
||||
static void parse_restricted(vector<const SingleAttribute *>& ra)
|
||||
static void parse_restricted(std::vector<const SingleAttribute *>& ra)
|
||||
{
|
||||
Template::parse_restricted(ra, restricted);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
InformationManager(
|
||||
HostPool * _hpool,
|
||||
VirtualMachinePool * _vmpool,
|
||||
const string& mad_location)
|
||||
const std::string& mad_location)
|
||||
: DriverManager(mad_location)
|
||||
, hpool(_hpool)
|
||||
, vmpool(_vmpool)
|
||||
@ -74,7 +74,9 @@ public:
|
||||
* @param name of the host
|
||||
* @param im_mad the driver name
|
||||
*/
|
||||
void stop_monitor(int hid, const string& name, const string& im_mad);
|
||||
void stop_monitor(int hid,
|
||||
const std::string& name,
|
||||
const std::string& im_mad);
|
||||
|
||||
/**
|
||||
* Starts the monitor process on the host
|
||||
@ -103,22 +105,22 @@ protected:
|
||||
/**
|
||||
* Received undefined message -> print error
|
||||
*/
|
||||
static void _undefined(unique_ptr<im_msg_t> msg);
|
||||
static void _undefined(std::unique_ptr<im_msg_t> msg);
|
||||
|
||||
/**
|
||||
* Message HOST_STATE update from monitor
|
||||
*/
|
||||
void _host_state(unique_ptr<im_msg_t> msg);
|
||||
void _host_state(std::unique_ptr<im_msg_t> msg);
|
||||
|
||||
/**
|
||||
* Message HOST_SYSTEM update from monitor
|
||||
*/
|
||||
void _host_system(unique_ptr<im_msg_t> msg);
|
||||
void _host_system(std::unique_ptr<im_msg_t> msg);
|
||||
|
||||
/**
|
||||
* Message VM_STATE from monitor
|
||||
*/
|
||||
void _vm_state(unique_ptr<im_msg_t> msg);
|
||||
void _vm_state(std::unique_ptr<im_msg_t> msg);
|
||||
|
||||
private:
|
||||
/**
|
||||
|
@ -18,13 +18,7 @@
|
||||
#define LIFE_CYCLE_MANAGER_H_
|
||||
|
||||
#include "ActionManager.h"
|
||||
#include "VirtualMachinePool.h"
|
||||
#include "HostPool.h"
|
||||
#include "ImagePool.h"
|
||||
#include "SecurityGroupPool.h"
|
||||
#include "ClusterPool.h"
|
||||
|
||||
using namespace std;
|
||||
#include "NebulaLog.h"
|
||||
|
||||
extern "C" void * lcm_action_loop(void *arg);
|
||||
|
||||
@ -33,6 +27,12 @@ class TransferManager;
|
||||
class DispatchManager;
|
||||
class VirtualMachineManager;
|
||||
class ImageManager;
|
||||
class ClusterPool;
|
||||
class HostPool;
|
||||
class ImagePool;
|
||||
class SecurityGroupPool;
|
||||
class VirtualMachinePool;
|
||||
class VirtualMachine;
|
||||
struct RequestAttributes;
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -24,8 +24,6 @@
|
||||
|
||||
#include "PoolObjectSQL.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* The Logger class is an interface used by OpenNebula components to log
|
||||
* messages
|
||||
@ -111,9 +109,9 @@ protected:
|
||||
class FileLog : public Log
|
||||
{
|
||||
public:
|
||||
FileLog(const string& file_name,
|
||||
const MessageType level = WARNING,
|
||||
ios_base::openmode mode = ios_base::app);
|
||||
FileLog(const std::string& file_name,
|
||||
const MessageType level = WARNING,
|
||||
std::ios_base::openmode mode = std::ios_base::app);
|
||||
|
||||
virtual ~FileLog();
|
||||
|
||||
@ -123,7 +121,7 @@ public:
|
||||
const char * message);
|
||||
|
||||
private:
|
||||
string log_file_name;
|
||||
std::string log_file_name;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -132,9 +130,9 @@ private:
|
||||
class FileLogTS : public FileLog
|
||||
{
|
||||
public:
|
||||
FileLogTS(const string& file_name,
|
||||
const MessageType level = WARNING,
|
||||
ios_base::openmode mode = ios_base::app)
|
||||
FileLogTS(const std::string& file_name,
|
||||
const MessageType level = WARNING,
|
||||
std::ios_base::openmode mode = std::ios_base::app)
|
||||
:FileLog(file_name,level,mode)
|
||||
{
|
||||
pthread_mutex_init(&log_mutex,0);
|
||||
@ -183,7 +181,7 @@ public:
|
||||
const char * message);
|
||||
|
||||
private:
|
||||
string resource_label;
|
||||
std::string resource_label;
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -195,8 +193,8 @@ private:
|
||||
class SysLog : public Log
|
||||
{
|
||||
public:
|
||||
SysLog(const MessageType level,
|
||||
const string& label);
|
||||
SysLog(const MessageType level,
|
||||
const std::string& label);
|
||||
|
||||
SysLog(const MessageType level,
|
||||
int oid,
|
||||
@ -232,7 +230,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
string resource_label;
|
||||
std::string resource_label;
|
||||
};
|
||||
|
||||
#endif /* _LOG_H_ */
|
||||
|
@ -169,37 +169,37 @@ public:
|
||||
* This function replicates the DB changes on followers before updating
|
||||
* the DB state
|
||||
*/
|
||||
int exec_wr(ostringstream& cmd)
|
||||
int exec_wr(std::ostringstream& cmd)
|
||||
{
|
||||
return _exec_wr(cmd, UINT64_MAX);
|
||||
}
|
||||
|
||||
int exec_wr(ostringstream& cmd, Callbackable* obj)
|
||||
int exec_wr(std::ostringstream& cmd, Callbackable* obj)
|
||||
{
|
||||
return exec_wr(cmd);
|
||||
}
|
||||
|
||||
int exec_federated_wr(ostringstream& cmd)
|
||||
int exec_federated_wr(std::ostringstream& cmd)
|
||||
{
|
||||
return _exec_wr(cmd, 0);
|
||||
}
|
||||
|
||||
int exec_federated_wr(ostringstream& cmd, uint64_t index)
|
||||
int exec_federated_wr(std::ostringstream& cmd, uint64_t index)
|
||||
{
|
||||
return _exec_wr(cmd, index);
|
||||
}
|
||||
|
||||
int exec_local_wr(ostringstream& cmd)
|
||||
int exec_local_wr(std::ostringstream& cmd)
|
||||
{
|
||||
return db->exec_local_wr(cmd);
|
||||
}
|
||||
|
||||
int exec_rd(ostringstream& cmd, Callbackable* obj)
|
||||
int exec_rd(std::ostringstream& cmd, Callbackable* obj)
|
||||
{
|
||||
return db->exec_rd(cmd, obj);
|
||||
}
|
||||
|
||||
char * escape_str(const string& str)
|
||||
char * escape_str(const std::string& str)
|
||||
{
|
||||
return db->escape_str(str);
|
||||
}
|
||||
@ -349,7 +349,7 @@ private:
|
||||
* @param federated UINT64_MAX not federated (fed_index = UINT64_MAX), 0
|
||||
* generate fed index (fed_index = index), > 0 set (fed_index = federated)
|
||||
*/
|
||||
int _exec_wr(ostringstream& cmd, uint64_t federated);
|
||||
int _exec_wr(std::ostringstream& cmd, uint64_t federated);
|
||||
|
||||
/**
|
||||
* Applies the SQL command of the given record to the database. The
|
||||
@ -397,19 +397,19 @@ public:
|
||||
|
||||
virtual ~FedLogDB(){};
|
||||
|
||||
int exec_wr(ostringstream& cmd);
|
||||
int exec_wr(std::ostringstream& cmd);
|
||||
|
||||
int exec_local_wr(ostringstream& cmd)
|
||||
int exec_local_wr(std::ostringstream& cmd)
|
||||
{
|
||||
return _logdb->exec_local_wr(cmd);
|
||||
}
|
||||
|
||||
int exec_rd(ostringstream& cmd, Callbackable* obj)
|
||||
int exec_rd(std::ostringstream& cmd, Callbackable* obj)
|
||||
{
|
||||
return _logdb->exec_rd(cmd, obj);
|
||||
}
|
||||
|
||||
char * escape_str(const string& str)
|
||||
char * escape_str(const std::string& str)
|
||||
{
|
||||
return _logdb->escape_str(str);
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
* @param xml the resulting XML string
|
||||
* @return a reference to the generated string
|
||||
*/
|
||||
string& to_xml(string& xml) const override;
|
||||
std::string& to_xml(std::string& xml) const override;
|
||||
|
||||
/**
|
||||
* Rebuilds the object from an xml formatted string
|
||||
@ -43,7 +43,7 @@ public:
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int from_xml(const string &xml_str) override;
|
||||
int from_xml(const std::string &xml_str) override;
|
||||
|
||||
/**
|
||||
* Adds this marketplace app's ID to the set.
|
||||
@ -68,7 +68,7 @@ public:
|
||||
/**
|
||||
* Returns a copy of the Image IDs set
|
||||
*/
|
||||
set<int> get_marketapp_ids()
|
||||
std::set<int> get_marketapp_ids()
|
||||
{
|
||||
return marketapps.clone();
|
||||
}
|
||||
@ -77,7 +77,7 @@ public:
|
||||
* Retrieves marketplace mad name
|
||||
* @return string mp mad name
|
||||
*/
|
||||
const string& get_market_mad() const
|
||||
const std::string& get_market_mad() const
|
||||
{
|
||||
return market_mad;
|
||||
};
|
||||
@ -141,7 +141,7 @@ private:
|
||||
/**
|
||||
* Name of the marketplace driver used to import apps
|
||||
*/
|
||||
string market_mad;
|
||||
std::string market_mad;
|
||||
|
||||
/**
|
||||
* Total capacity in MB
|
||||
@ -179,8 +179,8 @@ private:
|
||||
MarketPlace(
|
||||
int uid,
|
||||
int gid,
|
||||
const string& uname,
|
||||
const string& gname,
|
||||
const std::string& uname,
|
||||
const std::string& gname,
|
||||
int umask,
|
||||
MarketPlaceTemplate* mp_template);
|
||||
|
||||
@ -196,7 +196,7 @@ private:
|
||||
* @param error_str describing the error
|
||||
* @return 0 on success;
|
||||
*/
|
||||
int parse_template(string& error_str);
|
||||
int parse_template(std::string& error_str);
|
||||
|
||||
/**
|
||||
* Execute an INSERT or REPLACE Sql query.
|
||||
@ -205,7 +205,7 @@ private:
|
||||
* @param error_str Returns the error reason, if any
|
||||
* @return 0 one success
|
||||
*/
|
||||
int insert_replace(SqlDB *db, bool replace, string& error_str);
|
||||
int insert_replace(SqlDB *db, bool replace, std::string& error_str);
|
||||
|
||||
/**
|
||||
* Bootstraps the database table(s) associated to the MarketPlace
|
||||
@ -218,7 +218,7 @@ private:
|
||||
* @param db pointer to the db
|
||||
* @return 0 on success
|
||||
*/
|
||||
int insert(SqlDB *db, string& error_str) override;
|
||||
int insert(SqlDB *db, std::string& error_str) override;
|
||||
|
||||
/**
|
||||
* Writes/updates the MarketPlace's data fields in the database.
|
||||
@ -227,7 +227,7 @@ private:
|
||||
*/
|
||||
int update(SqlDB *db) override
|
||||
{
|
||||
string error_str;
|
||||
std::string error_str;
|
||||
return insert_replace(db, true, error_str);
|
||||
}
|
||||
|
||||
@ -243,7 +243,7 @@ private:
|
||||
* Verify the proper definition of the Market by checking the
|
||||
* attributes of the MARKET_MAD_CONF parameter
|
||||
*/
|
||||
int set_market_mad(string &tm_mad, string &error_str);
|
||||
int set_market_mad(std::string &tm_mad, std::string &error_str);
|
||||
|
||||
/**
|
||||
* Child classes can process the new template set with replace_template or
|
||||
@ -251,7 +251,7 @@ private:
|
||||
* @param error string describing the error if any
|
||||
* @return 0 on success
|
||||
*/
|
||||
int post_update_template(string& error) override;
|
||||
int post_update_template(std::string& error) override;
|
||||
};
|
||||
|
||||
#endif /*MARKETPLACE_H*/
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
MONITOR = 3
|
||||
};
|
||||
|
||||
static int action_from_str(string& st, Action& action)
|
||||
static int action_from_str(std::string& st, Action& action)
|
||||
{
|
||||
if (st == "create")
|
||||
{
|
||||
@ -79,7 +79,7 @@ public:
|
||||
* @param state The state
|
||||
* @return the string representation
|
||||
*/
|
||||
static string state_to_str(State state)
|
||||
static std::string state_to_str(State state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
@ -108,7 +108,7 @@ public:
|
||||
* @param ob the type
|
||||
* @return the string
|
||||
*/
|
||||
static string type_to_str(Type ob)
|
||||
static std::string type_to_str(Type ob)
|
||||
{
|
||||
switch (ob)
|
||||
{
|
||||
@ -125,14 +125,14 @@ public:
|
||||
* @param str_type string representing the type
|
||||
* @return the MarketPlaceType
|
||||
*/
|
||||
static Type str_to_type(string& str_type);
|
||||
static Type str_to_type(std::string& str_type);
|
||||
|
||||
/**
|
||||
* Function to print the MarketPlaceApp object into a string in XML format
|
||||
* @param xml the resulting XML string
|
||||
* @return a reference to the generated string
|
||||
*/
|
||||
string& to_xml(std::string& xml) const override;
|
||||
std::string& to_xml(std::string& xml) const override;
|
||||
|
||||
/**
|
||||
* Rebuilds the object from an xml formatted string
|
||||
@ -209,12 +209,12 @@ public:
|
||||
return origin_id;
|
||||
};
|
||||
|
||||
const string& get_source() const
|
||||
const std::string& get_source() const
|
||||
{
|
||||
return source;
|
||||
}
|
||||
|
||||
const string& get_md5() const
|
||||
const std::string& get_md5() const
|
||||
{
|
||||
return md5;
|
||||
}
|
||||
@ -224,7 +224,7 @@ public:
|
||||
return size_mb;
|
||||
}
|
||||
|
||||
const string& get_format() const
|
||||
const std::string& get_format() const
|
||||
{
|
||||
return format;
|
||||
}
|
||||
@ -367,7 +367,7 @@ private:
|
||||
* @param error_str describing the error
|
||||
* @return 0 on success;
|
||||
*/
|
||||
int parse_template(string& error_str);
|
||||
int parse_template(std::string& error_str);
|
||||
|
||||
/**
|
||||
* Execute an INSERT or REPLACE Sql query.
|
||||
|
@ -191,7 +191,7 @@ private:
|
||||
/**
|
||||
* Hash to store the number of times an app was missing from monitor data
|
||||
*/
|
||||
map<int, int> map_check;
|
||||
std::map<int, int> map_check;
|
||||
|
||||
/**
|
||||
* Max number of monitor that an app may be missing before deleting it
|
||||
|
@ -218,11 +218,11 @@ private:
|
||||
// -------------------------------------------------------------------------
|
||||
// Protocol implementation, procesing messages from driver
|
||||
// -------------------------------------------------------------------------
|
||||
static void _undefined(unique_ptr<market_msg_t> msg);
|
||||
void _import(unique_ptr<market_msg_t> msg);
|
||||
void _delete(unique_ptr<market_msg_t> msg);
|
||||
void _monitor(unique_ptr<market_msg_t> msg);
|
||||
static void _log(unique_ptr<market_msg_t> msg);
|
||||
static void _undefined(std::unique_ptr<market_msg_t> msg);
|
||||
void _import(std::unique_ptr<market_msg_t> msg);
|
||||
void _delete(std::unique_ptr<market_msg_t> msg);
|
||||
void _monitor(std::unique_ptr<market_msg_t> msg);
|
||||
static void _log(std::unique_ptr<market_msg_t> msg);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Action Listener interface
|
||||
|
@ -95,7 +95,7 @@ private:
|
||||
/**
|
||||
* The MySql connection pool handler
|
||||
*/
|
||||
queue<MYSQL *> db_connect;
|
||||
std::queue<MYSQL *> db_connect;
|
||||
|
||||
/**
|
||||
* Cached DB connection to escape strings (it uses the server character set)
|
||||
|
@ -280,7 +280,7 @@ public:
|
||||
* not defined the nebula location is "/".
|
||||
* @return the nebula location.
|
||||
*/
|
||||
const string& get_nebula_location()
|
||||
const std::string& get_nebula_location()
|
||||
{
|
||||
return nebula_location;
|
||||
};
|
||||
@ -291,7 +291,7 @@ public:
|
||||
* /usr/lib/one/mads.
|
||||
* @return the mad execs location.
|
||||
*/
|
||||
const string& get_mad_location()
|
||||
const std::string& get_mad_location()
|
||||
{
|
||||
return mad_location;
|
||||
};
|
||||
@ -301,7 +301,7 @@ public:
|
||||
* defined this path points to $ONE_LOCATION/etc, otherwise it is /etc/one
|
||||
* @return the mad defaults location.
|
||||
*/
|
||||
const string& get_defaults_location()
|
||||
const std::string& get_defaults_location()
|
||||
{
|
||||
return etc_location;
|
||||
};
|
||||
@ -312,7 +312,7 @@ public:
|
||||
* otherwise it is /var/log/one.
|
||||
* @return the log location.
|
||||
*/
|
||||
const string& get_log_location()
|
||||
const std::string& get_log_location()
|
||||
{
|
||||
return log_location;
|
||||
};
|
||||
@ -322,7 +322,7 @@ public:
|
||||
* points to $ONE_LOCATION/var, otherwise it is /var/lib/one.
|
||||
* @return the log location.
|
||||
*/
|
||||
const string& get_var_location()
|
||||
const std::string& get_var_location()
|
||||
{
|
||||
return var_location;
|
||||
};
|
||||
@ -332,7 +332,7 @@ public:
|
||||
* points to $ONE_LOCATION/share, otherwise it is /usr/share/one.
|
||||
* @return the log location.
|
||||
*/
|
||||
const string& get_share_location()
|
||||
const std::string& get_share_location()
|
||||
{
|
||||
return share_location;
|
||||
};
|
||||
@ -341,7 +341,7 @@ public:
|
||||
*
|
||||
*
|
||||
*/
|
||||
void get_ds_location(string& dsloc);
|
||||
void get_ds_location(std::string& dsloc);
|
||||
|
||||
/**
|
||||
* Returns the default vms location. When ONE_LOCATION is defined this path
|
||||
@ -350,7 +350,7 @@ public:
|
||||
* logs (in self-contained mode only)
|
||||
* @return the vms location.
|
||||
*/
|
||||
const string& get_vms_location()
|
||||
const std::string& get_vms_location()
|
||||
{
|
||||
return vms_location;
|
||||
};
|
||||
@ -363,13 +363,13 @@ public:
|
||||
* /var/log/one/$VM_ID.log
|
||||
* @return the log location for the VM.
|
||||
*/
|
||||
string get_vm_log_filename(int oid);
|
||||
std::string get_vm_log_filename(int oid);
|
||||
|
||||
/**
|
||||
* Returns the name of the host running oned
|
||||
* @return the name
|
||||
*/
|
||||
const string& get_nebula_hostname()
|
||||
const std::string& get_nebula_hostname()
|
||||
{
|
||||
return hostname;
|
||||
};
|
||||
@ -378,9 +378,9 @@ public:
|
||||
* Returns the version of oned
|
||||
* @return the version
|
||||
*/
|
||||
static string version()
|
||||
static std::string version()
|
||||
{
|
||||
ostringstream os;
|
||||
std::ostringstream os;
|
||||
os << "OpenNebula " << code_version();
|
||||
os << " (" << GITVERSION << ")";
|
||||
|
||||
@ -391,7 +391,7 @@ public:
|
||||
* Returns the version of oned
|
||||
* @return
|
||||
*/
|
||||
static string code_version()
|
||||
static std::string code_version()
|
||||
{
|
||||
return "5.13.80"; // bump version
|
||||
}
|
||||
@ -400,7 +400,7 @@ public:
|
||||
* Version needed for the DB, shared tables
|
||||
* @return
|
||||
*/
|
||||
static string shared_db_version()
|
||||
static std::string shared_db_version()
|
||||
{
|
||||
return "5.12.0";
|
||||
}
|
||||
@ -409,7 +409,7 @@ public:
|
||||
* Version needed for the DB, local tables
|
||||
* @return
|
||||
*/
|
||||
static string local_db_version()
|
||||
static std::string local_db_version()
|
||||
{
|
||||
return "5.12.0";
|
||||
}
|
||||
@ -462,7 +462,7 @@ public:
|
||||
return server_id;
|
||||
};
|
||||
|
||||
const string& get_master_oned()
|
||||
const std::string& get_master_oned()
|
||||
{
|
||||
return master_oned;
|
||||
};
|
||||
@ -477,7 +477,7 @@ public:
|
||||
* @param value of the attribute
|
||||
*/
|
||||
template<typename T>
|
||||
void get_configuration_attribute(const string& name, T& value) const
|
||||
void get_configuration_attribute(const std::string& name, T& value) const
|
||||
{
|
||||
nebula_configuration->get(name, value);
|
||||
};
|
||||
@ -570,7 +570,7 @@ public:
|
||||
/**
|
||||
* Gets a TM configuration attribute
|
||||
*/
|
||||
int get_tm_conf_attribute(const string& tm_name,
|
||||
int get_tm_conf_attribute(const std::string& tm_name,
|
||||
const VectorAttribute* &value) const
|
||||
{
|
||||
return get_conf_attribute("TM_MAD_CONF", tm_name, value);
|
||||
@ -579,7 +579,7 @@ public:
|
||||
/**
|
||||
* Gets a Market configuration attribute
|
||||
*/
|
||||
int get_market_conf_attribute( const string& mk_name,
|
||||
int get_market_conf_attribute( const std::string& mk_name,
|
||||
const VectorAttribute* &value) const
|
||||
{
|
||||
return get_conf_attribute("MARKET_MAD_CONF", mk_name, value);
|
||||
@ -589,7 +589,8 @@ public:
|
||||
* Gets an Auth driver configuration attribute
|
||||
*/
|
||||
template<typename T>
|
||||
int get_auth_conf_attribute(const string& driver, const string& attribute,
|
||||
int get_auth_conf_attribute(const std::string& driver,
|
||||
const std::string& attribute,
|
||||
T& value) const
|
||||
{
|
||||
return get_conf_attribute("AUTH_MAD_CONF", driver, attribute, value);
|
||||
@ -608,9 +609,9 @@ public:
|
||||
* Gets an XML document with all of the configuration attributes
|
||||
* @return the XML
|
||||
*/
|
||||
string get_configuration_xml() const
|
||||
std::string get_configuration_xml() const
|
||||
{
|
||||
string xml;
|
||||
std::string xml;
|
||||
return nebula_configuration->to_xml(xml);
|
||||
};
|
||||
|
||||
@ -618,7 +619,7 @@ public:
|
||||
* Gets the database backend type
|
||||
* @return database backend type
|
||||
*/
|
||||
string get_db_backend() const
|
||||
const std::string& get_db_backend() const
|
||||
{
|
||||
return db_backend_type;
|
||||
}
|
||||
@ -643,7 +644,7 @@ public:
|
||||
*
|
||||
* @return 0 if success
|
||||
*/
|
||||
int set_default_user_quota(Template *tmpl, string& error)
|
||||
int set_default_user_quota(Template *tmpl, std::string& error)
|
||||
{
|
||||
int rc = default_user_quota.set(tmpl, error);
|
||||
|
||||
@ -671,7 +672,7 @@ public:
|
||||
*
|
||||
* @return 0 if success
|
||||
*/
|
||||
int set_default_group_quota(Template *tmpl, string& error)
|
||||
int set_default_group_quota(Template *tmpl, std::string& error)
|
||||
{
|
||||
int rc = default_group_quota.set(tmpl, error);
|
||||
|
||||
@ -692,7 +693,7 @@ public:
|
||||
* @param cb Callback that will receive the attribute in XML
|
||||
* @return 0 on success
|
||||
*/
|
||||
int select_sys_attribute(const string& attr_name, string& attr_xml)
|
||||
int select_sys_attribute(const std::string& attr_name, std::string& attr_xml)
|
||||
{
|
||||
return system_db->select_sys_attribute(attr_name, attr_xml);
|
||||
};
|
||||
@ -703,9 +704,9 @@ public:
|
||||
* @return 0 on success
|
||||
*/
|
||||
int insert_sys_attribute(
|
||||
const string& attr_name,
|
||||
const string& xml_attr,
|
||||
string& error_str)
|
||||
const std::string& attr_name,
|
||||
const std::string& xml_attr,
|
||||
std::string& error_str)
|
||||
{
|
||||
return system_db->insert_sys_attribute(attr_name, xml_attr, error_str);
|
||||
};
|
||||
@ -716,9 +717,9 @@ public:
|
||||
* @return 0 on success
|
||||
*/
|
||||
int update_sys_attribute(
|
||||
const string& attr_name,
|
||||
const string& xml_attr,
|
||||
string& error_str)
|
||||
const std::string& attr_name,
|
||||
const std::string& xml_attr,
|
||||
std::string& error_str)
|
||||
{
|
||||
return system_db->update_sys_attribute(attr_name, xml_attr, error_str);
|
||||
};
|
||||
@ -788,17 +789,17 @@ private:
|
||||
// Environment variables
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
string nebula_location;
|
||||
std::string nebula_location;
|
||||
|
||||
string mad_location;
|
||||
string etc_location;
|
||||
string log_location;
|
||||
string var_location;
|
||||
string remotes_location;
|
||||
string vms_location;
|
||||
string share_location;
|
||||
std::string mad_location;
|
||||
std::string etc_location;
|
||||
std::string log_location;
|
||||
std::string var_location;
|
||||
std::string remotes_location;
|
||||
std::string vms_location;
|
||||
std::string share_location;
|
||||
|
||||
string hostname;
|
||||
std::string hostname;
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Configuration
|
||||
@ -810,12 +811,12 @@ private:
|
||||
// Federation - HA
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
bool federation_enabled;
|
||||
bool federation_master;
|
||||
bool cache;
|
||||
int zone_id;
|
||||
int server_id;
|
||||
string master_oned;
|
||||
bool federation_enabled;
|
||||
bool federation_master;
|
||||
bool cache;
|
||||
int zone_id;
|
||||
int server_id;
|
||||
std::string master_oned;
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Default quotas
|
||||
@ -828,8 +829,8 @@ private:
|
||||
// The system database
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
SystemDB * system_db;
|
||||
string db_backend_type;
|
||||
SystemDB * system_db;
|
||||
std::string db_backend_type;
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Nebula Pools
|
||||
|
@ -22,8 +22,6 @@
|
||||
#include <sstream>
|
||||
#include <syslog.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* The Logger class for the OpenNebula components
|
||||
*/
|
||||
@ -43,11 +41,11 @@ public:
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
static void init_log_system(
|
||||
LogType ltype,
|
||||
Log::MessageType clevel,
|
||||
const char * filename,
|
||||
ios_base::openmode mode,
|
||||
const string& daemon)
|
||||
LogType ltype,
|
||||
Log::MessageType clevel,
|
||||
const char * filename,
|
||||
std::ios_base::openmode mode,
|
||||
const std::string& daemon)
|
||||
{
|
||||
_log_type = ltype;
|
||||
|
||||
@ -68,7 +66,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static LogType str_to_type(string& type)
|
||||
static LogType str_to_type(std::string& type)
|
||||
{
|
||||
one_util::toupper(type);
|
||||
|
||||
@ -102,9 +100,9 @@ public:
|
||||
};
|
||||
|
||||
static void log(
|
||||
const char * module,
|
||||
const Log::MessageType type,
|
||||
const ostringstream& message)
|
||||
const char * module,
|
||||
const Log::MessageType type,
|
||||
const std::ostringstream& message)
|
||||
{
|
||||
logger->log(module,type,message.str().c_str());
|
||||
};
|
||||
@ -112,37 +110,37 @@ public:
|
||||
static void log(
|
||||
const char * module,
|
||||
const Log::MessageType type,
|
||||
const string& message)
|
||||
const std::string& message)
|
||||
{
|
||||
logger->log(module,type,message.c_str());
|
||||
};
|
||||
|
||||
static void error(const char* module, const string& msg)
|
||||
static void error(const char* module, const std::string& msg)
|
||||
{
|
||||
logger->log(module, Log::ERROR, msg.c_str());
|
||||
}
|
||||
|
||||
static void warn(const char* module, const string& msg)
|
||||
static void warn(const char* module, const std::string& msg)
|
||||
{
|
||||
logger->log(module, Log::WARNING, msg.c_str());
|
||||
}
|
||||
|
||||
static void info(const char* module, const string& msg)
|
||||
static void info(const char* module, const std::string& msg)
|
||||
{
|
||||
logger->log(module, Log::INFO, msg.c_str());
|
||||
}
|
||||
|
||||
static void debug(const char* module, const string& msg)
|
||||
static void debug(const char* module, const std::string& msg)
|
||||
{
|
||||
logger->log(module, Log::DEBUG, msg.c_str());
|
||||
}
|
||||
|
||||
static void ddebug(const char* module, const string& msg)
|
||||
static void ddebug(const char* module, const std::string& msg)
|
||||
{
|
||||
logger->log(module, Log::DDEBUG, msg.c_str());
|
||||
}
|
||||
|
||||
static void dddebug(const char* module, const string& msg)
|
||||
static void dddebug(const char* module, const std::string& msg)
|
||||
{
|
||||
logger->log(module, Log::DDDEBUG, msg.c_str());
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public:
|
||||
* not defined the nebula location is "/".
|
||||
* @return the nebula location.
|
||||
*/
|
||||
const string& get_nebula_location() const
|
||||
const std::string& get_nebula_location() const
|
||||
{
|
||||
return nebula_location;
|
||||
};
|
||||
@ -73,7 +73,7 @@ public:
|
||||
* /usr/lib/one/mads.
|
||||
* @return the mad execs location.
|
||||
*/
|
||||
const string& get_mad_location() const
|
||||
const std::string& get_mad_location() const
|
||||
{
|
||||
return mad_location;
|
||||
};
|
||||
@ -83,7 +83,7 @@ public:
|
||||
* defined this path points to $ONE_LOCATION/etc, otherwise it is /etc/one
|
||||
* @return the mad defaults location.
|
||||
*/
|
||||
const string& get_defaults_location() const
|
||||
const std::string& get_defaults_location() const
|
||||
{
|
||||
return etc_location;
|
||||
};
|
||||
@ -94,7 +94,7 @@ public:
|
||||
* otherwise it is /var/log/one.
|
||||
* @return the log location.
|
||||
*/
|
||||
const string& get_log_location() const
|
||||
const std::string& get_log_location() const
|
||||
{
|
||||
return log_location;
|
||||
};
|
||||
@ -104,7 +104,7 @@ public:
|
||||
* points to $ONE_LOCATION/var, otherwise it is /var/lib/one.
|
||||
* @return the log location.
|
||||
*/
|
||||
const string& get_var_location() const
|
||||
const std::string& get_var_location() const
|
||||
{
|
||||
return var_location;
|
||||
};
|
||||
@ -116,7 +116,7 @@ public:
|
||||
* logs (in self-contained mode only)
|
||||
* @return the vms location.
|
||||
*/
|
||||
const string& get_vms_location() const
|
||||
const std::string& get_vms_location() const
|
||||
{
|
||||
return vms_location;
|
||||
};
|
||||
@ -125,9 +125,9 @@ public:
|
||||
* Returns the version of oned
|
||||
* @return the version
|
||||
*/
|
||||
static string version()
|
||||
static std::string version()
|
||||
{
|
||||
ostringstream os;
|
||||
std::ostringstream os;
|
||||
os << "OpenNebula " << code_version();
|
||||
os << " (" << GITVERSION << ")";
|
||||
|
||||
@ -138,7 +138,7 @@ public:
|
||||
* Returns the version of oned
|
||||
* @return
|
||||
*/
|
||||
static string code_version()
|
||||
static std::string code_version()
|
||||
{
|
||||
return "5.9.90"; // bump version
|
||||
}
|
||||
@ -147,7 +147,7 @@ public:
|
||||
* Version needed for the DB, shared tables
|
||||
* @return
|
||||
*/
|
||||
static string shared_db_version()
|
||||
static std::string shared_db_version()
|
||||
{
|
||||
return "5.12.0";
|
||||
}
|
||||
@ -156,7 +156,7 @@ public:
|
||||
* Version needed for the DB, local tables
|
||||
* @return
|
||||
*/
|
||||
static string local_db_version()
|
||||
static std::string local_db_version()
|
||||
{
|
||||
return "5.12.0";
|
||||
}
|
||||
@ -170,7 +170,7 @@ public:
|
||||
* @param value of the attribute
|
||||
*/
|
||||
template<typename T>
|
||||
void get_configuration_attribute(const string& name, T& value) const
|
||||
void get_configuration_attribute(const std::string& name, T& value) const
|
||||
{
|
||||
config->get(name, value);
|
||||
};
|
||||
@ -179,9 +179,9 @@ public:
|
||||
* Gets an XML document with all of the configuration attributes
|
||||
* @return the XML
|
||||
*/
|
||||
string get_configuration_xml() const
|
||||
std::string get_configuration_xml() const
|
||||
{
|
||||
string xml;
|
||||
std::string xml;
|
||||
return config->to_xml(xml);
|
||||
};
|
||||
|
||||
@ -241,14 +241,14 @@ private:
|
||||
// Environment variables
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
string nebula_location;
|
||||
std::string nebula_location;
|
||||
|
||||
string mad_location;
|
||||
string etc_location;
|
||||
string log_location;
|
||||
string var_location;
|
||||
string remotes_location;
|
||||
string vms_location;
|
||||
std::string mad_location;
|
||||
std::string etc_location;
|
||||
std::string log_location;
|
||||
std::string var_location;
|
||||
std::string remotes_location;
|
||||
std::string vms_location;
|
||||
};
|
||||
|
||||
#endif /*NEBULA_SERVICE_H_*/
|
||||
|
@ -27,7 +27,7 @@
|
||||
class NebulaTemplate : public Template
|
||||
{
|
||||
public:
|
||||
NebulaTemplate(const string& etc_location, const char * _conf_name,
|
||||
NebulaTemplate(const std::string& etc_location, const char * _conf_name,
|
||||
const char * root_name) : Template(false, '=', root_name)
|
||||
{
|
||||
conf_file = etc_location + _conf_name;
|
||||
@ -44,12 +44,12 @@ protected:
|
||||
/**
|
||||
* Full path to the configuration file
|
||||
*/
|
||||
string conf_file;
|
||||
std::string conf_file;
|
||||
|
||||
/**
|
||||
* Defaults for the configuration file
|
||||
*/
|
||||
multimap<string, Attribute*> conf_default;
|
||||
std::multimap<std::string, Attribute*> conf_default;
|
||||
|
||||
/**
|
||||
* Sets the defaults value for the template
|
||||
|
@ -21,8 +21,6 @@
|
||||
|
||||
#include "PoolObjectSQL.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* Class to store a set of PoolObjectSQL IDs.
|
||||
*/
|
||||
@ -30,10 +28,10 @@ class ObjectCollection
|
||||
{
|
||||
public:
|
||||
|
||||
ObjectCollection(const string& _collection_name)
|
||||
ObjectCollection(const std::string& _collection_name)
|
||||
:collection_name(_collection_name){};
|
||||
|
||||
ObjectCollection(const string& cname, const set<int>& cset)
|
||||
ObjectCollection(const std::string& cname, const std::set<int>& cset)
|
||||
:collection_name(cname), collection_set(cset){};
|
||||
|
||||
~ObjectCollection(){};
|
||||
@ -78,7 +76,7 @@ public:
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int from_xml(const ObjectXML* xml, const string& xpath_prefix);
|
||||
int from_xml(const ObjectXML* xml, const std::string& xpath_prefix);
|
||||
|
||||
/**
|
||||
* Function to print the Collection object into a string in
|
||||
@ -86,20 +84,20 @@ public:
|
||||
* @param xml the resulting XML string
|
||||
* @return a reference to the generated string
|
||||
*/
|
||||
string& to_xml(string& xml) const;
|
||||
std::string& to_xml(std::string& xml) const;
|
||||
|
||||
/**
|
||||
* Returns a copy of the IDs set
|
||||
*/
|
||||
set<int> clone() const
|
||||
std::set<int> clone() const
|
||||
{
|
||||
return set<int>(collection_set);
|
||||
return std::set<int>(collection_set);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a reference to the IDs set
|
||||
*/
|
||||
const set<int>& get_collection() const
|
||||
const std::set<int>& get_collection() const
|
||||
{
|
||||
return collection_set;
|
||||
};
|
||||
@ -132,12 +130,12 @@ private:
|
||||
/**
|
||||
* The collection's name
|
||||
*/
|
||||
string collection_name;
|
||||
std::string collection_name;
|
||||
|
||||
/**
|
||||
* Set containing the relations IDs
|
||||
*/
|
||||
set<int> collection_set;
|
||||
std::set<int> collection_set;
|
||||
|
||||
/**
|
||||
* Rebuilds the object from an xml node
|
||||
|
@ -20,8 +20,6 @@
|
||||
#include "Callbackable.h"
|
||||
#include "SqlDB.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* ObjectSQL class. Provides a SQL backend interface, it should be implemented
|
||||
* by persistent objects.
|
||||
@ -50,7 +48,7 @@ protected:
|
||||
*/
|
||||
virtual int insert(
|
||||
SqlDB * db,
|
||||
string& error_str) = 0;
|
||||
std::string& error_str) = 0;
|
||||
|
||||
/**
|
||||
* Updates the ObjectSQL in the database.
|
||||
|
@ -29,7 +29,8 @@ class OpenNebulaTemplate : public NebulaTemplate
|
||||
{
|
||||
public:
|
||||
|
||||
OpenNebulaTemplate(const string& etc_location, const string& _var_location):
|
||||
OpenNebulaTemplate(const std::string& etc_location,
|
||||
const std::string& _var_location):
|
||||
NebulaTemplate(etc_location, conf_name, "OPENNEBULA_CONFIGURATION"),
|
||||
var_location(_var_location)
|
||||
{};
|
||||
@ -79,7 +80,7 @@ private:
|
||||
/**
|
||||
* Path for the var directory, for defaults
|
||||
*/
|
||||
string var_location;
|
||||
std::string var_location;
|
||||
|
||||
/**
|
||||
* Default set of VM action permissions
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
AclRule& other_rule,
|
||||
int zone_id) const;
|
||||
|
||||
string type_to_str() const
|
||||
std::string type_to_str() const
|
||||
{
|
||||
return PoolObjectSQL::type_to_str(obj_type);
|
||||
};
|
||||
@ -65,7 +65,7 @@ public:
|
||||
int oid;
|
||||
int uid;
|
||||
int gid;
|
||||
set<int> cids;
|
||||
std::set<int> cids;
|
||||
|
||||
int owner_u;
|
||||
int owner_m;
|
||||
|
@ -24,8 +24,6 @@
|
||||
#include <pthread.h>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class PoolObjectAuth;
|
||||
|
||||
/**
|
||||
@ -85,7 +83,7 @@ public:
|
||||
|
||||
static const long int LockableObject;
|
||||
|
||||
static string type_to_str(ObjectType ob)
|
||||
static std::string type_to_str(ObjectType ob)
|
||||
{
|
||||
switch (ob)
|
||||
{
|
||||
@ -113,7 +111,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static ObjectType str_to_type(const string& type)
|
||||
static ObjectType str_to_type(const std::string& type)
|
||||
{
|
||||
if ( type == "VM" ) return VM;
|
||||
else if ( type == "HOST" ) return HOST;
|
||||
@ -138,7 +136,7 @@ public:
|
||||
else return NONE;
|
||||
};
|
||||
|
||||
static string lock_state_to_str(LockStates ob)
|
||||
static std::string lock_state_to_str(LockStates ob)
|
||||
{
|
||||
switch (ob)
|
||||
{
|
||||
@ -152,14 +150,14 @@ public:
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
PoolObjectSQL(int id,
|
||||
ObjectType _obj_type,
|
||||
const string& _name,
|
||||
int _uid,
|
||||
int _gid,
|
||||
const string& _uname,
|
||||
const string& _gname,
|
||||
const char * _table)
|
||||
PoolObjectSQL(int id,
|
||||
ObjectType _obj_type,
|
||||
const std::string& _name,
|
||||
int _uid,
|
||||
int _gid,
|
||||
const std::string& _uname,
|
||||
const std::string& _gname,
|
||||
const char * _table)
|
||||
:ObjectSQL(),
|
||||
ObjectXML(),
|
||||
oid(id),
|
||||
@ -213,19 +211,21 @@ public:
|
||||
* @param error_str describing the error
|
||||
* @return true if the name is valid
|
||||
*/
|
||||
static bool name_is_valid(const string& obj_name, const string& extra_chars,
|
||||
string& error_str);
|
||||
static bool name_is_valid(const std::string& obj_name,
|
||||
const std::string& extra_chars,
|
||||
std::string& error_str);
|
||||
|
||||
/**
|
||||
* Check if the object name is valid, no extra characters needed to be
|
||||
* tested.
|
||||
*/
|
||||
static bool name_is_valid(const string& obj_name, string& error_str)
|
||||
static bool name_is_valid(const std::string& obj_name,
|
||||
std::string& error_str)
|
||||
{
|
||||
return name_is_valid(obj_name, "", error_str);
|
||||
}
|
||||
|
||||
const string& get_name() const
|
||||
const std::string& get_name() const
|
||||
{
|
||||
return name;
|
||||
};
|
||||
@ -237,7 +237,7 @@ public:
|
||||
*
|
||||
* @return 0 if the name was changed
|
||||
*/
|
||||
int set_name(const string& _name, string& error_str)
|
||||
int set_name(const std::string& _name, std::string& error_str)
|
||||
{
|
||||
if (!name_is_valid(_name, error_str))
|
||||
{
|
||||
@ -259,12 +259,12 @@ public:
|
||||
return gid;
|
||||
};
|
||||
|
||||
const string& get_uname() const
|
||||
const std::string& get_uname() const
|
||||
{
|
||||
return uname;
|
||||
};
|
||||
|
||||
const string& get_gname() const
|
||||
const std::string& get_gname() const
|
||||
{
|
||||
return gname;
|
||||
};
|
||||
@ -274,7 +274,7 @@ public:
|
||||
* @param _uid New User ID
|
||||
* @param _uname Name of the new user
|
||||
*/
|
||||
void set_user(int _uid, const string& _uname)
|
||||
void set_user(int _uid, const std::string& _uname)
|
||||
{
|
||||
uid = _uid;
|
||||
uname = _uname;
|
||||
@ -285,7 +285,7 @@ public:
|
||||
* @param _gid New Group ID
|
||||
* @param _gname Name of the new group
|
||||
*/
|
||||
void set_group(int _gid, const string& _gname)
|
||||
void set_group(int _gid, const std::string& _gname)
|
||||
{
|
||||
gid = _gid;
|
||||
gname = _gname;
|
||||
@ -316,7 +316,7 @@ public:
|
||||
int _other_u,
|
||||
int _other_m,
|
||||
int _other_a,
|
||||
string& error_str);
|
||||
std::string& error_str);
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
/**
|
||||
@ -339,14 +339,14 @@ public:
|
||||
* @param xml the resulting XML string
|
||||
* @return a reference to the generated string
|
||||
*/
|
||||
virtual string& to_xml64(string &xml64);
|
||||
virtual std::string& to_xml64(std::string &xml64);
|
||||
|
||||
/**
|
||||
* Function to print the object into a string in XML format
|
||||
* @param xml the resulting XML string
|
||||
* @return a reference to the generated string
|
||||
*/
|
||||
virtual string& to_xml(string& xml) const = 0;
|
||||
virtual std::string& to_xml(std::string& xml) const = 0;
|
||||
|
||||
/**
|
||||
* Rebuilds the object from an xml formatted string
|
||||
@ -354,7 +354,7 @@ public:
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
virtual int from_xml(const string &xml_str) = 0;
|
||||
virtual int from_xml(const std::string &xml_str) = 0;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Template
|
||||
@ -365,12 +365,12 @@ public:
|
||||
* @param name the attribute name.
|
||||
* @return true first attribute or 0 if not found or wrong type
|
||||
*/
|
||||
const VectorAttribute * get_template_attribute(const string& s) const
|
||||
const VectorAttribute * get_template_attribute(const std::string& s) const
|
||||
{
|
||||
return obj_template->get(s);
|
||||
}
|
||||
|
||||
VectorAttribute * get_template_attribute(const string& s)
|
||||
VectorAttribute * get_template_attribute(const std::string& s)
|
||||
{
|
||||
return obj_template->get(s);
|
||||
}
|
||||
@ -382,13 +382,8 @@ public:
|
||||
* @return the number of values
|
||||
*/
|
||||
template<typename T>
|
||||
int get_template_attribute(const string& name, vector<const T*>& values) const
|
||||
{
|
||||
return obj_template->get(name, values);
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
int get_template_attribute(const string& name, vector<T*>& values) const
|
||||
int get_template_attribute(const std::string& name,
|
||||
std::vector<const T*>& values) const
|
||||
{
|
||||
return obj_template->get(name, values);
|
||||
};
|
||||
@ -404,7 +399,7 @@ public:
|
||||
* target value
|
||||
*/
|
||||
template<typename T>
|
||||
bool get_template_attribute(const string& name, T& value) const
|
||||
bool get_template_attribute(const std::string& name, T& value) const
|
||||
{
|
||||
return obj_template->get(name, value);
|
||||
}
|
||||
@ -417,7 +412,7 @@ public:
|
||||
* @return the number of attributes erased
|
||||
*/
|
||||
template<typename T>
|
||||
int erase_template_attribute(const string& name, T& value)
|
||||
int erase_template_attribute(const std::string& name, T& value)
|
||||
{
|
||||
obj_template->get(name, value);
|
||||
return obj_template->erase(name);
|
||||
@ -431,7 +426,7 @@ public:
|
||||
* @return 0 on success
|
||||
*/
|
||||
template<typename T>
|
||||
int replace_template_attribute(const string& name, const T& value)
|
||||
int replace_template_attribute(const std::string& name, const T& value)
|
||||
{
|
||||
return obj_template->replace(name, value);
|
||||
}
|
||||
@ -444,7 +439,7 @@ public:
|
||||
* @return the number of attributes removed
|
||||
*/
|
||||
template<typename T>
|
||||
int remove_template_attribute(const string& n, vector<T *>& v)
|
||||
int remove_template_attribute(const std::string& n, std::vector<T *>& v)
|
||||
{
|
||||
return obj_template->remove(n, v);
|
||||
}
|
||||
@ -453,7 +448,7 @@ public:
|
||||
* Generates a XML string for the template of the Object
|
||||
* @param xml the string to store the XML description.
|
||||
*/
|
||||
string& template_to_xml(string &xml) const
|
||||
std::string& template_to_xml(std::string &xml) const
|
||||
{
|
||||
return obj_template->to_xml(xml);
|
||||
}
|
||||
@ -462,7 +457,7 @@ public:
|
||||
* Removes an attribute
|
||||
* @param name of the attribute
|
||||
*/
|
||||
int remove_template_attribute(const string& name)
|
||||
int remove_template_attribute(const std::string& name)
|
||||
{
|
||||
return obj_template->erase(name);
|
||||
}
|
||||
@ -471,7 +466,7 @@ public:
|
||||
* Sets an error message with timestamp in the template
|
||||
* @param message Message string
|
||||
*/
|
||||
virtual void set_template_error_message(const string& message);
|
||||
virtual void set_template_error_message(const std::string& message);
|
||||
|
||||
/**
|
||||
* Deletes the error message from the template
|
||||
@ -484,13 +479,13 @@ public:
|
||||
* @param att_val Message string
|
||||
*/
|
||||
template<typename T>
|
||||
void add_template_attribute(const string& name, const T& value)
|
||||
void add_template_attribute(const std::string& name, const T& value)
|
||||
{
|
||||
obj_template->add(name, value);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void add_template_attribute(vector<T *>& values)
|
||||
void add_template_attribute(std::vector<T *>& values)
|
||||
{
|
||||
obj_template->set(values);
|
||||
}
|
||||
@ -514,7 +509,9 @@ public:
|
||||
* @param error string describing the error if any
|
||||
* @return 0 on success
|
||||
*/
|
||||
virtual int replace_template(const string& tmpl_str, bool keep_restricted, string& error);
|
||||
virtual int replace_template(const std::string& tmpl_str,
|
||||
bool keep_restricted,
|
||||
std::string& error);
|
||||
|
||||
/**
|
||||
* Append new attributes to this object's template. Object should be updated
|
||||
@ -525,7 +522,9 @@ public:
|
||||
* @param error string describing the error if any
|
||||
* @return 0 on success
|
||||
*/
|
||||
virtual int append_template(const string& tmpl_str, bool keep_restricted, string& error);
|
||||
virtual int append_template(const std::string& tmpl_str,
|
||||
bool keep_restricted,
|
||||
std::string& error);
|
||||
|
||||
/**
|
||||
* Fills a auth class to perform an authZ/authN request based on the object
|
||||
@ -606,7 +605,7 @@ protected:
|
||||
* @param db pointer to the db
|
||||
* @return 0 on success
|
||||
*/
|
||||
virtual int select(SqlDB *db, const string& _name, int _uid);
|
||||
virtual int select(SqlDB *db, const std::string& _name, int _uid);
|
||||
|
||||
/**
|
||||
* Search oid by its name and owner
|
||||
@ -616,7 +615,7 @@ protected:
|
||||
* @param _uid of owner
|
||||
* @return -1 if not found or oid otherwise
|
||||
*/
|
||||
static int select_oid(SqlDB *db, const char * _table, const string& _name,
|
||||
static int select_oid(SqlDB *db, const char * _table, const std::string& _name,
|
||||
int _uid);
|
||||
|
||||
/**
|
||||
@ -644,7 +643,7 @@ protected:
|
||||
* @param vaues the column values
|
||||
* @return 0 on success
|
||||
*/
|
||||
static int dump(ostringstream& oss, int num, char **values, char **names)
|
||||
static int dump(std::ostringstream& oss, int num, char **values, char **names)
|
||||
{
|
||||
if ( (!values[0]) || (num != 1) )
|
||||
{
|
||||
@ -660,7 +659,7 @@ protected:
|
||||
* @param xml the resulting XML string
|
||||
* @return a reference to the generated string
|
||||
*/
|
||||
string& perms_to_xml(string& xml) const;
|
||||
std::string& perms_to_xml(std::string& xml) const;
|
||||
|
||||
/**
|
||||
* Rebuilds the object permissions from the xml. ObjectXML::update_from_str
|
||||
@ -699,7 +698,8 @@ protected:
|
||||
* @param name of the error attribute
|
||||
* @param message Message string
|
||||
*/
|
||||
virtual void set_template_error_message(const string& name, const string& message);
|
||||
virtual void set_template_error_message(const std::string& name,
|
||||
const std::string& message);
|
||||
|
||||
/**
|
||||
* Child classes can process the new template set with replace_template or
|
||||
@ -707,7 +707,7 @@ protected:
|
||||
* @param error string describing the error if any
|
||||
* @return 0 on success
|
||||
*/
|
||||
virtual int post_update_template(string& error)
|
||||
virtual int post_update_template(std::string& error)
|
||||
{
|
||||
return 0;
|
||||
};
|
||||
@ -717,7 +717,7 @@ protected:
|
||||
* @param xml the resulting XML string
|
||||
* @return a reference to the generated string
|
||||
*/
|
||||
string& lock_db_to_xml(string& xml) const;
|
||||
std::string& lock_db_to_xml(std::string& xml) const;
|
||||
|
||||
/**
|
||||
* Rebuilds the lock info from the xml. ObjectXML::update_from_str
|
||||
@ -741,7 +741,7 @@ protected:
|
||||
/**
|
||||
* The object's name
|
||||
*/
|
||||
string name;
|
||||
std::string name;
|
||||
|
||||
/**
|
||||
* Object's owner, set it to -1 if owner is not used
|
||||
@ -756,12 +756,12 @@ protected:
|
||||
/**
|
||||
* Name of the object's owner, empty if owner is not used
|
||||
*/
|
||||
string uname;
|
||||
std::string uname;
|
||||
|
||||
/**
|
||||
* Name of the object's group,, empty if group is not used
|
||||
*/
|
||||
string gname;
|
||||
std::string gname;
|
||||
|
||||
/**
|
||||
* Permissions for the owner user
|
||||
@ -818,7 +818,7 @@ private:
|
||||
/**
|
||||
* Characters that can not be in a name
|
||||
*/
|
||||
static const string INVALID_NAME_CHARS;
|
||||
static const std::string INVALID_NAME_CHARS;
|
||||
|
||||
/**
|
||||
* Expiration time for the lock stored in the DB
|
||||
|
@ -23,8 +23,6 @@
|
||||
#include "PoolObjectSQL.h"
|
||||
#include "PoolSQLCache.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* PoolSQL class. Provides a base class to implement persistent generic pools.
|
||||
* The PoolSQL provides a synchronization mechanism (mutex) to operate in
|
||||
@ -54,7 +52,7 @@ public:
|
||||
*/
|
||||
virtual int allocate(
|
||||
PoolObjectSQL *objsql,
|
||||
string& error_str);
|
||||
std::string& error_str);
|
||||
|
||||
/**
|
||||
* Gets an object from the pool (if needed the object is loaded from the
|
||||
@ -81,12 +79,12 @@ public:
|
||||
*
|
||||
* @return oid of the object if it exists, -1 otherwise
|
||||
*/
|
||||
int exist(const string& name, int ouid)
|
||||
int exist(const std::string& name, int ouid)
|
||||
{
|
||||
return PoolObjectSQL::select_oid(db, table.c_str(), name, ouid);
|
||||
}
|
||||
|
||||
int exist(const string& name)
|
||||
int exist(const std::string& name)
|
||||
{
|
||||
return PoolObjectSQL::select_oid(db, table.c_str(), name, -1);
|
||||
}
|
||||
@ -96,7 +94,7 @@ public:
|
||||
return PoolObjectSQL::exist(db, table.c_str(), oid);
|
||||
}
|
||||
|
||||
void exist(const string& id_str, std::set<int>& id_list);
|
||||
void exist(const std::string& id_str, std::set<int>& id_list);
|
||||
|
||||
/**
|
||||
* Finds a set objects that satisfies a given condition
|
||||
@ -107,9 +105,9 @@ public:
|
||||
* @return 0 on success
|
||||
*/
|
||||
virtual int search(
|
||||
vector<int>& oids,
|
||||
const char * table,
|
||||
const string& where);
|
||||
std::vector<int>& oids,
|
||||
const char * table,
|
||||
const std::string& where);
|
||||
|
||||
/**
|
||||
* List the objects in the pool
|
||||
@ -119,8 +117,8 @@ public:
|
||||
* @return 0 on success
|
||||
*/
|
||||
int list(
|
||||
vector<int>& oids,
|
||||
const char * table)
|
||||
std::vector<int>& oids,
|
||||
const char * table)
|
||||
{
|
||||
return search(oids, table, "");
|
||||
}
|
||||
@ -145,7 +143,7 @@ public:
|
||||
* @param error_msg Error reason, if any
|
||||
* @return 0 on success, -1 DB error
|
||||
*/
|
||||
virtual int drop(PoolObjectSQL * objsql, string& error_msg)
|
||||
virtual int drop(PoolObjectSQL * objsql, std::string& error_msg)
|
||||
{
|
||||
int rc = objsql->drop(db);
|
||||
|
||||
@ -167,7 +165,7 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump(string& oss, const string& where, bool desc)
|
||||
int dump(std::string& oss, const std::string& where, bool desc)
|
||||
{
|
||||
return dump(oss, where, 0, -1, desc);
|
||||
}
|
||||
@ -183,8 +181,9 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
virtual int dump(string& oss, const string& where, int sid, int eid,
|
||||
bool desc) = 0;
|
||||
virtual int dump(std::string& oss, const std::string& where,
|
||||
int sid, int eid,
|
||||
bool desc) = 0;
|
||||
|
||||
/**
|
||||
* Dumps the pool in extended XML format
|
||||
@ -197,8 +196,8 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
virtual int dump_extended(string& oss,
|
||||
const string& where,
|
||||
virtual int dump_extended(std::string& oss,
|
||||
const std::string& where,
|
||||
int sid,
|
||||
int eid,
|
||||
bool desc)
|
||||
@ -224,13 +223,13 @@ public:
|
||||
*
|
||||
*/
|
||||
static void acl_filter(int uid,
|
||||
const set<int>& user_groups,
|
||||
const std::set<int>& user_groups,
|
||||
PoolObjectSQL::ObjectType auth_object,
|
||||
bool& all,
|
||||
bool disable_all_acl,
|
||||
bool disable_cluster_acl,
|
||||
bool disable_group_acl,
|
||||
string& filter);
|
||||
std::string& filter);
|
||||
/**
|
||||
* Creates a filter for the objects owned by a given user/group
|
||||
* @param uid the user id
|
||||
@ -240,22 +239,22 @@ public:
|
||||
* @param all user can access all objects
|
||||
* @param filter the resulting filter string
|
||||
*/
|
||||
static void usr_filter(int uid,
|
||||
int gid,
|
||||
const set<int>& user_groups,
|
||||
int filter_flag,
|
||||
bool all,
|
||||
const string& acl_str,
|
||||
string& filter);
|
||||
static void usr_filter(int uid,
|
||||
int gid,
|
||||
const std::set<int>& user_groups,
|
||||
int filter_flag,
|
||||
bool all,
|
||||
const std::string& acl_str,
|
||||
std::string& filter);
|
||||
/**
|
||||
* Creates a filter for a given set of objects based on their id
|
||||
* @param start_id first id
|
||||
* @param end_id last id
|
||||
* @param filter the resulting filter string
|
||||
*/
|
||||
static void oid_filter(int start_id,
|
||||
int end_id,
|
||||
string& filter);
|
||||
static void oid_filter(int start_id,
|
||||
int end_id,
|
||||
std::string& filter);
|
||||
|
||||
/**
|
||||
* This function returns a legal SQL string that can be used in an SQL
|
||||
@ -264,7 +263,7 @@ public:
|
||||
* @param str the string to be escaped
|
||||
* @return a valid SQL string or NULL in case of failure
|
||||
*/
|
||||
char * escape_str(const string& str)
|
||||
char * escape_str(const std::string& str)
|
||||
{
|
||||
return db->escape_str(str);
|
||||
}
|
||||
@ -296,7 +295,7 @@ protected:
|
||||
*
|
||||
* @return a pointer to the object, 0 in case of failure
|
||||
*/
|
||||
PoolObjectSQL * get(const string& name, int uid);
|
||||
PoolObjectSQL * get(const std::string& name, int uid);
|
||||
|
||||
/**
|
||||
* Gets a read only object from the pool (if needed the object is loaded from the
|
||||
@ -306,7 +305,7 @@ protected:
|
||||
*
|
||||
* @return a pointer to the object, 0 in case of failure
|
||||
*/
|
||||
PoolObjectSQL * get_ro(const string& name, int uid);
|
||||
PoolObjectSQL * get_ro(const std::string& name, int uid);
|
||||
|
||||
/**
|
||||
* Pointer to the database.
|
||||
@ -326,14 +325,14 @@ protected:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump(string& oss,
|
||||
const string& elem_name,
|
||||
const string& column,
|
||||
const char * table,
|
||||
const string& where,
|
||||
int start_id,
|
||||
int end_id,
|
||||
bool desc);
|
||||
int dump(std::string& oss,
|
||||
const std::string& elem_name,
|
||||
const std::string& column,
|
||||
const char * table,
|
||||
const std::string& where,
|
||||
int start_id,
|
||||
int end_id,
|
||||
bool desc);
|
||||
|
||||
/**
|
||||
* Dumps the pool in XML format. A filter can be also added to the
|
||||
@ -346,11 +345,11 @@ protected:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump(string& oss,
|
||||
const string& elem_name,
|
||||
const char * table,
|
||||
const string& where,
|
||||
bool desc)
|
||||
int dump(std::string& oss,
|
||||
const std::string& elem_name,
|
||||
const char * table,
|
||||
const std::string& where,
|
||||
bool desc)
|
||||
{
|
||||
return dump(oss, elem_name, "body", table, where, 0, -1, desc);
|
||||
}
|
||||
@ -364,9 +363,9 @@ protected:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump(string& oss,
|
||||
const string& root_elem_name,
|
||||
ostringstream& sql_query);
|
||||
int dump(std::string& oss,
|
||||
const std::string& root_elem_name,
|
||||
std::ostringstream& sql_query);
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Interface to access the lastOID assigned by the pool */
|
||||
@ -390,7 +389,7 @@ private:
|
||||
/**
|
||||
* Tablename for this pool
|
||||
*/
|
||||
string table;
|
||||
std::string table;
|
||||
|
||||
/**
|
||||
* The pool cache is implemented with a Map of SQL object pointers,
|
||||
|
@ -36,12 +36,12 @@ class PostgreSqlDB : public SqlDB
|
||||
{
|
||||
public:
|
||||
PostgreSqlDB(
|
||||
const string& _server,
|
||||
int _port,
|
||||
const string& _user,
|
||||
const string& _password,
|
||||
const string& _database,
|
||||
int _connections);
|
||||
const std::string& _server,
|
||||
int _port,
|
||||
const std::string& _user,
|
||||
const std::string& _password,
|
||||
const std::string& _database,
|
||||
int _connections);
|
||||
|
||||
~PostgreSqlDB();
|
||||
|
||||
@ -51,7 +51,7 @@ public:
|
||||
* @param str the string to be escaped
|
||||
* @return a valid SQL string or NULL in case of failure
|
||||
*/
|
||||
char * escape_str(const string& str) override;
|
||||
char * escape_str(const std::string& str) override;
|
||||
|
||||
/**
|
||||
* Frees a previously scaped string
|
||||
@ -102,7 +102,7 @@ private:
|
||||
/**
|
||||
* Connection pool
|
||||
*/
|
||||
queue<PGconn *> db_connect;
|
||||
std::queue<PGconn *> db_connect;
|
||||
|
||||
/**
|
||||
* DB connection to escape strings
|
||||
@ -112,11 +112,11 @@ private:
|
||||
/**
|
||||
* Connection parameters
|
||||
*/
|
||||
string server;
|
||||
int port;
|
||||
string user;
|
||||
string password;
|
||||
string database;
|
||||
std::string server;
|
||||
int port;
|
||||
std::string user;
|
||||
std::string password;
|
||||
std::string database;
|
||||
|
||||
/**
|
||||
* Fine-grain mutex for DB access (pool of DB connections)
|
||||
@ -169,18 +169,18 @@ class PostgreSqlDB : public SqlDB
|
||||
{
|
||||
public:
|
||||
PostgreSqlDB(
|
||||
const string& _server,
|
||||
int _port,
|
||||
const string& _user,
|
||||
const string& _password,
|
||||
const string& _database,
|
||||
int _connections)
|
||||
const std::string& _server,
|
||||
int _port,
|
||||
const std::string& _user,
|
||||
const std::string& _password,
|
||||
const std::string& _database,
|
||||
int _connections)
|
||||
{
|
||||
throw runtime_error("Aborting oned, PostgreSQL support not compiled!");
|
||||
throw std::runtime_error("Aborting oned, PostgreSQL support not compiled!");
|
||||
}
|
||||
~PostgreSqlDB(){}
|
||||
|
||||
char * escape_str(const string& str) override {return 0;};
|
||||
char * escape_str(const std::string& str) override {return 0;};
|
||||
|
||||
void free_str(char * str) override {};
|
||||
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
* @param error string
|
||||
* @return true if the operation can be performed
|
||||
*/
|
||||
virtual bool check(Template* tmpl, Quotas& default_quotas, string& error) = 0;
|
||||
virtual bool check(Template* tmpl, Quotas& default_quotas, std::string& error) = 0;
|
||||
|
||||
/**
|
||||
* Decrement usage counters when deallocating image
|
||||
@ -50,7 +50,7 @@ public:
|
||||
*
|
||||
* @return 0 on success -1 otherwise
|
||||
*/
|
||||
virtual int set(vector<VectorAttribute*> * quotas, string& error) = 0;
|
||||
virtual int set(std::vector<VectorAttribute*> * quotas, std::string& error) = 0;
|
||||
|
||||
/**
|
||||
* Check if a resource update in usage counters will exceed the
|
||||
@ -60,7 +60,7 @@ public:
|
||||
* @param error string
|
||||
* @return true if the operation can be performed
|
||||
*/
|
||||
virtual bool update(Template * tmpl, Quotas& default_quotas, string& error) = 0;
|
||||
virtual bool update(Template * tmpl, Quotas& default_quotas, std::string& error) = 0;
|
||||
|
||||
/**
|
||||
* Returns the name that identifies the quota in a template
|
||||
@ -73,7 +73,7 @@ public:
|
||||
* @param va The quota, if it is found
|
||||
* @return 0 on success, -1 if not found
|
||||
*/
|
||||
virtual int get_quota(const string& id, VectorAttribute **va) = 0;
|
||||
virtual int get_quota(const std::string& id, VectorAttribute **va) = 0;
|
||||
|
||||
protected:
|
||||
QuotaInterface(){};
|
||||
@ -88,7 +88,7 @@ protected:
|
||||
*/
|
||||
class QuotaDecorator : public QuotaInterface
|
||||
{
|
||||
virtual bool check(Template* tmpl, Quotas& default_quotas, string& error)
|
||||
virtual bool check(Template* tmpl, Quotas& default_quotas, std::string& error)
|
||||
{
|
||||
return quota->check(tmpl, default_quotas, error);
|
||||
}
|
||||
@ -98,12 +98,12 @@ class QuotaDecorator : public QuotaInterface
|
||||
return quota->del(tmpl);
|
||||
}
|
||||
|
||||
virtual int set(vector<VectorAttribute*> * quotas, string& error)
|
||||
virtual int set(std::vector<VectorAttribute*> * quotas, std::string& error)
|
||||
{
|
||||
return quota->set(quotas, error);
|
||||
}
|
||||
|
||||
virtual bool update(Template * tmpl, Quotas& default_quotas, string& error)
|
||||
virtual bool update(Template * tmpl, Quotas& default_quotas, std::string& error)
|
||||
{
|
||||
return quota->update(tmpl, default_quotas, error);
|
||||
}
|
||||
@ -113,7 +113,7 @@ class QuotaDecorator : public QuotaInterface
|
||||
return quota->get_quota_name();
|
||||
}
|
||||
|
||||
virtual int get_quota(const string& id, VectorAttribute **va)
|
||||
virtual int get_quota(const std::string& id, VectorAttribute **va)
|
||||
{
|
||||
return quota->get_quota(id, va);
|
||||
}
|
||||
@ -142,7 +142,7 @@ public:
|
||||
*
|
||||
* @return 0 on success -1 otherwise
|
||||
*/
|
||||
int set(vector<VectorAttribute*> * quotas, string& error);
|
||||
int set(std::vector<VectorAttribute*> * quotas, std::string& error);
|
||||
|
||||
/**
|
||||
* Check if a resource update in usage counters will exceed the
|
||||
@ -152,7 +152,7 @@ public:
|
||||
* @param error string
|
||||
* @return true if the operation can be performed
|
||||
*/
|
||||
virtual bool update(Template * tmpl, Quotas& default_quotas, string& error)
|
||||
virtual bool update(Template * tmpl, Quotas& default_quotas, std::string& error)
|
||||
{
|
||||
error = "Update operation for quotas not supported.";
|
||||
return false;
|
||||
@ -172,17 +172,17 @@ public:
|
||||
* @param va The quota, if it is found
|
||||
* @return 0 on success, -1 if not found
|
||||
*/
|
||||
virtual int get_quota(const string& id, VectorAttribute **va)
|
||||
virtual int get_quota(const std::string& id, VectorAttribute **va)
|
||||
{
|
||||
map<string, Attribute *>::iterator it;
|
||||
std::map<std::string, Attribute *>::iterator it;
|
||||
return get_quota(id, va, it);
|
||||
}
|
||||
|
||||
/**
|
||||
* Value for limit default
|
||||
*/
|
||||
static const int DEFAULT;
|
||||
static const string DEFAULT_STR;
|
||||
static const int DEFAULT;
|
||||
static const std::string DEFAULT_STR;
|
||||
|
||||
/**
|
||||
* Value for "unlimited" limit
|
||||
@ -246,18 +246,18 @@ protected:
|
||||
* @param error string describing the error
|
||||
* @return true if the request does not exceed current limits
|
||||
*/
|
||||
bool check_quota(const string& qid,
|
||||
map<string, float>& usage_req,
|
||||
bool check_quota(const std::string& qid,
|
||||
std::map<std::string, float>& usage_req,
|
||||
Quotas& default_quotas,
|
||||
string& error);
|
||||
std::string& error);
|
||||
|
||||
/**
|
||||
* Reduce usage from a given quota based on the current consumption
|
||||
* @param qid id that identifies the quota, to be used by get_quota
|
||||
* @param usage_req usage for each metric
|
||||
*/
|
||||
void del_quota(const string& qid,
|
||||
map<string, float>& usage_req);
|
||||
void del_quota(const std::string& qid,
|
||||
std::map<std::string, float>& usage_req);
|
||||
|
||||
/**
|
||||
* Gets the default quota identified by its ID.
|
||||
@ -268,7 +268,7 @@ protected:
|
||||
*
|
||||
* @return 0 on success, -1 if not found
|
||||
*/
|
||||
virtual int get_default_quota(const string& id,
|
||||
virtual int get_default_quota(const std::string& id,
|
||||
Quotas& default_quotas,
|
||||
VectorAttribute **va) = 0;
|
||||
|
||||
@ -282,16 +282,16 @@ protected:
|
||||
* @return 0 on success, -1 if not found
|
||||
*/
|
||||
virtual int get_quota(
|
||||
const string& id,
|
||||
const std::string& id,
|
||||
VectorAttribute **va,
|
||||
map<string, Attribute *>::iterator& it);
|
||||
std::map<std::string, Attribute *>::iterator& it);
|
||||
|
||||
/**
|
||||
* Checks if a quota has 0 limit and usage, and deletes it
|
||||
*
|
||||
* @param qid id of the quota
|
||||
*/
|
||||
void cleanup_quota(const string& qid);
|
||||
void cleanup_quota(const std::string& qid);
|
||||
|
||||
private:
|
||||
/**
|
||||
@ -319,7 +319,9 @@ private:
|
||||
* @param va_name name of the quota in the vector attribute
|
||||
* @param num value to add to the current quota;
|
||||
*/
|
||||
void add_to_quota(VectorAttribute * attr, const string& va_name, float num);
|
||||
void add_to_quota(VectorAttribute * attr,
|
||||
const std::string& va_name,
|
||||
float num);
|
||||
|
||||
/**
|
||||
* Sets new limit values for the quota
|
||||
@ -337,7 +339,8 @@ private:
|
||||
* @param limits stores the known limits
|
||||
* @return 0 on success
|
||||
*/
|
||||
int get_limits(const VectorAttribute * va, map<string, string>& limits);
|
||||
int get_limits(const VectorAttribute * va,
|
||||
std::map<std::string, std::string>& limits);
|
||||
};
|
||||
|
||||
#endif /*QUOTA_H_*/
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
* @param error string
|
||||
* @return true if the operation can be performed
|
||||
*/
|
||||
bool check(Template* tmpl, Quotas& default_quotas, string& error);
|
||||
bool check(Template* tmpl, Quotas& default_quotas, std::string& error);
|
||||
|
||||
/**
|
||||
* Decrement usage counters when deallocating image
|
||||
@ -73,7 +73,7 @@ protected:
|
||||
*
|
||||
* @return 0 on success, -1 if not found
|
||||
*/
|
||||
int get_default_quota(const string& id,
|
||||
int get_default_quota(const std::string& id,
|
||||
Quotas& default_quotas,
|
||||
VectorAttribute **va);
|
||||
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
* @param error string
|
||||
* @return true if the operation can be performed
|
||||
*/
|
||||
bool check(Template* tmpl, Quotas& default_quotas, string& error);
|
||||
bool check(Template* tmpl, Quotas& default_quotas, std::string& error);
|
||||
|
||||
/**
|
||||
* Decrement usage counters when deallocating image
|
||||
@ -71,7 +71,7 @@ protected:
|
||||
*
|
||||
* @return 0 on success, -1 if not found
|
||||
*/
|
||||
int get_default_quota(const string& id,
|
||||
int get_default_quota(const std::string& id,
|
||||
Quotas& default_quotas,
|
||||
VectorAttribute **va);
|
||||
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
* @param error string
|
||||
* @return true if the operation can be performed
|
||||
*/
|
||||
bool check(Template* tmpl, Quotas& default_quotas, string& err)
|
||||
bool check(Template* tmpl, Quotas& default_quotas, std::string& err)
|
||||
{
|
||||
return check(PoolObjectSQL::VM, tmpl, default_quotas, err);
|
||||
}
|
||||
@ -71,7 +71,7 @@ protected:
|
||||
*
|
||||
* @return 0 on success, -1 if not found
|
||||
*/
|
||||
int get_default_quota(const string& id,
|
||||
int get_default_quota(const std::string& id,
|
||||
Quotas& default_quotas,
|
||||
VectorAttribute **va);
|
||||
|
||||
@ -97,7 +97,7 @@ private:
|
||||
* @return true if the operation can be performed
|
||||
*/
|
||||
bool check(PoolObjectSQL::ObjectType otype, Template* tmpl,
|
||||
Quotas& default_quotas, string& error);
|
||||
Quotas& default_quotas, std::string& error);
|
||||
|
||||
/**
|
||||
* Decrement usage counters when freeing a lease. This method considers
|
||||
@ -120,7 +120,7 @@ public:
|
||||
|
||||
virtual ~QuotaNetworkVirtualRouter(){};
|
||||
|
||||
bool check(Template* tmpl, Quotas& default_quotas, string& err)
|
||||
bool check(Template* tmpl, Quotas& default_quotas, std::string& err)
|
||||
{
|
||||
QuotaNetwork * qn = static_cast<QuotaNetwork *>(quota);
|
||||
|
||||
|
@ -63,7 +63,7 @@ public:
|
||||
* @param error string
|
||||
* @return true if the operation can be performed
|
||||
*/
|
||||
bool check(Template* tmpl, Quotas& default_quotas, string& error);
|
||||
bool check(Template* tmpl, Quotas& default_quotas, std::string& error);
|
||||
|
||||
/**
|
||||
* Check if the resource update (change in MEMORY or CPU) will exceed the
|
||||
@ -73,7 +73,7 @@ public:
|
||||
* @param error string
|
||||
* @return true if the operation can be performed
|
||||
*/
|
||||
bool update(Template * tmpl, Quotas& default_quotas, string& error);
|
||||
bool update(Template * tmpl, Quotas& default_quotas, std::string& error);
|
||||
|
||||
/**
|
||||
* Decrement usage counters when deallocating image
|
||||
@ -88,7 +88,7 @@ public:
|
||||
*
|
||||
* @return a pointer to the quota or 0 if not found
|
||||
*/
|
||||
int get_quota(const string& id, VectorAttribute **va);
|
||||
int get_quota(const std::string& id, VectorAttribute **va);
|
||||
|
||||
protected:
|
||||
|
||||
@ -102,9 +102,9 @@ protected:
|
||||
* @return 0 on success, -1 if not found
|
||||
*/
|
||||
int get_quota(
|
||||
const string& id,
|
||||
const std::string& id,
|
||||
VectorAttribute **va,
|
||||
map<string, Attribute *>::iterator& it)
|
||||
std::map<std::string, Attribute *>::iterator& it)
|
||||
{
|
||||
it = attributes.begin();
|
||||
return get_quota(id, va);
|
||||
@ -120,7 +120,7 @@ protected:
|
||||
* @return 0 on success, -1 if not found
|
||||
*/
|
||||
int get_default_quota(
|
||||
const string& id,
|
||||
const std::string& id,
|
||||
Quotas& default_quotas,
|
||||
VectorAttribute **va);
|
||||
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int set(Template *tmpl, string& error);
|
||||
int set(Template *tmpl, std::string& error);
|
||||
|
||||
/**
|
||||
* Delete usage from quota counters.
|
||||
@ -65,7 +65,7 @@ public:
|
||||
*
|
||||
* @return 0 on success, -1 if not found
|
||||
*/
|
||||
int ds_get(const string& id, VectorAttribute **va)
|
||||
int ds_get(const std::string& id, VectorAttribute **va)
|
||||
{
|
||||
return datastore_quota.get_quota(id, va);
|
||||
}
|
||||
@ -78,7 +78,7 @@ public:
|
||||
*
|
||||
* @return 0 on success, -1 if not found
|
||||
*/
|
||||
int vm_get(const string& id, VectorAttribute **va)
|
||||
int vm_get(const std::string& id, VectorAttribute **va)
|
||||
{
|
||||
return vm_quota.get_quota(id, va);
|
||||
}
|
||||
@ -91,7 +91,7 @@ public:
|
||||
*
|
||||
* @return 0 on success, -1 if not found
|
||||
*/
|
||||
int network_get(const string& id, VectorAttribute **va)
|
||||
int network_get(const std::string& id, VectorAttribute **va)
|
||||
{
|
||||
return network_quota.get_quota(id, va);
|
||||
}
|
||||
@ -104,7 +104,7 @@ public:
|
||||
*
|
||||
* @return 0 on success, -1 if not found
|
||||
*/
|
||||
int image_get(const string& id, VectorAttribute **va)
|
||||
int image_get(const std::string& id, VectorAttribute **va)
|
||||
{
|
||||
return image_quota.get_quota(id, va);
|
||||
}
|
||||
@ -120,7 +120,7 @@ public:
|
||||
bool quota_check(QuotaType type,
|
||||
Template *tmpl,
|
||||
Quotas& default_quotas,
|
||||
string& error_str);
|
||||
std::string& error_str);
|
||||
|
||||
/**
|
||||
* Update usage of an existing quota (e.g. size of an image), it updates
|
||||
@ -134,7 +134,7 @@ public:
|
||||
bool quota_update(QuotaType type,
|
||||
Template *tmpl,
|
||||
Quotas& default_quotas,
|
||||
string& error_str);
|
||||
std::string& error_str);
|
||||
|
||||
/**
|
||||
* Delete usage from the given quota counters.
|
||||
@ -148,7 +148,7 @@ public:
|
||||
* @param xml the string to store the XML
|
||||
* @return the same xml string to use it in << compounds
|
||||
*/
|
||||
string& to_xml(string& xml) const;
|
||||
std::string& to_xml(std::string& xml) const;
|
||||
|
||||
/**
|
||||
* Builds quota object from an ObjectXML
|
||||
@ -177,7 +177,7 @@ public:
|
||||
* @param tmpl template for the vm with usage
|
||||
* @param error string
|
||||
*/
|
||||
static void vm_check(int uid, int gid, Template * tmpl, string& error)
|
||||
static void vm_check(int uid, int gid, Template * tmpl, std::string& error)
|
||||
{
|
||||
quota_check(VIRTUALMACHINE, uid, gid, tmpl, error);
|
||||
}
|
||||
@ -201,11 +201,9 @@ public:
|
||||
* @param gid of the group
|
||||
* @param tmpl template for the image, with usage
|
||||
*/
|
||||
static void ds_del(int uid, int gid, vector<Template *> tmpls)
|
||||
static void ds_del(int uid, int gid, std::vector<Template *> tmpls)
|
||||
{
|
||||
vector<Template *>::iterator it;
|
||||
|
||||
for ( it = tmpls.begin(); it != tmpls.end() ; ++it )
|
||||
for ( auto it = tmpls.begin(); it != tmpls.end() ; ++it )
|
||||
{
|
||||
quota_del(DATASTORE, uid, gid, *it);
|
||||
|
||||
@ -219,7 +217,7 @@ public:
|
||||
* *ARE FREED* by this function
|
||||
* @param ds_quotas a map with image_id and a tmpl with usage attributes
|
||||
*/
|
||||
static void ds_del_recreate(int uid, int gid, vector<Template *>& ds_quotas);
|
||||
static void ds_del_recreate(int uid, int gid, std::vector<Template *>& ds_quotas);
|
||||
|
||||
/**
|
||||
* Delete usage from the given quota counters for the given user and group
|
||||
@ -238,7 +236,7 @@ public:
|
||||
* @param tmpl template for the image, with usage
|
||||
*/
|
||||
static void quota_check(QuotaType type, int uid, int gid, Template * tmpl,
|
||||
string& error);
|
||||
std::string& error);
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
* @param db pointer to the db
|
||||
* @return 0 on success
|
||||
*/
|
||||
int insert(int _oid, SqlDB *db, string& error_str)
|
||||
int insert(int _oid, SqlDB *db, std::string& error_str)
|
||||
{
|
||||
oid = _oid;
|
||||
return insert(db, error_str);
|
||||
@ -83,7 +83,7 @@ protected:
|
||||
|
||||
virtual const char * table_oid_column() const = 0;
|
||||
|
||||
int from_xml(const string& xml);
|
||||
int from_xml(const std::string& xml);
|
||||
|
||||
private:
|
||||
/**
|
||||
@ -103,7 +103,7 @@ private:
|
||||
* @param db pointer to the db
|
||||
* @return 0 on success
|
||||
*/
|
||||
int insert(SqlDB *db, string& error_str)
|
||||
int insert(SqlDB *db, std::string& error_str)
|
||||
{
|
||||
return insert_replace(db, false, error_str);
|
||||
};
|
||||
@ -115,7 +115,7 @@ private:
|
||||
*/
|
||||
int update(SqlDB *db)
|
||||
{
|
||||
string error_str;
|
||||
std::string error_str;
|
||||
return insert_replace(db, true, error_str);
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ private:
|
||||
* @param error_str Returns the error reason, if any
|
||||
* @return 0 one success
|
||||
*/
|
||||
int insert_replace(SqlDB *db, bool replace, string& error_str);
|
||||
int insert_replace(SqlDB *db, bool replace, std::string& error_str);
|
||||
|
||||
/**
|
||||
* Generates a string representation of the quotas in XML format, enclosed
|
||||
@ -143,7 +143,7 @@ private:
|
||||
* @param xml the string to store the XML
|
||||
* @return the same xml string to use it in << compounds
|
||||
*/
|
||||
string& to_xml_db(string& xml) const;
|
||||
std::string& to_xml_db(std::string& xml) const;
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -166,7 +166,7 @@ public:
|
||||
*/
|
||||
static int bootstrap(SqlDB * db)
|
||||
{
|
||||
ostringstream oss_quota(one_db::group_quotas_db_bootstrap);
|
||||
std::ostringstream oss_quota(one_db::group_quotas_db_bootstrap);
|
||||
|
||||
return db->exec_local_wr(oss_quota);
|
||||
};
|
||||
@ -212,7 +212,7 @@ public:
|
||||
*/
|
||||
static int bootstrap(SqlDB * db)
|
||||
{
|
||||
ostringstream oss_quota(one_db::user_quotas_db_bootstrap);
|
||||
std::ostringstream oss_quota(one_db::user_quotas_db_bootstrap);
|
||||
|
||||
return db->exec_local_wr(oss_quota);
|
||||
};
|
||||
|
@ -58,7 +58,7 @@ public:
|
||||
RaftManager(int server_id, const VectorAttribute * leader_hook_mad,
|
||||
const VectorAttribute * follower_hook_mad, time_t log_purge,
|
||||
long long bcast, long long election, time_t xmlrpc,
|
||||
const string& remotes_location);
|
||||
const std::string& remotes_location);
|
||||
|
||||
~RaftManager()
|
||||
{
|
||||
@ -136,7 +136,7 @@ public:
|
||||
|
||||
static std::string state_to_str(State _state)
|
||||
{
|
||||
string st;
|
||||
std::string st;
|
||||
|
||||
switch (_state)
|
||||
{
|
||||
@ -409,7 +409,7 @@ private:
|
||||
/**
|
||||
* Value for name column in system_attributes table for raft state.
|
||||
*/
|
||||
static const string raft_state_name;
|
||||
static const std::string raft_state_name;
|
||||
|
||||
/**
|
||||
* After becoming a leader it is replicating and applying any pending
|
||||
|
@ -18,16 +18,7 @@
|
||||
#include "SchedulerTemplate.h"
|
||||
#include "RankPolicy.h"
|
||||
#include "UserPriorityPolicy.h"
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
class RankScheduler : public Scheduler
|
||||
{
|
||||
|
@ -26,8 +26,6 @@
|
||||
#include "Quotas.h"
|
||||
#include "UserPool.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* This class represents the dynamic attributes: specific for a request of the
|
||||
* same method.
|
||||
@ -38,25 +36,25 @@ public:
|
||||
int uid; /**< id of the user */
|
||||
int gid; /**< id of the user's group */
|
||||
|
||||
string uname; /**< name of the user */
|
||||
string gname; /**< name of the user's group */
|
||||
std::string uname; /**< name of the user */
|
||||
std::string gname; /**< name of the user's group */
|
||||
|
||||
string password; /**< password of the user */
|
||||
std::string password; /**< password of the user */
|
||||
|
||||
set<int> group_ids; /**< set of user's group ids */
|
||||
std::set<int> group_ids; /**< set of user's group ids */
|
||||
|
||||
string session; /**< Session from ONE XML-RPC API */
|
||||
std::string session; /**< Session from ONE XML-RPC API */
|
||||
int req_id; /**< Request ID for log messages */
|
||||
|
||||
int umask; /**< User umask for new objects */
|
||||
|
||||
xmlrpc_c::value * retval; /**< Return value from libxmlrpc-c */
|
||||
string retval_xml; /**< Return value in XML format */
|
||||
string extra_xml; /**< Extra information returned for API Hooks */
|
||||
std::string retval_xml; /**< Return value in XML format */
|
||||
std::string extra_xml; /**< Extra information returned for API Hooks */
|
||||
|
||||
PoolObjectSQL::ObjectType resp_obj; /**< object type */
|
||||
int resp_id; /**< Id of the object */
|
||||
string resp_msg; /**< Additional response message */
|
||||
std::string resp_msg; /**< Additional response message */
|
||||
|
||||
uint64_t replication_idx;
|
||||
|
||||
@ -161,12 +159,13 @@ class ParamList
|
||||
{
|
||||
public:
|
||||
|
||||
ParamList(const xmlrpc_c::paramList * paramList, const set<int>& hidden):
|
||||
ParamList(const xmlrpc_c::paramList * paramList,
|
||||
const std::set<int>& hidden):
|
||||
_paramList(paramList), _hidden(hidden){};
|
||||
|
||||
string& to_string(string& str) const
|
||||
std::string& to_string(std::string& str) const
|
||||
{
|
||||
ostringstream oss;
|
||||
std::ostringstream oss;
|
||||
|
||||
oss << get_value_as_string(0);
|
||||
|
||||
@ -180,14 +179,14 @@ public:
|
||||
return str;
|
||||
};
|
||||
|
||||
string get_value_as_string(int index) const
|
||||
std::string get_value_as_string(int index) const
|
||||
{
|
||||
if ( index == 0 || _hidden.count(index) == 1 )
|
||||
{
|
||||
return "****";
|
||||
}
|
||||
|
||||
ostringstream oss;
|
||||
std::ostringstream oss;
|
||||
xmlrpc_c::value::type_t type((*_paramList)[index].type());
|
||||
|
||||
if( type == xmlrpc_c::value::TYPE_INT)
|
||||
@ -227,7 +226,7 @@ public:
|
||||
private:
|
||||
const xmlrpc_c::paramList * _paramList;
|
||||
|
||||
const set<int>& _hidden;
|
||||
const std::set<int>& _hidden;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -259,7 +258,7 @@ public:
|
||||
* @param ob object for the auth operation
|
||||
* @return string equivalent of the object
|
||||
*/
|
||||
static string object_name(PoolObjectSQL::ObjectType ob);
|
||||
static std::string object_name(PoolObjectSQL::ObjectType ob);
|
||||
|
||||
/**
|
||||
* Sets the format string to log xml-rpc method calls. The format string
|
||||
@ -277,7 +276,7 @@ public:
|
||||
* %a -- client port (only IPv4)
|
||||
* %% -- %
|
||||
*/
|
||||
static void set_call_log_format(const string& log_format)
|
||||
static void set_call_log_format(const std::string& log_format)
|
||||
{
|
||||
format_str = log_format;
|
||||
}
|
||||
@ -286,14 +285,14 @@ protected:
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Global configuration attributes por API calls */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
static string format_str;
|
||||
static std::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;
|
||||
string method_name;
|
||||
PoolSQL * pool;
|
||||
std::string method_name;
|
||||
|
||||
// Configuration for authentication level of the API call
|
||||
PoolObjectSQL::ObjectType auth_object;
|
||||
@ -302,8 +301,8 @@ protected:
|
||||
VMActions::Action vm_action;
|
||||
|
||||
// Logging configuration fot the API call
|
||||
set<int> hidden_params;
|
||||
bool log_method_call;
|
||||
std::set<int> hidden_params;
|
||||
bool log_method_call;
|
||||
|
||||
//Method can be only execute by leaders or solo servers
|
||||
bool leader_only;
|
||||
@ -311,7 +310,9 @@ protected:
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Class Constructors */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
Request(const string& mn, const string& signature, const string& help)
|
||||
Request(const std::string& mn,
|
||||
const std::string& signature,
|
||||
const std::string& help)
|
||||
{
|
||||
pool = nullptr;
|
||||
|
||||
@ -369,7 +370,7 @@ protected:
|
||||
PoolObjectSQL::ObjectType type,
|
||||
RequestAttributes& att,
|
||||
PoolObjectAuth& perms,
|
||||
string& name,
|
||||
std::string& name,
|
||||
bool throw_error);
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -389,7 +390,7 @@ protected:
|
||||
* @param val string to be returned to the client
|
||||
* @param att the specific request attributes
|
||||
*/
|
||||
void success_response(const string& val, RequestAttributes& att);
|
||||
void success_response(const std::string& val, RequestAttributes& att);
|
||||
|
||||
/**
|
||||
* Builds an XML-RPC response updating retval. After calling this function
|
||||
@ -424,7 +425,7 @@ protected:
|
||||
* @param ec error code for this call
|
||||
* @param att the specific request attributes
|
||||
*/
|
||||
string failure_message(ErrorCode ec, RequestAttributes& att);
|
||||
std::string failure_message(ErrorCode ec, RequestAttributes& att);
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Authorization methods for requests */
|
||||
@ -488,7 +489,7 @@ protected:
|
||||
* @return true if the user is authorized.
|
||||
*/
|
||||
static bool quota_authorization(Template * tmpl, Quotas::QuotaType qtype,
|
||||
RequestAttributes& att, string& error_str);
|
||||
RequestAttributes& att, std::string& error_str);
|
||||
|
||||
/**
|
||||
* Performs rollback on usage counters for a previous quota check operation
|
||||
@ -510,10 +511,10 @@ private:
|
||||
/* Functions to manage user and group quotas */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
static bool user_quota_authorization(Template * tmpl, Quotas::QuotaType qtype,
|
||||
RequestAttributes& att, string& error_str);
|
||||
RequestAttributes& att, std::string& error_str);
|
||||
|
||||
static bool group_quota_authorization(Template * tmpl, Quotas::QuotaType qtype,
|
||||
RequestAttributes& att, string& error_str);
|
||||
RequestAttributes& att, std::string& error_str);
|
||||
|
||||
static void user_quota_rollback(Template * tmpl, Quotas::QuotaType qtype,
|
||||
RequestAttributes& att);
|
||||
@ -528,7 +529,7 @@ private:
|
||||
* @param va string representation of the error
|
||||
* @param ra the specific request attributes
|
||||
*/
|
||||
void failure_response(ErrorCode ec, const string& va, RequestAttributes& ra);
|
||||
void failure_response(ErrorCode ec, const std::string& va, RequestAttributes& ra);
|
||||
|
||||
/**
|
||||
* Logs the method invocation, including the arguments
|
||||
@ -539,7 +540,7 @@ private:
|
||||
* @param callInfoP information of client
|
||||
*/
|
||||
static void log_method_invoked(const RequestAttributes& att,
|
||||
const xmlrpc_c::paramList& paramList, const string& format_str,
|
||||
const xmlrpc_c::paramList& paramList, const std::string& format_str,
|
||||
const std::string& method_name, const std::set<int>& hidden_params,
|
||||
const xmlrpc_c::callInfo * callInfoP);
|
||||
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
#include <set>
|
||||
|
||||
using namespace std;
|
||||
|
||||
extern "C" void * rm_action_loop(void *arg);
|
||||
|
||||
@ -36,15 +35,15 @@ class RequestManager : public ActionListener
|
||||
public:
|
||||
|
||||
RequestManager(
|
||||
const string& _port,
|
||||
const std::string& _port,
|
||||
int _max_conn,
|
||||
int _max_conn_backlog,
|
||||
int _keepalive_timeout,
|
||||
int _keepalive_max_conn,
|
||||
int _timeout,
|
||||
const string& _xml_log_file,
|
||||
const string& call_log_format,
|
||||
const string& _listen_address,
|
||||
const std::string& _xml_log_file,
|
||||
const std::string& call_log_format,
|
||||
const std::string& _listen_address,
|
||||
int message_size);
|
||||
|
||||
~RequestManager(){};
|
||||
@ -79,7 +78,7 @@ public:
|
||||
*/
|
||||
xmlrpc_c::serverAbyss * create_abyss();
|
||||
|
||||
bool exist_method(const string& call)
|
||||
bool exist_method(const std::string& call)
|
||||
{
|
||||
return RequestManagerRegistry.exist(call);
|
||||
}
|
||||
@ -97,7 +96,7 @@ private:
|
||||
registry.addMethod(name, methodP);
|
||||
};
|
||||
|
||||
bool exist(const string& call)
|
||||
bool exist(const std::string& call)
|
||||
{
|
||||
return registered_methods.find(call) != registered_methods.end();
|
||||
}
|
||||
@ -124,7 +123,7 @@ private:
|
||||
/**
|
||||
* Port number where the connection will be open
|
||||
*/
|
||||
string port;
|
||||
std::string port;
|
||||
|
||||
/*
|
||||
* FD for the XML server socket
|
||||
@ -159,12 +158,12 @@ private:
|
||||
/**
|
||||
* Filename for the log of the xmlrpc server that listens
|
||||
*/
|
||||
string xml_log_file;
|
||||
std::string xml_log_file;
|
||||
|
||||
/**
|
||||
* Specifies the address xmlrpc server will bind to
|
||||
*/
|
||||
string listen_address;
|
||||
std::string listen_address;
|
||||
|
||||
/**
|
||||
* Action engine for the Manager
|
||||
|
@ -20,8 +20,6 @@
|
||||
#include "Request.h"
|
||||
#include "Nebula.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -29,9 +27,9 @@ using namespace std;
|
||||
class RequestManagerAcl: public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerAcl( const string& method_name,
|
||||
const string& help,
|
||||
const string& params)
|
||||
RequestManagerAcl( const std::string& method_name,
|
||||
const std::string& help,
|
||||
const std::string& params)
|
||||
:Request(method_name,params,help)
|
||||
{
|
||||
auth_object = PoolObjectSQL::ACL;
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "MarketPlaceTemplate.h"
|
||||
|
||||
#include "ClusterPool.h"
|
||||
#include "DatastorePool.h"
|
||||
#include "DocumentPool.h"
|
||||
#include "HookPool.h"
|
||||
#include "HostPool.h"
|
||||
@ -43,7 +44,6 @@
|
||||
#include "VNTemplatePool.h"
|
||||
#include "ZonePool.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -52,9 +52,9 @@ using namespace std;
|
||||
class RequestManagerAllocate: public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerAllocate(const string& method_name,
|
||||
const string& help,
|
||||
const string& xml_args,
|
||||
RequestManagerAllocate(const std::string& method_name,
|
||||
const std::string& help,
|
||||
const std::string& xml_args,
|
||||
bool _do_template)
|
||||
:Request(method_name,xml_args,help), do_template(_do_template)
|
||||
{
|
||||
@ -94,7 +94,7 @@ protected:
|
||||
int& id,
|
||||
RequestAttributes& att,
|
||||
int cluster_id,
|
||||
const string& cluster_name)
|
||||
const std::string& cluster_name)
|
||||
{
|
||||
return pool_allocate(_paramList, tmpl, id, att);
|
||||
};
|
||||
@ -107,7 +107,7 @@ protected:
|
||||
virtual int add_to_cluster(
|
||||
Cluster* cluster,
|
||||
int id,
|
||||
string& error_msg)
|
||||
std::string& error_msg)
|
||||
{
|
||||
return -1;
|
||||
};
|
||||
@ -204,7 +204,7 @@ public:
|
||||
int& id,
|
||||
RequestAttributes& att,
|
||||
int cluster_id,
|
||||
const string& cluster_name) override;
|
||||
const std::string& cluster_name) override;
|
||||
|
||||
int get_cluster_id(xmlrpc_c::paramList const& paramList) override
|
||||
{
|
||||
@ -214,7 +214,7 @@ public:
|
||||
int add_to_cluster(
|
||||
Cluster* cluster,
|
||||
int id,
|
||||
string& error_msg) override
|
||||
std::string& error_msg) override
|
||||
{
|
||||
return clpool->add_to_cluster(PoolObjectSQL::NET, cluster, id, error_msg);
|
||||
};
|
||||
@ -340,7 +340,7 @@ public:
|
||||
int& id,
|
||||
RequestAttributes& att,
|
||||
int cluster_id,
|
||||
const string& cluster_name) override;
|
||||
const std::string& cluster_name) override;
|
||||
|
||||
int get_cluster_id(xmlrpc_c::paramList const& paramList) override
|
||||
{
|
||||
@ -350,7 +350,7 @@ public:
|
||||
int add_to_cluster(
|
||||
Cluster* cluster,
|
||||
int id,
|
||||
string& error_msg) override
|
||||
std::string& error_msg) override
|
||||
{
|
||||
return clpool->add_to_cluster(PoolObjectSQL::HOST, cluster, id, error_msg);;
|
||||
};
|
||||
@ -451,7 +451,7 @@ public:
|
||||
int& id,
|
||||
RequestAttributes& att,
|
||||
int cluster_id,
|
||||
const string& cluster_name) override;
|
||||
const std::string& cluster_name) override;
|
||||
|
||||
int get_cluster_id(xmlrpc_c::paramList const& paramList) override
|
||||
{
|
||||
@ -461,7 +461,7 @@ public:
|
||||
int add_to_cluster(
|
||||
Cluster* cluster,
|
||||
int id,
|
||||
string& error_msg) override
|
||||
std::string& error_msg) override
|
||||
{
|
||||
return clpool->add_to_cluster(PoolObjectSQL::DATASTORE, cluster, id, error_msg);
|
||||
};
|
||||
|
@ -25,7 +25,7 @@
|
||||
class RequestManagerAllocateDB: public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerAllocateDB(const string& name): Request(name, "A:ss",
|
||||
RequestManagerAllocateDB(const std::string& name): Request(name, "A:ss",
|
||||
"Allocates a new object from its template representation")
|
||||
{
|
||||
auth_op = AuthRequest::MANAGE;
|
||||
|
@ -33,8 +33,6 @@
|
||||
#include "VMTemplatePool.h"
|
||||
#include "VNTemplatePool.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -42,8 +40,8 @@ using namespace std;
|
||||
class RequestManagerChmod : public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerChmod(const string& method_name, const string& help,
|
||||
const string& params = "A:siiiiiiiiii"):
|
||||
RequestManagerChmod(const std::string& method_name, const std::string& help,
|
||||
const std::string& params = "A:siiiiiiiiii"):
|
||||
Request(method_name, params, help){};
|
||||
|
||||
~RequestManagerChmod(){};
|
||||
|
@ -33,8 +33,6 @@
|
||||
#include "VMTemplatePool.h"
|
||||
#include "VNTemplatePool.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -42,9 +40,9 @@ using namespace std;
|
||||
class RequestManagerChown : public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerChown(const string& method_name,
|
||||
const string& help,
|
||||
const string& params = "A:siii")
|
||||
RequestManagerChown(const std::string& method_name,
|
||||
const std::string& help,
|
||||
const std::string& params = "A:siii")
|
||||
:Request(method_name,params,help)
|
||||
{
|
||||
auth_op = AuthRequest::MANAGE;
|
||||
|
@ -25,8 +25,6 @@
|
||||
#include "SecurityGroupPool.h"
|
||||
#include "VNTemplatePool.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -34,8 +32,8 @@ using namespace std;
|
||||
class RequestManagerClone: public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerClone(const string& method_name, const string& help,
|
||||
const string& params = "A:sis"):
|
||||
RequestManagerClone(const std::string& method_name, const std::string& help,
|
||||
const std::string& params = "A:sis"):
|
||||
Request(method_name,params,help){};
|
||||
|
||||
~RequestManagerClone(){};
|
||||
@ -52,8 +50,8 @@ protected:
|
||||
/**
|
||||
* Function to clone the object
|
||||
*/
|
||||
virtual ErrorCode clone(int source_id, const string &name, int &new_id,
|
||||
bool recursive, const string& s_uattr, RequestAttributes& att);
|
||||
virtual ErrorCode clone(int source_id, const std::string &name, int &new_id,
|
||||
bool recursive, const std::string& s_uattr, RequestAttributes& att);
|
||||
|
||||
/**
|
||||
* Function to clone the base template
|
||||
@ -63,7 +61,7 @@ protected:
|
||||
/**
|
||||
* Function to merge user/additional attributes in the cloned object
|
||||
*/
|
||||
virtual ErrorCode merge(Template * tmpl, const string &str_uattrs,
|
||||
virtual ErrorCode merge(Template * tmpl, const std::string &str_uattrs,
|
||||
RequestAttributes& att)
|
||||
{
|
||||
return SUCCESS;
|
||||
@ -95,23 +93,27 @@ public:
|
||||
|
||||
~VMTemplateClone(){};
|
||||
|
||||
ErrorCode request_execute(int source_id, const string &name, int &new_id,
|
||||
bool recursive, const string& s_uattrs, RequestAttributes& att)
|
||||
ErrorCode request_execute(int source_id, const std::string &name,
|
||||
int &new_id, bool recursive,
|
||||
const std::string& s_uattrs,
|
||||
RequestAttributes& att)
|
||||
{
|
||||
return clone(source_id, name, new_id, recursive, s_uattrs, att);
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
ErrorCode clone(int source_id, const string &name, int &new_id,
|
||||
bool recursive, const string& s_a, RequestAttributes& att) override;
|
||||
ErrorCode clone(int source_id, const std::string &name, int &new_id,
|
||||
bool recursive, const std::string& s_a,
|
||||
RequestAttributes& att) override;
|
||||
|
||||
Template * clone_template(PoolObjectSQL* obj) override
|
||||
{
|
||||
return static_cast<VMTemplate*>(obj)->clone_template();
|
||||
};
|
||||
|
||||
int pool_allocate(int sid, Template * tmpl, int& id, RequestAttributes& att) override
|
||||
int pool_allocate(int sid, Template * tmpl, int& id,
|
||||
RequestAttributes& att) override
|
||||
{
|
||||
VMTemplatePool * tpool = static_cast<VMTemplatePool *>(pool);
|
||||
VirtualMachineTemplate * t = static_cast<VirtualMachineTemplate*>(tmpl);
|
||||
@ -120,7 +122,8 @@ protected:
|
||||
t, &id, att.resp_msg);
|
||||
};
|
||||
|
||||
ErrorCode merge(Template * tmpl, const string &s_a, RequestAttributes& att) override
|
||||
ErrorCode merge(Template * tmpl, const std::string &s_a,
|
||||
RequestAttributes& att) override
|
||||
{
|
||||
VMTemplateInstantiate vm_instantiate;
|
||||
|
||||
@ -147,8 +150,9 @@ public:
|
||||
|
||||
~VNTemplateClone(){};
|
||||
|
||||
ErrorCode request_execute(int source_id, const string &name, int &new_id,
|
||||
const string& s_uattrs, RequestAttributes& att)
|
||||
ErrorCode request_execute(int source_id, const std::string &name,
|
||||
int &new_id, const std::string& s_uattrs,
|
||||
RequestAttributes& att)
|
||||
{
|
||||
return clone(source_id, name, new_id, false, s_uattrs, att);
|
||||
};
|
||||
|
@ -23,8 +23,6 @@
|
||||
#include "DatastorePool.h"
|
||||
#include "VirtualNetworkPool.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -32,9 +30,9 @@ using namespace std;
|
||||
class RequestManagerCluster: public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerCluster(const string& method_name,
|
||||
const string& help,
|
||||
const string& params)
|
||||
RequestManagerCluster(const std::string& method_name,
|
||||
const std::string& help,
|
||||
const std::string& params)
|
||||
:Request(method_name,params,help)
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -98,9 +96,9 @@ protected:
|
||||
virtual int add_object(
|
||||
Cluster* cluster,
|
||||
int id,
|
||||
string& error_msg) = 0;
|
||||
std::string& error_msg) = 0;
|
||||
|
||||
virtual int del_object(Cluster* cluster, int id, string& error_msg) = 0;
|
||||
virtual int del_object(Cluster* cluster, int id, std::string& error_msg) = 0;
|
||||
|
||||
virtual void get(int oid, PoolObjectSQL ** object, Clusterable ** cluster_obj) = 0;
|
||||
};
|
||||
@ -112,9 +110,9 @@ class RequestManagerClusterHost: public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerClusterHost(
|
||||
const string& method_name,
|
||||
const string& help,
|
||||
const string& params)
|
||||
const std::string& method_name,
|
||||
const std::string& help,
|
||||
const std::string& params)
|
||||
:Request(method_name,params,help)
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -195,9 +193,9 @@ class RequestManagerClusterDatastore : public RequestManagerCluster
|
||||
{
|
||||
public:
|
||||
RequestManagerClusterDatastore(
|
||||
const string& method_name,
|
||||
const string& help,
|
||||
const string& params):
|
||||
const std::string& method_name,
|
||||
const std::string& help,
|
||||
const std::string& params):
|
||||
RequestManagerCluster(method_name, help, params){};
|
||||
|
||||
~RequestManagerClusterDatastore(){};
|
||||
@ -205,12 +203,12 @@ public:
|
||||
virtual int add_object(
|
||||
Cluster* cluster,
|
||||
int id,
|
||||
string& error_msg) override
|
||||
std::string& error_msg) override
|
||||
{
|
||||
return clpool->add_to_cluster(PoolObjectSQL::DATASTORE, cluster, id, error_msg);
|
||||
};
|
||||
|
||||
virtual int del_object(Cluster* cluster, int id, string& error_msg) override
|
||||
virtual int del_object(Cluster* cluster, int id, std::string& error_msg) override
|
||||
{
|
||||
return clpool->del_from_cluster(PoolObjectSQL::DATASTORE, cluster, id, error_msg);
|
||||
};
|
||||
@ -280,9 +278,9 @@ class RequestManagerClusterVNet : public RequestManagerCluster
|
||||
public:
|
||||
|
||||
RequestManagerClusterVNet(
|
||||
const string& method_name,
|
||||
const string& help,
|
||||
const string& params):
|
||||
const std::string& method_name,
|
||||
const std::string& help,
|
||||
const std::string& params):
|
||||
RequestManagerCluster(method_name, help, params){};
|
||||
|
||||
~RequestManagerClusterVNet(){};
|
||||
@ -290,12 +288,12 @@ public:
|
||||
virtual int add_object(
|
||||
Cluster* cluster,
|
||||
int id,
|
||||
string& error_msg) override
|
||||
std::string& error_msg) override
|
||||
{
|
||||
return clpool->add_to_cluster(PoolObjectSQL::NET, cluster, id, error_msg);
|
||||
};
|
||||
|
||||
virtual int del_object(Cluster* cluster, int id, string& error_msg) override
|
||||
virtual int del_object(Cluster* cluster, int id, std::string& error_msg) override
|
||||
{
|
||||
return clpool->del_from_cluster(PoolObjectSQL::NET, cluster, id, error_msg);
|
||||
};
|
||||
|
@ -21,8 +21,6 @@
|
||||
#include "Nebula.h"
|
||||
#include "DatastorePool.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -30,9 +28,9 @@ using namespace std;
|
||||
class RequestManagerDatastore: public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerDatastore(const string& method_name,
|
||||
const string& help,
|
||||
const string& params)
|
||||
RequestManagerDatastore(const std::string& method_name,
|
||||
const std::string& help,
|
||||
const std::string& params)
|
||||
:Request(method_name,params,help)
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
@ -19,13 +19,12 @@
|
||||
|
||||
#include "Request.h"
|
||||
#include "ClusterPool.h"
|
||||
#include "Datastore.h"
|
||||
#include "Host.h"
|
||||
#include "VirtualNetwork.h"
|
||||
|
||||
class AclManager;
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -33,12 +32,12 @@ using namespace std;
|
||||
class RequestManagerDelete: public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerDelete(const string& method_name,
|
||||
const string& params,
|
||||
const string& help);
|
||||
RequestManagerDelete(const std::string& method_name,
|
||||
const std::string& params,
|
||||
const std::string& help);
|
||||
|
||||
RequestManagerDelete(const string& method_name,
|
||||
const string& help);
|
||||
RequestManagerDelete(const std::string& method_name,
|
||||
const std::string& help);
|
||||
|
||||
~RequestManagerDelete() = default;
|
||||
|
||||
@ -52,13 +51,13 @@ protected:
|
||||
|
||||
virtual int drop(PoolObjectSQL * obj, bool resive, RequestAttributes& att);
|
||||
|
||||
virtual set<int> get_cluster_ids(PoolObjectSQL * object)
|
||||
virtual std::set<int> get_cluster_ids(PoolObjectSQL * object)
|
||||
{
|
||||
set<int> empty;
|
||||
std::set<int> empty;
|
||||
return empty;
|
||||
};
|
||||
|
||||
virtual int del_from_cluster(Cluster* cluster, int id, string& error_msg)
|
||||
virtual int del_from_cluster(Cluster* cluster, int id, std::string& error_msg)
|
||||
{
|
||||
return -1;
|
||||
};
|
||||
@ -120,12 +119,12 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
set<int> get_cluster_ids(PoolObjectSQL * object) override
|
||||
std::set<int> get_cluster_ids(PoolObjectSQL * object) override
|
||||
{
|
||||
return static_cast<VirtualNetwork*>(object)->get_cluster_ids();
|
||||
};
|
||||
|
||||
int del_from_cluster(Cluster* cluster, int id, string& error_msg) override
|
||||
int del_from_cluster(Cluster* cluster, int id, std::string& error_msg) override
|
||||
{
|
||||
return clpool->del_from_cluster(PoolObjectSQL::NET, cluster, id, error_msg);
|
||||
};
|
||||
@ -168,16 +167,16 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
set<int> get_cluster_ids(PoolObjectSQL * object) override
|
||||
std::set<int> get_cluster_ids(PoolObjectSQL * object) override
|
||||
{
|
||||
set<int> ids;
|
||||
std::set<int> ids;
|
||||
|
||||
ids.insert( static_cast<Host*>(object)->get_cluster_id() );
|
||||
|
||||
return ids;
|
||||
};
|
||||
|
||||
int del_from_cluster(Cluster* cluster, int id, string& error_msg) override
|
||||
int del_from_cluster(Cluster* cluster, int id, std::string& error_msg) override
|
||||
{
|
||||
return clpool->del_from_cluster(PoolObjectSQL::HOST, cluster, id, error_msg);
|
||||
};
|
||||
@ -229,12 +228,12 @@ public:
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
set<int> get_cluster_ids(PoolObjectSQL * object) override
|
||||
std::set<int> get_cluster_ids(PoolObjectSQL * object) override
|
||||
{
|
||||
return static_cast<Datastore*>(object)->get_cluster_ids();
|
||||
};
|
||||
|
||||
int del_from_cluster(Cluster* cluster, int id, string& error_msg) override
|
||||
int del_from_cluster(Cluster* cluster, int id, std::string& error_msg) override
|
||||
{
|
||||
return clpool->del_from_cluster(PoolObjectSQL::DATASTORE, cluster, id, error_msg);
|
||||
};
|
||||
|
@ -25,7 +25,7 @@
|
||||
class RequestManagerDropDB: public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerDropDB(const string& name): Request(name, "A:si",
|
||||
RequestManagerDropDB(const std::string& name): Request(name, "A:si",
|
||||
"Drops an object from DB")
|
||||
{
|
||||
auth_op = AuthRequest::MANAGE;
|
||||
|
@ -20,8 +20,6 @@
|
||||
#include "Request.h"
|
||||
#include "Nebula.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -29,9 +27,9 @@ using namespace std;
|
||||
class RequestManagerGroup: public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerGroup(const string& method_name,
|
||||
const string& help,
|
||||
const string& params)
|
||||
RequestManagerGroup(const std::string& method_name,
|
||||
const std::string& help,
|
||||
const std::string& params)
|
||||
:Request(method_name,params,help)
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -76,9 +74,9 @@ public:
|
||||
RequestAttributes& att) override;
|
||||
|
||||
protected:
|
||||
GroupEditAdmin( const string& method_name,
|
||||
const string& help,
|
||||
const string& params)
|
||||
GroupEditAdmin( const std::string& method_name,
|
||||
const std::string& help,
|
||||
const std::string& params)
|
||||
:Request(method_name,params,help)
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -91,7 +89,7 @@ protected:
|
||||
|
||||
UserPool* upool;
|
||||
|
||||
virtual int edit_admin(Group* group, int user_id, string& error_msg) = 0;
|
||||
virtual int edit_admin(Group* group, int user_id, std::string& error_msg) = 0;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -107,7 +105,7 @@ public:
|
||||
|
||||
~GroupAddAdmin(){};
|
||||
|
||||
int edit_admin(Group* group, int user_id, string& error_msg) override;
|
||||
int edit_admin(Group* group, int user_id, std::string& error_msg) override;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -123,7 +121,7 @@ public:
|
||||
|
||||
~GroupDelAdmin(){};
|
||||
|
||||
int edit_admin(Group* group, int user_id, string& error_msg) override;
|
||||
int edit_admin(Group* group, int user_id, std::string& error_msg) override;
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -21,8 +21,6 @@
|
||||
#include "Nebula.h"
|
||||
#include "HookPool.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -30,9 +28,9 @@ using namespace std;
|
||||
class RequestManagerHook: public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerHook(const string& method_name,
|
||||
const string& help,
|
||||
const string& params)
|
||||
RequestManagerHook(const std::string& method_name,
|
||||
const std::string& help,
|
||||
const std::string& params)
|
||||
:Request(method_name,params,help)
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
@ -21,8 +21,6 @@
|
||||
#include "Nebula.h"
|
||||
#include "HostPool.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -30,9 +28,9 @@ using namespace std;
|
||||
class RequestManagerHost: public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerHost(const string& method_name,
|
||||
const string& help,
|
||||
const string& params)
|
||||
RequestManagerHost(const std::string& method_name,
|
||||
const std::string& help,
|
||||
const std::string& params)
|
||||
:Request(method_name,params,help)
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
@ -21,8 +21,6 @@
|
||||
#include "Nebula.h"
|
||||
#include "ImagePool.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -30,9 +28,9 @@ using namespace std;
|
||||
class RequestManagerImage: public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerImage(const string& method_name,
|
||||
const string& help,
|
||||
const string& params)
|
||||
RequestManagerImage(const std::string& method_name,
|
||||
const std::string& help,
|
||||
const std::string& params)
|
||||
:Request(method_name,params,help)
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -121,7 +119,7 @@ public:
|
||||
|
||||
~ImageClone(){};
|
||||
|
||||
ErrorCode request_execute(int clone_id, const string &name, int ds_id,
|
||||
ErrorCode request_execute(int clone_id, const std::string &name, int ds_id,
|
||||
bool persistent, int &new_id, RequestAttributes& att);
|
||||
|
||||
protected:
|
||||
|
@ -38,8 +38,6 @@
|
||||
#include "ZonePool.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -47,8 +45,8 @@ using namespace std;
|
||||
class RequestManagerInfo: public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerInfo(const string& method_name,
|
||||
const string& help)
|
||||
RequestManagerInfo(const std::string& method_name,
|
||||
const std::string& help)
|
||||
:Request(method_name, "A:si", help)
|
||||
{
|
||||
auth_op = AuthRequest::USE_NO_LCK;
|
||||
@ -64,7 +62,7 @@ protected:
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
virtual void to_xml(RequestAttributes& att, PoolObjectSQL * object,
|
||||
string& str)
|
||||
std::string& str)
|
||||
{
|
||||
object->to_xml(str);
|
||||
};
|
||||
@ -93,7 +91,7 @@ public:
|
||||
|
||||
protected:
|
||||
void to_xml(RequestAttributes& att, PoolObjectSQL * object,
|
||||
string& str) override
|
||||
std::string& str) override
|
||||
{
|
||||
static_cast<VirtualMachine *>(object)->to_xml_extended(str);
|
||||
};
|
||||
@ -145,7 +143,8 @@ public:
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
protected:
|
||||
void to_xml(RequestAttributes& att, PoolObjectSQL * object, string& str) override;
|
||||
void to_xml(RequestAttributes& att, PoolObjectSQL * object,
|
||||
std::string& str) override;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -228,7 +227,8 @@ public:
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
protected:
|
||||
void to_xml(RequestAttributes& att, PoolObjectSQL * object, string& str) override
|
||||
void to_xml(RequestAttributes& att, PoolObjectSQL * object,
|
||||
std::string& str) override
|
||||
{
|
||||
static_cast<Group*>(object)->to_xml_extended(str);
|
||||
};
|
||||
@ -252,7 +252,8 @@ public:
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
protected:
|
||||
void to_xml(RequestAttributes& att, PoolObjectSQL * object, string& str) override
|
||||
void to_xml(RequestAttributes& att, PoolObjectSQL * object,
|
||||
std::string& str) override
|
||||
{
|
||||
static_cast<User*>(object)->to_xml_extended(str);
|
||||
};
|
||||
@ -437,7 +438,7 @@ public:
|
||||
|
||||
protected:
|
||||
void to_xml(RequestAttributes& att, PoolObjectSQL * object,
|
||||
string& str)
|
||||
std::string& str)
|
||||
{
|
||||
(static_cast<Hook *>(object))->to_xml_extended(str);
|
||||
};
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
#include "Request.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -28,8 +26,8 @@ using namespace std;
|
||||
class RequestManagerLock: public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerLock(const string& method_name,
|
||||
const string& help)
|
||||
RequestManagerLock(const std::string& method_name,
|
||||
const std::string& help)
|
||||
:Request(method_name, "A:sis", help)
|
||||
{
|
||||
auth_op = AuthRequest::MANAGE_NO_LCK;
|
||||
@ -54,8 +52,8 @@ protected:
|
||||
class RequestManagerUnlock: public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerUnlock(const string& method_name,
|
||||
const string& help)
|
||||
RequestManagerUnlock(const std::string& method_name,
|
||||
const std::string& help)
|
||||
:Request(method_name, "A:sii", help)
|
||||
{
|
||||
auth_op = AuthRequest::MANAGE_NO_LCK;
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
#include "Request.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -53,8 +51,8 @@ public:
|
||||
bool disable_all_acl,
|
||||
bool disable_cluster_acl,
|
||||
bool disable_group_acl,
|
||||
const string& and_str,
|
||||
string& where_str);
|
||||
const std::string& and_str,
|
||||
std::string& where_str);
|
||||
|
||||
protected:
|
||||
/*
|
||||
@ -62,9 +60,9 @@ protected:
|
||||
*/
|
||||
bool extended;
|
||||
|
||||
RequestManagerPoolInfoFilter(const string& method_name,
|
||||
const string& help,
|
||||
const string& signature)
|
||||
RequestManagerPoolInfoFilter(const std::string& method_name,
|
||||
const std::string& help,
|
||||
const std::string& signature)
|
||||
:Request(method_name,signature,help)
|
||||
{
|
||||
leader_only = false;
|
||||
@ -78,19 +76,19 @@ protected:
|
||||
int filter_flag,
|
||||
int start_id,
|
||||
int end_id,
|
||||
const string& and_clause,
|
||||
const string& or_clause,
|
||||
const std::string& and_clause,
|
||||
const std::string& or_clause,
|
||||
bool disable_all_acl,
|
||||
bool disable_cluster_acl,
|
||||
bool disable_group_acl,
|
||||
string& where_string);
|
||||
std::string& where_string);
|
||||
|
||||
void dump(RequestAttributes& att,
|
||||
int filter_flag,
|
||||
int start_id,
|
||||
int end_id,
|
||||
const string& and_clause,
|
||||
const string& or_clause);
|
||||
const std::string& and_clause,
|
||||
const std::string& or_clause);
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -108,9 +106,9 @@ public:
|
||||
|
||||
VirtualMachinePoolInfo();
|
||||
|
||||
VirtualMachinePoolInfo(const string& method_name,
|
||||
const string& help,
|
||||
const string& signature);
|
||||
VirtualMachinePoolInfo(const std::string& method_name,
|
||||
const std::string& help,
|
||||
const std::string& signature);
|
||||
|
||||
void request_execute(
|
||||
xmlrpc_c::paramList const& paramList, RequestAttributes& att) override;
|
||||
|
@ -18,9 +18,6 @@
|
||||
#define REQUEST_MANAGER_PROXY_H_
|
||||
|
||||
#include "Request.h"
|
||||
#include "Client.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -28,8 +25,10 @@ using namespace std;
|
||||
class RequestManagerProxy: public Request
|
||||
{
|
||||
public:
|
||||
RequestManagerProxy(string _method): Request("RequestManagerProxy", "?",
|
||||
"Forwards the request to another OpenNebula"), method(_method)
|
||||
RequestManagerProxy(std::string _method)
|
||||
: Request("RequestManagerProxy", "?",
|
||||
"Forwards the request to another OpenNebula")
|
||||
, method(_method)
|
||||
{
|
||||
method_name = method;
|
||||
};
|
||||
@ -45,7 +44,7 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
string method;
|
||||
std::string method;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -38,8 +38,6 @@
|
||||
#include "ZonePool.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -47,9 +45,9 @@ using namespace std;
|
||||
class RequestManagerRename : public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerRename(const string& method_name,
|
||||
const string& help,
|
||||
const string& params = "A:sis")
|
||||
RequestManagerRename(const std::string& method_name,
|
||||
const std::string& help,
|
||||
const std::string& params = "A:sis")
|
||||
:Request(method_name,params,help)
|
||||
{
|
||||
pthread_mutex_init(&mutex, 0);
|
||||
@ -68,7 +66,7 @@ protected:
|
||||
* Gets and object by name and owner. Default implementation returns no
|
||||
* object
|
||||
*/
|
||||
virtual int exist(const string& name, int uid) = 0;
|
||||
virtual int exist(const std::string& name, int uid) = 0;
|
||||
|
||||
/**
|
||||
* Batch rename of related objects. Default implementation does nothing
|
||||
@ -81,7 +79,7 @@ protected:
|
||||
*/
|
||||
bool test_and_set_rename(int oid)
|
||||
{
|
||||
pair<set<int>::iterator,bool> rc;
|
||||
std::pair<std::set<int>::iterator,bool> rc;
|
||||
|
||||
pthread_mutex_lock(&mutex);
|
||||
|
||||
@ -124,7 +122,7 @@ private:
|
||||
/**
|
||||
* Set of IDs being renamed;
|
||||
*/
|
||||
set<int> rename_ids;
|
||||
std::set<int> rename_ids;
|
||||
|
||||
};
|
||||
|
||||
@ -145,7 +143,7 @@ public:
|
||||
|
||||
~VirtualMachineRename() = default;
|
||||
|
||||
int exist(const string& name, int uid) override
|
||||
int exist(const std::string& name, int uid) override
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@ -184,7 +182,7 @@ public:
|
||||
|
||||
~TemplateRename() = default;
|
||||
|
||||
int exist(const string& name, int uid) override
|
||||
int exist(const std::string& name, int uid) override
|
||||
{
|
||||
return pool->exist(name, uid);
|
||||
}
|
||||
@ -207,7 +205,7 @@ public:
|
||||
|
||||
~VirtualNetworkTemplateRename() = default;
|
||||
|
||||
int exist(const string& name, int uid) override
|
||||
int exist(const std::string& name, int uid) override
|
||||
{
|
||||
return pool->exist(name, uid);
|
||||
}
|
||||
@ -230,7 +228,7 @@ public:
|
||||
|
||||
~VirtualNetworkRename() = default;
|
||||
|
||||
int exist(const string& name, int uid) override
|
||||
int exist(const std::string& name, int uid) override
|
||||
{
|
||||
return pool->exist(name, uid);
|
||||
}
|
||||
@ -252,7 +250,7 @@ public:
|
||||
|
||||
~ImageRename() = default;
|
||||
|
||||
int exist(const string& name, int uid) override
|
||||
int exist(const std::string& name, int uid) override
|
||||
{
|
||||
return pool->exist(name, uid);
|
||||
}
|
||||
@ -274,7 +272,7 @@ public:
|
||||
|
||||
~DocumentRename() = default;
|
||||
|
||||
int exist(const string& name, int uid) override
|
||||
int exist(const std::string& name, int uid) override
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@ -296,7 +294,7 @@ public:
|
||||
|
||||
~ClusterRename() = default;
|
||||
|
||||
int exist(const string& name, int uid) override
|
||||
int exist(const std::string& name, int uid) override
|
||||
{
|
||||
return pool->exist(name);
|
||||
}
|
||||
@ -320,7 +318,7 @@ public:
|
||||
|
||||
~DatastoreRename() = default;
|
||||
|
||||
int exist(const string& name, int uid) override
|
||||
int exist(const std::string& name, int uid) override
|
||||
{
|
||||
return pool->exist(name);
|
||||
}
|
||||
@ -345,7 +343,7 @@ public:
|
||||
};
|
||||
~HostRename() = default;
|
||||
|
||||
int exist(const string& name, int uid) override
|
||||
int exist(const std::string& name, int uid) override
|
||||
{
|
||||
return pool->exist(name);
|
||||
}
|
||||
@ -369,7 +367,7 @@ public:
|
||||
|
||||
~ZoneRename() = default;
|
||||
|
||||
int exist(const string& name, int uid) override
|
||||
int exist(const std::string& name, int uid) override
|
||||
{
|
||||
return pool->exist(name);
|
||||
}
|
||||
@ -391,7 +389,7 @@ public:
|
||||
|
||||
~SecurityGroupRename() = default;
|
||||
|
||||
int exist(const string& name, int uid) override
|
||||
int exist(const std::string& name, int uid) override
|
||||
{
|
||||
return pool->exist(name, uid);
|
||||
}
|
||||
@ -413,7 +411,7 @@ public:
|
||||
|
||||
~VdcRename() = default;
|
||||
|
||||
int exist(const string& name, int uid) override
|
||||
int exist(const std::string& name, int uid) override
|
||||
{
|
||||
return pool->exist(name);
|
||||
}
|
||||
@ -435,7 +433,7 @@ public:
|
||||
|
||||
~VirtualRouterRename() = default;
|
||||
|
||||
int exist(const string& name, int uid) override
|
||||
int exist(const std::string& name, int uid) override
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@ -457,7 +455,7 @@ public:
|
||||
|
||||
~MarketPlaceRename() = default;
|
||||
|
||||
int exist(const string& name, int uid) override
|
||||
int exist(const std::string& name, int uid) override
|
||||
{
|
||||
return pool->exist(name);
|
||||
}
|
||||
@ -481,7 +479,7 @@ public:
|
||||
|
||||
~MarketPlaceAppRename() = default;
|
||||
|
||||
int exist(const string& name, int uid) override
|
||||
int exist(const std::string& name, int uid) override
|
||||
{
|
||||
return pool->exist(name, uid);
|
||||
}
|
||||
@ -503,7 +501,7 @@ public:
|
||||
|
||||
~VMGroupRename() = default;
|
||||
|
||||
int exist(const string& name, int uid) override
|
||||
int exist(const std::string& name, int uid) override
|
||||
{
|
||||
return pool->exist(name, uid);
|
||||
}
|
||||
@ -525,7 +523,7 @@ public:
|
||||
|
||||
~HookRename() = default;
|
||||
|
||||
int exist(const string& name, int uid)
|
||||
int exist(const std::string& name, int uid)
|
||||
{
|
||||
return pool->exist(name, uid);
|
||||
}
|
||||
|
@ -20,8 +20,6 @@
|
||||
#include "Request.h"
|
||||
#include "DefaultQuotas.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -29,8 +27,10 @@ using namespace std;
|
||||
class RequestManagerSystem: public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerSystem(const string& method_name, const string& help,
|
||||
const string& params) :Request(method_name,params,help)
|
||||
RequestManagerSystem(const std::string& method_name,
|
||||
const std::string& help,
|
||||
const std::string& params)
|
||||
: Request(method_name, params, help)
|
||||
{
|
||||
auth_op = AuthRequest::ADMIN;
|
||||
};
|
||||
@ -170,8 +170,8 @@ public:
|
||||
class QuotaUpdate : public RequestManagerSystem
|
||||
{
|
||||
protected:
|
||||
QuotaUpdate(const string& method_name,
|
||||
const string& help):
|
||||
QuotaUpdate(const std::string& method_name,
|
||||
const std::string& help):
|
||||
RequestManagerSystem(method_name,
|
||||
help,
|
||||
"A:ss") { }
|
||||
@ -181,7 +181,7 @@ protected:
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att) override;
|
||||
|
||||
virtual int set_default_quota(Template *tmpl, string& error) = 0;
|
||||
virtual int set_default_quota(Template *tmpl, std::string& error) = 0;
|
||||
|
||||
const virtual DefaultQuotas* get_default_quota() = 0;
|
||||
};
|
||||
@ -196,7 +196,7 @@ public:
|
||||
QuotaUpdate("one.userquota.update",
|
||||
"Updates the default user quota limits") { }
|
||||
|
||||
int set_default_quota(Template *tmpl, string& error) override;
|
||||
int set_default_quota(Template *tmpl, std::string& error) override;
|
||||
|
||||
const DefaultQuotas* get_default_quota() override;
|
||||
};
|
||||
@ -211,7 +211,7 @@ public:
|
||||
QuotaUpdate("one.groupquota.update",
|
||||
"Updates the default group quota limits") { }
|
||||
|
||||
int set_default_quota(Template *tmpl, string& error) override;
|
||||
int set_default_quota(Template *tmpl, std::string& error) override;
|
||||
|
||||
const DefaultQuotas* get_default_quota() override;
|
||||
};
|
||||
|
@ -25,7 +25,7 @@
|
||||
class RequestManagerUpdateDB: public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerUpdateDB(const string& name): Request(name, "A:sis",
|
||||
RequestManagerUpdateDB(const std::string& name): Request(name, "A:sis",
|
||||
"Updates the DB object from a XML document")
|
||||
{
|
||||
auth_op = AuthRequest::MANAGE;
|
||||
@ -73,7 +73,7 @@ protected:
|
||||
return NO_EXISTS;
|
||||
}
|
||||
|
||||
string old_xml;
|
||||
std::string old_xml;
|
||||
|
||||
object->to_xml(old_xml);
|
||||
|
||||
|
@ -38,8 +38,6 @@
|
||||
#include "VNTemplatePool.h"
|
||||
#include "ZonePool.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -47,8 +45,8 @@ using namespace std;
|
||||
class RequestManagerUpdateTemplate: public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerUpdateTemplate(const string& method_name,
|
||||
const string& help)
|
||||
RequestManagerUpdateTemplate(const std::string& method_name,
|
||||
const std::string& help)
|
||||
:Request(method_name, "A:sis", help)
|
||||
{
|
||||
auth_op = AuthRequest::MANAGE;
|
||||
@ -61,11 +59,15 @@ protected:
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att) override;
|
||||
|
||||
virtual int replace_template(PoolObjectSQL * object, const string & tmpl,
|
||||
const RequestAttributes &att, string &error_str);
|
||||
virtual int replace_template(PoolObjectSQL * object,
|
||||
const std::string & tmpl,
|
||||
const RequestAttributes &att,
|
||||
std::string &error_str);
|
||||
|
||||
virtual int append_template(PoolObjectSQL * object, const string & tmpl,
|
||||
const RequestAttributes &att, string &error_str);
|
||||
virtual int append_template(PoolObjectSQL * object,
|
||||
const std::string & tmpl,
|
||||
const RequestAttributes &att,
|
||||
std::string &error_str);
|
||||
|
||||
/**
|
||||
* Method por updating custom values not included in PoolSQL::update
|
||||
|
@ -20,8 +20,6 @@
|
||||
#include "Request.h"
|
||||
#include "Nebula.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -29,9 +27,9 @@ using namespace std;
|
||||
class RequestManagerUser: public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerUser(const string& method_name,
|
||||
const string& help,
|
||||
const string& params)
|
||||
RequestManagerUser(const std::string& method_name,
|
||||
const std::string& help,
|
||||
const std::string& params)
|
||||
:Request(method_name,params,help)
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -51,7 +49,7 @@ protected:
|
||||
virtual int user_action(int user_id,
|
||||
xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att,
|
||||
string& error_str ) = 0;
|
||||
std::string& error_str ) = 0;
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
};
|
||||
@ -76,7 +74,7 @@ public:
|
||||
int user_action(int user_id,
|
||||
xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att,
|
||||
string& err) override;
|
||||
std::string& err) override;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -99,7 +97,7 @@ public:
|
||||
int user_action(int user_id,
|
||||
xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att,
|
||||
string& err) override;
|
||||
std::string& err) override;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -121,7 +119,7 @@ public:
|
||||
int user_action(int user_id,
|
||||
xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att,
|
||||
string& err) override;
|
||||
std::string& err) override;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -156,9 +154,9 @@ class UserEditGroup : public Request
|
||||
{
|
||||
public:
|
||||
UserEditGroup(
|
||||
const string& method_name,
|
||||
const string& help,
|
||||
const string& params):
|
||||
const std::string& method_name,
|
||||
const std::string& help,
|
||||
const std::string& params):
|
||||
Request(method_name,params,help)
|
||||
{
|
||||
auth_object = PoolObjectSQL::USER;
|
||||
@ -181,7 +179,7 @@ protected:
|
||||
int user_id,
|
||||
int group_id,
|
||||
xmlrpc_c::paramList const& _paramList,
|
||||
string& error_str) = 0;
|
||||
std::string& error_str) = 0;
|
||||
|
||||
GroupPool * gpool;
|
||||
|
||||
@ -205,7 +203,7 @@ public:
|
||||
int user_id,
|
||||
int group_id,
|
||||
xmlrpc_c::paramList const& _paramList,
|
||||
string& error_str) override;
|
||||
std::string& error_str) override;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -225,7 +223,7 @@ public:
|
||||
int user_id,
|
||||
int group_id,
|
||||
xmlrpc_c::paramList const& _paramList,
|
||||
string& error_str) override;
|
||||
std::string& error_str) override;
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -21,8 +21,6 @@
|
||||
#include "Nebula.h"
|
||||
#include "VMTemplatePool.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -30,9 +28,9 @@ using namespace std;
|
||||
class RequestManagerVMTemplate: public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerVMTemplate(const string& method_name,
|
||||
const string& help,
|
||||
const string& params)
|
||||
RequestManagerVMTemplate(const std::string& method_name,
|
||||
const std::string& help,
|
||||
const std::string& params)
|
||||
:Request(method_name,params,help)
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -79,8 +77,8 @@ public:
|
||||
*
|
||||
* @return ErroCode for the request.
|
||||
*/
|
||||
ErrorCode request_execute(int id, string name, bool on_hold,
|
||||
const string& s_uattr, Template* extra_attrs, int& vid,
|
||||
ErrorCode request_execute(int id, std::string name, bool on_hold,
|
||||
const std::string& s_uattr, Template* extra_attrs, int& vid,
|
||||
RequestAttributes& att);
|
||||
|
||||
/**
|
||||
@ -90,7 +88,8 @@ public:
|
||||
* contents. Can be empty
|
||||
* @param att the specific request attributes
|
||||
*/
|
||||
ErrorCode merge(Template * tmpl, const string &s_uattr, RequestAttributes& att);
|
||||
ErrorCode merge(Template * tmpl, const std::string &s_uattr,
|
||||
RequestAttributes& att);
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
#include "Request.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -28,9 +26,9 @@ using namespace std;
|
||||
class RequestManagerVNTemplate: public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerVNTemplate(const string& method_name,
|
||||
const string& help,
|
||||
const string& params);
|
||||
RequestManagerVNTemplate(const std::string& method_name,
|
||||
const std::string& help,
|
||||
const std::string& params);
|
||||
|
||||
~RequestManagerVNTemplate() = default;
|
||||
|
||||
@ -67,8 +65,8 @@ public:
|
||||
*
|
||||
* @return ErroCode for the request.
|
||||
*/
|
||||
ErrorCode request_execute(int id, string name,
|
||||
const string& s_uattr, Template* extra_attrs, int& vid,
|
||||
ErrorCode request_execute(int id, std::string name,
|
||||
const std::string& s_uattr, Template* extra_attrs, int& vid,
|
||||
RequestAttributes& att);
|
||||
|
||||
/**
|
||||
@ -78,7 +76,8 @@ public:
|
||||
* contents. Can be empty
|
||||
* @param att the specific request attributes
|
||||
*/
|
||||
ErrorCode merge(Template * tmpl, const string &s_uattr, RequestAttributes& att);
|
||||
ErrorCode merge(Template * tmpl, const std::string &s_uattr,
|
||||
RequestAttributes& att);
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -20,13 +20,12 @@
|
||||
#include "Request.h"
|
||||
#include "Nebula.h"
|
||||
#include "ClusterPool.h"
|
||||
#include "DatastorePool.h"
|
||||
#include "HostPool.h"
|
||||
#include "VdcPool.h"
|
||||
#include "VirtualNetworkPool.h"
|
||||
#include "ZonePool.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -38,10 +37,10 @@ public:
|
||||
RequestAttributes& att);
|
||||
|
||||
protected:
|
||||
VdcEditGroup( const string& method_name,
|
||||
const string& help,
|
||||
const string& params,
|
||||
bool _check_obj_exist)
|
||||
VdcEditGroup(const std::string& method_name,
|
||||
const std::string& help,
|
||||
const std::string& params,
|
||||
bool _check_obj_exist)
|
||||
:Request(method_name,params,help),
|
||||
check_obj_exist(_check_obj_exist)
|
||||
{
|
||||
@ -60,7 +59,7 @@ protected:
|
||||
bool check_obj_exist;
|
||||
|
||||
virtual int edit_group(
|
||||
Vdc* vdc, int group_id, string& error_msg) = 0;
|
||||
Vdc* vdc, int group_id, std::string& error_msg) = 0;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -75,7 +74,7 @@ public:
|
||||
~VdcAddGroup() = default;
|
||||
|
||||
int edit_group(
|
||||
Vdc* vdc, int group_id, string& error_msg) override;
|
||||
Vdc* vdc, int group_id, std::string& error_msg) override;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -90,7 +89,7 @@ public:
|
||||
~VdcDelGroup() = default;
|
||||
|
||||
int edit_group(
|
||||
Vdc* vdc, int group_id, string& error_msg) override;
|
||||
Vdc* vdc, int group_id, std::string& error_msg) override;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -103,11 +102,11 @@ public:
|
||||
RequestAttributes& att);
|
||||
|
||||
protected:
|
||||
VdcEditResource(const string& method_name,
|
||||
const string& help,
|
||||
const string& params,
|
||||
bool _check_obj_exist,
|
||||
PoolSQL* respool,
|
||||
VdcEditResource(const std::string& method_name,
|
||||
const std::string& help,
|
||||
const std::string& params,
|
||||
bool _check_obj_exist,
|
||||
PoolSQL* respool,
|
||||
PoolObjectSQL::ObjectType res_obj_type)
|
||||
:Request(method_name,params,help),
|
||||
check_obj_exist(_check_obj_exist),
|
||||
@ -133,7 +132,7 @@ protected:
|
||||
PoolObjectSQL::ObjectType res_obj_type;
|
||||
|
||||
virtual int edit_resource(Vdc* vdc, int zone_id, int res_id,
|
||||
string& error_msg) = 0;
|
||||
std::string& error_msg) = 0;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -148,7 +147,8 @@ public:
|
||||
|
||||
~VdcAddCluster() = default;
|
||||
|
||||
int edit_resource(Vdc* vdc, int zone_id, int res_id, string& error_msg) override;
|
||||
int edit_resource(Vdc* vdc, int zone_id, int res_id,
|
||||
std::string& error_msg) override;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -163,7 +163,8 @@ public:
|
||||
|
||||
~VdcDelCluster() = default;
|
||||
|
||||
int edit_resource(Vdc* vdc, int zone_id, int res_id, string& error_msg) override;
|
||||
int edit_resource(Vdc* vdc, int zone_id, int res_id,
|
||||
std::string& error_msg) override;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -177,7 +178,8 @@ public:
|
||||
|
||||
~VdcAddHost() = default;
|
||||
|
||||
int edit_resource(Vdc* vdc, int zone_id, int res_id, string& error_msg) override;
|
||||
int edit_resource(Vdc* vdc, int zone_id, int res_id,
|
||||
std::string& error_msg) override;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -191,7 +193,8 @@ public:
|
||||
|
||||
~VdcDelHost() = default;
|
||||
|
||||
int edit_resource(Vdc* vdc, int zone_id, int res_id, string& error_msg) override;
|
||||
int edit_resource(Vdc* vdc, int zone_id, int res_id,
|
||||
std::string& error_msg) override;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -206,7 +209,8 @@ public:
|
||||
|
||||
~VdcAddDatastore() = default;
|
||||
|
||||
int edit_resource(Vdc* vdc, int zone_id, int res_id, string& error_msg) override;
|
||||
int edit_resource(Vdc* vdc, int zone_id, int res_id,
|
||||
std::string& error_msg) override;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -221,7 +225,8 @@ public:
|
||||
|
||||
~VdcDelDatastore() = default;
|
||||
|
||||
int edit_resource(Vdc* vdc, int zone_id, int res_id, string& error_msg) override;
|
||||
int edit_resource(Vdc* vdc, int zone_id, int res_id,
|
||||
std::string& error_msg) override;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -236,7 +241,8 @@ public:
|
||||
|
||||
~VdcAddVNet() = default;
|
||||
|
||||
int edit_resource(Vdc* vdc, int zone_id, int res_id, string& error_msg) override;
|
||||
int edit_resource(Vdc* vdc, int zone_id, int res_id,
|
||||
std::string& error_msg) override;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -251,7 +257,8 @@ public:
|
||||
|
||||
~VdcDelVNet() = default;
|
||||
|
||||
int edit_resource(Vdc* vdc, int zone_id, int res_id, string& error_msg) override;
|
||||
int edit_resource(Vdc* vdc, int zone_id, int res_id,
|
||||
std::string& error_msg) override;
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user