mirror of
https://github.com/OpenNebula/one.git
synced 2025-08-24 17:49:28 +03:00
Fix Update Template for empty restricted attributes
This commit is contained in:
@ -108,6 +108,11 @@ private:
|
|||||||
static string saving_attribute;
|
static string saving_attribute;
|
||||||
static string saving_hot_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
|
* Stores the attributes as restricted, these attributes will be used in
|
||||||
* ImageTemplate::check
|
* ImageTemplate::check
|
||||||
|
@ -390,6 +390,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void remove_all_except_restricted();
|
virtual void remove_all_except_restricted();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if the template defines one or more restricted attributes
|
||||||
|
*/
|
||||||
|
virtual bool has_restricted();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* The template attributes
|
* The template attributes
|
||||||
|
@ -91,6 +91,11 @@ private:
|
|||||||
|
|
||||||
static vector<string> restricted_attributes;
|
static vector<string> restricted_attributes;
|
||||||
|
|
||||||
|
bool has_restricted()
|
||||||
|
{
|
||||||
|
return restricted_attributes.size() > 0;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the attributes as restricted, these attributes will be used in
|
* Stores the attributes as restricted, these attributes will be used in
|
||||||
* VirtualMachineTemplate::check
|
* VirtualMachineTemplate::check
|
||||||
|
@ -64,6 +64,11 @@ private:
|
|||||||
|
|
||||||
static vector<string> restricted_attributes;
|
static vector<string> restricted_attributes;
|
||||||
|
|
||||||
|
bool has_restricted()
|
||||||
|
{
|
||||||
|
return restricted_attributes.size() > 0;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the attributes as restricted, these attributes will be used in
|
* Stores the attributes as restricted, these attributes will be used in
|
||||||
* VirtualMachineTemplate::check
|
* VirtualMachineTemplate::check
|
||||||
|
@ -184,7 +184,7 @@ int PoolObjectSQL::replace_template(
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keep_restricted)
|
if (keep_restricted && new_tmpl->has_restricted())
|
||||||
{
|
{
|
||||||
new_tmpl->remove_restricted();
|
new_tmpl->remove_restricted();
|
||||||
|
|
||||||
|
@ -236,7 +236,7 @@ void Template::set(Attribute * attr)
|
|||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int Template::replace(const string& name, const string& value)
|
int Template::replace(const string& name, const string& value)
|
||||||
{
|
{
|
||||||
pair<multimap<string, Attribute *>::iterator,
|
pair<multimap<string, Attribute *>::iterator,
|
||||||
multimap<string, Attribute *>::iterator> index;
|
multimap<string, Attribute *>::iterator> index;
|
||||||
|
|
||||||
@ -255,7 +255,7 @@ int Template::replace(const string& name, const string& value)
|
|||||||
attributes.erase(index.first, index.second);
|
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));
|
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)
|
void Template::remove_restricted(const vector<string> &restricted_attributes)
|
||||||
{
|
{
|
||||||
size_t pos;
|
size_t pos;
|
||||||
|
@ -210,7 +210,7 @@ int AddressRange::update_attributes(
|
|||||||
int pid;
|
int pid;
|
||||||
bool is_reservation = (get_attribute("PARENT_NETWORK_AR_ID", pid) == 0);
|
bool is_reservation = (get_attribute("PARENT_NETWORK_AR_ID", pid) == 0);
|
||||||
|
|
||||||
if (keep_restricted)
|
if (keep_restricted && restricted_set)
|
||||||
{
|
{
|
||||||
remove_restricted(vup);
|
remove_restricted(vup);
|
||||||
}
|
}
|
||||||
@ -248,7 +248,7 @@ int AddressRange::update_attributes(
|
|||||||
|
|
||||||
/* ----------------- restricted attributes ----------------- */
|
/* ----------------- restricted attributes ----------------- */
|
||||||
|
|
||||||
if (keep_restricted)
|
if (keep_restricted && restricted_set)
|
||||||
{
|
{
|
||||||
remove_all_except_restricted(attr);
|
remove_all_except_restricted(attr);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user