1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

Fix Update Template for empty restricted attributes

This commit is contained in:
Ruben S. Montero 2014-10-06 16:57:40 +02:00
parent ca06767719
commit e5361c550a
7 changed files with 33 additions and 5 deletions

View File

@ -108,6 +108,11 @@ private:
static string saving_attribute;
static string saving_hot_attribute;
bool has_restricted()
{
return restricted_attributes.size() > 0;
};
/**
* Stores the attributes as restricted, these attributes will be used in
* ImageTemplate::check

View File

@ -390,6 +390,11 @@ public:
*/
virtual void remove_all_except_restricted();
/**
* @return true if the template defines one or more restricted attributes
*/
virtual bool has_restricted();
protected:
/**
* The template attributes

View File

@ -91,6 +91,11 @@ private:
static vector<string> restricted_attributes;
bool has_restricted()
{
return restricted_attributes.size() > 0;
};
/**
* Stores the attributes as restricted, these attributes will be used in
* VirtualMachineTemplate::check

View File

@ -64,6 +64,11 @@ private:
static vector<string> restricted_attributes;
bool has_restricted()
{
return restricted_attributes.size() > 0;
};
/**
* Stores the attributes as restricted, these attributes will be used in
* VirtualMachineTemplate::check

View File

@ -184,7 +184,7 @@ int PoolObjectSQL::replace_template(
return -1;
}
if (keep_restricted)
if (keep_restricted && new_tmpl->has_restricted())
{
new_tmpl->remove_restricted();

View File

@ -236,7 +236,7 @@ void Template::set(Attribute * attr)
/* -------------------------------------------------------------------------- */
int Template::replace(const string& name, const string& value)
{
{
pair<multimap<string, Attribute *>::iterator,
multimap<string, Attribute *>::iterator> index;
@ -255,7 +255,7 @@ int Template::replace(const string& name, const string& value)
attributes.erase(index.first, index.second);
}
SingleAttribute * sattr = new SingleAttribute(name,value);
SingleAttribute * sattr = new SingleAttribute(name,value);
attributes.insert(make_pair(sattr->name(), sattr));
@ -872,6 +872,14 @@ void Template::remove_all_except_restricted()
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
bool Template::has_restricted()
{
return false;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void Template::remove_restricted(const vector<string> &restricted_attributes)
{
size_t pos;

View File

@ -210,7 +210,7 @@ int AddressRange::update_attributes(
int pid;
bool is_reservation = (get_attribute("PARENT_NETWORK_AR_ID", pid) == 0);
if (keep_restricted)
if (keep_restricted && restricted_set)
{
remove_restricted(vup);
}
@ -248,7 +248,7 @@ int AddressRange::update_attributes(
/* ----------------- restricted attributes ----------------- */
if (keep_restricted)
if (keep_restricted && restricted_set)
{
remove_all_except_restricted(attr);