mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-25 02:50:08 +03:00
parent
2721b50625
commit
123e08cfd6
@ -324,7 +324,6 @@ private:
|
||||
{
|
||||
std::vector<std::string> strings;
|
||||
std::vector<std::string> range;
|
||||
std::vector<std::string>::const_iterator it;
|
||||
|
||||
std::istringstream iss;
|
||||
|
||||
@ -332,10 +331,10 @@ private:
|
||||
|
||||
strings = one_util::split(reserved, ',', true);
|
||||
|
||||
for (it = strings.begin(); it != strings.end(); it++)
|
||||
for (const auto& str : strings)
|
||||
{
|
||||
// Try to split it by ':'
|
||||
range = one_util::split(*it, ':', true);
|
||||
range = one_util::split(str, ':', true);
|
||||
|
||||
iss.clear();
|
||||
iss.str(range[0]);
|
||||
|
@ -183,13 +183,12 @@ namespace one_util
|
||||
void split_unique(const std::string& st, char delim, std::set<T>& result)
|
||||
{
|
||||
T elem;
|
||||
std::vector<std::string>::const_iterator it;
|
||||
|
||||
std::vector<std::string> strings = split(st, delim, true);
|
||||
|
||||
for (it = strings.begin(); it != strings.end(); it++)
|
||||
for (const auto& str : strings)
|
||||
{
|
||||
std::istringstream iss(*it);
|
||||
std::istringstream iss(str);
|
||||
iss >> elem;
|
||||
|
||||
if ( iss.fail() )
|
||||
|
@ -262,11 +262,9 @@ public:
|
||||
*/
|
||||
void free_nodes(std::vector<xmlNodePtr>& content) const
|
||||
{
|
||||
std::vector<xmlNodePtr>::iterator it;
|
||||
|
||||
for (it = content.begin(); it < content.end(); it++)
|
||||
for (auto it : content)
|
||||
{
|
||||
xmlFreeNode(*it);
|
||||
xmlFreeNode(it);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -220,12 +220,11 @@ public:
|
||||
*/
|
||||
uint64_t get_next_index(int follower_id)
|
||||
{
|
||||
std::map<int, uint64_t>::iterator it;
|
||||
uint64_t _index = UINT64_MAX;
|
||||
|
||||
std::lock_guard<std::mutex> lock(raft_mutex);
|
||||
|
||||
it = next.find(follower_id);
|
||||
auto it = next.find(follower_id);
|
||||
|
||||
if ( it != next.end() )
|
||||
{
|
||||
|
@ -127,9 +127,9 @@ public:
|
||||
|
||||
std::lock_guard<std::mutex> lock(_mutex);
|
||||
|
||||
std::map<uint64_t, ReplicaRequest *>::iterator it = requests.find(rindex);
|
||||
auto it = requests.find(rindex);
|
||||
|
||||
if ( it != requests.end() && it->second != 0 )
|
||||
if ( it != requests.end() && it->second )
|
||||
{
|
||||
it->second->add_replica();
|
||||
|
||||
|
@ -347,13 +347,11 @@ private:
|
||||
|
||||
VMGroupRole * get(T k)
|
||||
{
|
||||
typename std::map<T, VMGroupRole *>::iterator it;
|
||||
|
||||
it = roles.find(k);
|
||||
auto it = roles.find(k);
|
||||
|
||||
if ( it == roles.end() )
|
||||
{
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
|
@ -58,13 +58,11 @@ public:
|
||||
|
||||
VMGroupRule(VMGroupPolicy p, std::set<int> roles_id):policy(p)
|
||||
{
|
||||
std::set<int>::iterator it;
|
||||
|
||||
for ( it = roles_id.begin(); it != roles_id.end(); ++it )
|
||||
for ( auto rid : roles_id )
|
||||
{
|
||||
if ( *it < VMGroupRoles::MAX_ROLES )
|
||||
if ( rid < VMGroupRoles::MAX_ROLES )
|
||||
{
|
||||
roles[*it] = 1;
|
||||
roles[rid] = 1;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -187,7 +187,6 @@ public:
|
||||
std::vector<VectorAttribute *> vas;
|
||||
std::vector<VectorAttribute *> alias;
|
||||
std::vector<VectorAttribute *> pcis;
|
||||
std::vector<VectorAttribute *>::iterator it;
|
||||
|
||||
tmpl->get(NIC_NAME, vas);
|
||||
|
||||
@ -195,17 +194,17 @@ public:
|
||||
|
||||
tmpl->get("PCI", pcis);
|
||||
|
||||
for ( it=pcis.begin(); it != pcis.end() ; ++it)
|
||||
for (auto pci : pcis)
|
||||
{
|
||||
if ( (*it)->vector_value("TYPE") == "NIC" )
|
||||
if ( pci->vector_value("TYPE") == "NIC" )
|
||||
{
|
||||
vas.push_back(*it);
|
||||
vas.push_back(pci);
|
||||
}
|
||||
}
|
||||
|
||||
for ( it=alias.begin(); it != alias.end(); ++it)
|
||||
for (auto al : alias)
|
||||
{
|
||||
vas.push_back(*it);
|
||||
vas.push_back(al);
|
||||
}
|
||||
|
||||
init(vas, false);
|
||||
|
@ -232,18 +232,15 @@ bool AclManager::authorize(
|
||||
|
||||
if (!obj_perms.disable_cluster_acl)
|
||||
{
|
||||
set<int>::iterator i;
|
||||
|
||||
for(i = obj_perms.cids.begin(); i != obj_perms.cids.end(); i++)
|
||||
for (auto perm : obj_perms.cids)
|
||||
{
|
||||
resource_cid_req.insert( obj_perms.obj_type |
|
||||
AclRule::CLUSTER_ID |
|
||||
*i
|
||||
);
|
||||
resource_cid_req.insert(obj_perms.obj_type |
|
||||
AclRule::CLUSTER_ID |
|
||||
perm);
|
||||
}
|
||||
}
|
||||
|
||||
long long resource_all_req ;
|
||||
long long resource_all_req;
|
||||
|
||||
if (!obj_perms.disable_all_acl)
|
||||
{
|
||||
@ -357,11 +354,9 @@ bool AclManager::authorize(
|
||||
// Look for rules that apply to each one of the user's groups
|
||||
// ----------------------------------------------------------
|
||||
|
||||
set<int>::iterator g_it;
|
||||
|
||||
for (g_it = user_groups.begin(); g_it != user_groups.end(); g_it++)
|
||||
for (auto group : user_groups)
|
||||
{
|
||||
user_req = AclRule::GROUP_ID | *g_it;
|
||||
user_req = AclRule::GROUP_ID | group;
|
||||
auth = match_rules_wrapper(user_req,
|
||||
resource_oid_req,
|
||||
resource_gid_req,
|
||||
@ -463,12 +458,10 @@ static bool match_cluster_req(
|
||||
long long resource_cid_mask,
|
||||
long long rule_resource)
|
||||
{
|
||||
set<long long>::iterator i;
|
||||
|
||||
for(i = resource_cid_req.begin(); i != resource_cid_req.end(); i++)
|
||||
for (auto cid : resource_cid_req)
|
||||
{
|
||||
// rule's object type and cluster object ID match
|
||||
if ( ( rule_resource & resource_cid_mask ) == *i )
|
||||
if ( ( rule_resource & resource_cid_mask ) == cid )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -495,18 +488,13 @@ bool AclManager::match_rules(
|
||||
bool auth = false;
|
||||
ostringstream oss;
|
||||
|
||||
multimap<long long, AclRule *>::const_iterator it;
|
||||
|
||||
pair<multimap<long long, AclRule *>::const_iterator,
|
||||
multimap<long long, AclRule *>::const_iterator> index;
|
||||
|
||||
long long zone_oid_mask = AclRule::INDIVIDUAL_ID | 0x00000000FFFFFFFFLL;
|
||||
long long zone_req = AclRule::INDIVIDUAL_ID | zone_id;
|
||||
long long zone_all_req = AclRule::ALL_ID;
|
||||
|
||||
index = rules.equal_range( user_req );
|
||||
auto index = rules.equal_range( user_req );
|
||||
|
||||
for ( it = index.first; it != index.second; it++)
|
||||
for ( auto it = index.first; it != index.second; it++)
|
||||
{
|
||||
if (NebulaLog::log_level() >= Log::DDEBUG)
|
||||
{
|
||||
@ -582,15 +570,11 @@ int AclManager::add_rule(long long user, long long resource, long long rights,
|
||||
ostringstream oss;
|
||||
int rc;
|
||||
|
||||
multimap<long long, AclRule *>::iterator it;
|
||||
pair<multimap<long long, AclRule *>::iterator,
|
||||
multimap<long long, AclRule *>::iterator> index;
|
||||
|
||||
bool found = false;
|
||||
|
||||
index = acl_rules.equal_range( user );
|
||||
auto index = acl_rules.equal_range( user );
|
||||
|
||||
for ( it = index.first; (it != index.second && !found); it++)
|
||||
for ( auto it = index.first; (it != index.second && !found); it++)
|
||||
{
|
||||
found = *(it->second) == *rule;
|
||||
}
|
||||
@ -652,11 +636,6 @@ error_common:
|
||||
|
||||
int AclManager::del_rule(int oid, string& error_str)
|
||||
{
|
||||
|
||||
multimap<long long, AclRule *>::iterator it;
|
||||
pair<multimap<long long, AclRule *>::iterator,
|
||||
multimap<long long, AclRule *>::iterator> index;
|
||||
|
||||
AclRule * rule;
|
||||
int rc;
|
||||
bool found = false;
|
||||
@ -690,9 +669,9 @@ int AclManager::del_rule(int oid, string& error_str)
|
||||
|
||||
found = false;
|
||||
|
||||
index = acl_rules.equal_range( rule->user );
|
||||
auto index = acl_rules.equal_range( rule->user );
|
||||
|
||||
it = index.first;
|
||||
auto it = index.first;
|
||||
while ( !found && it != index.second )
|
||||
{
|
||||
found = *rule == *(it->second);
|
||||
@ -854,7 +833,6 @@ void AclManager::del_resource_rules(int oid, PoolObjectSQL::ObjectType obj_type)
|
||||
void AclManager::del_user_matching_rules(long long user_req)
|
||||
{
|
||||
vector<int> oids;
|
||||
vector<int>::iterator oid_it;
|
||||
string error_str;
|
||||
|
||||
{
|
||||
@ -868,9 +846,9 @@ void AclManager::del_user_matching_rules(long long user_req)
|
||||
}
|
||||
}
|
||||
|
||||
for ( oid_it = oids.begin() ; oid_it < oids.end(); oid_it++ )
|
||||
for ( auto oid : oids )
|
||||
{
|
||||
del_rule(*oid_it, error_str);
|
||||
del_rule(oid, error_str);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,14 +141,11 @@ void Client::call(const std::string &method, const std::string format,
|
||||
va_list args;
|
||||
va_start(args, result);
|
||||
|
||||
std::string::const_iterator i;
|
||||
|
||||
std::string sval;
|
||||
int ival;
|
||||
bool bval;
|
||||
|
||||
std::set<int> * vval;
|
||||
std::set<int>::iterator it;
|
||||
|
||||
const char* pval;
|
||||
vector<xmlrpc_c::value> x_vval;
|
||||
@ -157,9 +154,9 @@ void Client::call(const std::string &method, const std::string format,
|
||||
|
||||
plist.add(xmlrpc_c::value_string(one_auth));
|
||||
|
||||
for (i = format.begin(); i != format.end(); ++i)
|
||||
for (auto ch : format)
|
||||
{
|
||||
switch(*i)
|
||||
switch(ch)
|
||||
{
|
||||
case 's':
|
||||
pval = static_cast<const char*>(va_arg(args, char *));
|
||||
@ -184,7 +181,7 @@ void Client::call(const std::string &method, const std::string format,
|
||||
vval = static_cast<std::set<int> *>(va_arg(args,
|
||||
std::set<int> *));
|
||||
|
||||
for (it = vval->begin(); it != vval->end(); ++it)
|
||||
for (auto it = vval->begin(); it != vval->end(); ++it)
|
||||
{
|
||||
x_vval.push_back(xmlrpc_c::value_int(*it));
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ void ClusterPool::cluster_acl_filter(ostringstream& filter,
|
||||
return;
|
||||
}
|
||||
|
||||
for ( vector<int>::const_iterator it = cids.begin(); it < cids.end(); it++ )
|
||||
for ( auto it = cids.begin(); it != cids.end(); it++ )
|
||||
{
|
||||
if ( it != cids.begin() )
|
||||
{
|
||||
|
@ -31,8 +31,6 @@ string VectorAttribute::marshall(const char * _sep) const
|
||||
ostringstream os;
|
||||
const char * my_sep;
|
||||
|
||||
map<string,string>::const_iterator it;
|
||||
|
||||
if ( _sep == 0 )
|
||||
{
|
||||
my_sep = magic_sep;
|
||||
@ -47,7 +45,7 @@ string VectorAttribute::marshall(const char * _sep) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
it = attribute_value.begin();
|
||||
auto it = attribute_value.begin();
|
||||
|
||||
os << it->first << "=" << it->second;
|
||||
|
||||
@ -64,11 +62,9 @@ string VectorAttribute::marshall(const char * _sep) const
|
||||
|
||||
void VectorAttribute::to_xml(ostringstream &oss) const
|
||||
{
|
||||
map<string,string>::const_iterator it;
|
||||
|
||||
oss << "<" << name() << ">";
|
||||
|
||||
for (it=attribute_value.begin();it!=attribute_value.end();it++)
|
||||
for (auto it=attribute_value.begin(); it!=attribute_value.end(); it++)
|
||||
{
|
||||
if ( it->first.empty() )
|
||||
{
|
||||
@ -91,7 +87,7 @@ void VectorAttribute::to_json(std::ostringstream& s) const
|
||||
return;
|
||||
}
|
||||
|
||||
map<string,string>::const_iterator it = attribute_value.begin();
|
||||
auto it = attribute_value.begin();
|
||||
bool is_first = true;
|
||||
|
||||
s << "{";
|
||||
@ -121,9 +117,7 @@ void VectorAttribute::to_json(std::ostringstream& s) const
|
||||
|
||||
void VectorAttribute::to_token(std::ostringstream& s) const
|
||||
{
|
||||
map<string,string>::const_iterator it;
|
||||
|
||||
for (it=attribute_value.begin(); it!=attribute_value.end(); it++)
|
||||
for (auto it=attribute_value.begin(); it!=attribute_value.end(); it++)
|
||||
{
|
||||
if (it->first.empty() || it->second.empty())
|
||||
{
|
||||
@ -205,14 +199,11 @@ void VectorAttribute::replace(const map<string,string>& attr)
|
||||
|
||||
void VectorAttribute::merge(VectorAttribute* vattr, bool replace)
|
||||
{
|
||||
map<string, string>::const_iterator it;
|
||||
map<string, string>::iterator jt;
|
||||
|
||||
const map<string,string>& source_values = vattr->value();
|
||||
|
||||
for(it=source_values.begin(); it!=source_values.end(); it++)
|
||||
for (auto it=source_values.begin(); it!=source_values.end(); it++)
|
||||
{
|
||||
jt = attribute_value.find(it->first);
|
||||
auto jt = attribute_value.find(it->first);
|
||||
|
||||
if (jt != attribute_value.end())
|
||||
{
|
||||
@ -235,9 +226,7 @@ void VectorAttribute::merge(VectorAttribute* vattr, bool replace)
|
||||
|
||||
void VectorAttribute::replace(const string& name, const string& value)
|
||||
{
|
||||
map<string,string>::iterator it;
|
||||
|
||||
it = attribute_value.find(name);
|
||||
auto it = attribute_value.find(name);
|
||||
|
||||
if ( it != attribute_value.end() )
|
||||
{
|
||||
@ -252,9 +241,7 @@ void VectorAttribute::replace(const string& name, const string& value)
|
||||
|
||||
void VectorAttribute::remove(const string& name)
|
||||
{
|
||||
map<string,string>::iterator it;
|
||||
|
||||
it = attribute_value.find(name);
|
||||
auto it = attribute_value.find(name);
|
||||
|
||||
if ( it != attribute_value.end() )
|
||||
{
|
||||
@ -267,9 +254,7 @@ void VectorAttribute::remove(const string& name)
|
||||
|
||||
string VectorAttribute::vector_value(const string& name) const
|
||||
{
|
||||
map<string,string>::const_iterator it;
|
||||
|
||||
it = attribute_value.find(name);
|
||||
auto it = attribute_value.find(name);
|
||||
|
||||
if ( it == attribute_value.end() )
|
||||
{
|
||||
@ -286,9 +271,7 @@ string VectorAttribute::vector_value(const string& name) const
|
||||
|
||||
int VectorAttribute::vector_value(const string& name, string& value) const
|
||||
{
|
||||
map<string,string>::const_iterator it;
|
||||
|
||||
it = attribute_value.find(name);
|
||||
auto it = attribute_value.find(name);
|
||||
|
||||
if (it == attribute_value.end())
|
||||
{
|
||||
@ -305,10 +288,8 @@ int VectorAttribute::vector_value(const string& name, string& value) const
|
||||
|
||||
int VectorAttribute::vector_value(const string& name, bool& value) const
|
||||
{
|
||||
map<string,string>::const_iterator it;
|
||||
|
||||
value = false;
|
||||
it = attribute_value.find(name);
|
||||
auto it = attribute_value.find(name);
|
||||
|
||||
if (it == attribute_value.end())
|
||||
{
|
||||
|
@ -21,9 +21,7 @@
|
||||
|
||||
ExtendedAttributeSet::~ExtendedAttributeSet()
|
||||
{
|
||||
std::map<int, ExtendedAttribute *>::iterator it;
|
||||
|
||||
for (it = a_set.begin(); it != a_set.end(); ++it)
|
||||
for (auto it = a_set.begin(); it != a_set.end(); ++it)
|
||||
{
|
||||
if ( dispose )
|
||||
{
|
||||
@ -39,11 +37,11 @@ ExtendedAttributeSet::~ExtendedAttributeSet()
|
||||
|
||||
ExtendedAttribute * ExtendedAttributeSet::get_attribute(int id) const
|
||||
{
|
||||
std::map<int, ExtendedAttribute*>::const_iterator it = a_set.find(id);
|
||||
auto it = a_set.find(id);
|
||||
|
||||
if ( it == a_set.end() )
|
||||
{
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
@ -55,10 +53,10 @@ ExtendedAttribute * ExtendedAttributeSet::get_attribute(int id) const
|
||||
void ExtendedAttributeSet::init_attribute_map(const std::string& id_name,
|
||||
std::vector<VectorAttribute *>& vas)
|
||||
{
|
||||
std::vector<VectorAttribute *>::iterator it;
|
||||
int id, auto_id;
|
||||
int id;
|
||||
int auto_id = 0;
|
||||
|
||||
for (it = vas.begin(), auto_id = 0; it != vas.end(); ++it, ++auto_id)
|
||||
for (auto it = vas.begin(); it != vas.end(); ++it, ++auto_id)
|
||||
{
|
||||
if (id_name.empty())
|
||||
{
|
||||
@ -80,11 +78,11 @@ void ExtendedAttributeSet::init_attribute_map(const std::string& id_name,
|
||||
|
||||
ExtendedAttribute * ExtendedAttributeSet::delete_attribute(int id)
|
||||
{
|
||||
std::map<int, ExtendedAttribute*>::iterator it = a_set.find(id);
|
||||
auto it = a_set.find(id);
|
||||
|
||||
if ( it == a_set.end() )
|
||||
{
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
a_set.erase(it);
|
||||
|
@ -326,19 +326,16 @@ static bool not_space(int c)
|
||||
|
||||
string one_util::trim(const string& str)
|
||||
{
|
||||
string::const_iterator wfirst;
|
||||
string::const_reverse_iterator rwlast;
|
||||
|
||||
wfirst = find_if(str.begin(), str.end(), not_space);
|
||||
auto wfirst = find_if(str.begin(), str.end(), not_space);
|
||||
|
||||
if (wfirst == str.end())
|
||||
{
|
||||
return string();
|
||||
}
|
||||
|
||||
rwlast = find_if(str.rbegin(),str.rend(),not_space);
|
||||
auto rwlast = find_if(str.rbegin(),str.rend(),not_space);
|
||||
|
||||
string::const_iterator wlast(rwlast.base());
|
||||
auto wlast(rwlast.base());
|
||||
|
||||
string tstr(wfirst, wlast);
|
||||
|
||||
@ -376,13 +373,11 @@ string one_util::gsub(const string& st, const string& sfind,
|
||||
|
||||
void one_util::escape_json(const string& str, ostringstream& s)
|
||||
{
|
||||
string::const_iterator it;
|
||||
|
||||
s << "\"";
|
||||
|
||||
for (it = str.begin(); it != str.end(); ++it)
|
||||
for (auto ch : str)
|
||||
{
|
||||
switch (*it)
|
||||
switch (ch)
|
||||
{
|
||||
case '\\': s << "\\\\"; break;
|
||||
case '"' : s << "\\\""; break;
|
||||
@ -392,7 +387,7 @@ void one_util::escape_json(const string& str, ostringstream& s)
|
||||
case '\n': s << "\\n"; break;
|
||||
case '\r': s << "\\r"; break;
|
||||
case '\t': s << "\\t"; break;
|
||||
default : s << *it;
|
||||
default : s << ch;
|
||||
}
|
||||
}
|
||||
|
||||
@ -404,11 +399,9 @@ void one_util::escape_json(const string& str, ostringstream& s)
|
||||
|
||||
void one_util::escape_token(const string& str, ostringstream& s)
|
||||
{
|
||||
string::const_iterator it;
|
||||
|
||||
for (it = str.begin(); it != str.end(); ++it)
|
||||
for (auto ch : str)
|
||||
{
|
||||
switch (*it)
|
||||
switch (ch)
|
||||
{
|
||||
case '-':
|
||||
case '_':
|
||||
@ -417,7 +410,7 @@ void one_util::escape_token(const string& str, ostringstream& s)
|
||||
s << '_';
|
||||
break;
|
||||
default :
|
||||
s << *it;
|
||||
s << ch;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -428,12 +421,10 @@ void one_util::escape_token(const string& str, ostringstream& s)
|
||||
template<>
|
||||
void one_util::split_unique(const string& st, char delim, set<string>& res)
|
||||
{
|
||||
vector<string>::const_iterator it;
|
||||
|
||||
vector<string> strings = split(st, delim, true);
|
||||
|
||||
for (it = strings.begin(); it != strings.end(); it++)
|
||||
for (const auto& str : strings)
|
||||
{
|
||||
res.insert(*it);
|
||||
res.insert(str);
|
||||
}
|
||||
}
|
||||
|
@ -99,8 +99,6 @@ void Datastore::disk_attribute(
|
||||
string current_val;
|
||||
string type;
|
||||
|
||||
vector<string>::const_iterator it;
|
||||
|
||||
disk->replace("DATASTORE", get_name());
|
||||
disk->replace("DATASTORE_ID", oid);
|
||||
disk->replace("TM_MAD", get_tm_mad());
|
||||
@ -155,14 +153,14 @@ void Datastore::disk_attribute(
|
||||
disk->replace("LN_TARGET", st);
|
||||
}
|
||||
|
||||
for (it = inherit_attrs.begin(); it != inherit_attrs.end(); it++)
|
||||
for (const auto& inherit : inherit_attrs)
|
||||
{
|
||||
current_val = disk->vector_value(*it);
|
||||
get_template_attribute(*it, inherit_val);
|
||||
current_val = disk->vector_value(inherit);
|
||||
get_template_attribute(inherit, inherit_val);
|
||||
|
||||
if ( current_val.empty() && !inherit_val.empty() )
|
||||
{
|
||||
disk->replace(*it, inherit_val);
|
||||
disk->replace(inherit, inherit_val);
|
||||
}
|
||||
}
|
||||
|
||||
@ -252,7 +250,7 @@ int Datastore::set_ds_mad(std::string &mad, std::string &error_str)
|
||||
std::vector <std::string> vrequired_attrs;
|
||||
|
||||
int rc;
|
||||
std::string required_attrs, required_attr, value;
|
||||
std::string required_attrs, value;
|
||||
|
||||
std::ostringstream oss;
|
||||
|
||||
@ -277,11 +275,8 @@ int Datastore::set_ds_mad(std::string &mad, std::string &error_str)
|
||||
|
||||
vrequired_attrs = one_util::split(required_attrs, ',');
|
||||
|
||||
for ( std::vector<std::string>::const_iterator it = vrequired_attrs.begin();
|
||||
it != vrequired_attrs.end(); it++ )
|
||||
for ( auto& required_attr : vrequired_attrs )
|
||||
{
|
||||
required_attr = *it;
|
||||
|
||||
required_attr = one_util::trim(required_attr);
|
||||
one_util::toupper(required_attr);
|
||||
|
||||
@ -289,7 +284,9 @@ int Datastore::set_ds_mad(std::string &mad, std::string &error_str)
|
||||
|
||||
if ( value.empty() )
|
||||
{
|
||||
goto error_required;
|
||||
oss << "Datastore template is missing the \"" << required_attr
|
||||
<< "\" attribute or it's empty.";
|
||||
goto error_common;
|
||||
}
|
||||
}
|
||||
|
||||
@ -299,10 +296,6 @@ error_conf:
|
||||
oss << "DS_MAD named \"" << mad << "\" is not defined in oned.conf";
|
||||
goto error_common;
|
||||
|
||||
error_required:
|
||||
oss << "Datastore template is missing the \"" << required_attr
|
||||
<< "\" attribute or it's empty.";
|
||||
|
||||
error_common:
|
||||
error_str = oss.str();
|
||||
return -1;
|
||||
@ -368,17 +361,15 @@ int Datastore::set_tm_mad(string &tm_mad, string &error_str)
|
||||
|
||||
if (!st.empty())
|
||||
{
|
||||
std::vector<std::string>::iterator it;
|
||||
|
||||
replace_template_attribute("TM_MAD_SYSTEM", st);
|
||||
|
||||
modes = one_util::split(st, ',', true);
|
||||
|
||||
string s;
|
||||
|
||||
for (it = modes.begin() ; it != modes.end(); ++it)
|
||||
for (const auto &mode : modes)
|
||||
{
|
||||
string tm_mad_t = one_util::trim(*it);
|
||||
string tm_mad_t = one_util::trim(mode);
|
||||
string tm_mad = one_util::toupper(tm_mad_t);
|
||||
|
||||
st = vatt->vector_value("LN_TARGET_" + tm_mad);
|
||||
|
@ -53,11 +53,9 @@ DatastorePool::DatastorePool(
|
||||
ostringstream oss;
|
||||
string error_str;
|
||||
|
||||
vector<const SingleAttribute *>::const_iterator it;
|
||||
|
||||
for (it = _inherit_attrs.begin(); it != _inherit_attrs.end(); it++)
|
||||
for (auto sattr : _inherit_attrs)
|
||||
{
|
||||
inherit_attrs.push_back((*it)->value());
|
||||
inherit_attrs.push_back(sattr->value());
|
||||
}
|
||||
|
||||
if (get_lastOID() == -1) //lastOID is set in PoolSQL::init_cb
|
||||
|
@ -267,7 +267,6 @@ int Group::from_xml(const string& xml)
|
||||
string error;
|
||||
|
||||
vector<xmlNodePtr> content;
|
||||
vector<xmlNodePtr>::iterator it;
|
||||
|
||||
// Initialize the internal XML object
|
||||
update_from_str(xml);
|
||||
|
@ -80,27 +80,25 @@ void HostSharePCI::init()
|
||||
|
||||
bool HostSharePCI::test(const vector<VectorAttribute *> &devs) const
|
||||
{
|
||||
vector<VectorAttribute *>::const_iterator it;
|
||||
map<string, PCIDevice *>::const_iterator jt;
|
||||
|
||||
std::set<string> assigned;
|
||||
|
||||
unsigned int vendor_id, device_id, class_id;
|
||||
int vendor_rc, device_rc, class_rc;
|
||||
bool found;
|
||||
|
||||
for ( it=devs.begin(); it!= devs.end(); it++)
|
||||
for (auto device : devs)
|
||||
{
|
||||
vendor_rc = get_pci_value("VENDOR", *it, vendor_id);
|
||||
device_rc = get_pci_value("DEVICE", *it, device_id);
|
||||
class_rc = get_pci_value("CLASS" , *it, class_id);
|
||||
vendor_rc = get_pci_value("VENDOR", device, vendor_id);
|
||||
device_rc = get_pci_value("DEVICE", device, device_id);
|
||||
class_rc = get_pci_value("CLASS" , device, class_id);
|
||||
|
||||
if (vendor_rc <= 0 && device_rc <= 0 && class_rc <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (jt= pci_devices.begin(), found=false; jt!=pci_devices.end(); jt++)
|
||||
found = false;
|
||||
for (auto jt = pci_devices.begin(); jt != pci_devices.end(); jt++)
|
||||
{
|
||||
PCIDevice * dev = jt->second;
|
||||
|
||||
@ -111,7 +109,7 @@ bool HostSharePCI::test(const vector<VectorAttribute *> &devs) const
|
||||
assigned.find(dev->address) == assigned.end())
|
||||
{
|
||||
assigned.insert(dev->address);
|
||||
found=true;
|
||||
found = true;
|
||||
|
||||
break;
|
||||
}
|
||||
@ -131,22 +129,19 @@ bool HostSharePCI::test(const vector<VectorAttribute *> &devs) const
|
||||
|
||||
void HostSharePCI::add(vector<VectorAttribute *> &devs, int vmid)
|
||||
{
|
||||
vector<VectorAttribute *>::iterator it;
|
||||
map<string, PCIDevice *>::const_iterator jt;
|
||||
|
||||
unsigned int vendor_id, device_id, class_id;
|
||||
string address;
|
||||
int vendor_rc, device_rc, class_rc, addr_rc;
|
||||
|
||||
for ( it=devs.begin(); it!= devs.end(); it++)
|
||||
for (auto device : devs)
|
||||
{
|
||||
vendor_rc = get_pci_value("VENDOR", *it, vendor_id);
|
||||
device_rc = get_pci_value("DEVICE", *it, device_id);
|
||||
class_rc = get_pci_value("CLASS" , *it, class_id);
|
||||
vendor_rc = get_pci_value("VENDOR", device, vendor_id);
|
||||
device_rc = get_pci_value("DEVICE", device, device_id);
|
||||
class_rc = get_pci_value("CLASS" , device, class_id);
|
||||
|
||||
addr_rc = (*it)->vector_value("ADDRESS", address);
|
||||
addr_rc = device->vector_value("ADDRESS", address);
|
||||
|
||||
for (jt = pci_devices.begin(); jt != pci_devices.end(); jt++)
|
||||
for (auto jt = pci_devices.begin(); jt != pci_devices.end(); jt++)
|
||||
{
|
||||
PCIDevice * dev = jt->second;
|
||||
|
||||
@ -160,21 +155,21 @@ void HostSharePCI::add(vector<VectorAttribute *> &devs, int vmid)
|
||||
dev->vmid = vmid;
|
||||
dev->attrs->replace("VMID", vmid);
|
||||
|
||||
(*it)->replace("DOMAIN", dev->attrs->vector_value("DOMAIN"));
|
||||
(*it)->replace("BUS", dev->attrs->vector_value("BUS"));
|
||||
(*it)->replace("SLOT", dev->attrs->vector_value("SLOT"));
|
||||
(*it)->replace("FUNCTION",dev->attrs->vector_value("FUNCTION"));
|
||||
device->replace("DOMAIN", dev->attrs->vector_value("DOMAIN"));
|
||||
device->replace("BUS", dev->attrs->vector_value("BUS"));
|
||||
device->replace("SLOT", dev->attrs->vector_value("SLOT"));
|
||||
device->replace("FUNCTION",dev->attrs->vector_value("FUNCTION"));
|
||||
|
||||
(*it)->replace("ADDRESS", dev->attrs->vector_value("ADDRESS"));
|
||||
device->replace("ADDRESS", dev->attrs->vector_value("ADDRESS"));
|
||||
|
||||
if (addr_rc != -1 && !address.empty())
|
||||
{
|
||||
(*it)->replace("PREV_ADDRESS", address);
|
||||
device->replace("PREV_ADDRESS", address);
|
||||
}
|
||||
|
||||
if (dev->attrs->vector_value("NUMA_NODE", node)==0 && node !=-1)
|
||||
{
|
||||
(*it)->replace("NUMA_NODE", node);
|
||||
device->replace("NUMA_NODE", node);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -188,24 +183,21 @@ void HostSharePCI::add(vector<VectorAttribute *> &devs, int vmid)
|
||||
|
||||
void HostSharePCI::del(const vector<VectorAttribute *> &devs)
|
||||
{
|
||||
vector<VectorAttribute *>::const_iterator it;
|
||||
map<string, PCIDevice *>::iterator pci_it;
|
||||
|
||||
for ( it=devs.begin(); it!= devs.end(); it++)
|
||||
for (auto device : devs)
|
||||
{
|
||||
pci_it = pci_devices.find((*it)->vector_value("PREV_ADDRESS"));
|
||||
auto pci_it = pci_devices.find(device->vector_value("PREV_ADDRESS"));
|
||||
|
||||
if (pci_it != pci_devices.end())
|
||||
{
|
||||
pci_it->second->vmid = -1;
|
||||
pci_it->second->attrs->replace("VMID",-1);
|
||||
|
||||
(*it)->remove("PREV_ADDRESS");
|
||||
device->remove("PREV_ADDRESS");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
pci_it = pci_devices.find((*it)->vector_value("ADDRESS"));
|
||||
pci_it = pci_devices.find(device->vector_value("ADDRESS"));
|
||||
|
||||
if (pci_it != pci_devices.end())
|
||||
{
|
||||
@ -213,7 +205,7 @@ void HostSharePCI::del(const vector<VectorAttribute *> &devs)
|
||||
pci_it->second->attrs->replace("VMID",-1);
|
||||
|
||||
// Clean address from VM as it's not using it anymore
|
||||
(*it)->remove("ADDRESS");
|
||||
device->remove("ADDRESS");
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -223,27 +215,21 @@ void HostSharePCI::del(const vector<VectorAttribute *> &devs)
|
||||
|
||||
void HostSharePCI::set_monitorization(Template& ht)
|
||||
{
|
||||
vector<VectorAttribute*>::iterator it;
|
||||
map<string, PCIDevice*>::iterator pci_it;
|
||||
|
||||
string address;
|
||||
|
||||
std::set<string> missing;
|
||||
std::set<string>::iterator jt;
|
||||
|
||||
vector<VectorAttribute*> pci_att;
|
||||
|
||||
ht.remove("PCI", pci_att);
|
||||
|
||||
for (pci_it = pci_devices.begin(); pci_it != pci_devices.end(); pci_it++)
|
||||
for (auto pci_it = pci_devices.begin(); pci_it != pci_devices.end(); pci_it++)
|
||||
{
|
||||
missing.insert(pci_it->first);
|
||||
}
|
||||
|
||||
for (it = pci_att.begin(); it != pci_att.end(); it++)
|
||||
for (auto pci : pci_att)
|
||||
{
|
||||
VectorAttribute * pci = *it;
|
||||
|
||||
address = pci->vector_value("ADDRESS");
|
||||
|
||||
if (address.empty())
|
||||
@ -252,7 +238,7 @@ void HostSharePCI::set_monitorization(Template& ht)
|
||||
continue;
|
||||
}
|
||||
|
||||
pci_it = pci_devices.find(address);
|
||||
auto pci_it = pci_devices.find(address);
|
||||
|
||||
if (pci_it != pci_devices.end())
|
||||
{
|
||||
@ -270,9 +256,9 @@ void HostSharePCI::set_monitorization(Template& ht)
|
||||
}
|
||||
|
||||
//Remove missing devices from the share if there are no VMs using them
|
||||
for ( jt = missing.begin() ; jt != missing.end(); jt ++ )
|
||||
for (const auto& miss : missing)
|
||||
{
|
||||
pci_it = pci_devices.find(*jt);
|
||||
auto pci_it = pci_devices.find(miss);
|
||||
|
||||
if ( pci_it->second->vmid != -1 )
|
||||
{
|
||||
@ -286,7 +272,6 @@ void HostSharePCI::set_monitorization(Template& ht)
|
||||
delete pci_it->second;
|
||||
|
||||
pci_devices.erase(pci_it);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -493,8 +493,6 @@ void Image::disk_attribute(VirtualMachineDisk * disk,
|
||||
|
||||
bool ro;
|
||||
|
||||
vector<string>::const_iterator it;
|
||||
|
||||
img_type = type;
|
||||
target = disk->vector_value("TARGET");
|
||||
driver = disk->vector_value("DRIVER");
|
||||
@ -654,13 +652,13 @@ void Image::disk_attribute(VirtualMachineDisk * disk,
|
||||
disk->replace("TARGET", template_target);
|
||||
}
|
||||
|
||||
for (it = inherit_attrs.begin(); it != inherit_attrs.end(); it++)
|
||||
for (const auto& inherit : inherit_attrs)
|
||||
{
|
||||
get_template_attribute(*it, inherit_val);
|
||||
get_template_attribute(inherit, inherit_val);
|
||||
|
||||
if (!inherit_val.empty())
|
||||
{
|
||||
disk->replace(*it, inherit_val);
|
||||
disk->replace(inherit, inherit_val);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -845,9 +843,9 @@ void Image::set_state(ImageState _state)
|
||||
LifeCycleManager* lcm = Nebula::instance().get_lcm();
|
||||
const set<int>& vms = vm_collection.get_collection();
|
||||
|
||||
for (set<int>::iterator i = vms.begin(); i != vms.end(); i++)
|
||||
for (auto vm_id : vms)
|
||||
{
|
||||
lcm->trigger_disk_lock_failure(*i);
|
||||
lcm->trigger_disk_lock_failure(vm_id);
|
||||
}
|
||||
}
|
||||
else if (state == LOCKED)
|
||||
@ -915,9 +913,9 @@ void Image::set_state_unlock()
|
||||
{
|
||||
const set<int>& vms = vm_collection.get_collection();
|
||||
|
||||
for (set<int>::iterator i = vms.begin(); i != vms.end(); i++)
|
||||
for (auto vm_id : vms)
|
||||
{
|
||||
lcm->trigger_disk_lock_success(*i);
|
||||
lcm->trigger_disk_lock_success(vm_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -54,11 +54,9 @@ ImagePool::ImagePool(
|
||||
_default_cdrom_dev_prefix = __default_cdrom_dev_prefix;
|
||||
|
||||
// Init inherit attributes
|
||||
vector<const SingleAttribute *>::const_iterator it;
|
||||
|
||||
for (it = _inherit_attrs.begin(); it != _inherit_attrs.end(); it++)
|
||||
for (auto sattr : _inherit_attrs)
|
||||
{
|
||||
inherit_attrs.push_back((*it)->value());
|
||||
inherit_attrs.push_back(sattr->value());
|
||||
}
|
||||
|
||||
// Set default type
|
||||
|
@ -66,7 +66,7 @@ int MarketPlace::set_market_mad(std::string &mad, std::string &error_str)
|
||||
std::vector <std::string> vrequired_attrs;
|
||||
|
||||
int rc;
|
||||
std::string required_attrs, required_attr, value;
|
||||
std::string required_attrs, value;
|
||||
|
||||
std::ostringstream oss;
|
||||
|
||||
@ -86,11 +86,8 @@ int MarketPlace::set_market_mad(std::string &mad, std::string &error_str)
|
||||
|
||||
vrequired_attrs = one_util::split(required_attrs, ',');
|
||||
|
||||
for ( std::vector<std::string>::const_iterator it = vrequired_attrs.begin();
|
||||
it != vrequired_attrs.end(); it++ )
|
||||
for ( auto& required_attr : vrequired_attrs )
|
||||
{
|
||||
required_attr = *it;
|
||||
|
||||
required_attr = one_util::trim(required_attr);
|
||||
one_util::toupper(required_attr);
|
||||
|
||||
@ -98,7 +95,10 @@ int MarketPlace::set_market_mad(std::string &mad, std::string &error_str)
|
||||
|
||||
if ( value.empty() )
|
||||
{
|
||||
goto error_required;
|
||||
oss << "MarketPlace template is missing the \"" << required_attr
|
||||
<< "\" attribute or it's empty.";
|
||||
|
||||
goto error_common;
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,10 +108,6 @@ error_conf:
|
||||
oss << "MARKET_MAD_CONF named \"" << mad << "\" is not defined in oned.conf";
|
||||
goto error_common;
|
||||
|
||||
error_required:
|
||||
oss << "MarketPlace template is missing the \"" << required_attr
|
||||
<< "\" attribute or it's empty.";
|
||||
|
||||
error_common:
|
||||
error_str = oss.str();
|
||||
return -1;
|
||||
@ -292,16 +288,15 @@ static void set_supported_actions(ActionSet<MarketPlaceApp::Action>& as,
|
||||
const string& astr)
|
||||
{
|
||||
std::vector<std::string> actions;
|
||||
std::vector<std::string>::iterator vit;
|
||||
|
||||
std::string action;
|
||||
MarketPlaceApp::Action id;
|
||||
|
||||
actions = one_util::split(astr, ',');
|
||||
|
||||
for (vit = actions.begin() ; vit != actions.end() ; ++vit)
|
||||
for (const auto& act : actions)
|
||||
{
|
||||
action = one_util::trim(*vit);
|
||||
action = one_util::trim(act);
|
||||
|
||||
if ( MarketPlaceApp::action_from_str(action, id) != 0 )
|
||||
{
|
||||
|
@ -315,7 +315,7 @@ const int MarketPlaceAppPool::MAX_MISSING_MONITORS = 3;
|
||||
|
||||
bool MarketPlaceAppPool::test_map_check(int app_id)
|
||||
{
|
||||
map<int, int>::iterator it = map_check.find(app_id);
|
||||
auto it = map_check.find(app_id);
|
||||
|
||||
if ( it == map_check.end() )
|
||||
{
|
||||
@ -338,7 +338,7 @@ bool MarketPlaceAppPool::test_map_check(int app_id)
|
||||
|
||||
void MarketPlaceAppPool::reset_map_check(int app_id)
|
||||
{
|
||||
map<int, int>::iterator it = map_check.find(app_id);
|
||||
auto it = map_check.find(app_id);
|
||||
|
||||
if ( it == map_check.end() )
|
||||
{
|
||||
|
@ -1298,7 +1298,6 @@ int Nebula::get_conf_attribute(
|
||||
const std::string& name,
|
||||
const VectorAttribute* &value) const
|
||||
{
|
||||
std::vector<const VectorAttribute*>::const_iterator it;
|
||||
std::vector<const VectorAttribute*> values;
|
||||
std::string template_name;
|
||||
std::string name_upper = name;
|
||||
@ -1307,20 +1306,20 @@ int Nebula::get_conf_attribute(
|
||||
|
||||
nebula_configuration->get(key, values);
|
||||
|
||||
for (it = values.begin(); it != values.end(); it ++)
|
||||
for (auto vattr : values)
|
||||
{
|
||||
value = *it;
|
||||
template_name = (*it)->vector_value("NAME");
|
||||
template_name = vattr->vector_value("NAME");
|
||||
|
||||
one_util::toupper(template_name);
|
||||
|
||||
if ( template_name == name_upper )
|
||||
{
|
||||
value = vattr;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
value = 0;
|
||||
value = nullptr;
|
||||
return -1;
|
||||
};
|
||||
|
||||
|
@ -1473,13 +1473,12 @@ yyreduce:
|
||||
#line 135 "expr_bool.y"
|
||||
{
|
||||
std::vector<int> val;
|
||||
std::vector<int>::iterator it;
|
||||
|
||||
(yyval.val_int) = false;
|
||||
|
||||
oxml->search((yyvsp[-3].val_str),val);
|
||||
|
||||
for (it=val.begin(); it != val.end(); ++it)
|
||||
for (auto it=val.begin(); it != val.end(); ++it)
|
||||
{
|
||||
if ((yyvsp[0].val_int) == *it)
|
||||
{
|
||||
@ -1539,13 +1538,12 @@ yyreduce:
|
||||
#line 181 "expr_bool.y"
|
||||
{
|
||||
std::vector<float> val;
|
||||
std::vector<float>::iterator it;
|
||||
|
||||
(yyval.val_int) = false;
|
||||
|
||||
oxml->search((yyvsp[-3].val_str),val);
|
||||
|
||||
for (it=val.begin(); it != val.end(); ++it)
|
||||
for (auto it=val.begin(); it != val.end(); ++it)
|
||||
{
|
||||
if ((yyvsp[0].val_float) == *it)
|
||||
{
|
||||
@ -1585,7 +1583,6 @@ yyreduce:
|
||||
#line 215 "expr_bool.y"
|
||||
{
|
||||
std::vector<std::string> val;
|
||||
std::vector<std::string>::iterator it;
|
||||
|
||||
(yyval.val_int) = false;
|
||||
|
||||
@ -1593,7 +1590,7 @@ yyreduce:
|
||||
{
|
||||
oxml->search((yyvsp[-3].val_str),val);
|
||||
|
||||
for (it=val.begin(); it != val.end(); ++it)
|
||||
for (auto it=val.begin(); it != val.end(); ++it)
|
||||
{
|
||||
if ( fnmatch((yyvsp[0].val_str), (*it).c_str(), 0) == 0 )
|
||||
{
|
||||
|
@ -134,13 +134,12 @@ expr: STRING '=' INTEGER {
|
||||
|
||||
| STRING '@''>' INTEGER {
|
||||
std::vector<int> val;
|
||||
std::vector<int>::iterator it;
|
||||
|
||||
$$ = false;
|
||||
|
||||
oxml->search($1,val);
|
||||
|
||||
for (it=val.begin(); it != val.end(); ++it)
|
||||
for (auto it=val.begin(); it != val.end(); ++it)
|
||||
{
|
||||
if ($4 == *it)
|
||||
{
|
||||
@ -180,13 +179,12 @@ expr: STRING '=' INTEGER {
|
||||
|
||||
| STRING '@''>' FLOAT {
|
||||
std::vector<float> val;
|
||||
std::vector<float>::iterator it;
|
||||
|
||||
$$ = false;
|
||||
|
||||
oxml->search($1,val);
|
||||
|
||||
for (it=val.begin(); it != val.end(); ++it)
|
||||
for (auto it=val.begin(); it != val.end(); ++it)
|
||||
{
|
||||
if ($4 == *it)
|
||||
{
|
||||
@ -214,7 +212,6 @@ expr: STRING '=' INTEGER {
|
||||
|
||||
| STRING '@''>' STRING {
|
||||
std::vector<std::string> val;
|
||||
std::vector<std::string>::iterator it;
|
||||
|
||||
$$ = false;
|
||||
|
||||
@ -222,7 +219,7 @@ expr: STRING '=' INTEGER {
|
||||
{
|
||||
oxml->search($1,val);
|
||||
|
||||
for (it=val.begin(); it != val.end(); ++it)
|
||||
for (auto it=val.begin(); it != val.end(); ++it)
|
||||
{
|
||||
if ( fnmatch($4, (*it).c_str(), 0) == 0 )
|
||||
{
|
||||
|
@ -106,9 +106,7 @@ string& ObjectCollection::to_xml(string& xml) const
|
||||
|
||||
int ObjectCollection::add(int id)
|
||||
{
|
||||
pair<set<int>::iterator,bool> ret;
|
||||
|
||||
ret = collection_set.insert(id);
|
||||
auto ret = collection_set.insert(id);
|
||||
|
||||
if( !ret.second )
|
||||
{
|
||||
@ -141,7 +139,7 @@ int ObjectCollection::pop(int& elem)
|
||||
return -1;
|
||||
}
|
||||
|
||||
set<int>::iterator it = collection_set.begin();
|
||||
auto it = collection_set.begin();
|
||||
|
||||
elem = *it;
|
||||
|
||||
|
@ -156,12 +156,11 @@ int PoolSQL::allocate(PoolObjectSQL *objsql, string& error_str)
|
||||
void PoolSQL::exist(const string& id_str, std::set<int>& id_list)
|
||||
{
|
||||
std::vector<int> existing_items;
|
||||
std::set<int>::iterator iterator;
|
||||
|
||||
one_util::split_unique(id_str, ',', id_list);
|
||||
search(existing_items, table.c_str(), "1 order by 1 ASC");
|
||||
|
||||
for (iterator = id_list.begin(); iterator != id_list.end(); ++iterator)
|
||||
for (auto iterator = id_list.begin(); iterator != id_list.end(); ++iterator)
|
||||
{
|
||||
if (!std::binary_search(existing_items.begin(), existing_items.end(), *iterator))
|
||||
{
|
||||
@ -291,7 +290,6 @@ void PoolSQL::acl_filter(int uid,
|
||||
AclManager* aclm = nd.get_aclm();
|
||||
|
||||
ostringstream acl_filter;
|
||||
vector<int>::iterator it;
|
||||
|
||||
vector<int> oids;
|
||||
vector<int> gids;
|
||||
@ -309,14 +307,14 @@ void PoolSQL::acl_filter(int uid,
|
||||
gids,
|
||||
cids);
|
||||
|
||||
for ( it = oids.begin(); it < oids.end(); it++ )
|
||||
for ( auto oid : oids )
|
||||
{
|
||||
acl_filter << " OR oid = " << *it;
|
||||
acl_filter << " OR oid = " << oid;
|
||||
}
|
||||
|
||||
for ( it = gids.begin(); it < gids.end(); it++ )
|
||||
for ( auto gid : gids )
|
||||
{
|
||||
acl_filter << " OR gid = " << *it;
|
||||
acl_filter << " OR gid = " << gid;
|
||||
}
|
||||
|
||||
ClusterPool::cluster_acl_filter(acl_filter, auth_object, cids);
|
||||
@ -336,8 +334,6 @@ void PoolSQL::usr_filter(int uid,
|
||||
{
|
||||
ostringstream uid_filter;
|
||||
|
||||
set<int>::iterator g_it;
|
||||
|
||||
if ( filter_flag == RequestManagerPoolInfoFilter::MINE )
|
||||
{
|
||||
uid_filter << "uid = " << uid;
|
||||
@ -352,9 +348,9 @@ void PoolSQL::usr_filter(int uid,
|
||||
|
||||
string sep = " ";
|
||||
|
||||
for (g_it = user_groups.begin(); g_it != user_groups.end(); g_it++)
|
||||
for (auto g_id : user_groups)
|
||||
{
|
||||
uid_filter << sep << "( gid = " << *g_it << " )";
|
||||
uid_filter << sep << "( gid = " << g_id << " )";
|
||||
sep = " OR ";
|
||||
}
|
||||
|
||||
@ -364,9 +360,9 @@ void PoolSQL::usr_filter(int uid,
|
||||
{
|
||||
uid_filter << " AND ( other_u = 1";
|
||||
|
||||
for (g_it = user_groups.begin(); g_it != user_groups.end(); g_it++)
|
||||
for (auto g_id : user_groups)
|
||||
{
|
||||
uid_filter << " OR ( gid = " << *g_it << " AND group_u = 1 )";
|
||||
uid_filter << " OR ( gid = " << g_id << " AND group_u = 1 )";
|
||||
}
|
||||
|
||||
uid_filter << acl_str << ")";
|
||||
@ -381,9 +377,9 @@ void PoolSQL::usr_filter(int uid,
|
||||
uid_filter << " uid = " << uid
|
||||
<< " OR other_u = 1";
|
||||
|
||||
for (g_it = user_groups.begin(); g_it != user_groups.end(); g_it++)
|
||||
for (auto g_id : user_groups)
|
||||
{
|
||||
uid_filter << " OR ( gid = " << *g_it << " AND group_u = 1 )";
|
||||
uid_filter << " OR ( gid = " << g_id << " AND group_u = 1 )";
|
||||
}
|
||||
|
||||
uid_filter << acl_str;
|
||||
@ -397,9 +393,9 @@ void PoolSQL::usr_filter(int uid,
|
||||
{
|
||||
uid_filter << " AND ( other_u = 1";
|
||||
|
||||
for (g_it = user_groups.begin(); g_it != user_groups.end(); g_it++)
|
||||
for (auto g_id : user_groups)
|
||||
{
|
||||
uid_filter << " OR ( gid = " << *g_it << " AND group_u = 1 )";
|
||||
uid_filter << " OR ( gid = " << g_id << " AND group_u = 1 )";
|
||||
}
|
||||
|
||||
uid_filter << acl_str << ")";
|
||||
|
@ -30,14 +30,12 @@ std::mutex * PoolSQLCache::lock_line(int oid)
|
||||
{
|
||||
static unsigned int num_locks = 0;
|
||||
|
||||
std::map<int, CacheLine *>::iterator it;
|
||||
|
||||
CacheLine * cl;
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_mutex);
|
||||
|
||||
it = cache.find(oid);
|
||||
auto it = cache.find(oid);
|
||||
|
||||
if ( it == cache.end() )
|
||||
{
|
||||
@ -77,7 +75,7 @@ std::mutex * PoolSQLCache::lock_line(int oid)
|
||||
|
||||
void PoolSQLCache::flush_cache_lines()
|
||||
{
|
||||
for (std::map<int,CacheLine *>::iterator it=cache.begin(); it!=cache.end();)
|
||||
for (auto it=cache.begin(); it!=cache.end();)
|
||||
{
|
||||
CacheLine * cl = it->second;
|
||||
|
||||
|
@ -41,9 +41,7 @@ FedReplicaManager::~FedReplicaManager()
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
||||
std::map<int, ZoneServers *>::iterator it;
|
||||
|
||||
for ( it = zones.begin() ; it != zones.end() ; ++it )
|
||||
for ( auto it = zones.begin() ; it != zones.end() ; ++it )
|
||||
{
|
||||
delete it->second;
|
||||
}
|
||||
@ -89,8 +87,6 @@ void FedReplicaManager::update_zones(std::vector<int>& zone_ids)
|
||||
Nebula& nd = Nebula::instance();
|
||||
ZonePool * zpool = nd.get_zonepool();
|
||||
|
||||
vector<int>::iterator it;
|
||||
|
||||
int zone_id = nd.get_zone_id();
|
||||
|
||||
if ( zpool->list_zones(zone_ids) != 0 )
|
||||
@ -104,7 +100,7 @@ void FedReplicaManager::update_zones(std::vector<int>& zone_ids)
|
||||
|
||||
zones.clear();
|
||||
|
||||
for (it = zone_ids.begin() ; it != zone_ids.end(); )
|
||||
for (auto it = zone_ids.begin() ; it != zone_ids.end(); )
|
||||
{
|
||||
if ( *it == zone_id )
|
||||
{
|
||||
@ -174,11 +170,9 @@ void FedReplicaManager::delete_zone(int zone_id)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
|
||||
std::map<int, ZoneServers *>::iterator it;
|
||||
|
||||
lock_guard<mutex> ul(fed_mutex);
|
||||
|
||||
it = zones.find(zone_id);
|
||||
auto it = zones.find(zone_id);
|
||||
|
||||
if ( it == zones.end() )
|
||||
{
|
||||
@ -212,7 +206,7 @@ int FedReplicaManager::get_next_record(int zone_id, std::string& zedp,
|
||||
{
|
||||
lock_guard<mutex> ul(fed_mutex);
|
||||
|
||||
std::map<int, ZoneServers *>::iterator it = zones.find(zone_id);
|
||||
auto it = zones.find(zone_id);
|
||||
|
||||
if ( it == zones.end() )
|
||||
{
|
||||
@ -275,7 +269,7 @@ void FedReplicaManager::replicate_success(int zone_id)
|
||||
{
|
||||
lock_guard<mutex> ul(fed_mutex);
|
||||
|
||||
std::map<int, ZoneServers *>::iterator it = zones.find(zone_id);
|
||||
auto it = zones.find(zone_id);
|
||||
|
||||
if ( it == zones.end() )
|
||||
{
|
||||
@ -300,7 +294,7 @@ void FedReplicaManager::replicate_failure(int zone_id, uint64_t last_zone)
|
||||
{
|
||||
lock_guard<mutex> ul(fed_mutex);
|
||||
|
||||
std::map<int, ZoneServers *>::iterator it = zones.find(zone_id);
|
||||
auto it = zones.find(zone_id);
|
||||
|
||||
if ( it != zones.end() )
|
||||
{
|
||||
|
@ -229,9 +229,7 @@ int RaftManager::get_leader_endpoint(std::string& endpoint)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::map<int, std::string>::iterator it;
|
||||
|
||||
it = servers.find(leader_id);
|
||||
auto it = servers.find(leader_id);
|
||||
|
||||
if ( it == servers.end() )
|
||||
{
|
||||
@ -332,7 +330,6 @@ void RaftManager::leader()
|
||||
|
||||
FedReplicaManager * frm = nd.get_frm();
|
||||
|
||||
std::map<int, std::string>::iterator it;
|
||||
std::vector<int> _follower_ids;
|
||||
|
||||
uint64_t index, _applied, _next_index;
|
||||
@ -383,7 +380,7 @@ void RaftManager::leader()
|
||||
_next_index = index + 1;
|
||||
}
|
||||
|
||||
for (it = servers.begin(); it != servers.end() ; ++it )
|
||||
for (auto it = servers.begin(); it != servers.end() ; ++it)
|
||||
{
|
||||
if ( it->first == server_id )
|
||||
{
|
||||
@ -523,9 +520,7 @@ void RaftManager::replicate_log(ReplicaRequest * request)
|
||||
//Count servers that need to replicate this record
|
||||
int to_commit = num_servers / 2;
|
||||
|
||||
std::map<int, uint64_t>::iterator it;
|
||||
|
||||
for (it = next.begin(); it != next.end() ; ++it)
|
||||
for (auto it = next.begin(); it != next.end() ; ++it)
|
||||
{
|
||||
if ( request->index() < it->second )
|
||||
{
|
||||
@ -561,11 +556,6 @@ void RaftManager::replicate_log(ReplicaRequest * request)
|
||||
|
||||
void RaftManager::replicate_success(int follower_id)
|
||||
{
|
||||
std::map<int, ReplicaRequest *>::iterator it;
|
||||
|
||||
std::map<int, uint64_t>::iterator next_it;
|
||||
std::map<int, uint64_t>::iterator match_it;
|
||||
|
||||
Nebula& nd = Nebula::instance();
|
||||
LogDB * logdb = nd.get_logdb();
|
||||
|
||||
@ -576,8 +566,8 @@ void RaftManager::replicate_success(int follower_id)
|
||||
|
||||
std::lock_guard<mutex> lock(raft_mutex);
|
||||
|
||||
next_it = next.find(follower_id);
|
||||
match_it = match.find(follower_id);
|
||||
auto next_it = next.find(follower_id);
|
||||
auto match_it = match.find(follower_id);
|
||||
|
||||
if ( next_it == next.end() || match_it == match.end() )
|
||||
{
|
||||
@ -606,11 +596,9 @@ void RaftManager::replicate_success(int follower_id)
|
||||
|
||||
void RaftManager::replicate_failure(int follower_id)
|
||||
{
|
||||
std::map<int, uint64_t>::iterator next_it;
|
||||
|
||||
std::lock_guard<mutex> lock(raft_mutex);
|
||||
|
||||
next_it = next.find(follower_id);
|
||||
auto next_it = next.find(follower_id);
|
||||
|
||||
if ( next_it != next.end() )
|
||||
{
|
||||
@ -795,8 +783,6 @@ void RaftManager::request_vote()
|
||||
int _server_id;
|
||||
|
||||
std::map<int, std::string> _servers;
|
||||
std::map<int, std::string>::iterator it;
|
||||
|
||||
|
||||
std::ostringstream oss;
|
||||
|
||||
@ -858,7 +844,7 @@ void RaftManager::request_vote()
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Request vote on all the followers */
|
||||
/* ------------------------------------------------------------------ */
|
||||
for (it = _servers.begin(); it != _servers.end() ; ++it, oss.str("") )
|
||||
for (auto it = _servers.begin(); it != _servers.end() ; ++it, oss.str("") )
|
||||
{
|
||||
int id = it->first;
|
||||
|
||||
@ -969,14 +955,12 @@ int RaftManager::xmlrpc_replicate_log(int follower_id, LogDBRecord * lr,
|
||||
|
||||
std::string follower_edp;
|
||||
|
||||
std::map<int, std::string>::iterator it;
|
||||
|
||||
int xml_rc = 0;
|
||||
|
||||
{
|
||||
std::lock_guard<mutex> lock(raft_mutex);
|
||||
|
||||
it = servers.find(follower_id);
|
||||
auto it = servers.find(follower_id);
|
||||
|
||||
if ( it == servers.end() )
|
||||
{
|
||||
@ -1065,14 +1049,12 @@ int RaftManager::xmlrpc_request_vote(int follower_id, uint64_t lindex,
|
||||
|
||||
std::string follower_edp;
|
||||
|
||||
std::map<int, std::string>::iterator it;
|
||||
|
||||
int xml_rc = 0;
|
||||
|
||||
{
|
||||
std::lock_guard<mutex> lock(raft_mutex);
|
||||
|
||||
it = servers.find(follower_id);
|
||||
auto it = servers.find(follower_id);
|
||||
|
||||
if ( it == servers.end() )
|
||||
{
|
||||
@ -1195,8 +1177,6 @@ std::string& RaftManager::to_xml(std::string& raft_xml)
|
||||
|
||||
void RaftManager::reset_index(int follower_id)
|
||||
{
|
||||
std::map<int, uint64_t>::iterator next_it;
|
||||
|
||||
unsigned int log_term;
|
||||
uint64_t log_index;
|
||||
|
||||
@ -1206,7 +1186,7 @@ void RaftManager::reset_index(int follower_id)
|
||||
|
||||
std::lock_guard<mutex> lock(raft_mutex);
|
||||
|
||||
next_it = next.find(follower_id);
|
||||
auto next_it = next.find(follower_id);
|
||||
|
||||
if ( next_it != next.end() )
|
||||
{
|
||||
|
@ -24,9 +24,7 @@
|
||||
|
||||
ReplicaThread * ReplicaManager::get_thread(int server_id)
|
||||
{
|
||||
std::map<int, ReplicaThread *>::iterator it;
|
||||
|
||||
it = thread_pool.find(server_id);
|
||||
auto it = thread_pool.find(server_id);
|
||||
|
||||
if ( it == thread_pool.end() )
|
||||
{
|
||||
@ -41,11 +39,9 @@ ReplicaThread * ReplicaManager::get_thread(int server_id)
|
||||
|
||||
void ReplicaManager::start_replica_threads(std::vector<int>& fids)
|
||||
{
|
||||
std::vector<int>::iterator it;
|
||||
|
||||
for (it = fids.begin(); it != fids.end(); ++it)
|
||||
for (auto id : fids)
|
||||
{
|
||||
add_replica_thread(*it);
|
||||
add_replica_thread(id);
|
||||
}
|
||||
};
|
||||
|
||||
@ -54,9 +50,7 @@ void ReplicaManager::start_replica_threads(std::vector<int>& fids)
|
||||
|
||||
void ReplicaManager::stop_replica_threads()
|
||||
{
|
||||
std::map<int, ReplicaThread *>::iterator it;
|
||||
|
||||
for ( it = thread_pool.begin() ; it != thread_pool.end() ; ++it )
|
||||
for ( auto it = thread_pool.begin() ; it != thread_pool.end() ; ++it )
|
||||
{
|
||||
it->second->finalize();
|
||||
}
|
||||
@ -69,9 +63,7 @@ void ReplicaManager::stop_replica_threads()
|
||||
|
||||
void ReplicaManager::replicate()
|
||||
{
|
||||
std::map<int, ReplicaThread *>::iterator it;
|
||||
|
||||
for ( it = thread_pool.begin() ; it != thread_pool.end() ; ++it )
|
||||
for ( auto it = thread_pool.begin() ; it != thread_pool.end() ; ++it )
|
||||
{
|
||||
it->second->add_request();
|
||||
}
|
||||
@ -94,10 +86,7 @@ void ReplicaManager::replicate(int follower)
|
||||
|
||||
void ReplicaManager::delete_replica_thread(int follower_id)
|
||||
{
|
||||
|
||||
std::map<int, ReplicaThread *>::iterator it;
|
||||
|
||||
it = thread_pool.find(follower_id);
|
||||
auto it = thread_pool.find(follower_id);
|
||||
|
||||
if ( it == thread_pool.end() )
|
||||
{
|
||||
|
@ -787,7 +787,6 @@ bool UserAllocate::allocate_authorization(
|
||||
PoolObjectAuth * cluster_perms)
|
||||
{
|
||||
vector<xmlrpc_c::value> param_arr;
|
||||
vector<xmlrpc_c::value>::const_iterator it;
|
||||
|
||||
if ( paramList.size() > 4 )
|
||||
{
|
||||
@ -799,7 +798,7 @@ bool UserAllocate::allocate_authorization(
|
||||
|
||||
ar.add_create_auth(att.uid, att.gid, auth_object, "");
|
||||
|
||||
for (it = param_arr.begin(); it != param_arr.end(); it++)
|
||||
for (auto it = param_arr.begin(); it != param_arr.end(); it++)
|
||||
{
|
||||
int tmp_gid = xmlrpc_c::value_int(*it);
|
||||
|
||||
@ -856,7 +855,6 @@ Request::ErrorCode UserAllocate::pool_allocate(
|
||||
int gid = -1;
|
||||
|
||||
vector<xmlrpc_c::value> param_arr;
|
||||
vector<xmlrpc_c::value>::const_iterator it;
|
||||
|
||||
if ( paramList.size() > 4 )
|
||||
{
|
||||
@ -866,7 +864,7 @@ Request::ErrorCode UserAllocate::pool_allocate(
|
||||
|
||||
AuthRequest ar(att.uid, att.group_ids);
|
||||
|
||||
for (it = param_arr.begin(); it != param_arr.end(); it++)
|
||||
for (auto it = param_arr.begin(); it != param_arr.end(); it++)
|
||||
{
|
||||
int tmp_gid = xmlrpc_c::value_int(*it);
|
||||
|
||||
|
@ -248,8 +248,7 @@ Request::ErrorCode TemplateChmod::chmod(
|
||||
if ( !error_ids.empty() )
|
||||
{
|
||||
att.resp_msg = "Cannot chmod " + object_name(PoolObjectSQL::IMAGE) +
|
||||
": " + one_util::join<set<int>::iterator>(error_ids.begin(),
|
||||
error_ids.end(), ',');
|
||||
": " + one_util::join(error_ids.begin(), error_ids.end(), ',');
|
||||
|
||||
return ACTION;
|
||||
}
|
||||
|
@ -230,7 +230,6 @@ int TemplateDelete::drop(std::unique_ptr<PoolObjectSQL> object, bool recursive,
|
||||
RequestAttributes& att)
|
||||
{
|
||||
vector<VectorAttribute *> vdisks;
|
||||
vector<VectorAttribute *>::iterator i;
|
||||
|
||||
VirtualMachineDisks disks(true);
|
||||
|
||||
@ -272,8 +271,7 @@ int TemplateDelete::drop(std::unique_ptr<PoolObjectSQL> object, bool recursive,
|
||||
if ( !error_ids.empty() )
|
||||
{
|
||||
att.resp_msg = "Cannot delete " + object_name(PoolObjectSQL::IMAGE) +
|
||||
": " + one_util::join<set<int>::iterator>(error_ids.begin(),
|
||||
error_ids.end(), ',');
|
||||
": " + one_util::join(error_ids.begin(), error_ids.end(), ',');
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -327,14 +327,13 @@ private:
|
||||
|
||||
if (s_name == "CURRENT_VMS")
|
||||
{
|
||||
typename std::vector<T>::iterator it;
|
||||
std::vector<T> results;
|
||||
|
||||
xpaths(results, "/HOST/VMS/ID");
|
||||
|
||||
for (it=results.begin(); it!=results.end(); it++)
|
||||
for (const auto& vm_id : results)
|
||||
{
|
||||
if (*it == value)
|
||||
if (vm_id == value)
|
||||
{
|
||||
return 0; //VMID found in VMS value is VMID
|
||||
}
|
||||
|
@ -74,14 +74,13 @@ int AclXML::load_rules(const string& xml_str)
|
||||
ObjectXML acl_xml(xml_str);
|
||||
|
||||
vector<xmlNodePtr> rules;
|
||||
vector<xmlNodePtr>::iterator it;
|
||||
|
||||
acl_xml.get_nodes("/ACL_POOL/ACL",rules);
|
||||
|
||||
for (it = rules.begin(); it != rules.end() ; it++)
|
||||
for (auto node : rules)
|
||||
{
|
||||
AclRule * rule = new AclRule(0,0,0,0,0);
|
||||
int rc = rule->from_xml(*it);
|
||||
int rc = rule->from_xml(node);
|
||||
|
||||
if ( rc == 0 )
|
||||
{
|
||||
@ -100,9 +99,7 @@ int AclXML::load_rules(const string& xml_str)
|
||||
|
||||
void AclXML::flush_rules()
|
||||
{
|
||||
multimap<long long, AclRule *>::iterator it;
|
||||
|
||||
for ( it = acl_rules.begin(); it != acl_rules.end(); it++ )
|
||||
for ( auto it = acl_rules.begin(); it != acl_rules.end(); it++ )
|
||||
{
|
||||
delete it->second;
|
||||
}
|
||||
|
@ -33,9 +33,7 @@ int HostPoolXML::set_up()
|
||||
{
|
||||
oss << "Discovered Hosts (enabled):" << endl;
|
||||
|
||||
map<int, ObjectXML*>::iterator it;
|
||||
|
||||
for (it=objects.begin();it!=objects.end();it++)
|
||||
for (auto it=objects.begin(); it!=objects.end(); it++)
|
||||
{
|
||||
HostXML * h = dynamic_cast<HostXML *>(it->second);
|
||||
|
||||
@ -98,15 +96,13 @@ int HostPoolXML::load_info(xmlrpc_c::value &result)
|
||||
|
||||
void HostPoolXML::merge_clusters(ClusterPoolXML * clpool)
|
||||
{
|
||||
map<int,ObjectXML*>::iterator it;
|
||||
|
||||
ClusterXML* cluster;
|
||||
HostXML* host;
|
||||
|
||||
int cluster_id;
|
||||
vector<xmlNodePtr> nodes;
|
||||
|
||||
for (it=objects.begin(); it!=objects.end(); it++)
|
||||
for (auto it=objects.begin(); it!=objects.end(); it++)
|
||||
{
|
||||
host = static_cast<HostXML*>(it->second);
|
||||
|
||||
@ -135,11 +131,9 @@ void HostPoolXML::merge_clusters(ClusterPoolXML * clpool)
|
||||
|
||||
void HostPoolXML::merge_monitoring(MonitorPoolXML * mpool)
|
||||
{
|
||||
map<int,ObjectXML*>::iterator it;
|
||||
|
||||
vector<xmlNodePtr> nodes;
|
||||
|
||||
for (it=objects.begin(); it!=objects.end(); it++)
|
||||
for (auto it=objects.begin(); it!=objects.end(); it++)
|
||||
{
|
||||
HostXML* host = static_cast<HostXML*>(it->second);
|
||||
|
||||
|
@ -27,8 +27,6 @@ void VMGroupXML::init_attributes()
|
||||
vector<xmlNodePtr> content;
|
||||
std::vector<std::string> srules;
|
||||
|
||||
std::vector<std::string>::iterator it;
|
||||
|
||||
xpath(oid, "/VM_GROUP/ID", -1);
|
||||
xpath(name,"/VM_GROUP/NAME", "undefined");
|
||||
|
||||
@ -46,11 +44,11 @@ void VMGroupXML::init_attributes()
|
||||
|
||||
xpaths(srules, "/VM_GROUP/TEMPLATE/AFFINED");
|
||||
|
||||
for ( it = srules.begin() ; it != srules.end(); ++it )
|
||||
for ( const auto& srule : srules )
|
||||
{
|
||||
std::set<int> id_set;
|
||||
|
||||
roles.names_to_ids(*it, id_set);
|
||||
roles.names_to_ids(srule, id_set);
|
||||
|
||||
VMGroupRule rule(VMGroupPolicy::AFFINED, id_set);
|
||||
|
||||
@ -61,11 +59,11 @@ void VMGroupXML::init_attributes()
|
||||
|
||||
xpaths(srules, "/VM_GROUP/TEMPLATE/ANTI_AFFINED");
|
||||
|
||||
for ( it = srules.begin() ; it != srules.end(); ++it )
|
||||
for ( const auto& srule : srules )
|
||||
{
|
||||
std::set<int> id_set;
|
||||
|
||||
roles.names_to_ids(*it, id_set);
|
||||
roles.names_to_ids(srule, id_set);
|
||||
|
||||
VMGroupRule rule(VMGroupPolicy::ANTI_AFFINED, id_set);
|
||||
|
||||
@ -79,8 +77,6 @@ void VMGroupXML::init_attributes()
|
||||
void VMGroupXML::set_antiaffinity_requirements(VirtualMachinePoolXML * vmpool,
|
||||
std::ostringstream& oss)
|
||||
{
|
||||
VMGroupRoles::role_iterator it;
|
||||
|
||||
oss << "\n";
|
||||
oss << setfill('-') << setw(80) << '-' << setfill(' ') << "\n";
|
||||
oss << "Intra-role Anti-affinity rules \n";
|
||||
@ -91,37 +87,34 @@ void VMGroupXML::set_antiaffinity_requirements(VirtualMachinePoolXML * vmpool,
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Intra-role anti-affinity placement rule */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
for ( it = roles.begin(); it != roles.end() ; ++it )
|
||||
for ( auto r : roles )
|
||||
{
|
||||
VMGroupRole * r = *it;
|
||||
|
||||
if ( r->policy() != VMGroupPolicy::ANTI_AFFINED || r->size_vms() <= 1 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const std::set<int>& vms = r->get_vms();
|
||||
std::set<int>::const_iterator jt;
|
||||
|
||||
for ( jt = vms.begin() ; jt != vms.end(); ++jt )
|
||||
for ( auto vm_id : vms )
|
||||
{
|
||||
std::string reqs;
|
||||
|
||||
VirtualMachineXML * vm = vmpool->get(*jt);
|
||||
VirtualMachineXML * vm = vmpool->get(vm_id);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
r->vm_role_requirements(*jt, reqs);
|
||||
r->vm_role_requirements(vm_id, reqs);
|
||||
|
||||
if ( !reqs.empty() )
|
||||
{
|
||||
vm->add_requirements(reqs);
|
||||
}
|
||||
|
||||
oss << left << setw(8) << r->id() << left << setw(8) << *jt << reqs
|
||||
oss << left << setw(8) << r->id() << left << setw(8) << vm_id << reqs
|
||||
<< "\n";
|
||||
}
|
||||
}
|
||||
@ -136,11 +129,10 @@ void VMGroupXML::set_antiaffinity_requirements(VirtualMachinePoolXML * vmpool,
|
||||
oss << left << setw(8)<< "ROLE" << " " << left << setw(8) <<"VM"
|
||||
<< " " << left << "ANTI_AFFINITY REQUIRMENTS\n"
|
||||
<< setfill('-') << setw(80) << '-' << setfill(' ') << "\n";
|
||||
VMGroupRule::rule_set::iterator rt;
|
||||
|
||||
for ( rt = anti_affined.begin() ; rt != anti_affined.end() ; ++rt )
|
||||
for ( const auto& rt : anti_affined )
|
||||
{
|
||||
VMGroupRule::role_bitset rroles = (*rt).get_roles();
|
||||
const VMGroupRule::role_bitset& rroles = rt.get_roles();
|
||||
|
||||
for ( int i=0 ; i < VMGroupRoles::MAX_ROLES; ++i)
|
||||
{
|
||||
@ -187,11 +179,10 @@ void VMGroupXML::set_antiaffinity_requirements(VirtualMachinePoolXML * vmpool,
|
||||
VMGroupRole * r = roles.get(i);
|
||||
|
||||
const std::set<int>& vms = r->get_vms();
|
||||
std::set<int>::const_iterator vt;
|
||||
|
||||
for ( vt=vms.begin() ; vt!=vms.end(); ++vt )
|
||||
for ( auto vm_id : vms )
|
||||
{
|
||||
VirtualMachineXML * vm = vmpool->get(*vt);
|
||||
VirtualMachineXML * vm = vmpool->get(vm_id);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
@ -200,7 +191,7 @@ void VMGroupXML::set_antiaffinity_requirements(VirtualMachinePoolXML * vmpool,
|
||||
|
||||
vm->add_requirements(role_reqs);
|
||||
|
||||
oss << left << setw(8) << r->id() << left << setw(8) << *vt
|
||||
oss << left << setw(8) << r->id() << left << setw(8) << vm_id
|
||||
<< vm->get_requirements() << "\n";
|
||||
}
|
||||
}
|
||||
@ -213,8 +204,6 @@ void VMGroupXML::set_antiaffinity_requirements(VirtualMachinePoolXML * vmpool,
|
||||
void VMGroupXML::set_host_requirements(VirtualMachinePoolXML * vmpool,
|
||||
std::ostringstream& oss)
|
||||
{
|
||||
VMGroupRoles::role_iterator it;
|
||||
|
||||
oss << "\n";
|
||||
oss << setfill('-') << setw(80) << '-' << setfill(' ') << "\n";
|
||||
oss << "Host affinity rules \n";
|
||||
@ -222,12 +211,10 @@ void VMGroupXML::set_host_requirements(VirtualMachinePoolXML * vmpool,
|
||||
<< " " << left << "AFFINITY REQUIRMENTS\n"
|
||||
<< setfill('-') << setw(80) << '-' << setfill(' ') << "\n";
|
||||
|
||||
for ( it = roles.begin(); it != roles.end() ; ++it )
|
||||
for ( auto r : roles )
|
||||
{
|
||||
std::string areqs, aareqs;
|
||||
|
||||
VMGroupRole * r = *it;
|
||||
|
||||
r->affined_host_requirements(areqs);
|
||||
|
||||
r->antiaffined_host_requirements(aareqs);
|
||||
@ -239,9 +226,9 @@ void VMGroupXML::set_host_requirements(VirtualMachinePoolXML * vmpool,
|
||||
|
||||
const std::set<int>& vms = r->get_vms();
|
||||
|
||||
for (std::set<int>::const_iterator jt=vms.begin(); jt!=vms.end(); ++jt)
|
||||
for (auto vm_id : vms)
|
||||
{
|
||||
VirtualMachineXML * vm = vmpool->get(*jt);
|
||||
VirtualMachineXML * vm = vmpool->get(vm_id);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
@ -258,7 +245,7 @@ void VMGroupXML::set_host_requirements(VirtualMachinePoolXML * vmpool,
|
||||
vm->add_requirements(aareqs);
|
||||
}
|
||||
|
||||
oss << left << setw(8) << r->id() << left << setw(8) << *jt
|
||||
oss << left << setw(8) << r->id() << left << setw(8) << vm_id
|
||||
<< vm->get_requirements() << "\n";
|
||||
}
|
||||
}
|
||||
@ -286,7 +273,7 @@ static void schecule_affined_set(const std::set<int>& vms,
|
||||
{
|
||||
VirtualMachineXML * vm = vm_roles_pool->get(*it);
|
||||
|
||||
if ( vm == 0 )
|
||||
if ( vm )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -299,7 +286,7 @@ static void schecule_affined_set(const std::set<int>& vms,
|
||||
}
|
||||
}
|
||||
|
||||
if ( hosts.size() == 0 )
|
||||
if ( hosts.empty() )
|
||||
{
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* No VMs of the set are running: */
|
||||
@ -313,13 +300,13 @@ static void schecule_affined_set(const std::set<int>& vms,
|
||||
{
|
||||
vm = vmpool->get(*it);
|
||||
|
||||
if ( vm != 0 )
|
||||
if ( !vm )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( vm == 0 )
|
||||
if ( vm )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -336,7 +323,7 @@ static void schecule_affined_set(const std::set<int>& vms,
|
||||
|
||||
VirtualMachineXML * tmp = vmpool->get(*it);
|
||||
|
||||
if ( tmp == 0 )
|
||||
if ( tmp )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -373,7 +360,7 @@ static void schecule_affined_set(const std::set<int>& vms,
|
||||
{
|
||||
VirtualMachineXML * vm = vmpool->get(*it);
|
||||
|
||||
if ( vm == 0 || reqs.empty())
|
||||
if ( vm || reqs.empty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -391,8 +378,6 @@ static void schecule_affined_set(const std::set<int>& vms,
|
||||
void VMGroupXML::set_affinity_requirements(VirtualMachinePoolXML * vmpool,
|
||||
VirtualMachineRolePoolXML * vm_roles_pool, std::ostringstream& oss)
|
||||
{
|
||||
VMGroupRoles::role_iterator it;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Intra-role affinity placement rule */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -402,10 +387,8 @@ void VMGroupXML::set_affinity_requirements(VirtualMachinePoolXML * vmpool,
|
||||
oss << left << setw(8) << "VMID" << " " << left << "REQUIREMENTS\n";
|
||||
oss << setfill('-') << setw(80) << '-' << setfill(' ') << "\n";
|
||||
|
||||
for ( it = roles.begin(); it != roles.end() ; ++it )
|
||||
for ( auto r : roles )
|
||||
{
|
||||
VMGroupRole * r = *it;
|
||||
|
||||
if ( r->policy() != VMGroupPolicy::AFFINED || r->size_vms() <= 1 )
|
||||
{
|
||||
continue;
|
||||
@ -423,7 +406,6 @@ void VMGroupXML::set_affinity_requirements(VirtualMachinePoolXML * vmpool,
|
||||
/* 3. Schedule the resulting set */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
VMGroupRule::rule_set reduced;
|
||||
VMGroupRule::rule_set::iterator rit;
|
||||
|
||||
oss << "\n";
|
||||
oss << setfill('-') << setw(80) << '-' << setfill(' ') << "\n";
|
||||
@ -433,9 +415,9 @@ void VMGroupXML::set_affinity_requirements(VirtualMachinePoolXML * vmpool,
|
||||
|
||||
VMGroupRule::reduce(affined, reduced);
|
||||
|
||||
for ( rit = reduced.begin() ; rit != reduced.end(); ++rit )
|
||||
for ( const auto& rit : reduced )
|
||||
{
|
||||
const VMGroupRule::role_bitset rroles = (*rit).get_roles();
|
||||
const VMGroupRule::role_bitset& rroles = rit.get_roles();
|
||||
std::set<int> rule_vms;
|
||||
|
||||
for (int i = 0 ; i <VMGroupRoles::MAX_ROLES ; ++i)
|
||||
@ -447,7 +429,7 @@ void VMGroupXML::set_affinity_requirements(VirtualMachinePoolXML * vmpool,
|
||||
|
||||
VMGroupRole * r = roles.get(i);
|
||||
|
||||
if ( r == 0 )
|
||||
if ( r )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -466,13 +448,11 @@ void VMGroupXML::set_affinity_requirements(VirtualMachinePoolXML * vmpool,
|
||||
|
||||
static ostream& operator<<(ostream& os, VMGroupRule::rule_set rules)
|
||||
{
|
||||
VMGroupRule::rule_set::iterator rit;
|
||||
|
||||
for ( rit = rules.begin() ; rit != rules.end(); ++rit )
|
||||
for ( const auto& rit : rules )
|
||||
{
|
||||
const VMGroupRule::role_bitset rroles = (*rit).get_roles();
|
||||
const VMGroupRule::role_bitset& rroles = rit.get_roles();
|
||||
|
||||
os << left << setw(14) << (*rit).get_policy() << " ";
|
||||
os << left << setw(14) << rit.get_policy() << " ";
|
||||
|
||||
for (int i = 0 ; i <VMGroupRoles::MAX_ROLES ; ++i)
|
||||
{
|
||||
@ -493,18 +473,16 @@ static ostream& operator<<(ostream& os, VMGroupRule::rule_set rules)
|
||||
|
||||
ostream& operator<<(ostream& os, VMGroupXML& vmg)
|
||||
{
|
||||
VMGroupRoles::role_iterator it;
|
||||
|
||||
os << left << setw(7)<< "ROLE ID" << " " << left << setw(8) << "NAME" << " "
|
||||
<< setw(12) << "POLICY" << " " << left << "VMS\n"
|
||||
<< setfill('-') << setw(80) << '-' << setfill(' ') << "\n";
|
||||
|
||||
for ( it = vmg.roles.begin() ; it != vmg.roles.end() ; ++it )
|
||||
for ( auto role : vmg.roles )
|
||||
{
|
||||
os << left << setw(7) << (*it)->id() << " "
|
||||
<< left << setw(8) << (*it)->name() << " "
|
||||
<< left << setw(12)<< (*it)->policy_s() << " "
|
||||
<< left << (*it)->vms_s() << "\n";
|
||||
os << left << setw(7) << role->id() << " "
|
||||
<< left << setw(8) << role->name() << " "
|
||||
<< left << setw(12)<< role->policy_s() << " "
|
||||
<< left << role->vms_s() << "\n";
|
||||
}
|
||||
|
||||
os << "\n";
|
||||
|
@ -121,8 +121,6 @@ int VirtualMachinePoolXML::set_up()
|
||||
|
||||
if ( rc == 0 )
|
||||
{
|
||||
map<int, ObjectXML*>::iterator it;
|
||||
|
||||
if (objects.empty())
|
||||
{
|
||||
return -2;
|
||||
@ -130,7 +128,7 @@ int VirtualMachinePoolXML::set_up()
|
||||
|
||||
vm_resources.clear();
|
||||
|
||||
for ( it = objects.begin(); it != objects.end(); ++it )
|
||||
for ( auto it = objects.begin(); it != objects.end(); ++it )
|
||||
{
|
||||
vm_resources.add_resource(it->first);
|
||||
}
|
||||
@ -149,7 +147,7 @@ int VirtualMachinePoolXML::set_up()
|
||||
<< " Image DS" << endl
|
||||
<< setw(60) << setfill('-') << "-" << setfill(' ') << endl;
|
||||
|
||||
for (it = objects.begin() ; it != objects.end() ; ++it)
|
||||
for (auto it = objects.begin() ; it != objects.end() ; ++it)
|
||||
{
|
||||
HostShareCapacity sr;
|
||||
|
||||
@ -178,9 +176,8 @@ int VirtualMachinePoolXML::set_up()
|
||||
<< right << setw(11) << sr.disk << " ";
|
||||
|
||||
map<int,long long> ds_usage = vm->get_storage_usage();
|
||||
map<int,long long>::const_iterator ds_it;
|
||||
|
||||
for ( ds_it = ds_usage.begin(); ds_it != ds_usage.end(); ds_it++)
|
||||
for ( auto ds_it = ds_usage.begin(); ds_it != ds_usage.end(); ds_it++)
|
||||
{
|
||||
oss << " DS " << ds_it->first << ": " << ds_it->second <<" ";
|
||||
}
|
||||
@ -361,9 +358,7 @@ int VirtualMachineActionsPoolXML::set_up()
|
||||
oss.str("");
|
||||
oss << "VMs with scheduled actions:" << endl;
|
||||
|
||||
map<int,ObjectXML*>::iterator it;
|
||||
|
||||
for (it=objects.begin();it!=objects.end();it++)
|
||||
for (auto it=objects.begin(); it!=objects.end(); it++)
|
||||
{
|
||||
oss << " " << it->first;
|
||||
}
|
||||
@ -547,9 +542,7 @@ int VirtualMachineRolePoolXML::set_up()
|
||||
|
||||
oss << "VMs in VMGroups:" << endl;
|
||||
|
||||
map<int,ObjectXML*>::iterator it;
|
||||
|
||||
for (it=objects.begin();it!=objects.end();it++)
|
||||
for (auto it=objects.begin(); it!=objects.end(); it++)
|
||||
{
|
||||
oss << " " << it->first;
|
||||
}
|
||||
|
@ -271,7 +271,6 @@ static bool isVolatile(const VectorAttribute * disk)
|
||||
void VirtualMachineXML::init_storage_usage()
|
||||
{
|
||||
vector<Attribute *> disks;
|
||||
vector<Attribute*>::iterator it;
|
||||
|
||||
long long size;
|
||||
long long snapshot_size;
|
||||
@ -283,11 +282,11 @@ void VirtualMachineXML::init_storage_usage()
|
||||
|
||||
int num = vm_template->remove("DISK", disks);
|
||||
|
||||
for (it=disks.begin(); it != disks.end(); it++)
|
||||
for (const auto attr : disks)
|
||||
{
|
||||
const VectorAttribute * disk = dynamic_cast<const VectorAttribute*>(*it);
|
||||
const VectorAttribute * disk = dynamic_cast<const VectorAttribute*>(attr);
|
||||
|
||||
if (disk == 0)
|
||||
if (!disk)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -39,9 +39,7 @@ int VirtualNetworkPoolXML::set_up()
|
||||
<< right << setw(8) << "Leases" << " " << endl
|
||||
<< setw(20) << setfill('-') << "-" << setfill(' ') << endl;
|
||||
|
||||
map<int, ObjectXML*>::iterator it;
|
||||
|
||||
for (it=objects.begin();it!=objects.end();it++)
|
||||
for (auto it=objects.begin(); it!=objects.end(); it++)
|
||||
{
|
||||
VirtualNetworkXML * n = dynamic_cast<VirtualNetworkXML *>(it->second);
|
||||
|
||||
|
@ -388,7 +388,6 @@ int Scheduler::set_up_pools()
|
||||
{
|
||||
int rc;
|
||||
ostringstream oss;
|
||||
map<int,int>::const_iterator it;
|
||||
map<int, int> shares;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@ -841,11 +840,6 @@ void Scheduler::match_schedule()
|
||||
|
||||
string m_error;
|
||||
|
||||
map<int, ObjectXML*>::const_iterator vm_it;
|
||||
map<int, ObjectXML*>::const_iterator obj_it;
|
||||
|
||||
vector<SchedulerPolicy *>::iterator it;
|
||||
|
||||
const map<int, ObjectXML*> pending_vms = vmpool->get_objects();
|
||||
const map<int, ObjectXML*> hosts = hpool->get_objects();
|
||||
const map<int, ObjectXML*> datastores = dspool->get_objects();
|
||||
@ -862,7 +856,7 @@ void Scheduler::match_schedule()
|
||||
|
||||
time_t stime = time(0);
|
||||
|
||||
for (vm_it=pending_vms.begin(); vm_it != pending_vms.end(); vm_it++)
|
||||
for (auto vm_it=pending_vms.begin(); vm_it != pending_vms.end(); vm_it++)
|
||||
{
|
||||
vm = static_cast<VirtualMachineXML*>(vm_it->second);
|
||||
|
||||
@ -902,7 +896,7 @@ void Scheduler::match_schedule()
|
||||
// ---------------------------------------------------------------------
|
||||
profile(true);
|
||||
|
||||
for (obj_it=hosts.begin(); obj_it != hosts.end(); obj_it++)
|
||||
for (auto obj_it=hosts.begin(); obj_it != hosts.end(); obj_it++)
|
||||
{
|
||||
host = static_cast<HostXML *>(obj_it->second);
|
||||
|
||||
@ -981,9 +975,9 @@ void Scheduler::match_schedule()
|
||||
// ---------------------------------------------------------------------
|
||||
profile(true);
|
||||
|
||||
for (it=host_policies.begin() ; it != host_policies.end() ; it++)
|
||||
for (auto sp : host_policies)
|
||||
{
|
||||
(*it)->schedule(vm);
|
||||
sp->schedule(vm);
|
||||
}
|
||||
|
||||
vm->sort_match_hosts();
|
||||
@ -1009,7 +1003,7 @@ void Scheduler::match_schedule()
|
||||
n_error = 0;
|
||||
n_fits = 0;
|
||||
|
||||
for (obj_it=datastores.begin(); obj_it != datastores.end(); obj_it++)
|
||||
for (auto obj_it=datastores.begin(); obj_it != datastores.end(); obj_it++)
|
||||
{
|
||||
ds = static_cast<DatastoreXML *>(obj_it->second);
|
||||
|
||||
@ -1100,9 +1094,9 @@ void Scheduler::match_schedule()
|
||||
|
||||
profile(true);
|
||||
|
||||
for (it=ds_policies.begin() ; it != ds_policies.end() ; it++)
|
||||
for (auto sp : ds_policies)
|
||||
{
|
||||
(*it)->schedule(vm);
|
||||
sp->schedule(vm);
|
||||
}
|
||||
|
||||
vm->sort_match_datastores();
|
||||
@ -1115,7 +1109,6 @@ void Scheduler::match_schedule()
|
||||
|
||||
profile(true);
|
||||
|
||||
set<int>::iterator it_nic;
|
||||
const set<int>& nics_ids = vm->get_nics_ids();
|
||||
|
||||
bool not_matched = false;
|
||||
@ -1130,7 +1123,7 @@ void Scheduler::match_schedule()
|
||||
n_fits = 0;
|
||||
|
||||
|
||||
for (obj_it = nets.begin(); obj_it != nets.end(); ++obj_it)
|
||||
for (auto obj_it = nets.begin(); obj_it != nets.end(); ++obj_it)
|
||||
{
|
||||
net = static_cast<VirtualNetworkXML *>(obj_it->second);
|
||||
|
||||
@ -1202,9 +1195,9 @@ void Scheduler::match_schedule()
|
||||
|
||||
profile(true);
|
||||
|
||||
for (it = nic_policies.begin() ; it != nic_policies.end() ; it++)
|
||||
for (auto sp : nic_policies)
|
||||
{
|
||||
(*it)->schedule(vm->get_nic(nic_id));
|
||||
sp->schedule(vm->get_nic(nic_id));
|
||||
}
|
||||
|
||||
vm->sort_match_networks(nic_id);
|
||||
@ -1253,7 +1246,7 @@ void Scheduler::match_schedule()
|
||||
|
||||
oss << "Scheduling Results:" << endl;
|
||||
|
||||
for (map<int, ObjectXML*>::const_iterator vm_it=pending_vms.begin();
|
||||
for (auto vm_it=pending_vms.begin();
|
||||
vm_it != pending_vms.end(); vm_it++)
|
||||
{
|
||||
vm = static_cast<VirtualMachineXML*>(vm_it->second);
|
||||
@ -1288,16 +1281,14 @@ void Scheduler::dispatch()
|
||||
|
||||
vector<Resource *>::const_reverse_iterator i, j, k, n;
|
||||
|
||||
vector<SchedulerPolicy *>::iterator sp_it;
|
||||
|
||||
ostringstream extra;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Schedule pending VMs according to the VM policies (e.g. User priority)
|
||||
//--------------------------------------------------------------------------
|
||||
for (sp_it = vm_policies.begin() ; sp_it != vm_policies.end() ; ++sp_it)
|
||||
for (auto sp : vm_policies)
|
||||
{
|
||||
(*sp_it)->schedule(0);
|
||||
sp->schedule(0);
|
||||
}
|
||||
|
||||
vmpool->sort_vm_resources();
|
||||
@ -1571,9 +1562,7 @@ void Scheduler::dispatch()
|
||||
|
||||
if ( num_matched_networks < nics_ids.size())
|
||||
{
|
||||
map<int,int>::iterator it;
|
||||
|
||||
for (it = matched_networks.begin(); it != matched_networks.end(); it++)
|
||||
for (auto it = matched_networks.begin(); it != matched_networks.end(); it++)
|
||||
{
|
||||
net = vnetpool->get(it->first);
|
||||
|
||||
@ -1588,9 +1577,7 @@ void Scheduler::dispatch()
|
||||
//------------------------------------------------------------------
|
||||
if (vmpool->dispatch((*k)->oid, hid, dsid, vm->is_resched(), extra.str()) != 0)
|
||||
{
|
||||
map<int,int>::iterator it;
|
||||
|
||||
for ( it = matched_networks.begin(); it != matched_networks.end(); it++)
|
||||
for ( auto it = matched_networks.begin(); it != matched_networks.end(); it++)
|
||||
{
|
||||
net = vnetpool->get(it->first);
|
||||
|
||||
@ -1635,11 +1622,9 @@ void Scheduler::dispatch()
|
||||
|
||||
if ( affined_vms.size() > 0 )
|
||||
{
|
||||
set<int>::const_iterator it;
|
||||
|
||||
for ( it = affined_vms.begin(); it != affined_vms.end(); ++it )
|
||||
for ( auto vm_id : affined_vms )
|
||||
{
|
||||
VirtualMachineXML * avm = vmpool->get(*it);
|
||||
VirtualMachineXML * avm = vmpool->get(vm_id);
|
||||
|
||||
if ( avm == 0 )
|
||||
{
|
||||
@ -1690,31 +1675,28 @@ int Scheduler::do_scheduled_actions()
|
||||
VirtualMachineXML* vm;
|
||||
|
||||
const map<int, ObjectXML*> vms = vmapool->get_objects();
|
||||
map<int, ObjectXML*>::const_iterator vm_it;
|
||||
|
||||
string action_st, args_st, error_msg;
|
||||
|
||||
string time_str = one_util::log_time(time(0));
|
||||
|
||||
for (vm_it=vms.begin(); vm_it != vms.end(); vm_it++)
|
||||
for (auto vm_it=vms.begin(); vm_it != vms.end(); vm_it++)
|
||||
{
|
||||
SchedActions::schedaction_iterator action;
|
||||
|
||||
vm = static_cast<VirtualMachineXML *>(vm_it->second);
|
||||
|
||||
SchedActions sas = vm->get_actions();
|
||||
|
||||
for ( action = sas.begin(); action != sas.end(); ++action)
|
||||
for ( auto action : sas)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
if (!(*action)->is_due(vm->get_stime()))
|
||||
if (!action->is_due(vm->get_stime()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
action_st = (*action)->vector_value("ACTION");
|
||||
args_st = (*action)->vector_value("ARGS");
|
||||
action_st = action->vector_value("ACTION");
|
||||
args_st = action->vector_value("ARGS");
|
||||
|
||||
int rc = VirtualMachineXML::parse_action_name(action_st);
|
||||
|
||||
@ -1734,13 +1716,13 @@ int Scheduler::do_scheduled_actions()
|
||||
time_t done_time = time(0);
|
||||
time_t next_time;
|
||||
|
||||
(*action)->remove("MESSAGE");
|
||||
action->remove("MESSAGE");
|
||||
|
||||
(*action)->replace("DONE", done_time);
|
||||
action->replace("DONE", done_time);
|
||||
|
||||
do
|
||||
{
|
||||
next_time = (*action)->next_action();
|
||||
next_time = action->next_action();
|
||||
} while ( next_time < done_time && next_time != -1 );
|
||||
|
||||
oss << "Success.";
|
||||
@ -1753,7 +1735,7 @@ int Scheduler::do_scheduled_actions()
|
||||
|
||||
oss_aux << time_str << " : " << error_msg;
|
||||
|
||||
(*action)->replace("MESSAGE", oss_aux.str());
|
||||
action->replace("MESSAGE", oss_aux.str());
|
||||
|
||||
oss << "Failure. " << error_msg;
|
||||
}
|
||||
@ -1775,14 +1757,13 @@ int Scheduler::do_scheduled_actions()
|
||||
|
||||
void Scheduler::do_vm_groups()
|
||||
{
|
||||
map<int, ObjectXML*>::const_iterator it;
|
||||
const map<int, ObjectXML*> vmgrps = vmgpool->get_objects();
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
oss << "VM Group Scheduling information\n";
|
||||
|
||||
for (it = vmgrps.begin(); it != vmgrps.end() ; ++it)
|
||||
for (auto it = vmgrps.begin(); it != vmgrps.end() ; ++it)
|
||||
{
|
||||
VMGroupXML * grp = static_cast<VMGroupXML*>(it->second);
|
||||
|
||||
|
@ -57,7 +57,6 @@ SecurityGroup::SecurityGroup(
|
||||
|
||||
int SecurityGroup::insert(SqlDB *db, string& error_str)
|
||||
{
|
||||
vector<const VectorAttribute*>::const_iterator it;
|
||||
vector<const VectorAttribute*> rules;
|
||||
|
||||
erase_template_attribute("NAME",name);
|
||||
@ -69,9 +68,9 @@ int SecurityGroup::insert(SqlDB *db, string& error_str)
|
||||
|
||||
get_template_attribute("RULE", rules);
|
||||
|
||||
for ( it = rules.begin(); it != rules.end(); it++ )
|
||||
for ( auto rule : rules )
|
||||
{
|
||||
if (!isValidRule(*it, error_str))
|
||||
if (!isValidRule(rule, error_str))
|
||||
{
|
||||
goto error_valid;
|
||||
}
|
||||
@ -280,15 +279,14 @@ int SecurityGroup::from_xml(const string& xml)
|
||||
|
||||
void SecurityGroup::get_rules(vector<VectorAttribute*>& result) const
|
||||
{
|
||||
vector<const VectorAttribute*>::const_iterator it;
|
||||
vector<const VectorAttribute*> rules;
|
||||
|
||||
get_template_attribute("RULE", rules);
|
||||
|
||||
for ( it = rules.begin(); it != rules.end(); it++ )
|
||||
for ( auto rule : rules )
|
||||
{
|
||||
VectorAttribute* new_rule = new VectorAttribute(
|
||||
"SECURITY_GROUP_RULE", (*it)->value());
|
||||
"SECURITY_GROUP_RULE", rule->value());
|
||||
|
||||
new_rule->replace("SECURITY_GROUP_ID", this->get_oid());
|
||||
new_rule->replace("SECURITY_GROUP_NAME", this->get_name());
|
||||
@ -435,14 +433,13 @@ bool SecurityGroup::isValidRule(const VectorAttribute * rule, string& error) con
|
||||
|
||||
int SecurityGroup::post_update_template(string& error)
|
||||
{
|
||||
vector<const VectorAttribute*>::const_iterator it;
|
||||
vector<const VectorAttribute*> rules;
|
||||
|
||||
get_template_attribute("RULE", rules);
|
||||
|
||||
for ( it = rules.begin(); it != rules.end(); it++ )
|
||||
for ( auto rule : rules )
|
||||
{
|
||||
if (!isValidRule(*it, error))
|
||||
if (!isValidRule(rule, error))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
@ -138,7 +138,6 @@ error_name:
|
||||
void SecurityGroupPool::get_security_group_rules(int vmid, int sgid,
|
||||
vector<VectorAttribute*> &rules)
|
||||
{
|
||||
vector<VectorAttribute*>::iterator rule_it;
|
||||
vector<VectorAttribute*> sg_rules;
|
||||
|
||||
int vnet_id;
|
||||
@ -160,14 +159,12 @@ void SecurityGroupPool::get_security_group_rules(int vmid, int sgid,
|
||||
return;
|
||||
}
|
||||
|
||||
for (rule_it = sg_rules.begin(); rule_it != sg_rules.end(); rule_it++)
|
||||
for (auto rule : sg_rules)
|
||||
{
|
||||
if ( (*rule_it)->vector_value("NETWORK_ID", vnet_id) != -1 )
|
||||
if ( rule->vector_value("NETWORK_ID", vnet_id) != -1 )
|
||||
{
|
||||
vector<VectorAttribute*> vnet_rules;
|
||||
|
||||
VectorAttribute* rule = *rule_it;
|
||||
|
||||
if ( auto vnet = vnet_pool->get_ro(vnet_id) )
|
||||
{
|
||||
vnet->process_security_rule(rule, vnet_rules);
|
||||
@ -184,7 +181,7 @@ void SecurityGroupPool::get_security_group_rules(int vmid, int sgid,
|
||||
}
|
||||
else
|
||||
{
|
||||
rules.push_back(*rule_it);
|
||||
rules.push_back(rule);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -818,13 +818,11 @@ uint64_t LogDB::last_federated()
|
||||
|
||||
uint64_t LogDB::previous_federated(uint64_t i)
|
||||
{
|
||||
set<uint64_t>::iterator it;
|
||||
|
||||
lock_guard<mutex> lock(_mutex);
|
||||
|
||||
uint64_t findex = UINT64_MAX;
|
||||
|
||||
it = fed_log.find(i);
|
||||
auto it = fed_log.find(i);
|
||||
|
||||
if ( it != fed_log.end() && it != fed_log.begin() )
|
||||
{
|
||||
@ -838,13 +836,11 @@ uint64_t LogDB::previous_federated(uint64_t i)
|
||||
|
||||
uint64_t LogDB::next_federated(uint64_t i)
|
||||
{
|
||||
set<uint64_t>::iterator it;
|
||||
|
||||
lock_guard<mutex> lock(_mutex);
|
||||
|
||||
uint64_t findex = UINT64_MAX;
|
||||
|
||||
it = fed_log.find(i);
|
||||
auto it = fed_log.find(i);
|
||||
|
||||
if ( it != fed_log.end() && it != --fed_log.end() )
|
||||
{
|
||||
|
@ -33,9 +33,7 @@ using namespace std;
|
||||
|
||||
Template::~Template()
|
||||
{
|
||||
multimap<string,Attribute *>::iterator it;
|
||||
|
||||
for ( it = attributes.begin(); it != attributes.end(); it++)
|
||||
for ( auto it = attributes.begin(); it != attributes.end(); it++)
|
||||
{
|
||||
delete it->second;
|
||||
}
|
||||
@ -193,13 +191,9 @@ void Template::set(Attribute * attr)
|
||||
{
|
||||
if ( replace_mode == true )
|
||||
{
|
||||
multimap<string, Attribute *>::iterator i;
|
||||
pair<multimap<string, Attribute *>::iterator,
|
||||
multimap<string, Attribute *>::iterator> index;
|
||||
auto index = attributes.equal_range(attr->name());
|
||||
|
||||
index = attributes.equal_range(attr->name());
|
||||
|
||||
for ( i = index.first; i != index.second; i++)
|
||||
for ( auto i = index.first; i != index.second; i++)
|
||||
{
|
||||
delete i->second;
|
||||
}
|
||||
@ -215,19 +209,13 @@ void Template::set(Attribute * attr)
|
||||
|
||||
int Template::replace(const string& name, const string& value)
|
||||
{
|
||||
pair<multimap<string, Attribute *>::iterator,
|
||||
multimap<string, Attribute *>::iterator> index;
|
||||
|
||||
index = attributes.equal_range(name);
|
||||
auto index = attributes.equal_range(name);
|
||||
|
||||
if (index.first != index.second )
|
||||
{
|
||||
multimap<string, Attribute *>::iterator i;
|
||||
|
||||
for ( i = index.first; i != index.second; i++)
|
||||
for ( auto i = index.first; i != index.second; i++)
|
||||
{
|
||||
Attribute * attr = i->second;
|
||||
delete attr;
|
||||
delete i->second;
|
||||
}
|
||||
|
||||
attributes.erase(index.first, index.second);
|
||||
@ -247,19 +235,13 @@ int Template::replace(const string& name, const bool& value)
|
||||
{
|
||||
string s_val;
|
||||
|
||||
pair<multimap<string, Attribute *>::iterator,
|
||||
multimap<string, Attribute *>::iterator> index;
|
||||
|
||||
index = attributes.equal_range(name);
|
||||
auto index = attributes.equal_range(name);
|
||||
|
||||
if (index.first != index.second )
|
||||
{
|
||||
multimap<string, Attribute *>::iterator i;
|
||||
|
||||
for ( i = index.first; i != index.second; i++)
|
||||
for ( auto i = index.first; i != index.second; i++)
|
||||
{
|
||||
Attribute * attr = i->second;
|
||||
delete attr;
|
||||
delete i->second;
|
||||
}
|
||||
|
||||
attributes.erase(index.first, index.second);
|
||||
@ -286,25 +268,18 @@ int Template::replace(const string& name, const bool& value)
|
||||
|
||||
int Template::erase(const string& name)
|
||||
{
|
||||
multimap<string, Attribute *>::iterator i;
|
||||
int j = 0;
|
||||
|
||||
pair<
|
||||
multimap<string, Attribute *>::iterator,
|
||||
multimap<string, Attribute *>::iterator
|
||||
> index;
|
||||
int j;
|
||||
|
||||
index = attributes.equal_range(name);
|
||||
auto index = attributes.equal_range(name);
|
||||
|
||||
if (index.first == index.second )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
for ( i = index.first,j=0 ; i != index.second ; i++,j++ )
|
||||
for ( auto i = index.first; i != index.second; i++,j++ )
|
||||
{
|
||||
Attribute * attr = i->second;
|
||||
delete attr;
|
||||
delete i->second;
|
||||
}
|
||||
|
||||
attributes.erase(index.first,index.second);
|
||||
@ -317,16 +292,9 @@ int Template::erase(const string& name)
|
||||
|
||||
Attribute * Template::remove(Attribute * att)
|
||||
{
|
||||
multimap<string, Attribute *>::iterator i;
|
||||
auto index = attributes.equal_range( att->name() );
|
||||
|
||||
pair<
|
||||
multimap<string, Attribute *>::iterator,
|
||||
multimap<string, Attribute *>::iterator
|
||||
> index;
|
||||
|
||||
index = attributes.equal_range( att->name() );
|
||||
|
||||
for ( i = index.first; i != index.second; i++ )
|
||||
for ( auto i = index.first; i != index.second; i++ )
|
||||
{
|
||||
if ( i->second == att )
|
||||
{
|
||||
@ -387,12 +355,11 @@ bool Template::get(const string& name, bool& value) const
|
||||
|
||||
string& Template::to_xml(string& xml) const
|
||||
{
|
||||
multimap<string,Attribute *>::const_iterator it;
|
||||
ostringstream oss;
|
||||
|
||||
oss << "<" << xml_root << ">";
|
||||
|
||||
for ( it = attributes.begin(); it!=attributes.end(); it++)
|
||||
for ( auto it = attributes.begin(); it!=attributes.end(); it++)
|
||||
{
|
||||
it->second->to_xml(oss);
|
||||
}
|
||||
@ -406,14 +373,13 @@ string& Template::to_xml(string& xml) const
|
||||
|
||||
string& Template::to_json(string& json) const
|
||||
{
|
||||
multimap<string, Attribute *>::const_iterator it;
|
||||
ostringstream oss;
|
||||
|
||||
bool is_first = true;
|
||||
|
||||
oss << "\"" << xml_root << "\": {";
|
||||
|
||||
for ( it = attributes.begin(); it!=attributes.end(); )
|
||||
for ( auto it = attributes.begin(); it!=attributes.end(); )
|
||||
{
|
||||
if (!is_first)
|
||||
{
|
||||
@ -467,9 +433,8 @@ string& Template::to_json(string& json) const
|
||||
string& Template::to_token(string& str) const
|
||||
{
|
||||
ostringstream os;
|
||||
multimap<string,Attribute *>::const_iterator it;
|
||||
|
||||
for ( it = attributes.begin(); it!=attributes.end(); it++)
|
||||
for ( auto it = attributes.begin(); it!=attributes.end(); it++)
|
||||
{
|
||||
it->second->to_token(os);
|
||||
}
|
||||
@ -672,9 +637,7 @@ void Template::clear()
|
||||
return;
|
||||
}
|
||||
|
||||
multimap<string,Attribute *>::iterator it;
|
||||
|
||||
for ( it = attributes.begin(); it != attributes.end(); it++)
|
||||
for ( auto it = attributes.begin(); it != attributes.end(); it++)
|
||||
{
|
||||
delete it->second;
|
||||
}
|
||||
@ -691,14 +654,12 @@ void Template::clear()
|
||||
|
||||
void Template::merge(const Template * from)
|
||||
{
|
||||
multimap<string, Attribute *>::const_iterator it, jt;
|
||||
|
||||
for (it = from->attributes.begin(); it != from->attributes.end(); ++it)
|
||||
for (auto it = from->attributes.begin(); it != from->attributes.end(); ++it)
|
||||
{
|
||||
erase(it->first);
|
||||
}
|
||||
|
||||
for (it = from->attributes.begin(); it != from->attributes.end(); ++it)
|
||||
for (auto it = from->attributes.begin(); it != from->attributes.end(); ++it)
|
||||
{
|
||||
if ( it->second->type() == Attribute::VECTOR )
|
||||
{
|
||||
@ -722,11 +683,9 @@ void Template::merge(const Template * from)
|
||||
static void parse_attributes(const vector<const SingleAttribute *>& as,
|
||||
std::map<std::string, std::set<std::string> >& as_m)
|
||||
{
|
||||
vector<const SingleAttribute *>::const_iterator it;
|
||||
|
||||
for (it = as.begin(); it != as.end(); ++it)
|
||||
for (auto attr : as)
|
||||
{
|
||||
string va = (*it)->value();
|
||||
string va = attr->value();
|
||||
size_t pos = va.find("/");
|
||||
|
||||
if (pos != string::npos) //Vector Attribute
|
||||
@ -734,9 +693,7 @@ static void parse_attributes(const vector<const SingleAttribute *>& as,
|
||||
string avector = va.substr(0,pos);
|
||||
string vattr = va.substr(pos+1);
|
||||
|
||||
map<std::string, std::set<string> >::iterator jt;
|
||||
|
||||
jt = as_m.find(avector);
|
||||
auto jt = as_m.find(avector);
|
||||
|
||||
if ( jt == as_m.end() )
|
||||
{
|
||||
@ -787,18 +744,17 @@ static bool restricted_values(const string& vname, const set<string>& vsubs,
|
||||
string value;
|
||||
bool exists;
|
||||
|
||||
vector<const VectorAttribute *>::const_iterator va_it;
|
||||
vector<const VectorAttribute *> va;
|
||||
|
||||
exists = tmpl->get(vname, va);
|
||||
|
||||
for ( va_it = va.begin(); va_it != va.end() ; ++va_it )
|
||||
for ( auto vattr : va )
|
||||
{
|
||||
for (set<string>::iterator jt = vsubs.begin(); jt != vsubs.end(); ++jt)
|
||||
for (const auto& sub : vsubs)
|
||||
{
|
||||
if ( (*va_it)->vector_value(*jt, value) == 0 )
|
||||
if ( vattr->vector_value(sub, value) == 0 )
|
||||
{
|
||||
rstrings.push_back(*jt + value);
|
||||
rstrings.push_back(sub + value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -811,9 +767,7 @@ static bool restricted_values(const string& vname, const set<string>& vsubs,
|
||||
bool Template::check_restricted(string& ra, const Template* base,
|
||||
const std::map<std::string, std::set<std::string> >& ras)
|
||||
{
|
||||
std::map<std::string, std::set<std::string> >::const_iterator rit;
|
||||
|
||||
for ( rit = ras.begin(); rit != ras.end(); ++rit )
|
||||
for ( auto rit = ras.begin(); rit != ras.end(); ++rit )
|
||||
{
|
||||
if (!(rit->second).empty())
|
||||
{
|
||||
@ -866,9 +820,7 @@ bool Template::check_restricted(string& ra, const Template* base,
|
||||
bool Template::check_restricted(string& ra,
|
||||
const std::map<std::string, std::set<std::string> >& ras)
|
||||
{
|
||||
std::map<std::string, std::set<std::string> >::const_iterator rit;
|
||||
|
||||
for ( rit = ras.begin(); rit != ras.end(); ++rit )
|
||||
for ( auto rit = ras.begin(); rit != ras.end(); ++rit )
|
||||
{
|
||||
const std::set<std::string>& sub = rit->second;
|
||||
|
||||
@ -876,20 +828,17 @@ bool Template::check_restricted(string& ra,
|
||||
{
|
||||
// -----------------------------------------------------------------
|
||||
// -----------------------------------------------------------------
|
||||
std::set<std::string>::iterator jt;
|
||||
std::vector<VectorAttribute *>::iterator va_it;
|
||||
|
||||
std::vector<VectorAttribute *> va;
|
||||
|
||||
get(rit->first, va);
|
||||
|
||||
for ( va_it = va.begin(); va_it != va.end() ; ++va_it )
|
||||
for ( auto vattr : va )
|
||||
{
|
||||
for ( jt = sub.begin(); jt != sub.end(); ++jt )
|
||||
for ( const auto& s : sub )
|
||||
{
|
||||
if ( (*va_it)->vector_value(*jt, ra) == 0 )
|
||||
if ( vattr->vector_value(s, ra) == 0 )
|
||||
{
|
||||
ra = *jt;
|
||||
ra = s;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -41,9 +41,7 @@ LoginTokenPool::~LoginTokenPool()
|
||||
|
||||
void LoginTokenPool::reset()
|
||||
{
|
||||
std::map<std::string, LoginToken *>::iterator it;
|
||||
|
||||
for (it = tokens.begin() ; it != tokens.end() ; ++it)
|
||||
for (auto it = tokens.begin() ; it != tokens.end() ; ++it)
|
||||
{
|
||||
delete it->second;
|
||||
}
|
||||
@ -75,9 +73,7 @@ int LoginTokenPool::set(std::string& utk, time_t valid, int egid)
|
||||
|
||||
int LoginTokenPool::reset(const std::string& utk)
|
||||
{
|
||||
std::map<std::string, LoginToken *>::iterator it;
|
||||
|
||||
it = tokens.find(utk);
|
||||
auto it = tokens.find(utk);
|
||||
|
||||
if ( it == tokens.end() )
|
||||
{
|
||||
@ -95,21 +91,13 @@ int LoginTokenPool::reset(const std::string& utk)
|
||||
|
||||
void LoginTokenPool::reset_expired()
|
||||
{
|
||||
std::map<std::string, LoginToken *>::iterator it, tmp_it;
|
||||
|
||||
for (it = tokens.begin(); it != tokens.end(); )
|
||||
for (auto it = tokens.begin(); it != tokens.end(); )
|
||||
{
|
||||
if ((it->second)->is_expired())
|
||||
{
|
||||
tmp_it = it;
|
||||
|
||||
++tmp_it;
|
||||
|
||||
delete it->second;
|
||||
|
||||
tokens.erase(it);
|
||||
|
||||
it = tmp_it;
|
||||
it = tokens.erase(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -122,10 +110,8 @@ void LoginTokenPool::reset_expired()
|
||||
|
||||
bool LoginTokenPool::is_valid(const std::string& utk, int& egid, bool& exists_token)
|
||||
{
|
||||
std::map<std::string, LoginToken *>::iterator it;
|
||||
|
||||
egid = -1;
|
||||
it = tokens.find(utk);
|
||||
auto it = tokens.find(utk);
|
||||
|
||||
if ( it == tokens.end() )
|
||||
{
|
||||
@ -134,7 +120,7 @@ bool LoginTokenPool::is_valid(const std::string& utk, int& egid, bool& exists_to
|
||||
}
|
||||
|
||||
exists_token = true;
|
||||
|
||||
|
||||
if ( it->second->is_valid(utk, egid) == true)
|
||||
{
|
||||
return true;
|
||||
@ -151,12 +137,10 @@ bool LoginTokenPool::is_valid(const std::string& utk, int& egid, bool& exists_to
|
||||
|
||||
void LoginTokenPool::from_xml_node(const std::vector<xmlNodePtr>& content)
|
||||
{
|
||||
std::vector<xmlNodePtr>::const_iterator it;
|
||||
|
||||
for (it = content.begin(); it != content.end(); ++it)
|
||||
for (auto node : content)
|
||||
{
|
||||
LoginToken * tk = new LoginToken;
|
||||
std::string utk = tk->from_xml_node(*it);
|
||||
std::string utk = tk->from_xml_node(node);
|
||||
|
||||
tokens.insert(std::pair<std::string, LoginToken *>(utk, tk));
|
||||
}
|
||||
@ -166,10 +150,9 @@ void LoginTokenPool::from_xml_node(const std::vector<xmlNodePtr>& content)
|
||||
|
||||
std::string& LoginTokenPool::to_xml(std::string& xml) const
|
||||
{
|
||||
std::map<std::string, LoginToken *>::const_iterator it;
|
||||
std::ostringstream oss;
|
||||
|
||||
for ( it = tokens.begin() ; it != tokens.end() ; ++it)
|
||||
for ( auto it = tokens.begin() ; it != tokens.end() ; ++it)
|
||||
{
|
||||
it->second->to_xml(oss);
|
||||
}
|
||||
|
@ -151,7 +151,6 @@ bool Quota::check_quota(const string& qid,
|
||||
{
|
||||
VectorAttribute * q;
|
||||
VectorAttribute * default_q;
|
||||
map<string, float>::iterator it;
|
||||
|
||||
bool check;
|
||||
float limit;
|
||||
@ -208,7 +207,7 @@ bool Quota::check_quota(const string& qid,
|
||||
|
||||
metrics_used += "_USED";
|
||||
|
||||
it = usage_req.find(metrics[i]);
|
||||
auto it = usage_req.find(metrics[i]);
|
||||
|
||||
if (it == usage_req.end())
|
||||
{
|
||||
@ -259,7 +258,7 @@ bool Quota::check_quota(const string& qid,
|
||||
|
||||
metrics_used += "_USED";
|
||||
|
||||
it = usage_req.find(metrics[i]);
|
||||
auto it = usage_req.find(metrics[i]);
|
||||
|
||||
if (it == usage_req.end())
|
||||
{
|
||||
@ -278,7 +277,6 @@ bool Quota::check_quota(const string& qid,
|
||||
void Quota::del_quota(const string& qid, map<string, float>& usage_req)
|
||||
{
|
||||
VectorAttribute * q;
|
||||
map<string, float>::iterator it;
|
||||
|
||||
if ( get_quota(qid, &q) == -1)
|
||||
{
|
||||
@ -296,7 +294,7 @@ void Quota::del_quota(const string& qid, map<string, float>& usage_req)
|
||||
|
||||
metrics_used += "_USED";
|
||||
|
||||
it = usage_req.find(metrics[i]);
|
||||
auto it = usage_req.find(metrics[i]);
|
||||
|
||||
if (it == usage_req.end())
|
||||
{
|
||||
|
@ -326,12 +326,9 @@ void Quotas::ds_del_recreate(int uid, int gid, vector<Template *>& ds_quotas)
|
||||
Nebula& nd = Nebula::instance();
|
||||
ImagePool * ipool = nd.get_ipool();
|
||||
|
||||
vector<Template *>::iterator it;
|
||||
|
||||
for (it = ds_quotas.begin(); it != ds_quotas.end(); it++)
|
||||
for (auto tmpl : ds_quotas)
|
||||
{
|
||||
int image_id = -1;
|
||||
Template * tmpl = *it;
|
||||
|
||||
bool vm_owner, img_owner;
|
||||
|
||||
|
@ -1176,7 +1176,6 @@ bool UserPool::authenticate_external(const string& username,
|
||||
int gid = -1;
|
||||
int rc;
|
||||
|
||||
set<int>::iterator it;
|
||||
set<int> empty_set;
|
||||
set<int> group_admin_ids;
|
||||
|
||||
|
@ -181,22 +181,21 @@ int Vdc::bootstrap(SqlDB * db)
|
||||
|
||||
int Vdc::drop(SqlDB * db)
|
||||
{
|
||||
set<int>::const_iterator it;
|
||||
int rc;
|
||||
|
||||
rc = PoolObjectSQL::drop(db);
|
||||
|
||||
if ( rc == 0 )
|
||||
{
|
||||
for (it = groups.begin(); it != groups.end(); it++)
|
||||
for (auto gid : groups)
|
||||
{
|
||||
clusters.del_group_rules(*it);
|
||||
clusters.del_group_rules(gid);
|
||||
|
||||
hosts.del_group_rules(*it);
|
||||
hosts.del_group_rules(gid);
|
||||
|
||||
datastores.del_group_rules(*it);
|
||||
datastores.del_group_rules(gid);
|
||||
|
||||
vnets.del_group_rules(*it);
|
||||
vnets.del_group_rules(gid);
|
||||
}
|
||||
}
|
||||
|
||||
@ -211,18 +210,15 @@ string& Vdc::to_xml(string& xml) const
|
||||
ostringstream oss;
|
||||
string template_xml;
|
||||
|
||||
set<pair<int,int> >::const_iterator it;
|
||||
set<int>::const_iterator group_it;
|
||||
|
||||
oss <<
|
||||
"<VDC>" <<
|
||||
"<ID>" << oid << "</ID>" <<
|
||||
"<NAME>" << name << "</NAME>" <<
|
||||
"<GROUPS>";
|
||||
|
||||
for (group_it = groups.begin(); group_it != groups.end(); group_it++)
|
||||
for (auto gid : groups)
|
||||
{
|
||||
oss << "<ID>" << *group_it << "</ID>";
|
||||
oss << "<ID>" << gid << "</ID>";
|
||||
}
|
||||
|
||||
oss << "</GROUPS>";
|
||||
@ -257,7 +253,6 @@ string& Vdc::to_xml(string& xml) const
|
||||
int Vdc::from_xml(const string& xml)
|
||||
{
|
||||
vector<xmlNodePtr> content;
|
||||
vector<xmlNodePtr>::iterator it;
|
||||
int rc = 0;
|
||||
|
||||
// Initialize the internal XML object
|
||||
@ -284,9 +279,9 @@ int Vdc::from_xml(const string& xml)
|
||||
// Set of Groups
|
||||
ObjectXML::get_nodes("/VDC/GROUPS/ID", content);
|
||||
|
||||
for (it = content.begin(); it != content.end(); it++)
|
||||
for (auto node : content)
|
||||
{
|
||||
ObjectXML tmp_xml(*it);
|
||||
ObjectXML tmp_xml(node);
|
||||
|
||||
int group_id;
|
||||
|
||||
@ -347,9 +342,7 @@ int Vdc::from_xml(const string& xml)
|
||||
|
||||
int Vdc::add_group(int group_id, string& error_msg)
|
||||
{
|
||||
pair<set<int>::iterator,bool> ret;
|
||||
|
||||
ret = groups.insert(group_id);
|
||||
auto ret = groups.insert(group_id);
|
||||
|
||||
if( !ret.second )
|
||||
{
|
||||
@ -401,7 +394,6 @@ void ResourceSet::insert_default_rules(string name_attr, PoolObjectSQL::ObjectTy
|
||||
{
|
||||
string default_vdc_acl;
|
||||
vector<string> vdc_acl;
|
||||
vector<string>::const_iterator it;
|
||||
long long op = AuthRequest::NONE;
|
||||
AuthRequest::Operation user_op;
|
||||
|
||||
@ -409,10 +401,10 @@ void ResourceSet::insert_default_rules(string name_attr, PoolObjectSQL::ObjectTy
|
||||
|
||||
vdc_acl = one_util::split(default_vdc_acl, '+', true);
|
||||
|
||||
for (it = vdc_acl.begin(); it != vdc_acl.end(); ++it)
|
||||
for (const auto& str : vdc_acl)
|
||||
{
|
||||
user_op = AuthRequest::str_to_operation(*it);
|
||||
if ( *it != "" && *it != "-" && user_op != AuthRequest::NONE )
|
||||
user_op = AuthRequest::str_to_operation(str);
|
||||
if ( str != "" && str != "-" && user_op != AuthRequest::NONE )
|
||||
{
|
||||
op = op | user_op;
|
||||
}
|
||||
@ -430,7 +422,6 @@ ResourceSet::ResourceSet(PoolObjectSQL::ObjectType _type):type(_type)
|
||||
{
|
||||
string default_vdc_acl;
|
||||
vector<string> cluster_res = { "HOST", "NET", "DATASTORE" };
|
||||
vector<string>::const_iterator it_c;
|
||||
string str_type;
|
||||
string name_attr= "";
|
||||
|
||||
@ -450,11 +441,11 @@ ResourceSet::ResourceSet(PoolObjectSQL::ObjectType _type):type(_type)
|
||||
// @<gid> DATASTORE+NET/%<cid> USE #<zid>
|
||||
case PoolObjectSQL::CLUSTER:
|
||||
|
||||
for (it_c = cluster_res.begin(); it_c != cluster_res.end(); ++it_c)
|
||||
for (const auto& cluster : cluster_res)
|
||||
{
|
||||
name_attr = "DEFAULT_VDC_CLUSTER_" + *it_c + "_ACL";
|
||||
name_attr = "DEFAULT_VDC_CLUSTER_" + cluster + "_ACL";
|
||||
|
||||
insert_default_rules(name_attr, PoolObjectSQL::str_to_type(*it_c));
|
||||
insert_default_rules(name_attr, PoolObjectSQL::str_to_type(cluster));
|
||||
}
|
||||
|
||||
xml_name = "CLUSTER";
|
||||
@ -470,9 +461,7 @@ ResourceSet::ResourceSet(PoolObjectSQL::ObjectType _type):type(_type)
|
||||
|
||||
void ResourceSet::to_xml(ostringstream &oss) const
|
||||
{
|
||||
set<pair<int,int> >::const_iterator it;
|
||||
|
||||
for (it = resources.begin(); it != resources.end(); it++)
|
||||
for (auto it = resources.begin(); it != resources.end(); it++)
|
||||
{
|
||||
oss << "<"<< xml_name<<">" <<
|
||||
"<ZONE_ID>" << it->first << "</ZONE_ID>"
|
||||
@ -486,7 +475,6 @@ void ResourceSet::to_xml(ostringstream &oss) const
|
||||
|
||||
int ResourceSet::from_xml_node(vector<xmlNodePtr>& content)
|
||||
{
|
||||
vector<xmlNodePtr>::iterator it;
|
||||
int rc = 0;
|
||||
|
||||
int zone_id, id;
|
||||
@ -494,9 +482,9 @@ int ResourceSet::from_xml_node(vector<xmlNodePtr>& content)
|
||||
string zone_path = "/" + xml_name + "/ZONE_ID";
|
||||
string resource_path = "/" + xml_name + "/" + xml_name + "_ID";
|
||||
|
||||
for (it = content.begin(); it != content.end(); it++)
|
||||
for (auto node : content)
|
||||
{
|
||||
ObjectXML tmp_xml(*it);
|
||||
ObjectXML tmp_xml(node);
|
||||
|
||||
rc += tmp_xml.xpath(zone_id, zone_path.c_str(), -1);
|
||||
rc += tmp_xml.xpath(id, resource_path.c_str(), -1);
|
||||
@ -513,11 +501,7 @@ int ResourceSet::from_xml_node(vector<xmlNodePtr>& content)
|
||||
int ResourceSet::add(const set<int>& groups, int zone_id, int id,
|
||||
string& error_msg)
|
||||
{
|
||||
set<int>::const_iterator it;
|
||||
|
||||
pair<set<pair<int, int> >::iterator,bool> ret;
|
||||
|
||||
ret = resources.insert(pair<int,int>(zone_id, id));
|
||||
auto ret = resources.insert(pair<int,int>(zone_id, id));
|
||||
|
||||
if( !ret.second )
|
||||
{
|
||||
@ -530,9 +514,9 @@ int ResourceSet::add(const set<int>& groups, int zone_id, int id,
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (it = groups.begin(); it != groups.end(); it++)
|
||||
for (auto group : groups)
|
||||
{
|
||||
add_rule(*it, zone_id, id);
|
||||
add_rule(group, zone_id, id);
|
||||
}
|
||||
|
||||
// When using the 'all' resource id, clear the other previous IDs
|
||||
@ -541,11 +525,8 @@ int ResourceSet::add(const set<int>& groups, int zone_id, int id,
|
||||
string error_aux;
|
||||
|
||||
vector<int> del_ids;
|
||||
vector<int>::iterator del_it;
|
||||
|
||||
set<pair<int, int> >::iterator res_it;
|
||||
|
||||
for (res_it = resources.begin(); res_it != resources.end(); res_it++)
|
||||
for (auto res_it = resources.begin(); res_it != resources.end(); res_it++)
|
||||
{
|
||||
if(res_it->first == zone_id && res_it->second != Vdc::ALL_RESOURCES)
|
||||
{
|
||||
@ -553,9 +534,9 @@ int ResourceSet::add(const set<int>& groups, int zone_id, int id,
|
||||
}
|
||||
}
|
||||
|
||||
for (del_it = del_ids.begin(); del_it != del_ids.end(); del_it++)
|
||||
for (auto id : del_ids)
|
||||
{
|
||||
this->del(groups, zone_id, *del_it, error_aux);
|
||||
this->del(groups, zone_id, id, error_aux);
|
||||
}
|
||||
}
|
||||
|
||||
@ -568,8 +549,6 @@ int ResourceSet::add(const set<int>& groups, int zone_id, int id,
|
||||
int ResourceSet::del(const set<int>& groups, int zone_id, int id,
|
||||
string& error_msg)
|
||||
{
|
||||
set<int>::const_iterator it;
|
||||
|
||||
if( resources.erase(pair<int,int>(zone_id, id)) != 1 )
|
||||
{
|
||||
ostringstream oss;
|
||||
@ -581,9 +560,9 @@ int ResourceSet::del(const set<int>& groups, int zone_id, int id,
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (it = groups.begin(); it != groups.end(); it++)
|
||||
for (auto group : groups)
|
||||
{
|
||||
del_rule(*it, zone_id, id);
|
||||
del_rule(group, zone_id, id);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -594,9 +573,7 @@ int ResourceSet::del(const set<int>& groups, int zone_id, int id,
|
||||
|
||||
void ResourceSet::add_group_rules(int group_id)
|
||||
{
|
||||
set<pair<int,int> >::const_iterator it;
|
||||
|
||||
for (it = resources.begin(); it != resources.end(); it++)
|
||||
for (auto it = resources.begin(); it != resources.end(); it++)
|
||||
{
|
||||
add_rule(group_id, it->first, it->second);
|
||||
}
|
||||
@ -607,9 +584,7 @@ void ResourceSet::add_group_rules(int group_id)
|
||||
|
||||
void ResourceSet::del_group_rules(int group_id)
|
||||
{
|
||||
set<pair<int,int> >::const_iterator it;
|
||||
|
||||
for (it = resources.begin(); it != resources.end(); it++)
|
||||
for (auto it = resources.begin(); it != resources.end(); it++)
|
||||
{
|
||||
del_rule(group_id, it->first, it->second);
|
||||
}
|
||||
@ -620,8 +595,6 @@ void ResourceSet::del_group_rules(int group_id)
|
||||
|
||||
void ResourceSet::add_rule(int group_id, int zone_id, int id)
|
||||
{
|
||||
set<pair<long long, long long> >::const_iterator it;
|
||||
|
||||
string error_msg;
|
||||
long long mask_prefix;
|
||||
|
||||
@ -640,7 +613,7 @@ void ResourceSet::add_rule(int group_id, int zone_id, int id)
|
||||
mask_prefix = AclRule::INDIVIDUAL_ID | id;
|
||||
}
|
||||
|
||||
for (it = rules.begin(); it != rules.end(); it++)
|
||||
for (auto it = rules.begin(); it != rules.end(); it++)
|
||||
{
|
||||
long long resource = it->first;
|
||||
long long rights = it->second;
|
||||
@ -664,8 +637,6 @@ void ResourceSet::add_rule(int group_id, int zone_id, int id)
|
||||
|
||||
void ResourceSet::del_rule(int group_id, int zone_id, int id)
|
||||
{
|
||||
set<pair<long long, long long> >::const_iterator it;
|
||||
|
||||
string error_msg;
|
||||
long long mask_prefix;
|
||||
|
||||
@ -684,7 +655,7 @@ void ResourceSet::del_rule(int group_id, int zone_id, int id)
|
||||
mask_prefix = AclRule::INDIVIDUAL_ID | id;
|
||||
}
|
||||
|
||||
for (it = rules.begin(); it != rules.end(); it++)
|
||||
for (auto it = rules.begin(); it != rules.end(); it++)
|
||||
{
|
||||
long long resource = it->first;
|
||||
long long rights = it->second;
|
||||
|
@ -369,9 +369,7 @@ int Snapshots::rename_snapshot(int id, const string& name, string& str_error)
|
||||
|
||||
const VectorAttribute * Snapshots::get_snapshot(int id) const
|
||||
{
|
||||
map<int, VectorAttribute *>::const_iterator it;
|
||||
|
||||
it = snapshot_pool.find(id);
|
||||
auto it = snapshot_pool.find(id);
|
||||
|
||||
if (it == snapshot_pool.end())
|
||||
{
|
||||
@ -456,10 +454,9 @@ bool Snapshots::test_delete(int id, string& error) const
|
||||
|
||||
long long Snapshots::get_total_size() const
|
||||
{
|
||||
map<int, VectorAttribute *>::const_iterator it;
|
||||
long long size_mb, total_mb = 0;
|
||||
|
||||
for ( it = snapshot_pool.begin(); it != snapshot_pool.end(); it++)
|
||||
for ( auto it = snapshot_pool.begin(); it != snapshot_pool.end(); it++)
|
||||
{
|
||||
if (it->second->vector_value("SIZE", size_mb) == 0)
|
||||
{
|
||||
|
@ -645,7 +645,7 @@ static int set_boot_order(Template * tmpl, string& error_str)
|
||||
|
||||
int index = 1;
|
||||
|
||||
for (vector<string>::iterator i = bdevs.begin(); i != bdevs.end(); ++i)
|
||||
for (auto& str_dev : bdevs)
|
||||
{
|
||||
vector<VectorAttribute *> * dev;
|
||||
int max;
|
||||
@ -654,16 +654,16 @@ static int set_boot_order(Template * tmpl, string& error_str)
|
||||
|
||||
const char * id_name;
|
||||
|
||||
one_util::toupper(*i);
|
||||
one_util::toupper(str_dev);
|
||||
|
||||
int rc = one_util::regex_match("^(DISK|NIC)[[:digit:]]+$", (*i).c_str());
|
||||
int rc = one_util::regex_match("^(DISK|NIC)[[:digit:]]+$", str_dev.c_str());
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
goto error_parsing;
|
||||
}
|
||||
|
||||
if ((*i).compare(0,4,"DISK") == 0)
|
||||
if (str_dev.compare(0,4,"DISK") == 0)
|
||||
{
|
||||
pos = 4;
|
||||
|
||||
@ -672,7 +672,7 @@ static int set_boot_order(Template * tmpl, string& error_str)
|
||||
|
||||
id_name = "DISK_ID";
|
||||
}
|
||||
else if ((*i).compare(0,3,"NIC") == 0)
|
||||
else if (str_dev.compare(0,3,"NIC") == 0)
|
||||
{
|
||||
pos = 3;
|
||||
|
||||
@ -686,7 +686,7 @@ static int set_boot_order(Template * tmpl, string& error_str)
|
||||
goto error_parsing;
|
||||
}
|
||||
|
||||
istringstream iss((*i).substr(pos, string::npos));
|
||||
istringstream iss(str_dev.substr(pos, string::npos));
|
||||
|
||||
iss >> disk_id;
|
||||
|
||||
@ -1545,7 +1545,7 @@ int VirtualMachine::automatic_requirements(set<int>& cluster_ids,
|
||||
|
||||
if ( !cluster_ids.empty() )
|
||||
{
|
||||
set<int>::iterator i = cluster_ids.begin();
|
||||
auto i = cluster_ids.begin();
|
||||
|
||||
oss << "(CLUSTER_ID = " << *i;
|
||||
|
||||
@ -1574,7 +1574,7 @@ int VirtualMachine::automatic_requirements(set<int>& cluster_ids,
|
||||
|
||||
if (num_public != 0)
|
||||
{
|
||||
set<string>::iterator it = clouds.begin();
|
||||
auto it = clouds.begin();
|
||||
|
||||
oss << " | (PUBLIC_CLOUD = YES & (";
|
||||
|
||||
@ -1598,7 +1598,7 @@ int VirtualMachine::automatic_requirements(set<int>& cluster_ids,
|
||||
{
|
||||
if ( !cluster_ids.empty() )
|
||||
{
|
||||
set<int>::iterator i = cluster_ids.begin();
|
||||
auto i = cluster_ids.begin();
|
||||
|
||||
oss << "(\"CLUSTERS/ID\" @> " << *i;
|
||||
|
||||
@ -1619,7 +1619,7 @@ int VirtualMachine::automatic_requirements(set<int>& cluster_ids,
|
||||
|
||||
if ( !datastore_ids.empty() )
|
||||
{
|
||||
set<int>::iterator i = datastore_ids.begin();
|
||||
auto i = datastore_ids.begin();
|
||||
|
||||
oss << "(\"ID\" @> " << *i;
|
||||
|
||||
@ -2081,20 +2081,18 @@ void VirtualMachine::set_auth_request(int uid,
|
||||
VirtualMachineTemplate *tmpl,
|
||||
bool check_lock)
|
||||
{
|
||||
VirtualMachineDisks::disk_iterator disk;
|
||||
VirtualMachineDisks tdisks(tmpl, false);
|
||||
|
||||
for (disk = tdisks.begin(); disk != tdisks.end(); ++disk)
|
||||
for (auto disk : tdisks)
|
||||
{
|
||||
(*disk)->authorize(uid, &ar, check_lock);
|
||||
disk->authorize(uid, &ar, check_lock);
|
||||
}
|
||||
|
||||
VirtualMachineNics::nic_iterator nic;
|
||||
VirtualMachineNics tnics(tmpl);
|
||||
|
||||
for (nic = tnics.begin(); nic != tnics.end(); ++nic)
|
||||
for (auto nic : tnics)
|
||||
{
|
||||
(*nic)->authorize(uid, &ar, check_lock);
|
||||
nic->authorize(uid, &ar, check_lock);
|
||||
}
|
||||
|
||||
const VectorAttribute * vmgroup = tmpl->get("VMGROUP");
|
||||
@ -2168,7 +2166,7 @@ string& VirtualMachine::to_xml_extended(string& xml, int n_history) const
|
||||
|
||||
VirtualMachineDisks::disk_iterator disk;
|
||||
|
||||
for (disk = const_cast<VirtualMachineDisks *>(&disks)->begin() ;
|
||||
for (auto disk = const_cast<VirtualMachineDisks *>(&disks)->begin() ;
|
||||
disk != const_cast<VirtualMachineDisks *>(&disks)->end() ; ++disk)
|
||||
{
|
||||
const Snapshots * snapshots = (*disk)->get_snapshots();
|
||||
@ -2397,7 +2395,6 @@ int VirtualMachine::from_xml(const string &xml_str)
|
||||
rc += obj_template->from_xml_node(content[0]);
|
||||
|
||||
vector<VectorAttribute *> vdisks, vnics, alias, pcis;
|
||||
vector<VectorAttribute *>::iterator it;
|
||||
|
||||
obj_template->get("DISK", vdisks);
|
||||
|
||||
@ -2409,17 +2406,17 @@ int VirtualMachine::from_xml(const string &xml_str)
|
||||
|
||||
obj_template->get("PCI", pcis);
|
||||
|
||||
for (it =pcis.begin(); it != pcis.end(); ++it)
|
||||
for (auto vattr : pcis)
|
||||
{
|
||||
if ( (*it)->vector_value("TYPE") == "NIC" )
|
||||
if ( vattr->vector_value("TYPE") == "NIC" )
|
||||
{
|
||||
vnics.push_back(*it);
|
||||
vnics.push_back(vattr);
|
||||
}
|
||||
}
|
||||
|
||||
for (it =alias.begin(); it != alias.end(); ++it)
|
||||
for (auto vattr : alias)
|
||||
{
|
||||
vnics.push_back(*it);
|
||||
vnics.push_back(vattr);
|
||||
}
|
||||
|
||||
nics.init(vnics, true);
|
||||
@ -2467,11 +2464,11 @@ int VirtualMachine::from_xml(const string &xml_str)
|
||||
// -------------------------------------------------------------------------
|
||||
ObjectXML::get_nodes("/VM/SNAPSHOTS", content);
|
||||
|
||||
for (vector<xmlNodePtr>::iterator it=content.begin();it!=content.end();it++)
|
||||
for (auto node : content)
|
||||
{
|
||||
Snapshots * snap = new Snapshots(-1, Snapshots::DENY);
|
||||
|
||||
rc += snap->from_xml_node(*it);
|
||||
rc += snap->from_xml_node(node);
|
||||
|
||||
if ( rc != 0)
|
||||
{
|
||||
@ -2692,7 +2689,6 @@ void VirtualMachine::clear_template_error_message()
|
||||
void VirtualMachine::get_public_clouds(const string& pname, set<string> &clouds) const
|
||||
{
|
||||
vector<VectorAttribute *> attrs;
|
||||
vector<VectorAttribute *>::const_iterator it;
|
||||
|
||||
user_obj_template->get(pname, attrs);
|
||||
|
||||
@ -2701,9 +2697,9 @@ void VirtualMachine::get_public_clouds(const string& pname, set<string> &clouds)
|
||||
clouds.insert("ec2");
|
||||
}
|
||||
|
||||
for (it = attrs.begin(); it != attrs.end(); it++)
|
||||
for (auto vattr : attrs)
|
||||
{
|
||||
string type = (*it)->vector_value("TYPE");
|
||||
string type = vattr->vector_value("TYPE");
|
||||
|
||||
if (!type.empty())
|
||||
{
|
||||
@ -2747,17 +2743,16 @@ static void replace_vector_values(Template *old_tmpl, Template *new_tmpl,
|
||||
else
|
||||
{
|
||||
std::vector<std::string> vnames = UPDATECONF_ATTRS[name];
|
||||
std::vector<std::string>::iterator it;
|
||||
|
||||
for (it = vnames.begin(); it != vnames.end(); ++it)
|
||||
for (const auto& vname : vnames)
|
||||
{
|
||||
if ( new_attr->vector_value(*it, value) == -1 )
|
||||
if ( new_attr->vector_value(vname, value) == -1 )
|
||||
{
|
||||
old_attr->remove(*it);
|
||||
old_attr->remove(vname);
|
||||
}
|
||||
else
|
||||
{
|
||||
old_attr->replace(*it, value);
|
||||
old_attr->replace(vname, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2781,15 +2776,14 @@ static void copy_vector_values(Template *old_tmpl, Template *new_tmpl,
|
||||
VectorAttribute * new_vattr = new VectorAttribute(name);
|
||||
|
||||
std::vector<std::string> vnames = UPDATECONF_ATTRS[name];
|
||||
std::vector<std::string>::iterator it;
|
||||
|
||||
for (it = vnames.begin(); it != vnames.end(); ++it)
|
||||
for (const auto& vname : vnames)
|
||||
{
|
||||
std::string vval = old_attr->vector_value(*it);
|
||||
std::string vval = old_attr->vector_value(vname);
|
||||
|
||||
if (!vval.empty())
|
||||
{
|
||||
new_vattr->replace(*it, vval);
|
||||
new_vattr->replace(vname, vval);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2985,12 +2979,10 @@ int VirtualMachine::get_disk_images(string& error_str)
|
||||
vector<Attribute *> adisks;
|
||||
vector<Attribute *> acontext_disks;
|
||||
|
||||
vector<Attribute*>::iterator it;
|
||||
|
||||
int num_context = user_obj_template->remove("CONTEXT", acontext_disks);
|
||||
int num_disks = user_obj_template->remove("DISK", adisks);
|
||||
|
||||
for (it = acontext_disks.begin(); it != acontext_disks.end(); )
|
||||
for (auto it = acontext_disks.begin(); it != acontext_disks.end(); )
|
||||
{
|
||||
if ( (*it)->type() != Attribute::VECTOR )
|
||||
{
|
||||
@ -3005,7 +2997,7 @@ int VirtualMachine::get_disk_images(string& error_str)
|
||||
}
|
||||
}
|
||||
|
||||
for (it = adisks.begin(); it != adisks.end(); )
|
||||
for (auto it = adisks.begin(); it != adisks.end(); )
|
||||
{
|
||||
if ( (*it)->type() != Attribute::VECTOR )
|
||||
{
|
||||
@ -3188,7 +3180,6 @@ int VirtualMachine::get_auto_network_leases(VirtualMachineTemplate * tmpl,
|
||||
string& estr)
|
||||
{
|
||||
vector<VectorAttribute *> vnics;
|
||||
vector<VectorAttribute*>::iterator it;
|
||||
|
||||
int nic_id;
|
||||
|
||||
@ -3197,11 +3188,11 @@ int VirtualMachine::get_auto_network_leases(VirtualMachineTemplate * tmpl,
|
||||
/* ---------------------------------------------------------------------- */
|
||||
tmpl->get("NIC", vnics);
|
||||
|
||||
for (it = vnics.begin(); it != vnics.end(); ++it)
|
||||
for (auto vattr : vnics)
|
||||
{
|
||||
std::string net_mode;
|
||||
|
||||
(*it)->vector_value("NIC_ID", nic_id);
|
||||
vattr->vector_value("NIC_ID", nic_id);
|
||||
|
||||
VirtualMachineNic * nic = get_nic(nic_id);
|
||||
|
||||
@ -3220,7 +3211,7 @@ int VirtualMachine::get_auto_network_leases(VirtualMachineTemplate * tmpl,
|
||||
return -1;
|
||||
}
|
||||
|
||||
nic->replace("NETWORK_ID", (*it)->vector_value("NETWORK_ID"));
|
||||
nic->replace("NETWORK_ID", vattr->vector_value("NETWORK_ID"));
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -3270,7 +3261,7 @@ int VirtualMachine::get_network_leases(string& estr)
|
||||
|
||||
user_obj_template->remove("NIC", anics);
|
||||
|
||||
for (vector<Attribute*>::iterator it = anics.begin(); it != anics.end(); )
|
||||
for (auto it = anics.begin(); it != anics.end(); )
|
||||
{
|
||||
if ( (*it)->type() != Attribute::VECTOR )
|
||||
{
|
||||
@ -3286,7 +3277,7 @@ int VirtualMachine::get_network_leases(string& estr)
|
||||
|
||||
user_obj_template->remove("NIC_ALIAS", alias);
|
||||
|
||||
for (vector<Attribute*>::iterator it = alias.begin(); it != alias.end(); )
|
||||
for (auto it = alias.begin(); it != alias.end(); )
|
||||
{
|
||||
if ( (*it)->type() != Attribute::VECTOR )
|
||||
{
|
||||
@ -3302,15 +3293,14 @@ int VirtualMachine::get_network_leases(string& estr)
|
||||
}
|
||||
|
||||
vector<VectorAttribute *> pcis;
|
||||
vector<VectorAttribute *>::iterator it;
|
||||
|
||||
get_template_attribute("PCI", pcis);
|
||||
|
||||
for (it =pcis.begin(); it != pcis.end(); ++it)
|
||||
for (auto vattr : pcis)
|
||||
{
|
||||
if ( (*it)->vector_value("TYPE") == "NIC" )
|
||||
if ( vattr->vector_value("TYPE") == "NIC" )
|
||||
{
|
||||
anics.push_back(*it);
|
||||
anics.push_back(vattr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3381,9 +3371,9 @@ int VirtualMachine::set_up_attach_nic(VirtualMachineTemplate * tmpl, string& err
|
||||
|
||||
obj_template->set(new_nic);
|
||||
|
||||
for (vector<VectorAttribute*>::iterator it=sgs.begin(); it!=sgs.end(); ++it)
|
||||
for (auto vattr : sgs)
|
||||
{
|
||||
obj_template->set(*it);
|
||||
obj_template->set(vattr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -3426,9 +3416,9 @@ int VirtualMachine::set_detach_nic(int nic_id)
|
||||
|
||||
one_util::split_unique(nic->vector_value("ALIAS_IDS"), ',', a_ids);
|
||||
|
||||
for (std::set<int>::iterator it = a_ids.begin(); it != a_ids.end(); ++it)
|
||||
for (const auto& id : a_ids)
|
||||
{
|
||||
if ( *it == nic_id )
|
||||
if ( id == nic_id )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -3438,7 +3428,7 @@ int VirtualMachine::set_detach_nic(int nic_id)
|
||||
oss << ",";
|
||||
}
|
||||
|
||||
oss << *it;
|
||||
oss << id;
|
||||
}
|
||||
|
||||
nic->replace("ALIAS_IDS", oss.str());
|
||||
@ -3456,11 +3446,11 @@ void VirtualMachine::delete_attach_alias(VirtualMachineNic *nic)
|
||||
|
||||
one_util::split_unique(nic->vector_value("ALIAS_IDS"), ',', a_ids);
|
||||
|
||||
for (const auto& id : a_ids)
|
||||
for (auto id : a_ids)
|
||||
{
|
||||
VirtualMachineNic * nic_a = nics.delete_nic(id);
|
||||
|
||||
if (nic_a != 0)
|
||||
if (nic_a)
|
||||
{
|
||||
obj_template->remove(nic_a->vector_attribute());
|
||||
}
|
||||
@ -3476,14 +3466,13 @@ void VirtualMachine::delete_attach_alias(VirtualMachineNic *nic)
|
||||
int VirtualMachine::get_vmgroup(string& error)
|
||||
{
|
||||
vector<Attribute *> vmgroups;
|
||||
vector<Attribute*>::iterator it;
|
||||
|
||||
bool found;
|
||||
bool found = false;
|
||||
VectorAttribute * thegroup = 0;
|
||||
|
||||
user_obj_template->remove("VMGROUP", vmgroups);
|
||||
|
||||
for (it = vmgroups.begin(), found = false; it != vmgroups.end(); )
|
||||
for (auto it = vmgroups.begin(); it != vmgroups.end(); )
|
||||
{
|
||||
if ( (*it)->type() != Attribute::VECTOR || found )
|
||||
{
|
||||
|
@ -62,12 +62,10 @@ int VirtualMachineAttributeSet::set_flag(int a_id, const string& flag_name)
|
||||
VirtualMachineAttribute * VirtualMachineAttributeSet::remove_attribute(
|
||||
const string& flag)
|
||||
{
|
||||
std::map<int, ExtendedAttribute*>::const_iterator it;
|
||||
|
||||
VirtualMachineAttribute * vma;
|
||||
VirtualMachineAttribute * tmp = 0;
|
||||
|
||||
for( it = a_set.begin(); it != a_set.end(); ++it)
|
||||
for (auto it = a_set.begin(); it != a_set.end(); ++it)
|
||||
{
|
||||
vma = static_cast<VirtualMachineAttribute *>(it->second);
|
||||
|
||||
@ -88,11 +86,9 @@ VirtualMachineAttribute * VirtualMachineAttributeSet::remove_attribute(
|
||||
VirtualMachineAttribute * VirtualMachineAttributeSet::clear_flag(
|
||||
const string& flag)
|
||||
{
|
||||
std::map<int, ExtendedAttribute *>::iterator it;
|
||||
|
||||
VirtualMachineAttribute * vma;
|
||||
|
||||
for( it = a_set.begin(); it != a_set.end(); ++it)
|
||||
for (auto it = a_set.begin(); it != a_set.end(); ++it)
|
||||
{
|
||||
vma = static_cast<VirtualMachineAttribute *>(it->second);
|
||||
|
||||
|
@ -82,8 +82,6 @@ int VirtualMachine::generate_context(string &files, int &disk_id,
|
||||
|
||||
vector<const VectorAttribute*> attrs;
|
||||
|
||||
map<string, string>::const_iterator it;
|
||||
|
||||
files = "";
|
||||
bool token;
|
||||
|
||||
@ -196,11 +194,11 @@ int VirtualMachine::generate_context(string &files, int &disk_id,
|
||||
files += (" " + history->token_file);
|
||||
}
|
||||
|
||||
const map<string, string> values = context->value();
|
||||
const map<string, string>& values = context->value();
|
||||
|
||||
file << "# Context variables generated by OpenNebula\n";
|
||||
|
||||
for (it=values.begin(); it != values.end(); it++ )
|
||||
for (auto it=values.begin(); it != values.end(); it++ )
|
||||
{
|
||||
//Replace every ' in value by '\''
|
||||
string escape_str(it->second);
|
||||
@ -251,35 +249,33 @@ static void parse_context_network(const std::vector<ContextVariable>& cvars,
|
||||
string alias_id = nic->vector_value("ALIAS_ID");
|
||||
string parent_id = nic->vector_value("PARENT_ID");
|
||||
|
||||
std::vector<ContextVariable>::const_iterator it;
|
||||
|
||||
for (it = cvars.begin(); it != cvars.end() ; ++it)
|
||||
for (const auto& con : cvars)
|
||||
{
|
||||
ostringstream cvar;
|
||||
string cval;
|
||||
|
||||
if (nic->name() == "NIC")
|
||||
{
|
||||
cvar << "ETH" << nic_id << "_" << (*it).context_name;
|
||||
cvar << "ETH" << nic_id << "_" << con.context_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
cvar << "ETH" << parent_id << "_ALIAS" << alias_id << "_"
|
||||
<< (*it).context_name;
|
||||
<< con.context_name;
|
||||
}
|
||||
|
||||
cval = nic->vector_value((*it).nic_name); //Check the NIC
|
||||
cval = nic->vector_value(con.nic_name); //Check the NIC
|
||||
|
||||
if ( cval.empty() && !((*it).nic_name_alt).empty() )
|
||||
if ( cval.empty() && !(con.nic_name_alt).empty() )
|
||||
{
|
||||
cval = nic->vector_value((*it).nic_name_alt);
|
||||
cval = nic->vector_value(con.nic_name_alt);
|
||||
}
|
||||
|
||||
if ( cval.empty() && (*it).ar_lookup ) //Will check the AR and VNET
|
||||
if ( cval.empty() && con.ar_lookup ) //Will check the AR and VNET
|
||||
{
|
||||
ostringstream cval_ss;
|
||||
|
||||
cval_ss << "$NETWORK["<< (*it).nic_name << ", NIC_ID=\""
|
||||
cval_ss << "$NETWORK["<< con.nic_name << ", NIC_ID=\""
|
||||
<< nic_id <<"\"]";
|
||||
|
||||
cval = cval_ss.str();
|
||||
@ -425,19 +421,17 @@ static void parse_pci_context_network(const std::vector<ContextVariable>& cvars,
|
||||
{
|
||||
string pci_id = nic->vector_value("PCI_ID");
|
||||
|
||||
std::vector<ContextVariable>::const_iterator it;
|
||||
|
||||
for (it = cvars.begin(); it != cvars.end() ; ++it)
|
||||
for (const auto& con : cvars)
|
||||
{
|
||||
ostringstream cvar;
|
||||
|
||||
cvar << "PCI" << pci_id << "_" << (*it).context_name;
|
||||
cvar << "PCI" << pci_id << "_" << con.context_name;
|
||||
|
||||
string cval = nic->vector_value((*it).nic_name);
|
||||
string cval = nic->vector_value(con.nic_name);
|
||||
|
||||
if ( cval.empty() )
|
||||
{
|
||||
cval = nic->vector_value((*it).nic_name_alt);
|
||||
cval = nic->vector_value(con.nic_name_alt);
|
||||
}
|
||||
|
||||
if (!cval.empty())
|
||||
@ -690,13 +684,12 @@ static void clear_context_network(const std::vector<ContextVariable>& cvars,
|
||||
VectorAttribute * context, int nic_id)
|
||||
{
|
||||
ostringstream att_name;
|
||||
std::vector<ContextVariable>::const_iterator it;
|
||||
|
||||
for (it = cvars.begin(); it != cvars.end() ; ++it)
|
||||
for (const auto& con : cvars)
|
||||
{
|
||||
att_name.str("");
|
||||
|
||||
att_name << "ETH" << nic_id << "_" << (*it).context_name;
|
||||
att_name << "ETH" << nic_id << "_" << con.context_name;
|
||||
|
||||
context->remove(att_name.str());
|
||||
}
|
||||
@ -724,14 +717,13 @@ static void clear_context_alias_network(const std::vector<ContextVariable>& cvar
|
||||
VectorAttribute * context, int nic_id, int alias_id)
|
||||
{
|
||||
ostringstream att_name;
|
||||
std::vector<ContextVariable>::const_iterator it;
|
||||
|
||||
for (it = cvars.begin(); it != cvars.end() ; ++it)
|
||||
for (const auto& con : cvars)
|
||||
{
|
||||
att_name.str("");
|
||||
|
||||
att_name << "ETH" << nic_id << "_ALIAS" << alias_id << "_"
|
||||
<< (*it).context_name;
|
||||
<< con.context_name;
|
||||
|
||||
context->remove(att_name.str());
|
||||
}
|
||||
|
@ -900,10 +900,9 @@ error_duplicated_target:
|
||||
error_common:
|
||||
ImageManager * imagem = nd.get_imagem();
|
||||
|
||||
for ( std::vector<int>::iterator img_it = acquired_images.begin() ;
|
||||
img_it != acquired_images.end(); ++img_it )
|
||||
for ( auto img_id : acquired_images )
|
||||
{
|
||||
imagem->release_image(vm_id, *img_it, false);
|
||||
imagem->release_image(vm_id, img_id, false);
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
@ -264,8 +264,7 @@ int VirtualMachineNics::get_network_leases(int vm_id, int uid,
|
||||
|
||||
set<int> sg_ids;
|
||||
|
||||
vector<Attribute*>::iterator it, it_a;
|
||||
int nic_id;
|
||||
int nic_id = 0;
|
||||
|
||||
vector<Attribute *> alias_nics;
|
||||
|
||||
@ -274,7 +273,7 @@ int VirtualMachineNics::get_network_leases(int vm_id, int uid,
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Get the interface network information */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
for (it=nics.begin(), nic_id=0 ; it != nics.end() ; ++it)
|
||||
for (auto it=nics.begin(); it != nics.end() ; ++it)
|
||||
{
|
||||
VectorAttribute * vnic = static_cast<VectorAttribute *>(*it);
|
||||
std::string net_mode = vnic->vector_value("NETWORK_MODE");
|
||||
@ -339,16 +338,14 @@ int VirtualMachineNics::get_network_leases(int vm_id, int uid,
|
||||
/* - NIC_ID */
|
||||
/* - NIC attributes (IP, MAC,...) */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
for (it=alias_nics.begin(); it != alias_nics.end() ; ++it, ++nic_id)
|
||||
for (auto it=alias_nics.begin(); it != alias_nics.end() ; ++it, ++nic_id)
|
||||
{
|
||||
std::map<std::string, NicAliasID>::iterator nit;
|
||||
|
||||
VirtualMachineNic * nic = new
|
||||
VirtualMachineNic(static_cast<VectorAttribute *>(*it), nic_id);
|
||||
|
||||
std::string pnic = nic->vector_value("PARENT");
|
||||
|
||||
nit = nic_map.find(pnic);
|
||||
auto nit = nic_map.find(pnic);
|
||||
|
||||
if ( nit == nic_map.end() )
|
||||
{
|
||||
@ -388,15 +385,13 @@ int VirtualMachineNics::get_network_leases(int vm_id, int uid,
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Set the ALIAS ids on the parent interfaces */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
for (it=nics.begin(); it != nics.end() ; ++it)
|
||||
for (auto it=nics.begin(); it != nics.end() ; ++it)
|
||||
{
|
||||
std::map<std::string, NicAliasID>::iterator nit;
|
||||
|
||||
VectorAttribute * vnic = static_cast<VectorAttribute *>(*it);
|
||||
|
||||
std::string nic_name = vnic->vector_value("NAME");
|
||||
|
||||
nit = nic_map.find(nic_name);
|
||||
auto nit = nic_map.find(nic_name);
|
||||
|
||||
if ( nit == nic_map.end() || nit->second.alias_id_s.empty())
|
||||
{
|
||||
@ -651,9 +646,9 @@ int VirtualMachineNics::set_up_attach_nic(int vmid, int uid, int cluster_id,
|
||||
|
||||
nic->get_security_groups(nic_sgs);
|
||||
|
||||
for (set<int>::iterator it = vm_sgs.begin(); it != vm_sgs.end(); ++it)
|
||||
for (auto sg : vm_sgs)
|
||||
{
|
||||
nic_sgs.erase(*it);
|
||||
nic_sgs.erase(sg);
|
||||
}
|
||||
|
||||
sgpool->get_security_group_rules(vmid, nic_sgs, sgs);
|
||||
|
@ -178,13 +178,11 @@ int VirtualMachine::parse_os(string& error_str)
|
||||
vector<Attribute *> os_attr;
|
||||
VectorAttribute * os;
|
||||
|
||||
vector<Attribute *>::iterator it;
|
||||
|
||||
num = user_obj_template->remove("OS", os_attr);
|
||||
|
||||
for (it=os_attr.begin(); it != os_attr.end(); it++)
|
||||
for (auto attr : os_attr)
|
||||
{
|
||||
obj_template->set(*it);
|
||||
obj_template->set(attr);
|
||||
}
|
||||
|
||||
if ( num == 0 )
|
||||
@ -349,13 +347,12 @@ static int check_pci_attributes(VectorAttribute * pci, const string& default_bus
|
||||
int VirtualMachine::parse_pci(string& error_str, Template * tmpl)
|
||||
{
|
||||
vector<VectorAttribute *> array_pci;
|
||||
vector<VectorAttribute *>::iterator it;
|
||||
|
||||
int pci_id = 0;
|
||||
|
||||
tmpl->remove("PCI", array_pci);
|
||||
|
||||
for (it = array_pci.begin(); it !=array_pci.end(); ++it, ++pci_id)
|
||||
for (auto it = array_pci.begin(); it !=array_pci.end(); ++it, ++pci_id)
|
||||
{
|
||||
(*it)->replace("PCI_ID", pci_id);
|
||||
|
||||
@ -367,9 +364,9 @@ int VirtualMachine::parse_pci(string& error_str, Template * tmpl)
|
||||
|
||||
nd.get_configuration_attribute("PCI_PASSTHROUGH_BUS", default_bus);
|
||||
|
||||
for (it = array_pci.begin(); it !=array_pci.end(); ++it)
|
||||
for (auto attr : array_pci)
|
||||
{
|
||||
if ( check_pci_attributes(*it, default_bus, error_str) != 0 )
|
||||
if ( check_pci_attributes(attr, default_bus, error_str) != 0 )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@ -706,7 +703,6 @@ int VirtualMachine::parse_public_clouds(const char * pname, string& error)
|
||||
int VirtualMachine::parse_cpu_model(Template * tmpl)
|
||||
{
|
||||
vector<VectorAttribute *> cm_attr;
|
||||
vector<VectorAttribute *>::iterator it;
|
||||
|
||||
int num = tmpl->remove("CPU_MODEL", cm_attr);
|
||||
|
||||
@ -715,7 +711,7 @@ int VirtualMachine::parse_cpu_model(Template * tmpl)
|
||||
return 0;
|
||||
}
|
||||
|
||||
it = cm_attr.begin();
|
||||
auto it = cm_attr.begin();
|
||||
|
||||
obj_template->set(*it);
|
||||
|
||||
|
@ -475,16 +475,11 @@ int VirtualMachinePool::calculate_showback(
|
||||
string &error_str)
|
||||
{
|
||||
vector<xmlNodePtr> nodes;
|
||||
vector<xmlNodePtr>::iterator node_it;
|
||||
|
||||
vector<time_t> showback_slots;
|
||||
vector<time_t>::iterator slot_it;
|
||||
|
||||
|
||||
map<int, map<time_t, SBRecord> > vm_cost;
|
||||
map<int, map<time_t, SBRecord> >::iterator vm_it;
|
||||
|
||||
map<time_t, SBRecord>::iterator vm_month_it;
|
||||
|
||||
int rc;
|
||||
ostringstream oss;
|
||||
@ -613,7 +608,7 @@ int VirtualMachinePool::calculate_showback(
|
||||
showback_slots.push_back(end_time);
|
||||
|
||||
#ifdef SBDDEBUG
|
||||
for ( slot_it = showback_slots.begin(); slot_it != showback_slots.end(); slot_it++ )
|
||||
for ( auto slot_it = showback_slots.begin(); slot_it != showback_slots.end(); slot_it++ )
|
||||
{
|
||||
debug.str("");
|
||||
debug << "Slot: " << put_time(*slot_it);
|
||||
@ -627,9 +622,9 @@ int VirtualMachinePool::calculate_showback(
|
||||
|
||||
rc = xml.get_nodes("/HISTORY_RECORDS/HISTORY", nodes);
|
||||
|
||||
for ( node_it = nodes.begin(); node_it != nodes.end(); node_it++ )
|
||||
for ( auto node : nodes )
|
||||
{
|
||||
ObjectXML history(*node_it);
|
||||
ObjectXML history(node);
|
||||
|
||||
history.xpath(vid, "/HISTORY/OID", -1);
|
||||
|
||||
@ -663,7 +658,7 @@ int VirtualMachinePool::calculate_showback(
|
||||
NebulaLog::log("SHOWBACK", Log::DEBUG, debug);
|
||||
#endif
|
||||
|
||||
for ( slot_it = showback_slots.begin(); slot_it != showback_slots.end()-1; slot_it++ )
|
||||
for ( auto slot_it = showback_slots.begin(); slot_it != showback_slots.end()-1; slot_it++ )
|
||||
{
|
||||
time_t t = *slot_it;
|
||||
time_t t_next = *(slot_it+1);
|
||||
@ -742,11 +737,11 @@ int VirtualMachinePool::calculate_showback(
|
||||
|
||||
int n_entries = 0;
|
||||
|
||||
for ( vm_it = vm_cost.begin(); vm_it != vm_cost.end(); vm_it++ )
|
||||
for ( auto vm_it = vm_cost.begin(); vm_it != vm_cost.end(); vm_it++ )
|
||||
{
|
||||
map<time_t, SBRecord>& totals = vm_it->second;
|
||||
|
||||
for ( vm_month_it = totals.begin(); vm_month_it != totals.end(); vm_month_it++ )
|
||||
for ( auto vm_month_it = totals.begin(); vm_month_it != totals.end(); vm_month_it++ )
|
||||
{
|
||||
int vmid = vm_it->first;
|
||||
|
||||
|
@ -78,16 +78,14 @@ int set_active_snapshot(int snap_id, const string& action,
|
||||
{
|
||||
int s_id;
|
||||
|
||||
vector<VectorAttribute *>::iterator it;
|
||||
|
||||
for ( it = snaps.begin() ; it != snaps.end() ; ++it )
|
||||
for ( auto snap : snaps )
|
||||
{
|
||||
(*it)->vector_value("SNAPSHOT_ID", s_id);
|
||||
snap->vector_value("SNAPSHOT_ID", s_id);
|
||||
|
||||
if ( s_id == snap_id )
|
||||
{
|
||||
(*it)->replace("ACTIVE", "YES");
|
||||
(*it)->replace("ACTION", action);
|
||||
snap->replace("ACTIVE", "YES");
|
||||
snap->replace("ACTION", action);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -119,15 +117,14 @@ int VirtualMachine::set_delete_snapshot(int snap_id)
|
||||
void VirtualMachine::update_snapshot_id(const string& hypervisor_id)
|
||||
{
|
||||
vector<VectorAttribute *> snaps;
|
||||
vector<VectorAttribute *>::iterator it;
|
||||
|
||||
obj_template->get("SNAPSHOT", snaps);
|
||||
|
||||
for ( it = snaps.begin() ; it != snaps.end() ; ++it )
|
||||
for ( auto snap : snaps )
|
||||
{
|
||||
if ( (*it)->vector_value("ACTIVE") == "YES" )
|
||||
if ( snap->vector_value("ACTIVE") == "YES" )
|
||||
{
|
||||
(*it)->replace("HYPERVISOR_ID", hypervisor_id);
|
||||
snap->replace("HYPERVISOR_ID", hypervisor_id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -136,16 +133,15 @@ void VirtualMachine::update_snapshot_id(const string& hypervisor_id)
|
||||
void VirtualMachine::update_snapshot_id()
|
||||
{
|
||||
vector<VectorAttribute *> snaps;
|
||||
vector<VectorAttribute *>::iterator it;
|
||||
|
||||
obj_template->get("SNAPSHOT", snaps);
|
||||
|
||||
for ( it = snaps.begin() ; it != snaps.end() ; ++it )
|
||||
for ( auto snap : snaps )
|
||||
{
|
||||
if ( (*it)->vector_value("ACTIVE") == "YES" )
|
||||
if ( snap->vector_value("ACTIVE") == "YES" )
|
||||
{
|
||||
string snap_id = (*it)->vector_value("SNAPSHOT_ID");
|
||||
(*it)->replace("HYPERVISOR_ID", snap_id);
|
||||
string snap_id = snap->vector_value("SNAPSHOT_ID");
|
||||
snap->replace("HYPERVISOR_ID", snap_id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -159,15 +155,14 @@ string VirtualMachine::get_snapshot_action() const
|
||||
string action;
|
||||
|
||||
vector<VectorAttribute *> snaps;
|
||||
vector<VectorAttribute *>::iterator it;
|
||||
|
||||
obj_template->get("SNAPSHOT", snaps);
|
||||
|
||||
for ( it = snaps.begin() ; it != snaps.end() ; ++it )
|
||||
for ( auto snap : snaps )
|
||||
{
|
||||
if ( (*it)->vector_value("ACTIVE") == "YES" )
|
||||
if ( snap->vector_value("ACTIVE") == "YES" )
|
||||
{
|
||||
action = (*it)->vector_value("ACTION");
|
||||
action = snap->vector_value("ACTION");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -181,16 +176,15 @@ string VirtualMachine::get_snapshot_action() const
|
||||
void VirtualMachine::clear_active_snapshot()
|
||||
{
|
||||
vector<VectorAttribute *> snaps;
|
||||
vector<VectorAttribute *>::iterator it;
|
||||
|
||||
obj_template->get("SNAPSHOT", snaps);
|
||||
|
||||
for ( it = snaps.begin() ; it != snaps.end() ; ++it )
|
||||
for ( auto snap : snaps )
|
||||
{
|
||||
if ( (*it)->vector_value("ACTIVE") == "YES" )
|
||||
if ( snap->vector_value("ACTIVE") == "YES" )
|
||||
{
|
||||
(*it)->remove("ACTIVE");
|
||||
(*it)->remove("ACTION");
|
||||
snap->remove("ACTIVE");
|
||||
snap->remove("ACTION");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -202,15 +196,14 @@ void VirtualMachine::clear_active_snapshot()
|
||||
void VirtualMachine::delete_active_snapshot()
|
||||
{
|
||||
vector<VectorAttribute *> snaps;
|
||||
vector<VectorAttribute *>::iterator it;
|
||||
|
||||
obj_template->get("SNAPSHOT", snaps);
|
||||
|
||||
for ( it = snaps.begin() ; it != snaps.end() ; ++it )
|
||||
for ( auto snap : snaps )
|
||||
{
|
||||
if ( (*it)->vector_value("ACTIVE") == "YES" )
|
||||
if ( snap->vector_value("ACTIVE") == "YES" )
|
||||
{
|
||||
delete obj_template->remove(*it);
|
||||
delete obj_template->remove(snap);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -157,11 +157,9 @@ string& VirtualMachineTemplate::to_xml_short(string& xml) const
|
||||
|
||||
if ( get("PUBLIC_CLOUD", attrs) > 0 )
|
||||
{
|
||||
vector<const VectorAttribute *>::const_iterator it;
|
||||
|
||||
for (it = attrs.begin(); it != attrs.end(); it++)
|
||||
for (auto vattr : attrs)
|
||||
{
|
||||
(*it)->to_xml(oss);
|
||||
vattr->to_xml(oss);
|
||||
}
|
||||
}
|
||||
|
||||
@ -169,11 +167,9 @@ string& VirtualMachineTemplate::to_xml_short(string& xml) const
|
||||
|
||||
if ( get("SCHED_ACTION", attrs) > 0 )
|
||||
{
|
||||
vector<const VectorAttribute *>::const_iterator it;
|
||||
|
||||
for (it = attrs.begin(); it != attrs.end(); it++)
|
||||
for (auto vattr : attrs)
|
||||
{
|
||||
(*it)->to_xml(oss);
|
||||
vattr->to_xml(oss);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -233,7 +233,6 @@ int VMGroup::bootstrap(SqlDB * db)
|
||||
int VMGroup::check_rule_names(VMGroupPolicy policy, std::string& error)
|
||||
{
|
||||
vector<const SingleAttribute *> affined;
|
||||
vector<const SingleAttribute *>::const_iterator jt;
|
||||
|
||||
std::ostringstream oss;
|
||||
oss << policy;
|
||||
@ -242,16 +241,16 @@ int VMGroup::check_rule_names(VMGroupPolicy policy, std::string& error)
|
||||
|
||||
obj_template->get(aname, affined);
|
||||
|
||||
for ( jt = affined.begin() ; jt != affined.end() ; ++jt )
|
||||
for ( auto sattr : affined )
|
||||
{
|
||||
std::set<int> id_set;
|
||||
|
||||
if ( roles.names_to_ids((*jt)->value(), id_set) != 0 )
|
||||
if ( roles.names_to_ids(sattr->value(), id_set) != 0 )
|
||||
{
|
||||
std::ostringstream oss;
|
||||
|
||||
oss << "Some roles used in " << aname << " attribute ("
|
||||
<< (*jt)->value() << ") are not defined";
|
||||
<< sattr->value() << ") are not defined";
|
||||
|
||||
error = oss.str();
|
||||
|
||||
@ -269,7 +268,6 @@ int VMGroup::get_rules(VMGroupPolicy policy, VMGroupRule::rule_set& rules,
|
||||
std::string& error_str)
|
||||
{
|
||||
vector<const SingleAttribute *> affined;
|
||||
vector<const SingleAttribute *>::const_iterator jt;
|
||||
|
||||
std::ostringstream oss;
|
||||
oss << policy;
|
||||
@ -278,23 +276,21 @@ int VMGroup::get_rules(VMGroupPolicy policy, VMGroupRule::rule_set& rules,
|
||||
|
||||
obj_template->get(aname, affined);
|
||||
|
||||
for ( jt = affined.begin() ; jt != affined.end() ; ++jt )
|
||||
for ( auto sattr : affined )
|
||||
{
|
||||
std::set<int> id_set;
|
||||
|
||||
std::pair<std::set<VMGroupRule>::iterator, bool> rc;
|
||||
|
||||
roles.names_to_ids((*jt)->value(), id_set);
|
||||
roles.names_to_ids(sattr->value(), id_set);
|
||||
|
||||
VMGroupRule rule(policy, id_set);
|
||||
|
||||
rc = rules.insert(rule);
|
||||
auto rc = rules.insert(rule);
|
||||
|
||||
if ( rc.second == false )
|
||||
{
|
||||
std::ostringstream oss;
|
||||
|
||||
oss << "Duplicated " << aname << " rule (" << (*jt)->value()
|
||||
oss << "Duplicated " << aname << " rule (" << sattr->value()
|
||||
<< ") detected.";
|
||||
|
||||
error_str = oss.str();
|
||||
@ -313,8 +309,6 @@ int VMGroup::check_rule_consistency(std::string& error)
|
||||
{
|
||||
VMGroupRule::rule_set affined, anti;
|
||||
|
||||
VMGroupRule::rule_set::iterator it;
|
||||
|
||||
VMGroupRule error_rule;
|
||||
|
||||
if ( get_rules(VMGroupPolicy::AFFINED, affined, error) == -1 )
|
||||
@ -322,9 +316,9 @@ int VMGroup::check_rule_consistency(std::string& error)
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (it=affined.begin() ; it != affined.end(); ++it)
|
||||
for (auto rule : affined)
|
||||
{
|
||||
const VMGroupRule::role_bitset rs = (*it).get_roles();
|
||||
const VMGroupRule::role_bitset rs = rule.get_roles();
|
||||
|
||||
for (int i = 0; i < VMGroupRoles::MAX_ROLES; ++i)
|
||||
{
|
||||
@ -381,7 +375,6 @@ int VMGroup::check_rule_consistency(std::string& error)
|
||||
int VMGroup::insert(SqlDB *db, string& error_str)
|
||||
{
|
||||
vector<Attribute*> va_roles;
|
||||
vector<Attribute*>::iterator it;
|
||||
|
||||
erase_template_attribute("NAME", name);
|
||||
|
||||
@ -395,9 +388,9 @@ int VMGroup::insert(SqlDB *db, string& error_str)
|
||||
|
||||
if ( num_role > VMGroupRoles::MAX_ROLES )
|
||||
{
|
||||
for ( it = va_roles.begin(); it != va_roles.end(); ++it )
|
||||
for ( auto attr : va_roles )
|
||||
{
|
||||
delete *it;
|
||||
delete attr;
|
||||
}
|
||||
|
||||
error_str = "Maximum number of roles in a VM Group reached";
|
||||
@ -405,19 +398,19 @@ int VMGroup::insert(SqlDB *db, string& error_str)
|
||||
|
||||
bool error = false;
|
||||
|
||||
for ( it = va_roles.begin(); it != va_roles.end(); ++it )
|
||||
for ( auto attr : va_roles )
|
||||
{
|
||||
VectorAttribute * vatt = dynamic_cast<VectorAttribute *>(*it);
|
||||
VectorAttribute * vatt = dynamic_cast<VectorAttribute *>(attr);
|
||||
|
||||
if (vatt == 0 || error)
|
||||
{
|
||||
delete *it;
|
||||
delete attr;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( roles.add_role(vatt, error_str) == -1 )
|
||||
{
|
||||
delete *it;
|
||||
delete attr;
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
|
@ -65,9 +65,7 @@ VMGroupPolicy VMGroupRole::policy()
|
||||
|
||||
void VMGroupRole::add_vm(int vm_id)
|
||||
{
|
||||
std::pair<std::set<int>::iterator, bool> rc;
|
||||
|
||||
rc = vms.insert(vm_id);
|
||||
auto rc = vms.insert(vm_id);
|
||||
|
||||
if ( rc.second == false )
|
||||
{
|
||||
@ -127,13 +125,12 @@ static void affinity_requirements(int vm_id, std::string& requirements,
|
||||
}
|
||||
|
||||
std::ostringstream oss;
|
||||
std::set<int>::const_iterator it;
|
||||
|
||||
bool first = true;
|
||||
|
||||
for ( it = vms.begin(); it != vms.end(); ++it )
|
||||
for ( auto id : vms )
|
||||
{
|
||||
if ( vm_id == -1 || vm_id != *it )
|
||||
if ( vm_id == -1 || vm_id != id )
|
||||
{
|
||||
if ( !first )
|
||||
{
|
||||
@ -142,7 +139,7 @@ static void affinity_requirements(int vm_id, std::string& requirements,
|
||||
|
||||
first = false;
|
||||
|
||||
oss << "(CURRENT_VMS " << op << " " << *it << ")";
|
||||
oss << "(CURRENT_VMS " << op << " " << id << ")";
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,20 +162,19 @@ void VMGroupRole::role_requirements(VMGroupPolicy pol, std::string& reqs)
|
||||
void VMGroupRole::host_requirements(std::set<int>& hosts, const std::string& op1,
|
||||
const std::string& op2, std::ostringstream& oss)
|
||||
{
|
||||
std::set<int>::const_iterator jt;
|
||||
bool empty = true;
|
||||
|
||||
for ( jt = hosts.begin() ; jt != hosts.end() ; ++jt )
|
||||
for ( auto hid : hosts )
|
||||
{
|
||||
if ( empty == true )
|
||||
{
|
||||
empty = false;
|
||||
|
||||
oss << "(ID" << op1 << *jt << ")";
|
||||
oss << "(ID" << op1 << hid << ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
oss << " " << op2 << " (ID" << op1 << *jt << ")";
|
||||
oss << " " << op2 << " (ID" << op1 << hid << ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -230,7 +226,6 @@ void VMGroupRole::antiaffined_host_requirements(std::string& reqs)
|
||||
int VMGroupRoles::from_xml_node(const xmlNodePtr node)
|
||||
{
|
||||
std::vector<VectorAttribute *> roles;
|
||||
std::vector<VectorAttribute *>::iterator it;
|
||||
|
||||
if ( roles_template.from_xml_node(node) == -1 )
|
||||
{
|
||||
@ -239,12 +234,12 @@ int VMGroupRoles::from_xml_node(const xmlNodePtr node)
|
||||
|
||||
roles_template.get("ROLE", roles);
|
||||
|
||||
for (it = roles.begin(); it != roles.end(); ++it)
|
||||
for (auto vattr : roles)
|
||||
{
|
||||
std::string rname = (*it)->vector_value("NAME");
|
||||
std::string rname = vattr->vector_value("NAME");
|
||||
|
||||
int rid;
|
||||
int rc = (*it)->vector_value("ID", rid);
|
||||
int rc = vattr->vector_value("ID", rid);
|
||||
|
||||
if ( rname.empty() || rc == -1 )
|
||||
{
|
||||
@ -256,7 +251,7 @@ int VMGroupRoles::from_xml_node(const xmlNodePtr node)
|
||||
next_role = rid + 1;
|
||||
}
|
||||
|
||||
VMGroupRole * role = new VMGroupRole((*it));
|
||||
VMGroupRole * role = new VMGroupRole(vattr);
|
||||
|
||||
if ( by_id.insert(rid, role) == false )
|
||||
{
|
||||
@ -366,7 +361,7 @@ int VMGroupRoles::vm_size()
|
||||
{
|
||||
int total = 0;
|
||||
|
||||
for ( role_iterator it = begin(); it != end() ; ++it )
|
||||
for ( auto it = begin(); it != end() ; ++it )
|
||||
{
|
||||
total += (*it)->get_vms().size();
|
||||
}
|
||||
@ -380,18 +375,17 @@ int VMGroupRoles::vm_size()
|
||||
int VMGroupRoles::names_to_ids(const std::string& rnames, std::set<int>& keyi)
|
||||
{
|
||||
std::set<std::string> a_set, key_set;
|
||||
std::set<std::string>::iterator it;
|
||||
|
||||
one_util::split_unique(rnames, ',', a_set);
|
||||
|
||||
for ( it = a_set.begin(); it != a_set.end() ; ++it )
|
||||
for ( const auto& name : a_set )
|
||||
{
|
||||
key_set.insert(one_util::trim(*it));
|
||||
key_set.insert(one_util::trim(name));
|
||||
}
|
||||
|
||||
for ( it = key_set.begin(); it != key_set.end(); ++it )
|
||||
for ( const auto& name : key_set )
|
||||
{
|
||||
VMGroupRole *r = by_name.get(*it);
|
||||
VMGroupRole *r = by_name.get(name);
|
||||
|
||||
if ( r == 0 )
|
||||
{
|
||||
|
@ -30,16 +30,14 @@ bool VMGroupRule::compatible(rule_set& affined, rule_set& anti,VMGroupRule& err)
|
||||
{
|
||||
VMGroupRule ta, taa;
|
||||
|
||||
rule_set::iterator it;
|
||||
|
||||
for (it=affined.begin() ; it != affined.end(); ++it)
|
||||
for (const auto& rule : affined)
|
||||
{
|
||||
ta |= *it;
|
||||
ta |= rule;
|
||||
}
|
||||
|
||||
for (it=anti.begin() ; it != anti.end(); ++it)
|
||||
for (const auto& rule : anti)
|
||||
{
|
||||
taa |= *it;
|
||||
taa |= rule;
|
||||
}
|
||||
|
||||
err = ta & taa;
|
||||
|
@ -56,16 +56,15 @@ static void do_network_hosts(ofstream& file,
|
||||
return;
|
||||
}
|
||||
|
||||
vector<string>::const_iterator it;
|
||||
vector<string> hosts;
|
||||
|
||||
hosts = one_util::split(cg_host, ' ');
|
||||
|
||||
file << ">" << endl;
|
||||
|
||||
for (it = hosts.begin(); it != hosts.end(); it++)
|
||||
for (const auto& host_str : hosts)
|
||||
{
|
||||
vector<string> parts = one_util::split(*it, ':');
|
||||
vector<string> parts = one_util::split(host_str, ':');
|
||||
|
||||
if (parts.empty())
|
||||
{
|
||||
|
@ -250,10 +250,8 @@ int XenDriver::deployment_description(
|
||||
|
||||
boots = one_util::split(boot, ',');
|
||||
|
||||
for (vector<string>::const_iterator it=boots.begin(); it!=boots.end(); it++)
|
||||
for (auto& boot_option : boots)
|
||||
{
|
||||
string boot_option = *it;
|
||||
|
||||
one_util::tolower(boot_option);
|
||||
|
||||
if ( boot_option == "hd" )
|
||||
|
@ -546,13 +546,12 @@ void AddressRange::addr_to_xml(unsigned int index, unsigned int rsize,
|
||||
void AddressRange::to_xml(ostringstream &oss) const
|
||||
{
|
||||
const map<string,string>& ar_attrs = attr->value();
|
||||
map<string,string>::const_iterator it;
|
||||
|
||||
unsigned int mac_end[2];
|
||||
|
||||
oss << "<AR>";
|
||||
|
||||
for (it=ar_attrs.begin(); it != ar_attrs.end(); it++)
|
||||
for (auto it=ar_attrs.begin(); it != ar_attrs.end(); it++)
|
||||
{
|
||||
if ( it->first == "ALLOCATED" )
|
||||
{
|
||||
@ -634,7 +633,6 @@ void AddressRange::to_xml(ostringstream &oss, const vector<int>& vms,
|
||||
const vector<int>& vns, const vector<int>& vrs) const
|
||||
{
|
||||
const map<string,string>& ar_attrs = attr->value();
|
||||
map<string,string>::const_iterator it;
|
||||
|
||||
int rc;
|
||||
unsigned int mac_end[2];
|
||||
@ -646,7 +644,7 @@ void AddressRange::to_xml(ostringstream &oss, const vector<int>& vms,
|
||||
|
||||
oss << "<AR>";
|
||||
|
||||
for (it=ar_attrs.begin(); it != ar_attrs.end(); it++)
|
||||
for (auto it=ar_attrs.begin(); it != ar_attrs.end(); it++)
|
||||
{
|
||||
if ( it->first == "ALLOCATED" )
|
||||
{
|
||||
@ -725,14 +723,12 @@ void AddressRange::to_xml(ostringstream &oss, const vector<int>& vms,
|
||||
}
|
||||
else
|
||||
{
|
||||
map<unsigned int, long long>::const_iterator it;
|
||||
|
||||
VectorAttribute lease("LEASE");
|
||||
bool is_in;
|
||||
|
||||
oss << "<LEASES>";
|
||||
|
||||
for (it = allocated.begin(); it != allocated.end(); it++)
|
||||
for (auto it = allocated.begin(); it != allocated.end(); it++)
|
||||
{
|
||||
lease.clear();
|
||||
|
||||
@ -1262,9 +1258,7 @@ void AddressRange::set_vnet(VectorAttribute *nic, const vector<string> &inherit)
|
||||
nic->replace("VLAN_ID", vlanid);
|
||||
}
|
||||
|
||||
vector<string>::const_iterator it;
|
||||
|
||||
for (it = inherit.begin(); it != inherit.end(); it++)
|
||||
for (auto it = inherit.begin(); it != inherit.end(); it++)
|
||||
{
|
||||
string inherit_val = attr->vector_value(*it);
|
||||
|
||||
@ -1286,11 +1280,9 @@ void AddressRange::allocated_to_attr()
|
||||
return;
|
||||
}
|
||||
|
||||
map<unsigned int, long long>::const_iterator it;
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
for (it = allocated.begin(); it != allocated.end(); it++)
|
||||
for (auto it = allocated.begin(); it != allocated.end(); it++)
|
||||
{
|
||||
oss << " " << it->first << " " << it->second;
|
||||
}
|
||||
@ -1351,9 +1343,7 @@ int AddressRange::free_allocated_addr(PoolObjectSQL::ObjectType ot, int obid,
|
||||
{
|
||||
long long lobid = obid & 0x00000000FFFFFFFFLL;
|
||||
|
||||
map<unsigned int, long long>::iterator it;
|
||||
|
||||
it = allocated.find(addr_index);
|
||||
auto it = allocated.find(addr_index);
|
||||
|
||||
if (it != allocated.end() && it->second == (ot|lobid))
|
||||
{
|
||||
@ -1618,7 +1608,7 @@ int AddressRange::free_addr_by_ip6(PoolObjectSQL::ObjectType ot, int obid,
|
||||
|
||||
int AddressRange::free_addr_by_owner(PoolObjectSQL::ObjectType ot, int obid)
|
||||
{
|
||||
map<unsigned int, long long>::iterator it = allocated.begin();
|
||||
auto it = allocated.begin();
|
||||
|
||||
long long obj_pack = ot | (obid & 0x00000000FFFFFFFFLL);
|
||||
|
||||
@ -1630,9 +1620,7 @@ int AddressRange::free_addr_by_owner(PoolObjectSQL::ObjectType ot, int obid)
|
||||
{
|
||||
if (it->second == obj_pack && free_addr(it->first, error_msg) == 0)
|
||||
{
|
||||
map<unsigned int, long long>::iterator prev_it = it++;
|
||||
|
||||
allocated.erase(prev_it);
|
||||
it = allocated.erase(it);
|
||||
|
||||
freed++;
|
||||
}
|
||||
@ -1665,7 +1653,7 @@ int AddressRange::free_addr_by_range(PoolObjectSQL::ObjectType ot, int obid,
|
||||
|
||||
if ((mac[0] <= mac_i[0]) && (index < size))
|
||||
{
|
||||
map<unsigned int, long long>::iterator it = allocated.find(index);
|
||||
auto it = allocated.find(index);
|
||||
|
||||
if (it == allocated.end())
|
||||
{
|
||||
@ -1679,9 +1667,7 @@ int AddressRange::free_addr_by_range(PoolObjectSQL::ObjectType ot, int obid,
|
||||
if (it != allocated.end() && it->second == obj_pack &&
|
||||
free_addr(it->first, error_msg) == 0)
|
||||
{
|
||||
map<unsigned int, long long>::iterator prev_it = it++;
|
||||
|
||||
allocated.erase(prev_it);
|
||||
it = allocated.erase(it);
|
||||
|
||||
freed++;
|
||||
}
|
||||
@ -1981,9 +1967,8 @@ bool AddressRange::check(string& rs_attr) const
|
||||
}
|
||||
|
||||
const map<string,string>& ar_attrs = attr->value();
|
||||
map<string,string>::const_iterator it;
|
||||
|
||||
for (it=ar_attrs.begin(); it != ar_attrs.end(); it++)
|
||||
for (auto it=ar_attrs.begin(); it != ar_attrs.end(); it++)
|
||||
{
|
||||
if (restricted_attributes.count(it->first) > 0)
|
||||
{
|
||||
@ -2017,16 +2002,15 @@ void AddressRange::set_restricted_attributes(vector<const SingleAttribute *>& ra
|
||||
|
||||
void AddressRange::remove_restricted(VectorAttribute* va)
|
||||
{
|
||||
set<string>::const_iterator it;
|
||||
size_t pos;
|
||||
|
||||
for (it=restricted_attributes.begin(); it!=restricted_attributes.end(); it++)
|
||||
for (const auto& restricted : restricted_attributes)
|
||||
{
|
||||
pos = it->find("AR/");
|
||||
pos = restricted.find("AR/");
|
||||
|
||||
if (pos != string::npos)
|
||||
{
|
||||
va->remove( it->substr(pos+3) );
|
||||
va->remove(restricted.substr(pos+3));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2036,12 +2020,11 @@ void AddressRange::remove_restricted(VectorAttribute* va)
|
||||
|
||||
void AddressRange::remove_all_except_restricted(VectorAttribute* va)
|
||||
{
|
||||
map<string,string>::iterator it;
|
||||
map<string,string> vals = va->value();
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
for(it = vals.begin(); it != vals.end(); it++)
|
||||
for (auto it = vals.begin(); it != vals.end(); it++)
|
||||
{
|
||||
oss.str("");
|
||||
oss << "AR/" << it->first;
|
||||
|
@ -32,9 +32,7 @@ AddressRangePool::AddressRangePool():ar_template(false,'=',"AR_POOL"),
|
||||
|
||||
AddressRangePool::~AddressRangePool()
|
||||
{
|
||||
map<unsigned int, AddressRange *>::iterator it;
|
||||
|
||||
for (it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
for (auto it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
{
|
||||
delete it->second;
|
||||
}
|
||||
@ -93,10 +91,9 @@ AddressRange * AddressRangePool::allocate_ar(const string& ipam_mad,
|
||||
|
||||
int AddressRangePool::add_ar(AddressRange * ar)
|
||||
{
|
||||
pair<map<unsigned int, AddressRange *>::iterator, bool> rc;
|
||||
string one_key;
|
||||
|
||||
rc = ar_pool.insert(make_pair(ar->ar_id(), ar));
|
||||
auto rc = ar_pool.insert(make_pair(ar->ar_id(), ar));
|
||||
|
||||
if (rc.second == false)
|
||||
{
|
||||
@ -117,20 +114,17 @@ int AddressRangePool::add_ar(AddressRange * ar)
|
||||
int AddressRangePool::update_ar(vector<VectorAttribute *> ars, bool keep_restricted,
|
||||
string& error_msg)
|
||||
{
|
||||
vector<VectorAttribute *>::iterator it;
|
||||
map<unsigned int, AddressRange *>::iterator ar_it;
|
||||
|
||||
unsigned int arid;
|
||||
|
||||
for (it = ars.begin(); it != ars.end(); it++)
|
||||
for (auto attr : ars)
|
||||
{
|
||||
if ((*it)->vector_value("AR_ID", arid) != 0)
|
||||
if (attr->vector_value("AR_ID", arid) != 0)
|
||||
{
|
||||
error_msg = "AR/AR_ID attribute is missing.";
|
||||
return -1;
|
||||
}
|
||||
|
||||
ar_it = ar_pool.find(arid);
|
||||
auto ar_it = ar_pool.find(arid);
|
||||
|
||||
if (ar_it == ar_pool.end())
|
||||
{
|
||||
@ -142,7 +136,7 @@ int AddressRangePool::update_ar(vector<VectorAttribute *> ars, bool keep_restric
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ar_it->second->update_attributes(*it, keep_restricted, error_msg);
|
||||
return ar_it->second->update_attributes(attr, keep_restricted, error_msg);
|
||||
}
|
||||
|
||||
error_msg = "Wrong AR definition. AR vector attribute is missing.";
|
||||
@ -193,9 +187,7 @@ int AddressRangePool::from_xml_node(const xmlNodePtr node)
|
||||
|
||||
int AddressRangePool::rm_ar(unsigned int ar_id, bool force, string& error_msg)
|
||||
{
|
||||
map<unsigned int, AddressRange *>::iterator it;
|
||||
|
||||
it = ar_pool.find(ar_id);
|
||||
auto it = ar_pool.find(ar_id);
|
||||
|
||||
if (it == ar_pool.end())
|
||||
{
|
||||
@ -246,9 +238,7 @@ int AddressRangePool::rm_ar(unsigned int ar_id, bool force, string& error_msg)
|
||||
|
||||
int AddressRangePool::rm_ars(string& error_msg)
|
||||
{
|
||||
map<unsigned int, AddressRange *>::iterator it;
|
||||
|
||||
for ( it = ar_pool.begin(); it != ar_pool.end(); )
|
||||
for ( auto it = ar_pool.begin(); it != ar_pool.end(); )
|
||||
{
|
||||
if(it->second->is_ipam())
|
||||
{
|
||||
@ -290,11 +280,10 @@ string& AddressRangePool::to_xml(string& sstream, bool extended,
|
||||
if (extended)
|
||||
{
|
||||
ostringstream oss;
|
||||
map<unsigned int, AddressRange *>::const_iterator it;
|
||||
|
||||
oss << "<AR_POOL>";
|
||||
|
||||
for (it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
for (auto it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
{
|
||||
it->second->to_xml(oss, vms, vnets, vrs);
|
||||
}
|
||||
@ -315,9 +304,7 @@ string& AddressRangePool::to_xml(string& sstream, bool extended,
|
||||
int AddressRangePool::allocate_addr(PoolObjectSQL::ObjectType ot, int obid,
|
||||
VectorAttribute * nic, const vector<string> &inherit)
|
||||
{
|
||||
map<unsigned int, AddressRange *>::iterator it;
|
||||
|
||||
for (it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
for (auto it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
{
|
||||
if (it->second->allocate_addr(ot, obid, nic, inherit) == 0)
|
||||
{
|
||||
@ -336,9 +323,7 @@ int AddressRangePool::allocate_by_mac(const string &mac,
|
||||
PoolObjectSQL::ObjectType ot, int obid, VectorAttribute * nic,
|
||||
const vector<string> &inherit)
|
||||
{
|
||||
map<unsigned int, AddressRange *>::iterator it;
|
||||
|
||||
for (it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
for (auto it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
{
|
||||
if (it->second->allocate_by_mac(mac, ot, obid, nic, inherit) == 0)
|
||||
{
|
||||
@ -357,9 +342,7 @@ int AddressRangePool::allocate_by_ip(const string &ip,
|
||||
PoolObjectSQL::ObjectType ot, int obid, VectorAttribute * nic,
|
||||
const vector<string> &inherit)
|
||||
{
|
||||
map<unsigned int, AddressRange *>::iterator it;
|
||||
|
||||
for (it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
for (auto it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
{
|
||||
if (it->second->allocate_by_ip(ip, ot, obid, nic, inherit) == 0)
|
||||
{
|
||||
@ -378,9 +361,7 @@ int AddressRangePool::allocate_by_ip6(const string &ip,
|
||||
PoolObjectSQL::ObjectType ot, int obid, VectorAttribute * nic,
|
||||
const vector<string> &inherit)
|
||||
{
|
||||
map<unsigned int, AddressRange *>::iterator it;
|
||||
|
||||
for (it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
for (auto it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
{
|
||||
if (it->second->allocate_by_ip6(ip, ot, obid, nic, inherit) == 0)
|
||||
{
|
||||
@ -398,9 +379,7 @@ int AddressRangePool::allocate_by_ip6(const string &ip,
|
||||
void AddressRangePool::free_addr(unsigned int arid, PoolObjectSQL::ObjectType ot,
|
||||
int obid, const string& mac)
|
||||
{
|
||||
map<unsigned int, AddressRange *>::iterator it;
|
||||
|
||||
it = ar_pool.find(arid);
|
||||
auto it = ar_pool.find(arid);
|
||||
|
||||
if (it!=ar_pool.end())
|
||||
{
|
||||
@ -417,9 +396,7 @@ void AddressRangePool::free_addr(unsigned int arid, PoolObjectSQL::ObjectType ot
|
||||
void AddressRangePool::free_addr_by_ip(unsigned int arid,
|
||||
PoolObjectSQL::ObjectType ot, int obid, const string& ip)
|
||||
{
|
||||
map<unsigned int, AddressRange *>::iterator it;
|
||||
|
||||
it = ar_pool.find(arid);
|
||||
auto it = ar_pool.find(arid);
|
||||
|
||||
if (it!=ar_pool.end())
|
||||
{
|
||||
@ -436,9 +413,7 @@ void AddressRangePool::free_addr_by_ip(unsigned int arid,
|
||||
void AddressRangePool::free_addr_by_ip6(unsigned int arid,
|
||||
PoolObjectSQL::ObjectType ot, int obid, const string& ip)
|
||||
{
|
||||
map<unsigned int, AddressRange *>::iterator it;
|
||||
|
||||
it = ar_pool.find(arid);
|
||||
auto it = ar_pool.find(arid);
|
||||
|
||||
if (it!=ar_pool.end())
|
||||
{
|
||||
@ -455,9 +430,7 @@ void AddressRangePool::free_addr_by_ip6(unsigned int arid,
|
||||
void AddressRangePool::free_addr(PoolObjectSQL::ObjectType ot, int obid,
|
||||
const string& mac_s)
|
||||
{
|
||||
map<unsigned int, AddressRange *>::iterator it;
|
||||
|
||||
for (it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
for (auto it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
{
|
||||
if (it->second->free_addr(ot, obid, mac_s) == 0)
|
||||
{
|
||||
@ -472,9 +445,7 @@ void AddressRangePool::free_addr(PoolObjectSQL::ObjectType ot, int obid,
|
||||
void AddressRangePool::free_addr_by_ip(PoolObjectSQL::ObjectType ot, int obid,
|
||||
const string& ip_s)
|
||||
{
|
||||
map<unsigned int, AddressRange *>::iterator it;
|
||||
|
||||
for (it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
for (auto it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
{
|
||||
if (it->second->free_addr_by_ip(ot, obid, ip_s) == 0)
|
||||
{
|
||||
@ -489,9 +460,7 @@ void AddressRangePool::free_addr_by_ip(PoolObjectSQL::ObjectType ot, int obid,
|
||||
void AddressRangePool::free_addr_by_ip6(PoolObjectSQL::ObjectType ot, int obid,
|
||||
const string& ip_s)
|
||||
{
|
||||
map<unsigned int, AddressRange *>::iterator it;
|
||||
|
||||
for (it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
for (auto it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
{
|
||||
if (it->second->free_addr_by_ip6(ot, obid, ip_s) == 0)
|
||||
{
|
||||
@ -505,10 +474,9 @@ void AddressRangePool::free_addr_by_ip6(PoolObjectSQL::ObjectType ot, int obid,
|
||||
|
||||
int AddressRangePool::free_addr_by_owner(PoolObjectSQL::ObjectType ot, int oid)
|
||||
{
|
||||
map<unsigned int, AddressRange *>::iterator it;
|
||||
unsigned int used_addr_ini = used_addr;
|
||||
|
||||
for (it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
for (auto it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
{
|
||||
used_addr -= it->second->free_addr_by_owner(ot, oid);
|
||||
}
|
||||
@ -522,11 +490,9 @@ int AddressRangePool::free_addr_by_owner(PoolObjectSQL::ObjectType ot, int oid)
|
||||
int AddressRangePool::free_addr_by_range(unsigned int arid,
|
||||
PoolObjectSQL::ObjectType ot, int obid, const string& mac, unsigned int rsize)
|
||||
{
|
||||
map<unsigned int, AddressRange *>::iterator it;
|
||||
|
||||
unsigned int freed = 0;
|
||||
|
||||
it = ar_pool.find(arid);
|
||||
auto it = ar_pool.find(arid);
|
||||
|
||||
if (it!=ar_pool.end())
|
||||
{
|
||||
@ -544,7 +510,7 @@ int AddressRangePool::free_addr_by_range(unsigned int arid,
|
||||
void AddressRangePool::get_attribute(const string& name, string& value,
|
||||
int ar_id) const
|
||||
{
|
||||
map<unsigned int, AddressRange *>::const_iterator it = ar_pool.find(ar_id);
|
||||
auto it = ar_pool.find(ar_id);
|
||||
|
||||
value.clear();
|
||||
|
||||
@ -560,7 +526,7 @@ void AddressRangePool::get_attribute(const string& name, string& value,
|
||||
int AddressRangePool::get_attribute(const string& name, int& value,
|
||||
int ar_id) const
|
||||
{
|
||||
map<unsigned int, AddressRange *>::const_iterator it = ar_pool.find(ar_id);
|
||||
auto it = ar_pool.find(ar_id);
|
||||
|
||||
int rc = -1;
|
||||
|
||||
@ -577,7 +543,7 @@ int AddressRangePool::get_attribute(const string& name, int& value,
|
||||
|
||||
const set<int>& AddressRangePool::get_security_groups(int ar_id) const
|
||||
{
|
||||
map<unsigned int, AddressRange *>::const_iterator it = ar_pool.find(ar_id);
|
||||
auto it = ar_pool.find(ar_id);
|
||||
|
||||
if (it == ar_pool.end())
|
||||
{
|
||||
@ -591,9 +557,7 @@ const set<int>& AddressRangePool::get_security_groups(int ar_id) const
|
||||
|
||||
void AddressRangePool::get_all_security_groups(set<int>& sgs) const
|
||||
{
|
||||
map<unsigned int, AddressRange *>::const_iterator it;
|
||||
|
||||
for (it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
for (auto it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
{
|
||||
it->second->get_security_groups(sgs);
|
||||
}
|
||||
@ -619,11 +583,9 @@ int AddressRangePool::get_ar_parent(int ar_id) const
|
||||
|
||||
unsigned int AddressRangePool::get_size() const
|
||||
{
|
||||
map<unsigned int, AddressRange *>::const_iterator it;
|
||||
|
||||
unsigned int total = 0;
|
||||
|
||||
for (it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
for (auto it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
{
|
||||
total += it->second->get_size();
|
||||
}
|
||||
@ -636,9 +598,7 @@ unsigned int AddressRangePool::get_size() const
|
||||
|
||||
int AddressRangePool::hold_by_ip(unsigned int ar_id, const string& ip_s)
|
||||
{
|
||||
map<unsigned int, AddressRange *>::const_iterator it;
|
||||
|
||||
it = ar_pool.find(ar_id);
|
||||
auto it = ar_pool.find(ar_id);
|
||||
|
||||
if (it == ar_pool.end())
|
||||
{
|
||||
@ -660,10 +620,9 @@ int AddressRangePool::hold_by_ip(unsigned int ar_id, const string& ip_s)
|
||||
|
||||
int AddressRangePool::hold_by_ip(const string& ip_s)
|
||||
{
|
||||
map<unsigned int, AddressRange *>::iterator it;
|
||||
int rc = -1;
|
||||
|
||||
for (it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
for (auto it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
{
|
||||
if (it->second->hold_by_ip(ip_s) == 0) //At least one AR hold the IP
|
||||
{
|
||||
@ -680,9 +639,7 @@ int AddressRangePool::hold_by_ip(const string& ip_s)
|
||||
|
||||
int AddressRangePool::hold_by_ip6(unsigned int ar_id, const string& ip_s)
|
||||
{
|
||||
map<unsigned int, AddressRange *>::const_iterator it;
|
||||
|
||||
it = ar_pool.find(ar_id);
|
||||
auto it = ar_pool.find(ar_id);
|
||||
|
||||
if (it == ar_pool.end())
|
||||
{
|
||||
@ -704,10 +661,9 @@ int AddressRangePool::hold_by_ip6(unsigned int ar_id, const string& ip_s)
|
||||
|
||||
int AddressRangePool::hold_by_ip6(const string& ip_s)
|
||||
{
|
||||
map<unsigned int, AddressRange *>::iterator it;
|
||||
int rc = -1;
|
||||
|
||||
for (it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
for (auto it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
{
|
||||
if (it->second->hold_by_ip6(ip_s) == 0) //At least one AR hold the IP
|
||||
{
|
||||
@ -724,9 +680,7 @@ int AddressRangePool::hold_by_ip6(const string& ip_s)
|
||||
|
||||
int AddressRangePool::hold_by_mac(unsigned int ar_id, const string& mac_s)
|
||||
{
|
||||
map<unsigned int, AddressRange *>::iterator it;
|
||||
|
||||
it = ar_pool.find(ar_id);
|
||||
auto it = ar_pool.find(ar_id);
|
||||
|
||||
if (it == ar_pool.end())
|
||||
{
|
||||
@ -748,10 +702,9 @@ int AddressRangePool::hold_by_mac(unsigned int ar_id, const string& mac_s)
|
||||
|
||||
int AddressRangePool::hold_by_mac(const string& mac_s)
|
||||
{
|
||||
map<unsigned int, AddressRange *>::iterator it;
|
||||
int rc = -1;
|
||||
|
||||
for (it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
for (auto it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
{
|
||||
if (it->second->hold_by_mac(mac_s) == 0) //At least one AR hold the IP
|
||||
{
|
||||
@ -769,9 +722,7 @@ int AddressRangePool::hold_by_mac(const string& mac_s)
|
||||
int AddressRangePool::reserve_addr(int vid, unsigned int rsize,
|
||||
AddressRange *rar)
|
||||
{
|
||||
map<unsigned int, AddressRange *>::iterator it;
|
||||
|
||||
for (it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
for (auto it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
{
|
||||
if ((it->second->get_free_addr() >= rsize) &&
|
||||
(it->second->reserve_addr(vid, rsize, rar) == 0))
|
||||
@ -790,9 +741,7 @@ int AddressRangePool::reserve_addr(int vid, unsigned int rsize,
|
||||
int AddressRangePool::reserve_addr(int vid, unsigned int rsize,
|
||||
unsigned int ar_id, AddressRange *rar)
|
||||
{
|
||||
map<unsigned int, AddressRange *>::iterator it;
|
||||
|
||||
it = ar_pool.find(ar_id);
|
||||
auto it = ar_pool.find(ar_id);
|
||||
|
||||
if (it == ar_pool.end())
|
||||
{
|
||||
@ -815,9 +764,7 @@ int AddressRangePool::reserve_addr(int vid, unsigned int rsize,
|
||||
int AddressRangePool::reserve_addr_by_ip(int vid, unsigned int rsize,
|
||||
unsigned int ar_id, const string& ip, AddressRange *rar)
|
||||
{
|
||||
map<unsigned int, AddressRange *>::iterator it;
|
||||
|
||||
it = ar_pool.find(ar_id);
|
||||
auto it = ar_pool.find(ar_id);
|
||||
|
||||
if (it == ar_pool.end())
|
||||
{
|
||||
@ -839,9 +786,7 @@ int AddressRangePool::reserve_addr_by_ip(int vid, unsigned int rsize,
|
||||
int AddressRangePool::reserve_addr_by_mac(int vid, unsigned int rsize,
|
||||
unsigned int ar_id, const string& mac, AddressRange *rar)
|
||||
{
|
||||
map<unsigned int, AddressRange *>::iterator it;
|
||||
|
||||
it = ar_pool.find(ar_id);
|
||||
auto it = ar_pool.find(ar_id);
|
||||
|
||||
if (it == ar_pool.end())
|
||||
{
|
||||
@ -863,9 +808,7 @@ int AddressRangePool::reserve_addr_by_mac(int vid, unsigned int rsize,
|
||||
int AddressRangePool::reserve_addr_by_ip6(int vid, unsigned int rsize,
|
||||
unsigned int ar_id, const string& ip, AddressRange *rar)
|
||||
{
|
||||
map<unsigned int, AddressRange *>::iterator it;
|
||||
|
||||
it = ar_pool.find(ar_id);
|
||||
auto it = ar_pool.find(ar_id);
|
||||
|
||||
if (it == ar_pool.end())
|
||||
{
|
||||
@ -888,9 +831,7 @@ void AddressRangePool::process_security_rule(
|
||||
VectorAttribute * rule,
|
||||
vector<VectorAttribute*> &new_rules)
|
||||
{
|
||||
map<unsigned int, AddressRange *>::iterator it;
|
||||
|
||||
for (it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
for (auto it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
{
|
||||
VectorAttribute* new_rule = new VectorAttribute(
|
||||
"SECURITY_GROUP_RULE", rule->value());
|
||||
|
@ -578,8 +578,6 @@ string& VirtualNetwork::to_xml_extended(string& xml, bool extended_and_check,
|
||||
{
|
||||
ostringstream os;
|
||||
|
||||
vector<int>::const_iterator it;
|
||||
|
||||
string clusters_xml;
|
||||
string vrouters_xml;
|
||||
string template_xml;
|
||||
@ -665,11 +663,11 @@ string& VirtualNetwork::to_xml_extended(string& xml, bool extended_and_check,
|
||||
{
|
||||
os << "<VROUTERS>";
|
||||
|
||||
for (it = vrs.begin(); it != vrs.end(); it++)
|
||||
for (auto vr_id : vrs)
|
||||
{
|
||||
if (vrouters.contains(*it))
|
||||
if (vrouters.contains(vr_id))
|
||||
{
|
||||
os << "<ID>" << *it << "</ID>";
|
||||
os << "<ID>" << vr_id << "</ID>";
|
||||
}
|
||||
}
|
||||
|
||||
@ -791,8 +789,6 @@ int VirtualNetwork::nic_attribute(
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
vector<string>::const_iterator it;
|
||||
|
||||
set<int> nic_sgs;
|
||||
int ar_id;
|
||||
|
||||
@ -847,13 +843,13 @@ int VirtualNetwork::nic_attribute(
|
||||
nic->replace("BRIDGE_TYPE", bridge_type);
|
||||
}
|
||||
|
||||
for (it = inherit_attrs.begin(); it != inherit_attrs.end(); it++)
|
||||
for (const auto& inherited : inherit_attrs)
|
||||
{
|
||||
PoolObjectSQL::get_template_attribute(*it, inherit_val);
|
||||
PoolObjectSQL::get_template_attribute(inherited, inherit_val);
|
||||
|
||||
if (!inherit_val.empty())
|
||||
{
|
||||
nic->replace(*it, inherit_val);
|
||||
nic->replace(inherited, inherit_val);
|
||||
}
|
||||
}
|
||||
|
||||
@ -927,7 +923,6 @@ int VirtualNetwork::vrouter_nic_attribute(
|
||||
{
|
||||
int rc = 0;
|
||||
bool floating;
|
||||
vector<string>::const_iterator it;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Set default values from the Virtual Network
|
||||
@ -1001,9 +996,9 @@ void VirtualNetwork::process_security_rule(
|
||||
|
||||
int VirtualNetwork::add_var(vector<VectorAttribute *> &var, string& error_msg)
|
||||
{
|
||||
for (vector<VectorAttribute *>::iterator it=var.begin(); it!=var.end(); it++)
|
||||
for (auto vattr : var)
|
||||
{
|
||||
VectorAttribute * ar = (*it)->clone();
|
||||
VectorAttribute * ar = vattr->clone();
|
||||
|
||||
if (ar_pool.from_vattr(ar, error_msg) != 0)
|
||||
{
|
||||
@ -1370,11 +1365,9 @@ bool VirtualNetwork::is_reservation() const
|
||||
|
||||
void VirtualNetwork::get_security_groups(set<int> & sgs)
|
||||
{
|
||||
std::set<int>::const_iterator it;
|
||||
|
||||
for (it = security_groups.begin(); it != security_groups.end(); it++)
|
||||
for (auto sg_id : security_groups)
|
||||
{
|
||||
sgs.insert(*it);
|
||||
sgs.insert(sg_id);
|
||||
}
|
||||
|
||||
ar_pool.get_all_security_groups(sgs);
|
||||
|
@ -58,8 +58,6 @@ VirtualNetworkPool::VirtualNetworkPool(
|
||||
int count = 0;
|
||||
unsigned int tmp;
|
||||
|
||||
vector<const SingleAttribute *>::const_iterator it;
|
||||
|
||||
BitMap<4096> vlan_id_bitmap(vlan_conf, VLAN_BITMAP_ID, vlan_table);
|
||||
|
||||
string mac = prefix;
|
||||
@ -101,9 +99,9 @@ VirtualNetworkPool::VirtualNetworkPool(
|
||||
// Parse encrypted attributes
|
||||
VirtualNetworkTemplate::parse_encrypted(encrypted_attrs);
|
||||
|
||||
for (it = _inherit_attrs.begin(); it != _inherit_attrs.end(); it++)
|
||||
for (auto attr : _inherit_attrs)
|
||||
{
|
||||
inherit_attrs.push_back((*it)->value());
|
||||
inherit_attrs.push_back(attr->value());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,13 +54,12 @@ static void prepare_nic_vm(VectorAttribute * nic)
|
||||
vrouter_prefix(nic, "VLAN_ID");
|
||||
|
||||
std::set<std::string> restricted;
|
||||
std::set<std::string>::iterator it;
|
||||
|
||||
VirtualMachineTemplate::restricted_nic(restricted);
|
||||
|
||||
for (it = restricted.begin(); it != restricted.end(); ++it)
|
||||
for (const auto& restr : restricted)
|
||||
{
|
||||
nic->remove(*it);
|
||||
nic->remove(restr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -169,17 +168,13 @@ int VirtualRouter::shutdown_vms(const set<int>& _vms, const RequestAttributes& r
|
||||
{
|
||||
DispatchManager * dm = Nebula::instance().get_dm();
|
||||
|
||||
set<int>::const_iterator it;
|
||||
|
||||
string error;
|
||||
|
||||
int rc;
|
||||
int result = 0;
|
||||
|
||||
for (it = _vms.begin(); it != _vms.end(); it++)
|
||||
for (auto vm_id : _vms)
|
||||
{
|
||||
int vm_id = *it;
|
||||
|
||||
rc = dm->terminate(vm_id, true, ra, error);
|
||||
|
||||
if (rc != 0)
|
||||
@ -575,8 +570,6 @@ VectorAttribute * VirtualRouter::attach_nic(
|
||||
VirtualNetworkPool * vnpool;
|
||||
vector<VectorAttribute *> nics;
|
||||
|
||||
vector<VectorAttribute *>::const_iterator it;
|
||||
|
||||
int rc;
|
||||
int nic_id;
|
||||
|
||||
@ -590,9 +583,9 @@ VectorAttribute * VirtualRouter::attach_nic(
|
||||
|
||||
obj_template->get("NIC", nics);
|
||||
|
||||
for (it = nics.begin(); it != nics.end(); it++)
|
||||
for (auto nic : nics)
|
||||
{
|
||||
(*it)->vector_value("NIC_ID", nic_id);
|
||||
nic->vector_value("NIC_ID", nic_id);
|
||||
|
||||
if ( nic_id > max_nic_id )
|
||||
{
|
||||
@ -673,17 +666,16 @@ VectorAttribute* VirtualRouter::get_nic(int nic_id) const
|
||||
int tnic_id;
|
||||
|
||||
vector<VectorAttribute *> nics;
|
||||
vector<VectorAttribute *>::iterator nic_it;
|
||||
|
||||
obj_template->get("NIC", nics);
|
||||
|
||||
for (nic_it = nics.begin(); nic_it != nics.end(); nic_it++)
|
||||
for (auto nic : nics)
|
||||
{
|
||||
(*nic_it)->vector_value("NIC_ID", tnic_id);
|
||||
nic->vector_value("NIC_ID", tnic_id);
|
||||
|
||||
if ( tnic_id == nic_id )
|
||||
{
|
||||
return (*nic_it);
|
||||
return nic;
|
||||
}
|
||||
}
|
||||
|
||||
@ -696,12 +688,11 @@ VectorAttribute* VirtualRouter::get_nic(int nic_id) const
|
||||
void VirtualRouter::set_auth_request(int uid, AuthRequest& ar, Template *tmpl,
|
||||
bool check_lock)
|
||||
{
|
||||
VirtualMachineNics::nic_iterator nic;
|
||||
VirtualMachineNics tnics(tmpl);
|
||||
|
||||
for (nic = tnics.begin(); nic != tnics.end(); ++nic)
|
||||
for (auto nic : tnics)
|
||||
{
|
||||
(*nic)->authorize_vrouter(uid, &ar, check_lock);
|
||||
nic->authorize_vrouter(uid, &ar, check_lock);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -308,9 +308,6 @@ int Zone::post_update_template(string& error)
|
||||
|
||||
int Zone::add_server(Template& tmpl, int& sid, string& xmlep, string& error)
|
||||
{
|
||||
vector<VectorAttribute *> vs;
|
||||
vector<VectorAttribute *>::iterator it;
|
||||
|
||||
VectorAttribute * server;
|
||||
|
||||
sid = -1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user