1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-23 17:33:56 +03:00

Feature #3167, #3169: Fix replace_template for Zone

This commit is contained in:
Carlos Martín 2014-09-04 18:11:38 +02:00 committed by Ruben S. Montero
parent 1fd5b1059d
commit 7484ed9008
2 changed files with 20 additions and 3 deletions

View File

@ -47,9 +47,13 @@ public:
/**
* Replace template for this object. Object should be updated
* after calling this method
* @param tmpl string representation of the template
* @param tmpl_str new contents
* @param keep_restricted If true, the restricted attributes of the
* current template will override the new template
* @param error string describing the error if any
* @return 0 on success
*/
int replace_template(const string& tmpl_str, string& error);
int replace_template(const string& tmpl_str, bool keep_restricted, string& error);
private:

View File

@ -251,7 +251,7 @@ int Zone::from_xml(const string& xml)
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
int Zone::replace_template(const string& tmpl_str, string& error_str)
int Zone::replace_template(const string& tmpl_str, bool keep_restricted, string& error_str)
{
Template * new_tmpl = get_new_template();
@ -267,6 +267,19 @@ int Zone::replace_template(const string& tmpl_str, string& error_str)
return -1;
}
if (keep_restricted)
{
new_tmpl->remove_restricted();
if (obj_template != 0)
{
obj_template->remove_all_except_restricted();
string aux_error;
new_tmpl->merge(obj_template, aux_error);
}
}
string new_endpoint;
new_tmpl->get("ENDPOINT", new_endpoint);