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 
23  const opt::variables_map &var_map = params.var_map();
24  try {
25  params.ParseArguments(argc, argv);
26  } catch (...) {
27  cout << "Invalid arguments. ";
28  cout << params.options() << endl;
29  exit(0);
30  }
31 
32  if (var_map.count("help")) {
33  cout << params.options() << endl;
34  exit(0);
35  }
36 
37  if (var_map.count("version")) {
38  cout << BuildInfo << endl;
39  exit(0);
40  }
41 
42  string init_file = "";
43  if (var_map.count("config_file")) {
44  init_file = var_map["config_file"].as<string>();
45  struct stat s;
46  if (stat(init_file.c_str(), &s) != 0) {
47  LOG(ERROR, "Error opening config file <" << init_file
48  << ">. Error number <" << errno << ">");
49  exit(EINVAL);
50  }
51  }
52 
53  // Read agent parameters from config file and arguments
54  params.Init(init_file, argv[0]);
55 
56  // Initialize TBB
57  // Call to GetScheduler::GetInstance() will also create Task Scheduler
58  TaskScheduler::Initialize(params.tbb_thread_count());
59 
60  // Initialize the agent-init control class
62  Agent *agent = init.agent();
63 
64  MiscUtils::LogVersionInfo(BuildInfo, Category::VROUTER);
65 
66  init.set_agent_param(&params);
67 
68  // kick start initialization
69  int ret = 0;
70  if ((ret = init.Start()) != 0) {
71  return ret;
72  }
73 
74  agent->event_manager()->Run();
75 
76  return 0;
77 }
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
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:478
void RouterIdDepInit(Agent *agent)
#define LOG(_Level, _Msg)
Definition: logging.h:33
void init()
Definition: bgp_log.cc:37
const std::string BuildInfo