1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

B #5096: Remove unneeded functions

This commit is contained in:
Ruben S. Montero 2021-06-09 19:51:28 +00:00
parent 7814dc597a
commit ba9983bd7d
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87
6 changed files with 5 additions and 139 deletions

View File

@ -457,12 +457,6 @@ public:
return false;
}
virtual bool test_restricted_merge(string& rs_attr,
const Template* base) const
{
return false;
}
/**
* Encrypt all secret attributes
*/
@ -547,8 +541,6 @@ protected:
bool check_restricted(string& rs_attr,
const std::map<std::string, std::set<std::string> >& ras);
bool test_restricted_merge(string& rs_attr, const Template* base,
const std::map<std::string, std::set<std::string> >& ras) const;
/**
* Parses a list of encrypted attributes in the form ATTRIBUTE_NAME or
* ATTRIBUTE_NAME/SUBATTRIBUTE.

View File

@ -1198,11 +1198,9 @@ public:
* @param err description if any
* @return template with the attributes
*/
VirtualMachineTemplate * get_updateconf_template() const;
bool test_restricted_merge(string& ra, const VirtualMachineTemplate * source) const
bool check_restricted(string& ra, VirtualMachineTemplate * source) const
{
return source->test_restricted_merge(ra, obj_template);
return source->check_restricted(ra, obj_template);
}
// -------------------------------------------------------------------------

View File

@ -66,11 +66,6 @@ public:
return Template::check_restricted(rs_attr, base, restricted);
}
virtual bool test_restricted_merge(string& rs_attr, const Template* base) const override
{
return Template::test_restricted_merge(rs_attr, base, restricted);
}
virtual bool check_restricted(string& rs_attr)
{
return Template::check_restricted(rs_attr, restricted);

View File

@ -3181,7 +3181,7 @@ void VirtualMachineUpdateConf::request_execute(
{
string aname;
bool has_restricted = vm->test_restricted_merge(aname, uc_tmpl.get());
bool has_restricted = vm->check_restricted(aname, uc_tmpl.get());
if (has_restricted)
{

View File

@ -865,48 +865,6 @@ bool Template::check_restricted(string& ra, const Template* base,
return false;
}
// -----------------------------------------------------------------------------
bool Template::test_restricted_merge(string& ra, const Template* base,
const std::map<std::string, std::set<std::string> >& ras) const
{
std::map<std::string, std::set<std::string> >::const_iterator rit;
for ( rit = ras.begin(); rit != ras.end(); ++rit )
{
if (!(rit->second).empty())
{
vector<string> rvalues, rvalues_base;
bool has_restricted;
has_restricted = restricted_values(rit->first, rit->second, this, rvalues);
restricted_values(rit->first, rit->second, base, rvalues_base);
if ( rvalues != rvalues_base && has_restricted)
{
ra = rit->first;
return true;
}
}
else
{
if ( get(rit->first, ra) )
{
string ra_b;
base->get(rit->first, ra_b);
if ( ra_b != ra )
{
ra = rit->first;
return true;
}
}
}
}
return false;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

View File

@ -2737,17 +2737,6 @@ void VirtualMachine::get_public_clouds(const string& pname, set<string> &clouds)
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
static std::map<std::string,std::vector<std::string>> UPDATECONF_ATTRS = {
{"OS", {"ARCH", "MACHINE", "KERNEL", "INITRD", "BOOTLOADER", "BOOT", "KERNEL_CMD", "ROOT", "SD_DISK_BUS"} },
{"FEATURES", {"PAE", "ACPI", "APIC", "LOCALTIME", "HYPERV", "GUEST_AGENT",
"VIRTIO_SCSI_QUEUES"} },
{"INPUT", {"TYPE", "BUS"} },
{"GRAPHICS", {"TYPE", "LISTEN", "PASSWD", "KEYMAP", "COMMAND"} },
{"RAW", {"TYPE", "DATA", "DATA_VMX"} },
{"CPU_MODEL", {"MODEL"} }
};
/**
* Replaces the values of a vector value, preserving the existing ones
*/
@ -2769,8 +2758,8 @@ static void replace_vector_values(Template *old_tmpl, Template *new_tmpl,
}
else
{
std::vector<std::string> vnames = UPDATECONF_ATTRS[name];
std::vector<std::string>::iterator it;
std::vector<std::string> vnames = VirtualMachineTemplate::UPDATECONF_ATTRS[name];
std::vector<std::string>::iterator it;
for (it = vnames.begin(); it != vnames.end(); ++it)
{
@ -2786,45 +2775,6 @@ static void replace_vector_values(Template *old_tmpl, Template *new_tmpl,
}
};
/**
* returns a copy the values of a vector value
*/
static void copy_vector_values(Template *old_tmpl, Template *new_tmpl,
const char * name)
{
string value;
VectorAttribute * old_attr = old_tmpl->get(name);
if ( old_attr == 0 )
{
return;
}
VectorAttribute * new_vattr = new VectorAttribute(name);
std::vector<std::string> vnames = UPDATECONF_ATTRS[name];
std::vector<std::string>::iterator it;
for (it = vnames.begin(); it != vnames.end(); ++it)
{
std::string vval = old_attr->vector_value(*it);
if (!vval.empty())
{
new_vattr->replace(*it, vval);
}
}
if ( new_vattr->empty() )
{
delete new_vattr;
}
else
{
new_tmpl->set(new_vattr);
}
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
@ -2974,33 +2924,6 @@ int VirtualMachine::updateconf(VirtualMachineTemplate& tmpl, string &err)
return 0;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
VirtualMachineTemplate * VirtualMachine::get_updateconf_template() const
{
VirtualMachineTemplate * conf_tmpl = new VirtualMachineTemplate();
copy_vector_values(obj_template, conf_tmpl, "OS");
copy_vector_values(obj_template, conf_tmpl, "FEATURES");
copy_vector_values(obj_template, conf_tmpl, "INPUT");
copy_vector_values(obj_template, conf_tmpl, "GRAPHICS");
copy_vector_values(obj_template, conf_tmpl, "RAW");
VectorAttribute * context = obj_template->get("CONTEXT");
if ( context != 0 )
{
conf_tmpl->set(context->clone());
}
return conf_tmpl;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* VirtualMachine Disks Interface */