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