mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-28 14:50:08 +03:00
F #1548: Fixes for update templates
This commit is contained in:
parent
f19345a982
commit
de436a9e8d
@ -2052,16 +2052,10 @@ private:
|
||||
*/
|
||||
int parse_public_clouds(const char *name, string& error);
|
||||
|
||||
/**
|
||||
* Child classes can process the new template set with replace_template or
|
||||
* append_template with this method
|
||||
* @param error string describing the error if any
|
||||
* @return 0 on success
|
||||
*/
|
||||
int post_update_template(string& error);
|
||||
|
||||
/**
|
||||
* This method removes sched_action DONE/MESSAGE attributes
|
||||
* @param error_str with error description
|
||||
* @return -1 in case of error 0 otherwise
|
||||
*/
|
||||
int parse_sched_action(string& error_str);
|
||||
|
||||
|
@ -1057,6 +1057,14 @@ int VirtualMachine::insert(SqlDB * db, string& error_str)
|
||||
goto error_rollback;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Parse VM actions
|
||||
// ------------------------------------------------------------------------
|
||||
if ( parse_sched_action(error_str) == -1 )
|
||||
{
|
||||
goto error_rollback;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
parse_well_known_attributes();
|
||||
@ -2285,6 +2293,22 @@ int VirtualMachine::replace_template(
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Parse attributes in USER_TEMPLATE: */
|
||||
/* - SCHED_ACTION */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
SchedActions sactions(new_tmpl);
|
||||
|
||||
if ( sactions.parse(error, false) == -1 )
|
||||
{
|
||||
delete new_tmpl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Replace new_tmpl to the current user_template */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
if (user_obj_template != 0)
|
||||
{
|
||||
if (keep_restricted && new_tmpl->check_restricted(ra, user_obj_template))
|
||||
@ -2303,13 +2327,6 @@ int VirtualMachine::replace_template(
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (post_update_template(error) == -1)
|
||||
{
|
||||
delete user_obj_template;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
delete user_obj_template;
|
||||
|
||||
user_obj_template = new_tmpl;
|
||||
@ -2341,6 +2358,21 @@ int VirtualMachine::append_template(
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Parse attributes in USER_TEMPLATE: */
|
||||
/* - SCHED_ACTION */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
SchedActions sactions(new_tmpl);
|
||||
|
||||
if ( sactions.parse(error, false) == -1 )
|
||||
{
|
||||
delete new_tmpl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Append new_tmpl to the current user_template */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
if (user_obj_template != 0)
|
||||
{
|
||||
if (keep_restricted && new_tmpl->check_restricted(rname, user_obj_template))
|
||||
@ -2364,13 +2396,6 @@ int VirtualMachine::append_template(
|
||||
user_obj_template = new_tmpl;
|
||||
}
|
||||
|
||||
if (post_update_template(error) == -1)
|
||||
{
|
||||
delete user_obj_template;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -3094,6 +3119,9 @@ void VirtualMachine::release_vmgroup()
|
||||
vmgrouppool->del_vm(thegroup, get_oid());
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
int VirtualMachine::parse_sched_action(string& error_str)
|
||||
{
|
||||
SchedActions sactions(user_obj_template);
|
||||
@ -3101,17 +3129,3 @@ int VirtualMachine::parse_sched_action(string& error_str)
|
||||
return sactions.parse(error_str, false);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
int VirtualMachine::post_update_template(string& error)
|
||||
{
|
||||
int rc = parse_sched_action(error);
|
||||
if (rc == -1)
|
||||
{
|
||||
return rc;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user