1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-16 22:50:10 +03:00

M #-: Reduce attribute copies on updateconf

(cherry picked from commit 99d165856d3132f5d5a495a75c8c80bb0865bfca)
This commit is contained in:
Ruben S. Montero 2021-06-10 09:55:21 +02:00
parent 29ef52b896
commit 0ebda56330
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87
2 changed files with 9 additions and 10 deletions

View File

@ -1206,13 +1206,16 @@ public:
int updateconf(VirtualMachineTemplate* tmpl, std::string &err);
/**
* Get the configuration attributes used in an updateconf API call.
* @param err description if any
* @return template with the attributes
* Check if the template includes any restricted attribute, different from
* this VM template.
* @param template to look for for restricted. The resulting tgt template
* will have the same restricted Attributes as this VM.
* @param ra the restricted attribute found to be different
* @return true if a different restricted is found
*/
std::unique_ptr<VirtualMachineTemplate> get_updateconf_template() const
bool check_restricted(std::string& ra, VirtualMachineTemplate * tgt) const
{
return static_cast<VirtualMachineTemplate*>(obj_template.get())->get_updateconf_template();
return tgt->check_restricted(ra, obj_template.get());
}
// -------------------------------------------------------------------------

View File

@ -3076,11 +3076,7 @@ void VirtualMachineUpdateConf::request_execute(
{
string aname;
auto conf_tmpl = vm->get_updateconf_template();
bool has_restricted = uc_tmpl->check_restricted(aname, conf_tmpl.get());
if (has_restricted)
if ( vm->check_restricted(aname, uc_tmpl.get()) )
{
att.resp_msg = "Template includes a restricted attribute " + aname;
failure_response(AUTHORIZATION, att);