mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-20 10:50:08 +03:00
M #-: Add more build warnings, const version of vector_value method (#2534)
* M #-: const version of vector_value returns const& * M #-: Turn on compiler flags -Wextra -Werror (cherry picked from commit 75ee27eb325b08901ef83302f21a3a85b11f21a8)
This commit is contained in:
parent
26e277af74
commit
cf96aa8275
34
SConstruct
34
SConstruct
@ -118,7 +118,7 @@ main_env.Append(LIBPATH=[
|
||||
main_env.Append(CPPFLAGS=[
|
||||
"-g",
|
||||
"-Wall",
|
||||
"-std=c++14"
|
||||
"-std=c++17"
|
||||
])
|
||||
|
||||
# Linking flags & common libraries
|
||||
@ -129,6 +129,26 @@ main_env.Append(LIBS=['z'])
|
||||
# EXTRA CONFIGURATION #
|
||||
#######################
|
||||
|
||||
# Generate help text
|
||||
vars = Variables('custom.py')
|
||||
vars.Add('sqlite_dir', 'Path to sqlite directory', '')
|
||||
vars.Add('sqlite', 'Build with SQLite support', 'yes')
|
||||
vars.Add('mysql', 'Build with MySQL support', 'no')
|
||||
vars.Add('postgresql', 'Build with PostgreSQL support', 'no')
|
||||
vars.Add('parsers', 'Obsolete. Rebuild flex/bison files', 'no')
|
||||
vars.Add('xmlrpc', 'Path to xmlrpc directory', '')
|
||||
vars.Add('new_xmlrpc', 'Use xmlrpc-c version >=1.31', 'no')
|
||||
vars.Add('sunstone', 'Build Sunstone', 'no')
|
||||
vars.Add('fireedge', 'Build FireEdge', 'no')
|
||||
vars.Add('systemd', 'Build with systemd support', 'no')
|
||||
vars.Add('docker_machine', 'Build Docker machine driver', 'no')
|
||||
vars.Add('rubygems', 'Generate Ruby gems', 'no')
|
||||
vars.Add('svncterm', 'Build VNC support for LXD drivers', 'yes')
|
||||
vars.Add('context', 'Download guest contextualization packages', 'no')
|
||||
vars.Add('strict', 'Strict C++ compiler, more warnings, treat warnings as errors', 'no')
|
||||
env = Environment(variables = vars)
|
||||
Help(vars.GenerateHelpText(env))
|
||||
|
||||
# SQLITE
|
||||
sqlite_dir = ARGUMENTS.get('sqlite_dir', "none")
|
||||
if sqlite_dir != 'none':
|
||||
@ -192,6 +212,18 @@ if build_parsers == 'yes':
|
||||
else:
|
||||
main_env.Append(parsers='no')
|
||||
|
||||
# strict: Add more warnings add treat warnings as errors
|
||||
strict = ARGUMENTS.get('strict', 'no')
|
||||
if strict == 'yes':
|
||||
main_env.Append(CPPFLAGS=[
|
||||
"-Wextra",
|
||||
"-Werror",
|
||||
"-Wno-error=deprecated-declarations",
|
||||
"-Wno-unused-parameter",
|
||||
"-Wno-unused-result"
|
||||
])
|
||||
|
||||
|
||||
# Rubygem generation
|
||||
main_env.Append(rubygems=ARGUMENTS.get('rubygems', 'no'))
|
||||
|
||||
|
@ -32,13 +32,10 @@ class Attribute
|
||||
{
|
||||
public:
|
||||
|
||||
Attribute(const std::string& aname):attribute_name(aname)
|
||||
Attribute(const std::string& aname)
|
||||
: attribute_name(aname)
|
||||
{
|
||||
transform (
|
||||
attribute_name.begin(),
|
||||
attribute_name.end(),
|
||||
attribute_name.begin(),
|
||||
(int(*)(int))toupper);
|
||||
one_util::toupper(attribute_name);
|
||||
|
||||
// FIX Attribute name if it does not conform XML element
|
||||
// naming conventions
|
||||
@ -117,6 +114,8 @@ protected:
|
||||
* The attribute name.
|
||||
*/
|
||||
std::string attribute_name;
|
||||
|
||||
static const std::string EMPTY_ATTRIBUTE;
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -267,16 +266,15 @@ public:
|
||||
, attribute_value(value)
|
||||
{}
|
||||
|
||||
VectorAttribute(const VectorAttribute& va)
|
||||
: Attribute(va.attribute_name)
|
||||
, attribute_value(va.attribute_value)
|
||||
{}
|
||||
VectorAttribute(const VectorAttribute& va) = default;
|
||||
|
||||
VectorAttribute(const VectorAttribute* va)
|
||||
: Attribute(va->attribute_name)
|
||||
, attribute_value(va->attribute_value)
|
||||
{}
|
||||
|
||||
VectorAttribute& operator=(const VectorAttribute& va) = default;
|
||||
|
||||
~VectorAttribute(){};
|
||||
|
||||
/**
|
||||
@ -291,9 +289,23 @@ public:
|
||||
* Returns the string value
|
||||
* @param name of the attribute
|
||||
*
|
||||
* @return the value of the attribute if found, empty otherwise
|
||||
* @return copy of the value of the attribute if found, empty otherwise
|
||||
*
|
||||
* @note Non const version must return copy, as subsequent call to replace or remove
|
||||
* may change the value
|
||||
*/
|
||||
std::string vector_value(const std::string& name) const;
|
||||
std::string vector_value(const std::string& name);
|
||||
|
||||
/**
|
||||
* Returns the string value
|
||||
* @param name of the attribute
|
||||
*
|
||||
* @return reference of the value of the attribute if found, empty otherwise
|
||||
*
|
||||
* @note It's safe to return reference here, as we are using
|
||||
* the const object, which can't change the value
|
||||
*/
|
||||
const std::string& vector_value(const std::string& name) const;
|
||||
|
||||
/**
|
||||
* Returns the value of the given element of the VectorAttribute
|
||||
@ -371,18 +383,18 @@ public:
|
||||
* @return the value in string form on success, "" otherwise
|
||||
*/
|
||||
template<typename T>
|
||||
std::string vector_value_str(const std::string& name, T& value) const
|
||||
const std::string& vector_value_str(const std::string& name, T& value) const
|
||||
{
|
||||
auto it = attribute_value.find(name);
|
||||
|
||||
if ( it == attribute_value.end() )
|
||||
{
|
||||
return "";
|
||||
return EMPTY_ATTRIBUTE;
|
||||
}
|
||||
|
||||
if ( it->second.empty() )
|
||||
{
|
||||
return "";
|
||||
return EMPTY_ATTRIBUTE;
|
||||
}
|
||||
|
||||
std::istringstream iss(it->second);
|
||||
@ -390,7 +402,7 @@ public:
|
||||
|
||||
if (iss.fail() || !iss.eof())
|
||||
{
|
||||
return "";
|
||||
return EMPTY_ATTRIBUTE;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
@ -445,7 +457,7 @@ public:
|
||||
* Replace the value of the given vector attribute
|
||||
*/
|
||||
template<typename T>
|
||||
void replace(const std::string& name, T value)
|
||||
void replace(const std::string& name, const T& value)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
|
||||
|
@ -110,9 +110,9 @@ private:
|
||||
template<typename D>
|
||||
int DriverManager<D>::load_driver(const VectorAttribute* mad_config)
|
||||
{
|
||||
auto name = mad_config->vector_value("NAME");
|
||||
const auto& name = mad_config->vector_value("NAME");
|
||||
auto exec = mad_config->vector_value("EXECUTABLE");
|
||||
auto args = mad_config->vector_value("ARGUMENTS");
|
||||
const auto& args = mad_config->vector_value("ARGUMENTS");
|
||||
int threads;
|
||||
|
||||
mad_config->vector_value("THREADS", threads, 0);
|
||||
|
@ -48,13 +48,18 @@ public:
|
||||
return va->vector_value(name, value);
|
||||
}
|
||||
|
||||
std::string vector_value(const std::string& name) const
|
||||
std::string vector_value(const std::string& name)
|
||||
{
|
||||
return va->vector_value(name);
|
||||
}
|
||||
|
||||
const std::string& vector_value(const std::string& name) const
|
||||
{
|
||||
return const_cast<const VectorAttribute*>(va)->vector_value(name);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void replace(const std::string& name, T value)
|
||||
void replace(const std::string& name, const T& value)
|
||||
{
|
||||
va->replace(name, value);
|
||||
}
|
||||
|
@ -152,7 +152,6 @@ public:
|
||||
void trigger_suspend(int vid, const RequestAttributes& ra);
|
||||
void trigger_restore(int vid, const RequestAttributes& ra);
|
||||
void trigger_stop(int vid, const RequestAttributes& ra);
|
||||
void trigger_checkpoint(int vid);
|
||||
void trigger_migrate(int vid, const RequestAttributes& ra,
|
||||
VMActions::Action vm_action);
|
||||
void trigger_migrate(int vid, const RequestAttributes& ra)
|
||||
|
@ -301,7 +301,7 @@ private:
|
||||
*
|
||||
* @return a new attribute representing the quota, 0 on error
|
||||
*/
|
||||
VectorAttribute * new_quota(VectorAttribute* va);
|
||||
VectorAttribute * new_quota(const VectorAttribute* va);
|
||||
|
||||
/**
|
||||
* Adds a new quota, it also updates an internal index for fast accessing
|
||||
|
@ -148,7 +148,7 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int snapshot_transfer_command(VirtualMachine * vm,
|
||||
int snapshot_transfer_command(const VirtualMachine * vm,
|
||||
const char * snap_action,
|
||||
std::ostream& xfr);
|
||||
|
||||
@ -292,11 +292,6 @@ public:
|
||||
*/
|
||||
void trigger_epilog_detach(VirtualMachine * vm);
|
||||
|
||||
/**
|
||||
* This function starts the epilog sequence
|
||||
*/
|
||||
void trigger_checkpoint(int vid);
|
||||
|
||||
/**
|
||||
* This function cancels the operation being performed by the driver
|
||||
*/
|
||||
|
@ -75,7 +75,7 @@ public:
|
||||
*/
|
||||
VMGroupPolicy policy();
|
||||
|
||||
std::string policy_s()
|
||||
std::string policy_s() const
|
||||
{
|
||||
return va->vector_value("POLICY");
|
||||
};
|
||||
|
@ -603,7 +603,7 @@ public:
|
||||
*/
|
||||
VirtualMachineDisk * set_up_attach(int vmid, int uid, int cluster_id,
|
||||
VectorAttribute * vdisk, const std::string& tsys,
|
||||
VectorAttribute * vcontext, std::string& error);
|
||||
const VectorAttribute * vcontext, std::string& error);
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Save as Interface */
|
||||
|
@ -40,6 +40,8 @@ public:
|
||||
|
||||
VirtualMachineTemplate(const Template& vmt):Template(vmt){};
|
||||
|
||||
VirtualMachineTemplate(const VirtualMachineTemplate& t) = default;
|
||||
|
||||
VirtualMachineTemplate& operator=(const VirtualMachineTemplate& t)
|
||||
{
|
||||
if (this != &t)
|
||||
|
@ -25,6 +25,7 @@ using namespace std;
|
||||
|
||||
const char * VectorAttribute::magic_sep = "@^_^@";
|
||||
const int VectorAttribute::magic_sep_size = 5;
|
||||
const string Attribute::EMPTY_ATTRIBUTE = "";
|
||||
|
||||
string VectorAttribute::marshall(const char * _sep) const
|
||||
{
|
||||
@ -252,13 +253,30 @@ void VectorAttribute::remove(const string& name)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
string VectorAttribute::vector_value(const string& name) const
|
||||
string VectorAttribute::vector_value(const string& name)
|
||||
{
|
||||
auto it = attribute_value.find(name);
|
||||
|
||||
if ( it == attribute_value.end() )
|
||||
{
|
||||
return "";
|
||||
return EMPTY_ATTRIBUTE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
const string& VectorAttribute::vector_value(const string& name) const
|
||||
{
|
||||
auto it = attribute_value.find(name);
|
||||
|
||||
if ( it == attribute_value.end() )
|
||||
{
|
||||
return EMPTY_ATTRIBUTE;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -29,7 +29,7 @@ Log::MessageType NebulaService::get_debug_level(Log::MessageType default_) const
|
||||
|
||||
if (log != 0)
|
||||
{
|
||||
string value = log->vector_value("DEBUG_LEVEL");
|
||||
const string& value = log->vector_value("DEBUG_LEVEL");
|
||||
|
||||
log_level_int = std::atoi(value.c_str());
|
||||
|
||||
|
@ -465,7 +465,7 @@ int DispatchManager::terminate(int vid, bool hard, const RequestAttributes& ra,
|
||||
break;
|
||||
}
|
||||
// else fallthrough to default
|
||||
|
||||
[[fallthrough]];
|
||||
default:
|
||||
oss.str("");
|
||||
oss << "Could not terminate VM " << vid
|
||||
@ -1220,6 +1220,8 @@ int DispatchManager::delete_recreate(unique_ptr<VirtualMachine> vm,
|
||||
|
||||
do_quotas = true;
|
||||
|
||||
[[fallthrough]];
|
||||
|
||||
case VirtualMachine::HOLD:
|
||||
if (vm->hasHistory())
|
||||
{
|
||||
@ -1294,6 +1296,8 @@ int DispatchManager::delete_vm_db(unique_ptr<VirtualMachine> vm,
|
||||
|
||||
hpool->del_capacity(vm->get_hid(), sr);
|
||||
|
||||
[[fallthrough]];
|
||||
|
||||
case VirtualMachine::STOPPED:
|
||||
case VirtualMachine::UNDEPLOYED:
|
||||
case VirtualMachine::INIT:
|
||||
|
@ -340,7 +340,7 @@ void HostSharePCI::clear()
|
||||
int HostSharePCI::get_pci_value(const char * name,
|
||||
const VectorAttribute * pci_device, unsigned int &pci_value)
|
||||
{
|
||||
string temp = pci_device->vector_value(name);
|
||||
const string& temp = pci_device->vector_value(name);
|
||||
|
||||
if (temp.empty())
|
||||
{
|
||||
|
@ -862,6 +862,8 @@ void LifeCycleManager::trigger_delete(int vid, const RequestAttributes& ra)
|
||||
vm->set_state(VirtualMachine::CLEANUP_DELETE);
|
||||
vmpool->update(vm.get());
|
||||
|
||||
[[fallthrough]];
|
||||
|
||||
case VirtualMachine::CLEANUP_DELETE:
|
||||
dm->trigger_done(vid);
|
||||
break;
|
||||
|
@ -1941,6 +1941,7 @@ void LifeCycleManager::trigger_disk_snapshot_success(int vid)
|
||||
{
|
||||
case VirtualMachine::DISK_SNAPSHOT:
|
||||
vm->set_state(VirtualMachine::RUNNING);
|
||||
[[fallthrough]];
|
||||
case VirtualMachine::DISK_SNAPSHOT_POWEROFF:
|
||||
case VirtualMachine::DISK_SNAPSHOT_SUSPENDED:
|
||||
vm->log("LCM", Log::INFO, "VM disk snapshot operation completed.");
|
||||
@ -1955,6 +1956,7 @@ void LifeCycleManager::trigger_disk_snapshot_success(int vid)
|
||||
|
||||
case VirtualMachine::DISK_SNAPSHOT_DELETE:
|
||||
vm->set_state(VirtualMachine::RUNNING);
|
||||
[[fallthrough]];
|
||||
case VirtualMachine::DISK_SNAPSHOT_DELETE_POWEROFF:
|
||||
case VirtualMachine::DISK_SNAPSHOT_DELETE_SUSPENDED:
|
||||
vm->log("LCM", Log::INFO, "VM disk snapshot deleted.");
|
||||
@ -2089,6 +2091,7 @@ void LifeCycleManager::trigger_disk_snapshot_failure(int vid)
|
||||
{
|
||||
case VirtualMachine::DISK_SNAPSHOT:
|
||||
vm->set_state(VirtualMachine::RUNNING);
|
||||
[[fallthrough]];
|
||||
case VirtualMachine::DISK_SNAPSHOT_POWEROFF:
|
||||
case VirtualMachine::DISK_SNAPSHOT_SUSPENDED:
|
||||
vm->log("LCM", Log::ERROR, "Could not take disk snapshot.");
|
||||
@ -2098,6 +2101,7 @@ void LifeCycleManager::trigger_disk_snapshot_failure(int vid)
|
||||
|
||||
case VirtualMachine::DISK_SNAPSHOT_DELETE:
|
||||
vm->set_state(VirtualMachine::RUNNING);
|
||||
[[fallthrough]];
|
||||
case VirtualMachine::DISK_SNAPSHOT_DELETE_POWEROFF:
|
||||
case VirtualMachine::DISK_SNAPSHOT_REVERT_POWEROFF:
|
||||
case VirtualMachine::DISK_SNAPSHOT_DELETE_SUSPENDED:
|
||||
@ -2312,6 +2316,7 @@ void LifeCycleManager::trigger_disk_resize_success(int vid)
|
||||
{
|
||||
case VirtualMachine::DISK_RESIZE:
|
||||
vm->set_state(VirtualMachine::RUNNING);
|
||||
[[fallthrough]];
|
||||
|
||||
case VirtualMachine::DISK_RESIZE_POWEROFF:
|
||||
case VirtualMachine::DISK_RESIZE_UNDEPLOYED:
|
||||
@ -2390,7 +2395,7 @@ void LifeCycleManager::trigger_disk_resize_failure(int vid)
|
||||
{
|
||||
case VirtualMachine::DISK_RESIZE:
|
||||
vm->set_state(VirtualMachine::RUNNING);
|
||||
|
||||
[[fallthrough]];
|
||||
case VirtualMachine::DISK_RESIZE_POWEROFF:
|
||||
case VirtualMachine::DISK_RESIZE_UNDEPLOYED:
|
||||
vm->log("LCM", Log::INFO, "VM disk resize operation completed.");
|
||||
|
@ -1296,20 +1296,14 @@ int Nebula::get_conf_attribute(
|
||||
const VectorAttribute* &value) const
|
||||
{
|
||||
std::vector<const VectorAttribute*> values;
|
||||
std::string template_name;
|
||||
std::string name_upper = name;
|
||||
|
||||
one_util::toupper(name_upper);
|
||||
|
||||
nebula_configuration->get(key, values);
|
||||
|
||||
for (auto vattr : values)
|
||||
{
|
||||
template_name = vattr->vector_value("NAME");
|
||||
const string& template_name = vattr->vector_value("NAME");
|
||||
|
||||
one_util::toupper(template_name);
|
||||
|
||||
if ( template_name == name_upper )
|
||||
if ( one_util::icasecmp(name, template_name) )
|
||||
{
|
||||
value = vattr;
|
||||
return 0;
|
||||
|
@ -67,7 +67,7 @@ RaftManager::RaftManager(int id, const VectorAttribute * leader_hook_mad,
|
||||
Nebula& nd = Nebula::instance();
|
||||
LogDB * logdb = nd.get_logdb();
|
||||
|
||||
std::string raft_xml, cmd, arg;
|
||||
std::string raft_xml;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Initialize Raft variables:
|
||||
@ -138,8 +138,8 @@ RaftManager::RaftManager(int id, const VectorAttribute * leader_hook_mad,
|
||||
|
||||
if ( leader_hook_mad != 0 )
|
||||
{
|
||||
cmd = leader_hook_mad->vector_value("COMMAND");
|
||||
arg = leader_hook_mad->vector_value("ARGUMENTS");
|
||||
const string& cmd = leader_hook_mad->vector_value("COMMAND");
|
||||
const string& arg = leader_hook_mad->vector_value("ARGUMENTS");
|
||||
|
||||
if ( cmd.empty() )
|
||||
{
|
||||
@ -159,8 +159,8 @@ RaftManager::RaftManager(int id, const VectorAttribute * leader_hook_mad,
|
||||
|
||||
if ( follower_hook_mad != 0 )
|
||||
{
|
||||
cmd = follower_hook_mad->vector_value("COMMAND");
|
||||
arg = follower_hook_mad->vector_value("ARGUMENTS");
|
||||
const string& cmd = follower_hook_mad->vector_value("COMMAND");
|
||||
const string& arg = follower_hook_mad->vector_value("ARGUMENTS");
|
||||
|
||||
if ( cmd.empty() )
|
||||
{
|
||||
|
@ -414,7 +414,7 @@ public:
|
||||
*
|
||||
* @param action sched action to update
|
||||
*/
|
||||
bool update_sched_action(SchedAction* action);
|
||||
bool update_sched_action(const SchedAction* action);
|
||||
|
||||
/**
|
||||
* Sets an attribute in the VM Template, it must be allocated in the heap
|
||||
|
@ -677,13 +677,13 @@ int VirtualMachineXML::parse_action_name(string& action_st)
|
||||
// Updates to oned
|
||||
//******************************************************************************
|
||||
|
||||
bool VirtualMachineXML::update_sched_action(SchedAction* action)
|
||||
bool VirtualMachineXML::update_sched_action(const SchedAction* action)
|
||||
{
|
||||
xmlrpc_c::value result;
|
||||
|
||||
try
|
||||
{
|
||||
string action_id_str = action->vector_value("ID");
|
||||
const string& action_id_str = action->vector_value("ID");
|
||||
int action_id = std::stoi(action_id_str);
|
||||
|
||||
ostringstream oss;
|
||||
|
@ -71,14 +71,8 @@ int TransferManager::prolog_transfer_command(
|
||||
ostream& xfr,
|
||||
ostringstream& os)
|
||||
{
|
||||
string source;
|
||||
string type;
|
||||
string clon;
|
||||
string size;
|
||||
string format;
|
||||
string tm_mad;
|
||||
string tm_mad_system;
|
||||
string ds_id;
|
||||
|
||||
int disk_id = disk->get_disk_id();
|
||||
|
||||
@ -91,7 +85,7 @@ int TransferManager::prolog_transfer_command(
|
||||
// -----------------------------------------------------------------
|
||||
// Generate a swap disk image
|
||||
// -----------------------------------------------------------------
|
||||
size = disk->vector_value("SIZE");
|
||||
const string& size = disk->vector_value("SIZE");
|
||||
|
||||
if ( size.empty() )
|
||||
{
|
||||
@ -115,8 +109,8 @@ int TransferManager::prolog_transfer_command(
|
||||
// -----------------------------------------------------------------
|
||||
// Create a clean file system disk image
|
||||
// -----------------------------------------------------------------
|
||||
size = disk->vector_value("SIZE");
|
||||
format = disk->vector_value("FORMAT");
|
||||
const string& size = disk->vector_value("SIZE");
|
||||
const string& format = disk->vector_value("FORMAT");
|
||||
|
||||
if ( size.empty() || format.empty() )
|
||||
{
|
||||
@ -141,10 +135,10 @@ int TransferManager::prolog_transfer_command(
|
||||
// -----------------------------------------------------------------
|
||||
// Get transfer attributes & check errors
|
||||
// -----------------------------------------------------------------
|
||||
tm_mad = disk->vector_value("TM_MAD");
|
||||
ds_id = disk->vector_value("DATASTORE_ID");
|
||||
source = disk->vector_value("SOURCE");
|
||||
clon = disk->vector_value("CLONE");
|
||||
const string& tm_mad = disk->vector_value("TM_MAD");
|
||||
const string& ds_id = disk->vector_value("DATASTORE_ID");
|
||||
const string& source = disk->vector_value("SOURCE");
|
||||
const string& clon = disk->vector_value("CLONE");
|
||||
|
||||
if ( source.empty() ||
|
||||
tm_mad.empty() ||
|
||||
@ -213,7 +207,7 @@ static string prolog_os_transfer_commands(
|
||||
{
|
||||
string base_ds = base + "_DS";
|
||||
|
||||
string name_ds = os_attr->vector_value(base_ds);
|
||||
const string& name_ds = os_attr->vector_value(base_ds);
|
||||
|
||||
if ( name_ds.empty() )
|
||||
{
|
||||
@ -224,9 +218,9 @@ static string prolog_os_transfer_commands(
|
||||
string base_ds_id = base + "_DS_DSID";
|
||||
string base_tm = base + "_DS_TM";
|
||||
|
||||
string source = os_attr->vector_value(base_source);
|
||||
string ds_id = os_attr->vector_value(base_ds_id);
|
||||
string tm_mad = os_attr->vector_value(base_tm);
|
||||
const string& source = os_attr->vector_value(base_source);
|
||||
const string& ds_id = os_attr->vector_value(base_ds_id);
|
||||
const string& tm_mad = os_attr->vector_value(base_tm);
|
||||
|
||||
if ( source.empty() || ds_id.empty() || tm_mad.empty() )
|
||||
{
|
||||
@ -236,7 +230,7 @@ static string prolog_os_transfer_commands(
|
||||
ostringstream base_dst;
|
||||
string name = base;
|
||||
|
||||
transform(name.begin(), name.end(), name.begin(), (int(*)(int))tolower);
|
||||
one_util::tolower(name);
|
||||
|
||||
base_dst << vm->get_system_dir() << "/" << name;
|
||||
|
||||
@ -943,9 +937,9 @@ void TransferManager::epilog_transfer_command(
|
||||
|
||||
if ( one_util::toupper(save) == "YES" )
|
||||
{
|
||||
string source = disk->vector_value("SOURCE");
|
||||
string tm_mad = disk->vector_value("TM_MAD");
|
||||
string ds_id = disk->vector_value("DATASTORE_ID");
|
||||
const string& source = disk->vector_value("SOURCE");
|
||||
const string& tm_mad = disk->vector_value("TM_MAD");
|
||||
const string& ds_id = disk->vector_value("DATASTORE_ID");
|
||||
|
||||
if ( ds_id.empty() || tm_mad.empty() )
|
||||
{
|
||||
@ -959,7 +953,7 @@ void TransferManager::epilog_transfer_command(
|
||||
return;
|
||||
}
|
||||
|
||||
string tsys = disk->vector_value("TM_MAD_SYSTEM");
|
||||
const string& tsys = disk->vector_value("TM_MAD_SYSTEM");
|
||||
if (!tsys.empty())
|
||||
{
|
||||
tm_mad_system = "." + tsys;
|
||||
@ -992,7 +986,7 @@ void TransferManager::epilog_transfer_command(
|
||||
vv_rc = disk->vector_value("DATASTORE_ID", ds_id_i);
|
||||
}
|
||||
|
||||
string tsys = disk->vector_value("TM_MAD_SYSTEM");
|
||||
const string& tsys = disk->vector_value("TM_MAD_SYSTEM");
|
||||
if (!tsys.empty())
|
||||
{
|
||||
tm_mad_system = "." + tsys;
|
||||
@ -1220,7 +1214,7 @@ void TransferManager::trigger_epilog_stop(VirtualMachine * vm)
|
||||
}
|
||||
}
|
||||
|
||||
string tsys = disk->vector_value("TM_MAD_SYSTEM");
|
||||
const string& tsys = disk->vector_value("TM_MAD_SYSTEM");
|
||||
if (!tsys.empty())
|
||||
{
|
||||
tm_mad_system = "." + tsys;
|
||||
@ -1350,7 +1344,7 @@ int TransferManager::epilog_delete_commands(VirtualMachine *vm,
|
||||
// -------------------------------------------------------------------------
|
||||
// Delete disk images and the remote system Directory
|
||||
// -------------------------------------------------------------------------
|
||||
for (auto disk : disks)
|
||||
for (const auto* disk : disks)
|
||||
{
|
||||
disk_id = disk->get_disk_id();
|
||||
|
||||
@ -1370,7 +1364,7 @@ int TransferManager::epilog_delete_commands(VirtualMachine *vm,
|
||||
}
|
||||
}
|
||||
|
||||
string tsys = disk->vector_value("TM_MAD_SYSTEM");
|
||||
const string& tsys = disk->vector_value("TM_MAD_SYSTEM");
|
||||
if (!tsys.empty())
|
||||
{
|
||||
tm_mad_system = "." + tsys;
|
||||
@ -1816,14 +1810,6 @@ void TransferManager::trigger_driver_cancel(int vid)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void TransferManager::trigger_checkpoint(int vid)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void TransferManager::trigger_saveas_hot(int vid)
|
||||
{
|
||||
trigger([this, vid] {
|
||||
@ -1833,7 +1819,6 @@ void TransferManager::trigger_saveas_hot(int vid)
|
||||
string snap_id;
|
||||
string tm_mad;
|
||||
string ds_id;
|
||||
string tsys;
|
||||
string tm_mad_system;
|
||||
string hostname;
|
||||
|
||||
@ -1843,7 +1828,7 @@ void TransferManager::trigger_saveas_hot(int vid)
|
||||
string xfr_name;
|
||||
|
||||
const Driver<transfer_msg_t> * tm_md;
|
||||
VirtualMachineDisk * disk;
|
||||
const VirtualMachineDisk * disk;
|
||||
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
||||
@ -1886,7 +1871,7 @@ void TransferManager::trigger_saveas_hot(int vid)
|
||||
|
||||
if (disk != nullptr)
|
||||
{
|
||||
tsys = disk->vector_value("TM_MAD_SYSTEM");
|
||||
const string& tsys = disk->vector_value("TM_MAD_SYSTEM");
|
||||
if (!tsys.empty())
|
||||
{
|
||||
tm_mad_system = "." + tsys;
|
||||
@ -1974,15 +1959,14 @@ void TransferManager::migrate_transfer_command(
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int TransferManager::snapshot_transfer_command(
|
||||
VirtualMachine * vm, const char * snap_action, ostream& xfr)
|
||||
const VirtualMachine * vm, const char * snap_action, ostream& xfr)
|
||||
{
|
||||
string tm_mad;
|
||||
string tsys;
|
||||
string tm_mad_system;
|
||||
int ds_id;
|
||||
int disk_id;
|
||||
int snap_id;
|
||||
VirtualMachineDisk * disk;
|
||||
const VirtualMachineDisk * disk;
|
||||
|
||||
if (vm->get_snapshot_disk(ds_id, tm_mad, disk_id, snap_id) == -1)
|
||||
{
|
||||
@ -1995,7 +1979,7 @@ int TransferManager::snapshot_transfer_command(
|
||||
|
||||
if (disk != nullptr)
|
||||
{
|
||||
tsys = disk->vector_value("TM_MAD_SYSTEM");
|
||||
const string& tsys = disk->vector_value("TM_MAD_SYSTEM");
|
||||
if (!tsys.empty())
|
||||
{
|
||||
tm_mad_system = "." + tsys;
|
||||
@ -2146,7 +2130,7 @@ void TransferManager::resize_command(VirtualMachine * vm,
|
||||
ds_id = disk->vector_value("DATASTORE_ID");
|
||||
}
|
||||
|
||||
string tsys = disk->vector_value("TM_MAD_SYSTEM");
|
||||
const string& tsys = disk->vector_value("TM_MAD_SYSTEM");
|
||||
if (!tsys.empty())
|
||||
{
|
||||
tm_mad_system = "." + tsys;
|
||||
|
@ -363,14 +363,13 @@ int Quota::update_limits(
|
||||
VectorAttribute * quota,
|
||||
const VectorAttribute * va)
|
||||
{
|
||||
string limit;
|
||||
float limit_f;
|
||||
|
||||
for (int i=0; i < num_metrics; i++)
|
||||
{
|
||||
limit = va->vector_value_str(metrics[i], limit_f);
|
||||
const string& limit = va->vector_value_str(metrics[i], limit_f);
|
||||
|
||||
if (limit == "")
|
||||
if (limit.empty())
|
||||
{
|
||||
if ( is_default )
|
||||
{
|
||||
@ -401,11 +400,10 @@ int Quota::update_limits(
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
VectorAttribute * Quota::new_quota(VectorAttribute * va)
|
||||
VectorAttribute * Quota::new_quota(const VectorAttribute * va)
|
||||
{
|
||||
map<string,string> limits;
|
||||
|
||||
string limit;
|
||||
float limit_f;
|
||||
|
||||
for (int i=0; i < num_metrics; i++)
|
||||
@ -414,9 +412,9 @@ VectorAttribute * Quota::new_quota(VectorAttribute * va)
|
||||
|
||||
metrics_used += "_USED";
|
||||
|
||||
limit = va->vector_value_str(metrics[i], limit_f);
|
||||
const string& limit = va->vector_value_str(metrics[i], limit_f);
|
||||
|
||||
if (limit == "")
|
||||
if (limit.empty())
|
||||
{
|
||||
if ( is_default )
|
||||
{
|
||||
@ -441,7 +439,7 @@ VectorAttribute * Quota::new_quota(VectorAttribute * va)
|
||||
limits.insert(make_pair(metrics_used, "0"));
|
||||
}
|
||||
|
||||
string id = va->vector_value("ID");
|
||||
const string& id = va->vector_value("ID");
|
||||
|
||||
if ( !id.empty() )
|
||||
{
|
||||
|
@ -2721,9 +2721,9 @@ void VirtualMachine::get_public_clouds(const string& pname, set<string> &clouds)
|
||||
clouds.insert("ec2");
|
||||
}
|
||||
|
||||
for (auto vattr : attrs)
|
||||
for (const auto* vattr : attrs)
|
||||
{
|
||||
string type = vattr->vector_value("TYPE");
|
||||
const string& type = vattr->vector_value("TYPE");
|
||||
|
||||
if (!type.empty())
|
||||
{
|
||||
|
@ -417,9 +417,9 @@ int VirtualMachine::generate_network_context(VectorAttribute* context,
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
static void parse_pci_context_network(const std::vector<ContextVariable>& cvars,
|
||||
VectorAttribute * context, VectorAttribute * nic)
|
||||
VectorAttribute * context, const VectorAttribute * nic)
|
||||
{
|
||||
string pci_id = nic->vector_value("PCI_ID");
|
||||
const string& pci_id = nic->vector_value("PCI_ID");
|
||||
|
||||
for (const auto& con : cvars)
|
||||
{
|
||||
|
@ -174,14 +174,7 @@ int VirtualMachineDisk::get_image_id(int &id, int uid) const
|
||||
|
||||
string VirtualMachineDisk::get_tm_mad_system() const
|
||||
{
|
||||
std::string tm_mad_system;
|
||||
|
||||
if (vector_value("TM_MAD_SYSTEM", tm_mad_system) != 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
return tm_mad_system;
|
||||
return vector_value("TM_MAD_SYSTEM");
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -1085,7 +1078,8 @@ int VirtualMachineDisks::set_attach(int id)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
VirtualMachineDisk * VirtualMachineDisks::set_up_attach(int vmid, int uid,
|
||||
int cluster_id, VectorAttribute * vdisk, const std::string& tsys, VectorAttribute * vcontext,
|
||||
int cluster_id, VectorAttribute * vdisk, const std::string& tsys,
|
||||
const VectorAttribute * vcontext,
|
||||
string& error)
|
||||
{
|
||||
set<string> used_targets;
|
||||
@ -1113,7 +1107,7 @@ VirtualMachineDisk * VirtualMachineDisks::set_up_attach(int vmid, int uid,
|
||||
|
||||
if ( vcontext != 0 )
|
||||
{
|
||||
string target = vcontext->vector_value("TARGET");
|
||||
const string& target = vcontext->vector_value("TARGET");
|
||||
|
||||
if ( !target.empty() )
|
||||
{
|
||||
|
@ -154,9 +154,7 @@ void VirtualMachineNic::authorize(PoolObjectSQL::ObjectType ot, int uid,
|
||||
|
||||
set<int> sgroups;
|
||||
|
||||
string net_mode = "";
|
||||
|
||||
net_mode = this->vector_value("NETWORK_MODE");
|
||||
string net_mode = this->vector_value("NETWORK_MODE");
|
||||
|
||||
if ( one_util::icasecmp(net_mode, "AUTO") )
|
||||
{
|
||||
@ -195,17 +193,17 @@ void VirtualMachineNic::authorize(PoolObjectSQL::ObjectType ot, int uid,
|
||||
|
||||
void VirtualMachineNic::to_xml_short(std::ostringstream& oss) const
|
||||
{
|
||||
std::string ip = vector_value("IP");
|
||||
std::string ip6 = vector_value("IP6");
|
||||
std::string ip6_ula = vector_value("IP6_ULA");
|
||||
const string& ip = vector_value("IP");
|
||||
const string& ip6 = vector_value("IP6");
|
||||
const string& ip6_ula = vector_value("IP6_ULA");
|
||||
|
||||
std::string ip6_link = vector_value("IP6_LINK");
|
||||
std::string ip6_global = vector_value("IP6_GLOBAL");
|
||||
std::string ip_external = vector_value("EXTERNAL_IP"); /* PROVISION AWS_IPAM */
|
||||
const string& ip6_link = vector_value("IP6_LINK");
|
||||
const string& ip6_global = vector_value("IP6_GLOBAL");
|
||||
const string& ip_external = vector_value("EXTERNAL_IP"); /* PROVISION AWS_IPAM */
|
||||
|
||||
std::string reqs = vector_value("SCHED_REQUIREMENTS");
|
||||
std::string rank = vector_value("SCHED_RANK");
|
||||
std::string mode = vector_value("NETWORK_MODE");
|
||||
const string& reqs = vector_value("SCHED_REQUIREMENTS");
|
||||
const string& rank = vector_value("SCHED_RANK");
|
||||
const string& mode = vector_value("NETWORK_MODE");
|
||||
|
||||
oss << "<NIC>";
|
||||
|
||||
|
@ -263,7 +263,7 @@ static void copy_vector_values(const Template *old_tmpl, Template *new_tmpl,
|
||||
|
||||
for (const auto& vname : vnames)
|
||||
{
|
||||
std::string vval = old_attr->vector_value(vname);
|
||||
const string& vval = old_attr->vector_value(vname);
|
||||
|
||||
if (!vval.empty())
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ std::unique_ptr<VMGroup> VMGroupPool::get_from_attribute(
|
||||
{
|
||||
std::unique_ptr<VMGroup> vmgroup;
|
||||
|
||||
string vmg_name = va->vector_value("VMGROUP_NAME");
|
||||
const string& vmg_name = va->vector_value("VMGROUP_NAME");
|
||||
int vmg_id;
|
||||
|
||||
if ( !vmg_name.empty() )
|
||||
@ -140,7 +140,7 @@ void VMGroupPool::del_vm(const VectorAttribute * va, int vid)
|
||||
return;
|
||||
}
|
||||
|
||||
string vmg_role = va->vector_value("ROLE");
|
||||
const string& vmg_role = va->vector_value("ROLE");
|
||||
|
||||
if ( vmg_role.empty() )
|
||||
{
|
||||
|
@ -189,7 +189,7 @@ static void pin_cpu(ofstream& file, const VectorAttribute * topology,
|
||||
unsigned int nv = 0;
|
||||
|
||||
std::vector<unsigned int> cpus_a;
|
||||
std::string cpus = (*it)->vector_value("CPUS");
|
||||
const string& cpus = (*it)->vector_value("CPUS");
|
||||
|
||||
(*it)->vector_value("TOTAL_CPUS", nv);
|
||||
|
||||
@ -281,8 +281,8 @@ static void vtopol(ofstream& file, const VectorAttribute * topology,
|
||||
{
|
||||
unsigned int ncpu = 0;
|
||||
|
||||
std::string mem = (*it)->vector_value("MEMORY");
|
||||
std::string mem_id = (*it)->vector_value("MEMORY_NODE_ID");
|
||||
const string& mem = (*it)->vector_value("MEMORY");
|
||||
const string& mem_id = (*it)->vector_value("MEMORY_NODE_ID");
|
||||
|
||||
(*it)->vector_value("TOTAL_CPUS", ncpu);
|
||||
|
||||
@ -671,7 +671,7 @@ int LibVirtDriver::deployment_description_kvm(
|
||||
auto os = vm->get_template_attribute("OS");
|
||||
if (os)
|
||||
{
|
||||
auto uuid = os->vector_value("UUID");
|
||||
const string& uuid = os->vector_value("UUID");
|
||||
if (!uuid.empty())
|
||||
{
|
||||
file << "\t<uuid>" << uuid << "</uuid>" << endl;
|
||||
|
@ -2430,7 +2430,7 @@ int VirtualMachineManager::load_drivers(const vector<const VectorAttribute*>& _m
|
||||
ostringstream oss;
|
||||
VirtualMachineManagerDriver * vmm_driver = nullptr;
|
||||
|
||||
string name = vattr->vector_value("NAME");
|
||||
const string& name = vattr->vector_value("NAME");
|
||||
string type = vattr->vector_value("TYPE");
|
||||
|
||||
one_util::toupper(type);
|
||||
|
@ -1116,9 +1116,9 @@ int VirtualNetwork::hold_leases(VirtualNetworkTemplate * leases_template,
|
||||
|
||||
unsigned int ar_id;
|
||||
|
||||
string ip = lease->vector_value("IP");
|
||||
string ip6 = lease->vector_value("IP6");
|
||||
string mac = lease->vector_value("MAC");
|
||||
const string& ip = lease->vector_value("IP");
|
||||
const string& ip6 = lease->vector_value("IP6");
|
||||
const string& mac = lease->vector_value("MAC");
|
||||
|
||||
int ip_ne = ip.empty() ? 0 : 1;
|
||||
int ip6_ne = ip6.empty() ? 0 : 1;
|
||||
@ -1192,9 +1192,9 @@ int VirtualNetwork::free_leases(VirtualNetworkTemplate * leases_template,
|
||||
|
||||
unsigned int ar_id;
|
||||
|
||||
string ip = lease->vector_value("IP");
|
||||
string ip6 = lease->vector_value("IP6");
|
||||
string mac = lease->vector_value("MAC");
|
||||
const string& ip = lease->vector_value("IP");
|
||||
const string& ip6 = lease->vector_value("IP6");
|
||||
const string& mac = lease->vector_value("MAC");
|
||||
|
||||
int ip_ne = ip.empty() ? 0 : 1;
|
||||
int ip6_ne = ip6.empty() ? 0 : 1;
|
||||
|
@ -417,7 +417,6 @@ int VirtualRouter::release_network_leases(const VectorAttribute * nic)
|
||||
|
||||
int vnid;
|
||||
int ar_id;
|
||||
string mac;
|
||||
|
||||
if (nic == nullptr)
|
||||
{
|
||||
@ -429,7 +428,7 @@ int VirtualRouter::release_network_leases(const VectorAttribute * nic)
|
||||
return -1;
|
||||
}
|
||||
|
||||
mac = nic->vector_value("VROUTER_MAC");
|
||||
const string& mac = nic->vector_value("VROUTER_MAC");
|
||||
|
||||
auto vn = vnpool->get(vnid);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user