1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-13 12:58:17 +03:00

Merge branch 'juanmont-feature-5015' into feature-5015

This commit is contained in:
Ruben S. Montero 2017-07-19 11:29:20 +02:00
commit c68b54851e
2 changed files with 41 additions and 2 deletions

View File

@ -141,6 +141,13 @@ private:
*/ */
int insert_replace(SqlDB *db, bool replace, string& error_str); int insert_replace(SqlDB *db, bool replace, string& error_str);
/**
* Execute this method after update the template.
* @param error Returns the error reason, if any
* @return 0 one success
*/
int post_update_template(string& error);
/** /**
* Bootstraps the database table(s) associated to the VMTemplate * Bootstraps the database table(s) associated to the VMTemplate
* @return 0 on success * @return 0 on success
@ -160,6 +167,11 @@ private:
*/ */
int from_xml(const string &xml_str); int from_xml(const string &xml_str);
/**
* This method removes sched_action DONE/MESSAGE attributes
*/
void parse_sched_action();
protected: protected:
// ************************************************************************* // *************************************************************************

View File

@ -74,13 +74,16 @@ int VMTemplate::insert(SqlDB *db, string& error_str)
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// Check default attributes // Check default attributes
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
erase_template_attribute("NAME", name); erase_template_attribute("NAME", name);
// ---------------------------------------------------------------------
// Remove DONE/MESSAGE from SCHED_ACTION
// ---------------------------------------------------------------------
parse_sched_action();
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// Insert the Template // Insert the Template
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
return insert_replace(db, false, error_str); return insert_replace(db, false, error_str);
} }
@ -167,6 +170,30 @@ error_common:
return -1; return -1;
} }
void VMTemplate::parse_sched_action()
{
vector<VectorAttribute *> _sched_actions;
vector<VectorAttribute *>::iterator i;
get_template_attribute("SCHED_ACTION", _sched_actions);
for ( i = _sched_actions.begin(); i != _sched_actions.end() ; ++i)
{
(*i)->remove("DONE");
(*i)->remove("MESSAGE");
}
}
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
int VMTemplate::post_update_template(string& error)
{
parse_sched_action();
return 0;
}
/* ************************************************************************ */ /* ************************************************************************ */
/* VMTemplate :: Misc */ /* VMTemplate :: Misc */
/* ************************************************************************ */ /* ************************************************************************ */