Skip to content

Commit

Permalink
Issue: debug value specified in config file
Browse files Browse the repository at this point in the history
(contrail-vrouter-agent.conf) is not honoured properly. If
debug keyword is specified in the file,irrespective of the
value, debug flags at other classes(Agent, KSyncDebug) are set.
Fix: Definition of debug program option is modified as a
name/value pair and flag is set properly by retrieving the value.
closes-bug: #1561005

Change-Id: I162fb1bdcdfda61bd6e2b82d27dcfeef283662c6
  • Loading branch information
ravi-bk committed Apr 22, 2016
1 parent 4b80855 commit e51debc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/vnsw/agent/contrail-vrouter-agent.conf
Expand Up @@ -20,7 +20,7 @@
# agent_mode=

# Enable/disable debug logging. Possible values are 0 (disable) and 1 (enable)
# debug=0
debug=0

# Aging time for flow-records in seconds
# flow_cache_timeout=0
Expand Down
14 changes: 3 additions & 11 deletions src/vnsw/agent/init/agent_param.cc
Expand Up @@ -427,13 +427,7 @@ void AgentParam::ParseDefaultSection() {
log_local_ = false;
}

if (optional<bool> debug_opt =
tree_.get_optional<bool>("DEFAULT.debug")) {
debug_ = true;
} else {
debug_ = false;
}

GetValueFromTree<bool>(debug_, "DEFAULT.debug");
GetValueFromTree<bool>(use_syslog_, "DEFAULT.use_syslog");
if (!GetValueFromTree<string>(syslog_facility_, "DEFAULT.syslog_facility")) {
syslog_facility_ = "LOG_LOCAL0";
Expand Down Expand Up @@ -717,15 +711,13 @@ void AgentParam::ParseDefaultSectionArguments
GetValueFromTree<long>(log_file_size_, "DEFAULT.log_file_size");
GetOptValue<string>(var_map, log_level_, "DEFAULT.log_level");
GetOptValue<string>(var_map, syslog_facility_, "DEFAULT.syslog_facility");
GetOptValue<bool>(var_map, debug_, "DEFAULT.debug");
if (var_map.count("DEFAULT.use_syslog")) {
use_syslog_ = true;
}
if (var_map.count("DEFAULT.log_local")) {
log_local_ = true;
}
if (var_map.count("DEFAULT.debug")) {
debug_ = true;
}
if (var_map.count("DEFAULT.log_flow")) {
log_flow_ = true;
}
Expand Down Expand Up @@ -1277,7 +1269,7 @@ AgentParam::AgentParam(bool enable_flow_options,
("DEFAULT.collectors",
opt::value<std::vector<std::string> >()->multitoken(),
"Collector server list")
("DEFAULT.debug", "Enable debug logging")
("DEFAULT.debug", opt::value<bool>(), "Enable / Disable debug logging")
("DEFAULT.flow_cache_timeout",
opt::value<uint16_t>()->default_value(Agent::kDefaultFlowCacheTimeout),
"Flow aging time in seconds")
Expand Down
2 changes: 1 addition & 1 deletion src/vnsw/agent/init/test/cfg-default1.ini
Expand Up @@ -16,7 +16,7 @@ server=127.0.0.1
agent_mode=tsn

# Enable/disable debug logging. Possible values are 0 (disable) and 1 (enable)
debug=1
debug=0

# Aging time for flow-records in seconds
flow_cache_timeout=60
Expand Down
2 changes: 2 additions & 0 deletions src/vnsw/agent/init/test/test_agent_init.cc
Expand Up @@ -63,6 +63,7 @@ TEST_F(FlowTest, Agent_Conf_file_1) {
EXPECT_EQ(param.agent_mode(), AgentParam::VROUTER_AGENT);
EXPECT_STREQ(param.agent_base_dir().c_str(), "/var/lib/contrail");
EXPECT_EQ(param.subnet_hosts_resolvable(), true);
EXPECT_TRUE(param.debug());
}

TEST_F(FlowTest, Agent_Conf_file_2) {
Expand Down Expand Up @@ -311,6 +312,7 @@ TEST_F(FlowTest, Default_Cmdline_arg1) {
EXPECT_STREQ(param.log_level().c_str(), "SYS_ERR");
EXPECT_TRUE(param.isXenMode());
EXPECT_EQ(param.agent_mode(), AgentParam::TSN_AGENT);
EXPECT_FALSE(param.debug());
}

/* Some command line args have default values. If user has not passed these
Expand Down

0 comments on commit e51debc

Please sign in to comment.