diff --git a/include/AclManager.h b/include/AclManager.h index eb312d3fc1..1af6564617 100644 --- a/include/AclManager.h +++ b/include/AclManager.h @@ -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& user_groups, + const std::set& 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& user_groups, + const std::set& user_groups, PoolObjectSQL::ObjectType obj_type, AuthRequest::Operation op, bool disable_all_acl, bool disable_cluster_acl, bool disable_group_acl, bool& all, - vector& oids, - vector& gids, - vector& cids); + std::vector& oids, + std::vector& gids, + std::vector& 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 acl_rules; + std::multimap acl_rules; /** * Rules indexed by oid. Stores the same rules as acl_rules */ - map acl_rules_oids; + std::map 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& 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& rules); + long long user_req, + long long resource_oid_req, + long long resource_gid_req, + const std::set& 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& 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& 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 &tmp_rules); + long long user_req, + long long resource_oid_req, + long long resource_gid_req, + const std::set& 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 &tmp_rules); /** * Deletes all rules that match the user mask * diff --git a/include/AclRule.h b/include/AclRule.h index 8f2ddde329..0c5a3c3406 100644 --- a/include/AclRule.h +++ b/include/AclRule.h @@ -17,14 +17,12 @@ #ifndef ACL_RULE_H_ #define ACL_RULE_H_ -#include #include #include #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 diff --git a/include/AddressRange.h b/include/AddressRange.h index d1862ebb17..8731bb6bb2 100644 --- a/include/AddressRange.h +++ b/include/AddressRange.h @@ -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& vms, - const vector& vnets, const vector& vrs) const; + void to_xml(std::ostringstream &oss, const std::vector& vms, + const std::vector& vnets, const std::vector& 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 &inherit); + VectorAttribute * nic, const std::vector &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 &inherit); + int allocate_by_mac(const std::string& mac, PoolObjectSQL::ObjectType ot, + int obid, VectorAttribute * nic, const std::vector &inherit); - int allocate_by_ip(const string& ip, PoolObjectSQL::ObjectType ot, - int obid, VectorAttribute * nic, const vector &inherit); + int allocate_by_ip(const std::string& ip, PoolObjectSQL::ObjectType ot, + int obid, VectorAttribute * nic, const std::vector &inherit); - int allocate_by_ip6(const string& ip6, PoolObjectSQL::ObjectType ot, - int obid, VectorAttribute * nic, const vector &inherit); + int allocate_by_ip6(const std::string& ip6, PoolObjectSQL::ObjectType ot, + int obid, VectorAttribute * nic, const std::vector &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& ras); + static void set_restricted_attributes(std::vector& ras); /** * Get the security groups for this AR. * @return a reference to the security group set */ - const set& get_security_groups() const + const std::set& get_security_groups() const { return security_groups; } @@ -380,13 +378,11 @@ public: /** * Copy security groups into set */ - void get_security_groups(set& sgs) + void get_security_groups(std::set& sgs) { - std::set::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 allocated; + std::map 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 &inherit) const; + void set_vnet(VectorAttribute *nic, + const std::vector &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& inherit); + PoolObjectSQL::ObjectType ot, + int obid, + VectorAttribute* nic, + const std::vector& 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 security_groups; + std::set 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 restricted_attributes; + static std::set restricted_attributes; /** * Attributes to be process for Security Group rules diff --git a/include/AddressRangeIPAM.h b/include/AddressRangeIPAM.h index 9b61038b67..a52ee28ad5 100644 --- a/include/AddressRangeIPAM.h +++ b/include/AddressRangeIPAM.h @@ -20,7 +20,6 @@ #include #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 diff --git a/include/AddressRangeInternal.h b/include/AddressRangeInternal.h index ddda4f7681..b9b53a5c3c 100644 --- a/include/AddressRangeInternal.h +++ b/include/AddressRangeInternal.h @@ -20,7 +20,6 @@ #include #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; }; diff --git a/include/AddressRangePool.h b/include/AddressRangePool.h index f335ed831e..a43518a9c8 100644 --- a/include/AddressRangePool.h +++ b/include/AddressRangePool.h @@ -22,15 +22,12 @@ #include #include -#include - #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 ars, bool keep_restricted, - string& error_msg); + int update_ar(std::vector 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 &inherit); + VectorAttribute * nic, const std::vector &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 &inherit); + int allocate_by_mac(const std::string &mac, PoolObjectSQL::ObjectType ot, + int obid, VectorAttribute * nic, + const std::vector &inherit); - int allocate_by_ip(const string &ip, PoolObjectSQL::ObjectType ot, int obid, - VectorAttribute * nic, const vector &inherit); + int allocate_by_ip(const std::string &ip, PoolObjectSQL::ObjectType ot, + int obid, VectorAttribute * nic, + const std::vector &inherit); - int allocate_by_ip6(const string &ip, PoolObjectSQL::ObjectType ot, int obid, - VectorAttribute * nic, const vector &inherit); + int allocate_by_ip6(const std::string &ip, PoolObjectSQL::ObjectType ot, + int obid, VectorAttribute * nic, + const std::vector &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 &new_rules); + VectorAttribute * rule, + std::vector &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& get_security_groups(int ar_id) const; + const std::set& 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& sgs); + void get_all_security_groups(std::set& 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& vms, - const vector& vnets, const vector& vrs) const; + std::string& to_xml(std::string& sstream, + bool extended, + const std::vector& vms, + const std::vector& vnets, + const std::vector& vrs) const; /** * Encrypt all secret attributes @@ -368,7 +374,7 @@ private: /** * Map to access each range */ - map ar_pool; + std::map 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 diff --git a/include/Attribute.h b/include/Attribute.h index eebef005ab..47438322d0 100644 --- a/include/Attribute.h +++ b/include/Attribute.h @@ -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& eas) {}; + virtual void encrypt(const std::string& one_key, const std::set& eas) {}; /** * Decrypt all secret attributes */ - virtual void decrypt(const string& one_key, const set& eas) {}; + virtual void decrypt(const std::string& one_key, const std::set& 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& eas) override; + void encrypt(const std::string& one_key, + const std::set& eas) override; /** * Decrypt all secret attributes */ - virtual void decrypt(const string& one_key, const set& eas) override; + void decrypt(const std::string& one_key, + const std::set& 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& value): + VectorAttribute(const std::string& name, + const std::map& 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& value() const + const std::map& 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 - int vector_value(const string& name, T& value) const + int vector_value(const std::string& name, T& value) const { - map::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 - 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 - string vector_value_str(const string& name, T& value) const + std::string vector_value_str(const std::string& name, T& value) const { - map::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& attr); + void replace(const std::map& 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 - 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& eas) override; + void encrypt(const std::string& one_key, + const std::set& eas) override; /** * Decrypt all secret attributes */ - virtual void decrypt(const string& one_key, const set& eas) override; + void decrypt(const std::string& one_key, + const std::set& eas) override; private: @@ -512,7 +513,7 @@ private: static const int magic_sep_size; - map attribute_value; + std::map attribute_value; }; #endif /*ATTRIBUTE_H_*/ diff --git a/include/AuthManager.h b/include/AuthManager.h index cabcdaf8a0..076a076ae9 100644 --- a/include/AuthManager.h +++ b/include/AuthManager.h @@ -175,7 +175,7 @@ private: * @return the Auth driver with attribute name equal to value * or 0 in not found */ - const Driver * get(const string& name) + const Driver * get(const std::string& name) { return DriverManager::get_driver(name); } @@ -214,22 +214,22 @@ private: /** * */ - static void _undefined(unique_ptr msg); + static void _undefined(std::unique_ptr msg); /** * */ - void _authorize(unique_ptr msg); + void _authorize(std::unique_ptr msg); /** * */ - void _authenticate(unique_ptr msg); + void _authenticate(std::unique_ptr msg); /** * */ - static void _log(unique_ptr msg); + static void _log(std::unique_ptr msg); // ------------------------------------------------------------------------- // Action Listener interface diff --git a/include/CachePool.h b/include/CachePool.h index dd0b2f0b1b..f791023dab 100644 --- a/include/CachePool.h +++ b/include/CachePool.h @@ -17,15 +17,9 @@ #ifndef CACHE_POOL_H_ #define CACHE_POOL_H_ -#include -#include #include +#include -#include - -#include - -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::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::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::iterator it = resources.find(oid); + auto it = resources.find(oid); if ( it != resources.end() ) { diff --git a/include/Callbackable.h b/include/Callbackable.h index 171fc97d89..e95b6f94f5 100644 --- a/include/Callbackable.h +++ b/include/Callbackable.h @@ -24,8 +24,6 @@ #include -using namespace std; - /** * This class represents a SQL callback */ @@ -233,7 +231,7 @@ public: private: - set * ids; + std::set * ids; }; /* -------------------------------------------------------------------------- */ @@ -243,7 +241,7 @@ template class vector_cb : public Callbackable { public: - void set_callback(vector * _oids) + void set_callback(std::vector * _oids) { oids = _oids; @@ -271,7 +269,7 @@ public: private: - vector * oids; + std::vector * 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; }; /* -------------------------------------------------------------------------- */ diff --git a/include/Client.h b/include/Client.h index 23ecea1ba7..c200cdb72c 100644 --- a/include/Client.h +++ b/include/Client.h @@ -23,8 +23,6 @@ #include -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; diff --git a/include/Cluster.h b/include/Cluster.h index 143a60aa79..9834f028a8 100644 --- a/include/Cluster.h +++ b/include/Cluster.h @@ -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 get_datastores() + std::set 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& ds_collection); + static int get_default_system_ds(const std::set& ds_collection); /** * Returns a copy of the host IDs set */ - set get_host_ids() + std::set get_host_ids() { return hosts.clone(); } @@ -59,7 +58,7 @@ public: /** * Returns a copy of the datastore IDs set */ - set get_datastore_ids() + std::set get_datastore_ids() { return datastores.clone(); } @@ -67,7 +66,7 @@ public: /** * Returns a copy of the vnet IDs set */ - set get_vnet_ids() + std::set 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; diff --git a/include/ClusterPool.h b/include/ClusterPool.h index bda1f65134..5b6e34873f 100644 --- a/include/ClusterPool.h +++ b/include/ClusterPool.h @@ -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& encrypted_attrs); + std::vector& 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& cids); + static void cluster_acl_filter(std::ostringstream& filter, + PoolObjectSQL::ObjectType auth_object, const std::vector& 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 &cluster_ids); + int query_datastore_clusters(int oid, std::set &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 &cluster_ids); + int query_vnet_clusters(int oid, std::set &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. diff --git a/include/ClusterTemplate.h b/include/ClusterTemplate.h index 6762fd8daa..53a7590e7a 100644 --- a/include/ClusterTemplate.h +++ b/include/ClusterTemplate.h @@ -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& ea) + static void parse_encrypted(std::vector& ea) { Template::parse_encrypted(ea, encrypted); } diff --git a/include/Datastore.h b/include/Datastore.h index bae3394985..166d00984d 100644 --- a/include/Datastore.h +++ b/include/Datastore.h @@ -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 get_image_ids() + std::set 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& inherit_attrs); + VirtualMachineDisk * disk, + const std::vector& 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 &compatible_sys_ds) + void get_compatible_system_ds(std::set &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 &cluster_ids); + const std::set &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_*/ diff --git a/include/DatastorePool.h b/include/DatastorePool.h index aa5ee26c64..f3f775659c 100644 --- a/include/DatastorePool.h +++ b/include/DatastorePool.h @@ -21,15 +21,13 @@ #include "PoolSQL.h" #include "OneDB.h" -using namespace std; - class DatastorePool : public PoolSQL { public: DatastorePool(SqlDB * db, - const vector& _inherit_attrs, - vector& encrypted_attrs); + const std::vector& _inherit_attrs, + std::vector& 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 &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& 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& oids) + int list(std::vector& oids) { return PoolSQL::list(oids, one_db::ds_table); } @@ -181,7 +179,7 @@ private: /** * Datastore attributes to be inherited into the VM disk */ - vector inherit_attrs; + std::vector inherit_attrs; /** * Factory method to produce objects @@ -189,7 +187,7 @@ private: */ PoolObjectSQL * create() { - set empty; + std::set empty; return new Datastore(-1,-1,"","", 0, 0, empty); }; diff --git a/include/DatastoreTemplate.h b/include/DatastoreTemplate.h index 7e983b5b82..6d1631ea07 100644 --- a/include/DatastoreTemplate.h +++ b/include/DatastoreTemplate.h @@ -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& ea) + static void parse_encrypted(std::vector& ea) { Template::parse_encrypted(ea, encrypted); } diff --git a/include/DefaultQuotas.h b/include/DefaultQuotas.h index 807763a5b0..57708c8537 100644 --- a/include/DefaultQuotas.h +++ b/include/DefaultQuotas.h @@ -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_*/ diff --git a/include/DispatchManager.h b/include/DispatchManager.h index 914dd39f5e..d7af4b222d 100644 --- a/include/DispatchManager.h +++ b/include/DispatchManager.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 diff --git a/include/Document.h b/include/Document.h index 4f424698a6..93d9b9da22 100644 --- a/include/Document.h +++ b/include/Document.h @@ -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); }; }; diff --git a/include/DocumentPool.h b/include/DocumentPool.h index bdcff3d029..ffbecff021 100644 --- a/include/DocumentPool.h +++ b/include/DocumentPool.h @@ -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), diff --git a/include/DriverManager.h b/include/DriverManager.h index 8fbc66cf71..52eba1b1f4 100644 --- a/include/DriverManager.h +++ b/include/DriverManager.h @@ -36,7 +36,7 @@ public: int load_driver(const VectorAttribute* mad_config); - int load_drivers(const vector& mads_config); + int load_drivers(const std::vector& mads_config); D * get_driver(const std::string& name) const; @@ -156,7 +156,7 @@ int DriverManager::load_driver(const VectorAttribute* mad_config) /* -------------------------------------------------------------------------- */ template -int DriverManager::load_drivers(const vector& mads_config) +int DriverManager::load_drivers(const std::vector& mads_config) { NebulaLog::info("DrM", "Loading drivers."); @@ -224,12 +224,12 @@ int DriverManager::start(std::string& error) template void DriverManager::stop(int secs) { - vector threads; + std::vector 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::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)); } /* -------------------------------------------------------------------------- */ diff --git a/include/ExtendedAttribute.h b/include/ExtendedAttribute.h index d4cc9a3d6d..590fe420ca 100644 --- a/include/ExtendedAttribute.h +++ b/include/ExtendedAttribute.h @@ -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)); } /** diff --git a/include/Group.h b/include/Group.h index 96e4b2623c..f46c261501 100644 --- a/include/Group.h +++ b/include/Group.h @@ -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_*/ diff --git a/include/GroupPool.h b/include/GroupPool.h index f281189622..74b237bcca 100644 --- a/include/GroupPool.h +++ b/include/GroupPool.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& restricted_attrs); + std::vector& 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: diff --git a/include/GroupTemplate.h b/include/GroupTemplate.h index 158cce467e..5896850788 100644 --- a/include/GroupTemplate.h +++ b/include/GroupTemplate.h @@ -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& ra) + static void parse_restricted(std::vector& ra) { Template::parse_restricted(ra, restricted); } diff --git a/include/History.h b/include/History.h index 3d898187f8..d9c9dfeb8c 100644 --- a/include/History.h +++ b/include/History.h @@ -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); diff --git a/include/Hook.h b/include/Hook.h index b77b233a8c..fb84434831 100644 --- a/include/Hook.h +++ b/include/Hook.h @@ -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 diff --git a/include/HookManager.h b/include/HookManager.h index 24d6cae26f..008a6d3342 100644 --- a/include/HookManager.h +++ b/include/HookManager.h @@ -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 msg); + static void _undefined(std::unique_ptr msg); /** * */ - void _execute(unique_ptr msg); + void _execute(std::unique_ptr msg); /** * */ - void _retry(unique_ptr msg); + void _retry(std::unique_ptr msg); /** * */ - static void _log(unique_ptr msg); + static void _log(std::unique_ptr msg); // ------------------------------------------------------------------------- // Action Listener interface diff --git a/include/HookPool.h b/include/HookPool.h index 481e8c68b3..2dbddf20d4 100644 --- a/include/HookPool.h +++ b/include/HookPool.h @@ -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 diff --git a/include/Host.h b/include/Host.h index f40124f2fe..a8e06c63f1 100644 --- a/include/Host.h +++ b/include/Host.h @@ -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 get_vm_ids() + std::set 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 diff --git a/include/HostPool.h b/include/HostPool.h index 4e01d1c48e..1511fbd9dc 100644 --- a/include/HostPool.h +++ b/include/HostPool.h @@ -22,7 +22,6 @@ #include "HostMonitoringTemplate.h" #include "OneDB.h" -#include #include #include @@ -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(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(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(objsql); @@ -233,7 +232,7 @@ public: * * @return 0 on success */ - int search(vector& oids, const string& where) + int search(std::vector& 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; diff --git a/include/HostShare.h b/include/HostShare.h index 1778bcfe72..20a25957b4 100644 --- a/include/HostShare.h +++ b/include/HostShare.h @@ -19,9 +19,6 @@ #include "ObjectXML.h" #include "Template.h" -#include -#include -#include #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& pci_devs, string& error) const; + bool test_pci(std::vector& 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_*/ diff --git a/include/HostShareCapacity.h b/include/HostShareCapacity.h index 4eff347ed8..45e272dbbf 100644 --- a/include/HostShareCapacity.h +++ b/include/HostShareCapacity.h @@ -48,11 +48,11 @@ struct HostShareCapacity long long mem; long long disk; - vector pci; + std::vector pci; VectorAttribute * topology; - vector nodes; + std::vector nodes; }; #endif /*HOST_SHARE_CAPACITY_H_*/ diff --git a/include/HostShareNUMA.h b/include/HostShareNUMA.h index a22f25dfa3..f59476b084 100644 --- a/include/HostShareNUMA.h +++ b/include/HostShareNUMA.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 &ns, unsigned int _vt); + int from_xml_node(const std::vector &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); diff --git a/include/HostSharePCI.h b/include/HostSharePCI.h index b746a116fa..c6ec7e77d4 100644 --- a/include/HostSharePCI.h +++ b/include/HostSharePCI.h @@ -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 &devs) const; + bool test(const std::vector &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 &devs, int vmid); + void add(std::vector &devs, int vmid); /** * Remove the VM assignment from the PCI device list */ - void del(const vector &devs); + void del(const std::vector &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 pci_devices; + std::map pci_devices; }; #endif /*HOST_SHARE_PCI_H_*/ diff --git a/include/HostTemplate.h b/include/HostTemplate.h index 0ef033c06d..15e20fd633 100644 --- a/include/HostTemplate.h +++ b/include/HostTemplate.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& ea) + static void parse_encrypted(std::vector& ea) { Template::parse_encrypted(ea, encrypted); } diff --git a/include/IPAMManager.h b/include/IPAMManager.h index 94b86eaefc..b3afacda3b 100644 --- a/include/IPAMManager.h +++ b/include/IPAMManager.h @@ -210,17 +210,17 @@ private: /** * */ - static void _undefined(unique_ptr msg); + static void _undefined(std::unique_ptr msg); /** * */ - void _notify_request(unique_ptr msg); + void _notify_request(std::unique_ptr msg); /** * */ - static void _log(unique_ptr msg); + static void _log(std::unique_ptr msg); // ------------------------------------------------------------------------- // Action Listener interface diff --git a/include/IPAMRequest.h b/include/IPAMRequest.h index b6d9f8ebaf..58946d488b 100644 --- a/include/IPAMRequest.h +++ b/include/IPAMRequest.h @@ -163,12 +163,12 @@ private: /** * XML representation for this request ... */ - 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 diff --git a/include/Image.h b/include/Image.h index f56ce41144..4eb2b72bd4 100644 --- a/include/Image.h +++ b/include/Image.h @@ -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 get_running_ids() const + std::set 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& inherit_attrs); + void disk_attribute(VirtualMachineDisk * disk, + ImageType& img_type, + std::string& dev_prefix, + const std::vector& 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. diff --git a/include/ImageManager.h b/include/ImageManager.h index 5afc058d5f..f20e8ba3c1 100644 --- a/include/ImageManager.h +++ b/include/ImageManager.h @@ -405,57 +405,57 @@ private: /** * */ - static void _undefined(unique_ptr msg); + static void _undefined(std::unique_ptr msg); /** * */ - void _stat(unique_ptr msg); + void _stat(std::unique_ptr msg); /** * */ - void _cp(unique_ptr msg); + void _cp(std::unique_ptr msg); /** * */ - void _clone(unique_ptr msg); + void _clone(std::unique_ptr msg); /** * */ - void _mkfs(unique_ptr msg); + void _mkfs(std::unique_ptr msg); /** * */ - void _rm(unique_ptr msg); + void _rm(std::unique_ptr msg); /** * */ - void _monitor(unique_ptr msg); + void _monitor(std::unique_ptr msg); /** * */ - void _snap_delete(unique_ptr msg); + void _snap_delete(std::unique_ptr msg); /** * */ - void _snap_revert(unique_ptr msg); + void _snap_revert(std::unique_ptr msg); /** * */ - void _snap_flatten(unique_ptr msg); + void _snap_flatten(std::unique_ptr msg); /** * */ - static void _log(unique_ptr msg); + static void _log(std::unique_ptr msg); // ------------------------------------------------------------------------- // Action Listener interface diff --git a/include/ImagePool.h b/include/ImagePool.h index af72ccfd49..0cdc6d532b 100644 --- a/include/ImagePool.h +++ b/include/ImagePool.h @@ -23,16 +23,11 @@ #include "Datastore.h" #include "OneDB.h" -#include -#include - -#include #include 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& restricted_attrs, - const vector& _inherit_image_attrs); + const std::string& __default_type, + const std::string& __default_dev_prefix, + const std::string& __default_cdrom_dev_prefix, + std::vector& restricted_attrs, + const std::vector& _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(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(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 inherit_attrs; + std::vector inherit_attrs; //-------------------------------------------------------------------------- // Pool Attributes diff --git a/include/ImageTemplate.h b/include/ImageTemplate.h index 3d89bde778..bf12650247 100644 --- a/include/ImageTemplate.h +++ b/include/ImageTemplate.h @@ -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& ra) + static void parse_restricted(std::vector& ra) { Template::parse_restricted(ra, restricted); } diff --git a/include/InformationManager.h b/include/InformationManager.h index 88366d469d..4ed6d15b5c 100644 --- a/include/InformationManager.h +++ b/include/InformationManager.h @@ -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 msg); + static void _undefined(std::unique_ptr msg); /** * Message HOST_STATE update from monitor */ - void _host_state(unique_ptr msg); + void _host_state(std::unique_ptr msg); /** * Message HOST_SYSTEM update from monitor */ - void _host_system(unique_ptr msg); + void _host_system(std::unique_ptr msg); /** * Message VM_STATE from monitor */ - void _vm_state(unique_ptr msg); + void _vm_state(std::unique_ptr msg); private: /** diff --git a/include/LifeCycleManager.h b/include/LifeCycleManager.h index a43abb69d4..a7370a9642 100644 --- a/include/LifeCycleManager.h +++ b/include/LifeCycleManager.h @@ -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; /* -------------------------------------------------------------------------- */ diff --git a/include/Log.h b/include/Log.h index 8c4d634b0d..af7591de59 100644 --- a/include/Log.h +++ b/include/Log.h @@ -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_ */ diff --git a/include/LogDB.h b/include/LogDB.h index 23558529ff..b7ce2e995f 100644 --- a/include/LogDB.h +++ b/include/LogDB.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); } diff --git a/include/MarketPlace.h b/include/MarketPlace.h index d8a9c50543..499dbf3d0c 100644 --- a/include/MarketPlace.h +++ b/include/MarketPlace.h @@ -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 get_marketapp_ids() + std::set 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*/ diff --git a/include/MarketPlaceApp.h b/include/MarketPlaceApp.h index 9dc1990f95..6870f4dc05 100644 --- a/include/MarketPlaceApp.h +++ b/include/MarketPlaceApp.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. diff --git a/include/MarketPlaceAppPool.h b/include/MarketPlaceAppPool.h index d196bda453..9af9acc97b 100644 --- a/include/MarketPlaceAppPool.h +++ b/include/MarketPlaceAppPool.h @@ -191,7 +191,7 @@ private: /** * Hash to store the number of times an app was missing from monitor data */ - map map_check; + std::map map_check; /** * Max number of monitor that an app may be missing before deleting it diff --git a/include/MarketPlaceManager.h b/include/MarketPlaceManager.h index d811581231..8158ed80c0 100644 --- a/include/MarketPlaceManager.h +++ b/include/MarketPlaceManager.h @@ -218,11 +218,11 @@ private: // ------------------------------------------------------------------------- // Protocol implementation, procesing messages from driver // ------------------------------------------------------------------------- - static void _undefined(unique_ptr msg); - void _import(unique_ptr msg); - void _delete(unique_ptr msg); - void _monitor(unique_ptr msg); - static void _log(unique_ptr msg); + static void _undefined(std::unique_ptr msg); + void _import(std::unique_ptr msg); + void _delete(std::unique_ptr msg); + void _monitor(std::unique_ptr msg); + static void _log(std::unique_ptr msg); // ------------------------------------------------------------------------- // Action Listener interface diff --git a/include/MySqlDB.h b/include/MySqlDB.h index 4a5186c64f..8956ddc311 100644 --- a/include/MySqlDB.h +++ b/include/MySqlDB.h @@ -95,7 +95,7 @@ private: /** * The MySql connection pool handler */ - queue db_connect; + std::queue db_connect; /** * Cached DB connection to escape strings (it uses the server character set) diff --git a/include/Nebula.h b/include/Nebula.h index d603af55ec..823e3fecb8 100644 --- a/include/Nebula.h +++ b/include/Nebula.h @@ -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 - 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 - 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 diff --git a/include/NebulaLog.h b/include/NebulaLog.h index 3c5e2ee700..d3c5de924b 100644 --- a/include/NebulaLog.h +++ b/include/NebulaLog.h @@ -22,8 +22,6 @@ #include #include -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()); } diff --git a/include/NebulaService.h b/include/NebulaService.h index 38045ab233..bc29a71579 100644 --- a/include/NebulaService.h +++ b/include/NebulaService.h @@ -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 - 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_*/ diff --git a/include/NebulaTemplate.h b/include/NebulaTemplate.h index 5857f224c2..89b97ed5d6 100644 --- a/include/NebulaTemplate.h +++ b/include/NebulaTemplate.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 conf_default; + std::multimap conf_default; /** * Sets the defaults value for the template diff --git a/include/ObjectCollection.h b/include/ObjectCollection.h index 7868e09bf3..68d85000d3 100644 --- a/include/ObjectCollection.h +++ b/include/ObjectCollection.h @@ -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& cset) + ObjectCollection(const std::string& cname, const std::set& 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 clone() const + std::set clone() const { - return set(collection_set); + return std::set(collection_set); }; /** * Returns a reference to the IDs set */ - const set& get_collection() const + const std::set& 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 collection_set; + std::set collection_set; /** * Rebuilds the object from an xml node diff --git a/include/ObjectSQL.h b/include/ObjectSQL.h index 1c4b3e5776..2894e95f62 100644 --- a/include/ObjectSQL.h +++ b/include/ObjectSQL.h @@ -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. diff --git a/include/OpenNebulaTemplate.h b/include/OpenNebulaTemplate.h index 7edd9f5669..18e56c5d75 100644 --- a/include/OpenNebulaTemplate.h +++ b/include/OpenNebulaTemplate.h @@ -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 diff --git a/include/PoolObjectAuth.h b/include/PoolObjectAuth.h index 4f9b7fb858..87b480521b 100644 --- a/include/PoolObjectAuth.h +++ b/include/PoolObjectAuth.h @@ -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 cids; + std::set cids; int owner_u; int owner_m; diff --git a/include/PoolObjectSQL.h b/include/PoolObjectSQL.h index 1080ea8035..78bc083271 100644 --- a/include/PoolObjectSQL.h +++ b/include/PoolObjectSQL.h @@ -24,8 +24,6 @@ #include #include -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 - int get_template_attribute(const string& name, vector& values) const - { - return obj_template->get(name, values); - }; - - template - int get_template_attribute(const string& name, vector& values) const + int get_template_attribute(const std::string& name, + std::vector& values) const { return obj_template->get(name, values); }; @@ -404,7 +399,7 @@ public: * target value */ template - 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 - 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 - 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 - int remove_template_attribute(const string& n, vector& v) + int remove_template_attribute(const std::string& n, std::vector& 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 - 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 - void add_template_attribute(vector& values) + void add_template_attribute(std::vector& 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 diff --git a/include/PoolSQL.h b/include/PoolSQL.h index f74f5c6235..492c95616b 100644 --- a/include/PoolSQL.h +++ b/include/PoolSQL.h @@ -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& id_list); + void exist(const std::string& id_str, std::set& id_list); /** * Finds a set objects that satisfies a given condition @@ -107,9 +105,9 @@ public: * @return 0 on success */ virtual int search( - vector& oids, - const char * table, - const string& where); + std::vector& 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& oids, - const char * table) + std::vector& 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& user_groups, + const std::set& 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& user_groups, - int filter_flag, - bool all, - const string& acl_str, - string& filter); + static void usr_filter(int uid, + int gid, + const std::set& 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, diff --git a/include/PostgreSqlDB.h b/include/PostgreSqlDB.h index ee0ca0abde..1ef42693fa 100644 --- a/include/PostgreSqlDB.h +++ b/include/PostgreSqlDB.h @@ -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 @@ -64,7 +64,7 @@ public: * @param eid the rowcount * @return string with compatible LIMIT clause syntax * LIMIT row_count OFFSET offset - * + * * +---+---+---+---+---+---+---+---+-- * | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |... * +---+---+---+---+---+---+---+---+-- @@ -102,7 +102,7 @@ private: /** * Connection pool */ - queue db_connect; + std::queue 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 {}; diff --git a/include/Quota.h b/include/Quota.h index 067d44d4c5..230a1ea25f 100644 --- a/include/Quota.h +++ b/include/Quota.h @@ -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 * quotas, string& error) = 0; + virtual int set(std::vector * 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 * quotas, string& error) + virtual int set(std::vector * 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 * quotas, string& error); + int set(std::vector * 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::iterator it; + std::map::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& usage_req, + bool check_quota(const std::string& qid, + std::map& 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& usage_req); + void del_quota(const std::string& qid, + std::map& 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::iterator& it); + std::map::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& limits); + int get_limits(const VectorAttribute * va, + std::map& limits); }; #endif /*QUOTA_H_*/ diff --git a/include/QuotaDatastore.h b/include/QuotaDatastore.h index 3276852ebc..d6b5ea2434 100644 --- a/include/QuotaDatastore.h +++ b/include/QuotaDatastore.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); diff --git a/include/QuotaImage.h b/include/QuotaImage.h index 351bb06b05..2de3aa54bb 100644 --- a/include/QuotaImage.h +++ b/include/QuotaImage.h @@ -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); diff --git a/include/QuotaNetwork.h b/include/QuotaNetwork.h index 3c08a168c7..50ef05a8a1 100644 --- a/include/QuotaNetwork.h +++ b/include/QuotaNetwork.h @@ -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(quota); diff --git a/include/QuotaVirtualMachine.h b/include/QuotaVirtualMachine.h index 6071f3e274..2639e4f77d 100644 --- a/include/QuotaVirtualMachine.h +++ b/include/QuotaVirtualMachine.h @@ -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::iterator& it) + std::map::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); diff --git a/include/Quotas.h b/include/Quotas.h index 3f45962d5a..347756af2f 100644 --- a/include/Quotas.h +++ b/include/Quotas.h @@ -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