OpenSDN source code
controller/src/vnsw/agent/vxlan_agent/linux/main.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 #include <base/misc_utils.h>
5 #include <cmn/buildinfo.h>
6 #include <cmn/agent_cmn.h>
7 #include <init/agent_param.h>
10 
11 namespace opt = boost::program_options;
12 using namespace std;
13 
14 void RouterIdDepInit(Agent *agent) {
15  // Parse config and then connect
17  LOG(DEBUG, "Router ID Dependent modules (Nova and BGP) INITIALIZED");
18 }
19 
20 int main(int argc, char *argv[]) {
21  AgentParam params(false, false, false, false);
22  Logging logging;
23 
24  const opt::variables_map &var_map = params.var_map();
25  try {
26  params.ParseArguments(argc, argv);
27  } catch (...) {
28  cout << "Invalid arguments. ";
29  cout << params.options() << endl;
30  exit(0);
31  }
32 
33  if (var_map.count("help")) {
34  cout << params.options() << endl;
35  exit(0);
36  }
37 
38  if (var_map.count("version")) {
39  cout << BuildInfo << endl;
40  exit(0);
41  }
42 
43  string init_file = "";
44  if (var_map.count("config_file")) {
45  init_file = var_map["config_file"].as<string>();
46  struct stat s;
47  if (stat(init_file.c_str(), &s) != 0) {
48  LOG(ERROR, "Error opening config file <" << init_file
49  << ">. Error number <" << errno << ">");
50  exit(EINVAL);
51  }
52  }
53 
54  // Read agent parameters from config file and arguments
55  params.Init(init_file, argv[0]);
56 
57  // Initialize TBB
58  // Call to GetScheduler::GetInstance() will also create Task Scheduler
59  TaskScheduler::Initialize(params.tbb_thread_count());
60 
61  // Initialize the agent-init control class
63  Agent *agent = init.agent();
64 
65  MiscUtils::LogVersionInfo(BuildInfo, Category::VROUTER);
66 
67  init.set_agent_param(&params);
68 
69  // kick start initialization
70  int ret = 0;
71  if ((ret = init.Start(logging)) != 0) {
72  return ret;
73  }
74 
75  agent->event_manager()->Run();
76 
77  return 0;
78 }
Definition: agent.h:360
VNController * controller() const
Definition: agent.cc:984
EventManager * event_manager() const
Definition: agent.h:1105
static Agent * GetInstance()
Definition: agent.h:438
A class providing basic control over logging capabilities in OpenSDN control plane.
Definition: logging.h:43
static void LogVersionInfo(const std::string str, Category::type categ)
Definition: misc_utils.cc:36
static void Initialize(uint32_t thread_count=0, EventManager *evm=NULL)
Definition: task.cc:485
void RouterIdDepInit(Agent *agent)
#define LOG(_Level, _Msg)
Definition: logging.h:34
void init()
Definition: bgp_log.cc:37
const std::string BuildInfo