1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-11 05:17:41 +03:00

Merge monitor information for the VM (instead of recreating). Update

Template.merge interface
This commit is contained in:
Ruben S. Montero 2016-04-26 15:35:07 +02:00
parent 2560c2da92
commit 03b7b77ce8
7 changed files with 17 additions and 28 deletions

View File

@ -394,11 +394,8 @@ public:
* replacing the existing ones * replacing the existing ones
* *
* @param from_tmpl the template to be merged * @param from_tmpl the template to be merged
* @param error_str string describing the error
*
* @return 0 on success.
*/ */
int merge(const Template * from_tmpl, string& error_str); void merge(const Template * from_tmpl);
/** /**
* Deletes all restricted attributes * Deletes all restricted attributes

View File

@ -41,20 +41,22 @@ public:
*/ */
int update(const string& monitor_data, string& error) int update(const string& monitor_data, string& error)
{ {
VirtualMachineMonitorInfo new_info;
char * error_c = 0; char * error_c = 0;
clear(); if (new_info.parse(monitor_data, &error_c) != 0)
int rc = parse(monitor_data, &error_c);
if (rc != 0)
{ {
error = error_c; error = error_c;
free(error_c); free(error_c);
return -1;
} }
return rc; merge(&new_info);
return 0;
}; };
char remove_state() char remove_state()

View File

@ -248,8 +248,6 @@ int Host::update_info(Template &tmpl,
int vmid; int vmid;
float val; float val;
string error_st;
ostringstream zombie; ostringstream zombie;
ostringstream wild; ostringstream wild;
@ -286,7 +284,7 @@ int Host::update_info(Template &tmpl,
// Copy monitor, extract share info & update last_monitored and state // Copy monitor, extract share info & update last_monitored and state
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
obj_template->merge(&tmpl, error_st); obj_template->merge(&tmpl);
touch(true); touch(true);

View File

@ -200,8 +200,7 @@ int PoolObjectSQL::replace_template(
{ {
obj_template->remove_all_except_restricted(); obj_template->remove_all_except_restricted();
string aux_error; new_tmpl->merge(obj_template);
new_tmpl->merge(obj_template, aux_error);
} }
} }
@ -260,7 +259,8 @@ int PoolObjectSQL::append_template(
{ {
old_tmpl = new Template(*obj_template); old_tmpl = new Template(*obj_template);
obj_template->merge(new_tmpl, error); obj_template->merge(new_tmpl);
delete new_tmpl; delete new_tmpl;
} }
else else

View File

@ -271,12 +271,7 @@ Request::ErrorCode VMTemplateInstantiate::merge(
} }
} }
rc = tmpl->merge(&uattrs, att.resp_msg); tmpl->merge(&uattrs);
if ( rc != 0 )
{
return INTERNAL;
}
return SUCCESS; return SUCCESS;
} }

View File

@ -587,7 +587,7 @@ int Template::from_xml_node(const xmlNodePtr node)
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
int Template::merge(const Template * from_tmpl, string& error_str) void Template::merge(const Template * from_tmpl)
{ {
multimap<string,Attribute *>::const_iterator it; multimap<string,Attribute *>::const_iterator it;
@ -600,8 +600,6 @@ int Template::merge(const Template * from_tmpl, string& error_str)
{ {
this->set(it->second->clone()); this->set(it->second->clone());
} }
return 0;
} }
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */

View File

@ -4166,8 +4166,7 @@ int VirtualMachine::replace_template(
{ {
user_obj_template->remove_all_except_restricted(); user_obj_template->remove_all_except_restricted();
string aux_error; new_tmpl->merge(user_obj_template);
new_tmpl->merge(user_obj_template, aux_error);
} }
} }
@ -4208,7 +4207,7 @@ int VirtualMachine::append_template(
if (user_obj_template != 0) if (user_obj_template != 0)
{ {
user_obj_template->merge(new_tmpl, error); user_obj_template->merge(new_tmpl);
delete new_tmpl; delete new_tmpl;
} }
else else