mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-02 09:47:00 +03:00
* Fix argument parsing for onemonitord * Update NebulaTemplate.h
This commit is contained in:
parent
c37d98ae06
commit
08e0e6c305
@ -30,9 +30,16 @@ public:
|
||||
NebulaTemplate(const std::string& etc_location, const char * _conf_name,
|
||||
const char * root_name)
|
||||
: Template(false, '=', root_name)
|
||||
, conf_file(etc_location + _conf_name)
|
||||
, hidden_attributes{ { "DB", { "PASSWD" } } }
|
||||
{
|
||||
if (_conf_name[0] == '/')
|
||||
{
|
||||
conf_file = _conf_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
conf_file = etc_location + _conf_name;
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~NebulaTemplate() = default;
|
||||
|
@ -30,8 +30,9 @@ class OpenNebulaTemplate : public NebulaTemplate
|
||||
public:
|
||||
|
||||
OpenNebulaTemplate(const std::string& etc_location,
|
||||
const std::string& _var_location):
|
||||
NebulaTemplate(etc_location, conf_name, "OPENNEBULA_CONFIGURATION"),
|
||||
const std::string& _var_location,
|
||||
const std::string& _conf_name = conf_name):
|
||||
NebulaTemplate(etc_location, _conf_name.c_str(), "OPENNEBULA_CONFIGURATION"),
|
||||
var_location(_var_location)
|
||||
{};
|
||||
|
||||
|
@ -36,7 +36,7 @@ void Monitor::start()
|
||||
// -------------------------------------------------------------------------
|
||||
// Configuration File
|
||||
// -------------------------------------------------------------------------
|
||||
OpenNebulaTemplate oned_config(get_defaults_location(), get_var_location());
|
||||
OpenNebulaTemplate oned_config(get_defaults_location(), get_var_location(), oned_filename);
|
||||
|
||||
if (oned_config.load_configuration() != 0)
|
||||
{
|
||||
|
@ -79,10 +79,19 @@ int main(int argc, char **argv)
|
||||
|
||||
if ( argv[1] != 0 )
|
||||
{
|
||||
//oned passes a single string with all the arguments for monitord
|
||||
// oned passes all arguments as single string, we need to split
|
||||
// the first argument and add the rest to allow also execution from
|
||||
// command line:
|
||||
// onemonitord -c monitord.conf -o oned.conf
|
||||
std::string argv_1 = argv[1];
|
||||
|
||||
std::vector<std::string> _argv = one_util::split(argv_1, ' ');
|
||||
|
||||
for (int i = 2; i < argc; ++i)
|
||||
{
|
||||
_argv.push_back(argv[i]);
|
||||
}
|
||||
|
||||
int _argc = _argv.size() + 1;
|
||||
|
||||
char ** _argv_c = (char **) malloc(sizeof(char *) * (_argc + 1));
|
||||
@ -99,15 +108,15 @@ int main(int argc, char **argv)
|
||||
static struct option long_options[] = {
|
||||
{"version",no_argument, 0, 'v'},
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"config", no_argument, 0, 'c'},
|
||||
{"oned-config", no_argument, 0, 'o'},
|
||||
{"config", required_argument, 0, 'c'},
|
||||
{"oned-config", required_argument, 0, 'o'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
int long_index = 0;
|
||||
int opt;
|
||||
|
||||
while ((opt = getopt_long(_argc, _argv_c, "vhc:",
|
||||
while ((opt = getopt_long(_argc, _argv_c, "vhc:o:",
|
||||
long_options, &long_index)) != -1)
|
||||
{
|
||||
switch(opt)
|
||||
|
Loading…
x
Reference in New Issue
Block a user