OpenSDN source code
cfg_init.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 <cmn/agent_cmn.h>
6 
7 #include <boost/property_tree/xml_parser.hpp>
8 #include <db/db_graph.h>
9 
10 #include <cmn/agent.h>
11 #include <cmn/agent_db.h>
12 
13 #include <bgp_schema_types.h>
14 
15 #include <cfg/cfg_init.h>
16 #include <cfg/cfg_filter.h>
17 #include <cfg/cfg_mirror.h>
18 
19 #include <oper/vn.h>
20 #include <oper/sg.h>
21 #include <oper/vm.h>
22 #include <oper/vrf.h>
23 #include <oper/nexthop.h>
24 #include <oper/interface_common.h>
25 #include <oper/mirror_table.h>
26 #include <oper/route_common.h>
27 #include <oper/operdb_init.h>
28 #include <oper/global_vrouter.h>
29 #include <oper/service_instance.h>
30 #include <oper/physical_device.h>
31 
32 #include <vgw/cfg_vgw.h>
33 #include <vgw/vgw.h>
34 #include <filter/acl.h>
35 
36 using namespace std;
37 using namespace autogen;
38 using namespace boost::property_tree;
39 using namespace boost::uuids;
40 using boost::optional;
41 
43 
45 
47  : agent_(agent) {
48  cfg_filter_ = std::unique_ptr<CfgFilter>(new CfgFilter(this));
49 
50  cfg_graph_ = std::unique_ptr<DBGraph>(new DBGraph());
51  cfg_mirror_table_ = std::unique_ptr<MirrorCfgTable>(new MirrorCfgTable(this));
53 
54  cfg_intf_mirror_table_ = std::unique_ptr<IntfMirrorCfgTable>
55  (new IntfMirrorCfgTable(this));
57 }
58 
60  cfg_filter_.reset();
61  cfg_parser_.reset();
62  cfg_graph_.reset();
63  cfg_mirror_table_.reset();
64  cfg_intf_mirror_table_.reset();
65 }
66 
68  // Create parser once we know the db
69  cfg_parser_ = std::unique_ptr<IFMapAgentParser>(new IFMapAgentParser(db));
70  vnc_cfg_Agent_ModuleInit(db, cfg_graph_.get());
71  vnc_cfg_Agent_ParserInit(db, cfg_parser_.get());
72  bgp_schema_Agent_ModuleInit(db, cfg_graph_.get());
73  bgp_schema_Agent_ParserInit(db, cfg_parser_.get());
77  new IFMapAgentStaleCleaner(db, cfg_graph_.get());
79 
81 }
82 
83 void AgentConfig::Register(const char *node_name, AgentDBTable *table,
84  int need_property_id) {
85 }
86 
88 
90  (IFMapTable::FindTable(agent_->db(), "virtual-machine-interface")));
92 
93  cfg_acl_table_ = (static_cast<IFMapAgentTable *>
94  (IFMapTable::FindTable(agent_->db(), "access-control-list")));
95  assert(cfg_acl_table_);
96 
97  cfg_vm_table_ = (static_cast<IFMapAgentTable *>
98  (IFMapTable::FindTable(agent_->db(), "virtual-machine")));
99  assert(cfg_vm_table_);
100 
101  cfg_vn_table_ = (static_cast<IFMapAgentTable *>
102  (IFMapTable::FindTable(agent_->db(), "virtual-network")));
103  assert(cfg_vn_table_);
104 
105  cfg_sg_table_ = (static_cast<IFMapAgentTable *>
106  (IFMapTable::FindTable(agent_->db(), "security-group")));
107  assert(cfg_sg_table_);
108 
109  cfg_vrf_table_ = (static_cast<IFMapAgentTable *>
110  (IFMapTable::FindTable(agent_->db(), "routing-instance")));
111  assert(cfg_vrf_table_);
112 
113  cfg_instanceip_table_ = (static_cast<IFMapAgentTable *>
114  (IFMapTable::FindTable(agent_->db(), "instance-ip")));
115  assert(cfg_instanceip_table_);
116 
117  cfg_floatingip_table_ = (static_cast<IFMapAgentTable *>
118  (IFMapTable::FindTable(agent_->db(), "floating-ip")));
119  assert(cfg_floatingip_table_);
120 
121  cfg_aliasip_table_ = (static_cast<IFMapAgentTable *>
122  (IFMapTable::FindTable(agent_->db(), "alias-ip")));
123  assert(cfg_aliasip_table_);
124 
126  (IFMapTable::FindTable(agent_->db(), "floating-ip-pool")));
128 
129  cfg_aliasip_pool_table_ = (static_cast<IFMapAgentTable *>
130  (IFMapTable::FindTable(agent_->db(), "alias-ip-pool")));
131  assert(cfg_aliasip_pool_table_);
132 
133  cfg_network_ipam_table_ = (static_cast<IFMapAgentTable *>
134  (IFMapTable::FindTable(agent_->db(), "network-ipam")));
135  assert(cfg_network_ipam_table_);
136 
139  "virtual-network-network-ipam")));
141 
142  cfg_vm_port_vrf_table_ = (static_cast<IFMapAgentTable *>
144  "virtual-machine-interface-routing-instance")));
145  assert(cfg_vm_port_vrf_table_);
146 
147  cfg_route_table_ = (static_cast<IFMapAgentTable *>
149  "interface-route-table")));
150  assert(cfg_route_table_);
151 
154  "service_instance")));
156 
159  "service-template")));
161 
164  "security_group")));
166 
167  cfg_subnet_table_ = (static_cast<IFMapAgentTable *>
169  "subnet")));
170  assert(cfg_route_table_);
171 
172  cfg_logical_port_table_ = (static_cast<IFMapAgentTable *>
174  "logical-interface")));
175  assert(cfg_logical_port_table_);
176 
179  "physical-router")));
181 
182  cfg_health_check_table_ = (static_cast<IFMapAgentTable *>
184  "service-health-check")));
185  assert(cfg_health_check_table_);
186 
187  cfg_qos_table_ = (static_cast<IFMapAgentTable *>
189  "qos-config")));
190  assert(cfg_qos_table_);
191 
192  cfg_global_qos_table_ = (static_cast<IFMapAgentTable *>
194  "global-qos-config")));
195  assert(cfg_global_qos_table_);
196 
197  cfg_qos_queue_table_ = (static_cast<IFMapAgentTable *>
199  "qos-queue")));
200  assert(cfg_qos_queue_table_);
201 
204  "forwarding-class")));
206 
207  cfg_bridge_domain_table_ = (static_cast<IFMapAgentTable *>
209  "bridge-domain")));
210  assert(cfg_bridge_domain_table_);
211 
214  "virtual-machine-interface-bridge-domain")));
216 
217  cfg_policy_set_table_ = (static_cast<IFMapAgentTable *>
219  "application-policy-set")));
220  assert(cfg_policy_set_table_);
221 
224  "firewall-policy")));
226 
227  cfg_firewall_rule_table_ = (static_cast<IFMapAgentTable *>
229  "firewall-rule")));
230  assert(cfg_firewall_rule_table_);
231 
232  cfg_service_group_table_ = (static_cast<IFMapAgentTable *>
234  "service-group")));
235  assert(cfg_service_group_table_);
236 
237  cfg_address_group_table_ = (static_cast<IFMapAgentTable *>
239  "address-group")));
240  assert(cfg_address_group_table_);
241 
243  (static_cast<IFMapAgentTable *>(IFMapTable::FindTable(agent_->db(),
244  "firewall-policy-firewall-rule")));
246 
248  (static_cast<IFMapAgentTable *>(IFMapTable::FindTable(agent_->db(),
249  "tag")));
250  assert(cfg_tag_table_);
251 
253  (static_cast<IFMapAgentTable *>(IFMapTable::FindTable(agent_->db(),
254  "application-policy-set-firewall-policy")));
256 
258  IFMapTable::FindTable(agent_->db(), "policy-management")));
260 
262  (static_cast<IFMapAgentTable *>(IFMapTable::FindTable(agent_->db(),
263  "project")));
264  assert(cfg_project_table_);
265 
266  cfg_slo_table_ = (static_cast<IFMapAgentTable *>
268  "security-logging-object")));
269  assert(cfg_slo_table_);
270 
271  cfg_port_tuple_table_ = (static_cast<IFMapAgentTable *>
273  "port-tuple")));
274  assert(cfg_port_tuple_table_);
275 
278  "multicast-policy")));
280 }
281 
283  cfg_filter_->Init();
284  cfg_mirror_table_->Init();
285  cfg_intf_mirror_table_->Init();
286 }
287 
289 }
290 
292  cfg_filter_->Shutdown();
293 
294  cfg_mirror_table_->Shutdown();
295  cfg_intf_mirror_table_->Shutdown();
296 
297  agent_->set_ifmap_parser(NULL);
298 
300  delete agent_->ifmap_stale_cleaner();
302 }
SandeshTraceBufferPtr CfgTraceBuf(SandeshTraceBufferCreate("Config", 2000))
void IFMapAgentSandeshInit(DB *, IFMapAgentParser *)
IFMapAgentTable * cfg_vm_port_vrf_table_
Definition: cfg_init.h:203
void Shutdown()
Definition: cfg_init.cc:291
IFMapAgentTable * cfg_policy_set_table_
Definition: cfg_init.h:220
IFMapAgentTable * cfg_subnet_table_
Definition: cfg_init.h:206
virtual ~AgentConfig()
Definition: cfg_init.cc:59
IFMapAgentTable * cfg_floatingip_table_
Definition: cfg_init.h:197
IFMapAgentTable * cfg_firewall_rule_table_
Definition: cfg_init.h:222
IFMapAgentTable * cfg_vm_table_
Definition: cfg_init.h:191
IFMapAgentTable * cfg_policy_management_table_
Definition: cfg_init.h:228
IFMapAgentTable * cfg_acl_table_
Definition: cfg_init.h:194
IFMapAgentTable * cfg_tag_table_
Definition: cfg_init.h:226
std::unique_ptr< DBGraph > cfg_graph_
Definition: cfg_init.h:184
IFMapAgentTable * cfg_bridge_domain_table_
Definition: cfg_init.h:218
void Register(const char *node_name, AgentDBTable *table, int need_property_id)
Definition: cfg_init.cc:83
IFMapAgentTable * cfg_service_instance_table_
Definition: cfg_init.h:210
IFMapAgentTable * cfg_vrf_table_
Definition: cfg_init.h:195
IFMapAgentTable * cfg_vn_table_
Definition: cfg_init.h:192
std::unique_ptr< IFMapAgentParser > cfg_parser_
Definition: cfg_init.h:183
std::unique_ptr< IntfMirrorCfgTable > cfg_intf_mirror_table_
Definition: cfg_init.h:186
IFMapAgentTable * cfg_service_group_table_
Definition: cfg_init.h:223
IFMapAgentTable * cfg_vm_interface_table_
Definition: cfg_init.h:190
void RegisterDBClients(DB *db)
Definition: cfg_init.cc:87
IFMapAgentTable * cfg_slo_table_
Definition: cfg_init.h:230
IFMapAgentTable * cfg_instanceip_table_
Definition: cfg_init.h:196
IFMapAgentTable * cfg_route_table_
Definition: cfg_init.h:204
IFMapAgentTable * cfg_qos_table_
Definition: cfg_init.h:214
IFMapAgentTable * cfg_forwarding_class_table_
Definition: cfg_init.h:217
IFMapAgentTable * cfg_policy_set_firewall_policy_table_
Definition: cfg_init.h:227
IFMapAgentTable * cfg_aliasip_table_
Definition: cfg_init.h:198
IFMapAgentTable * cfg_firewall_policy_table_
Definition: cfg_init.h:221
IFMapAgentTable * cfg_network_ipam_table_
Definition: cfg_init.h:201
std::unique_ptr< MirrorCfgTable > cfg_mirror_table_
Definition: cfg_init.h:185
IFMapAgentTable * cfg_global_qos_table_
Definition: cfg_init.h:215
IFMapAgentTable * cfg_multicast_policy_table_
Definition: cfg_init.h:232
IFMapAgentTable * cfg_security_group_table_
Definition: cfg_init.h:211
IFMapAgentTable * cfg_floatingip_pool_table_
Definition: cfg_init.h:199
std::unique_ptr< CfgFilter > cfg_filter_
Definition: cfg_init.h:182
IFMapAgentTable * cfg_sg_table_
Definition: cfg_init.h:193
IFMapAgentTable * cfg_aliasip_pool_table_
Definition: cfg_init.h:200
IFMapAgentTable * cfg_vm_port_bridge_domain_table_
Definition: cfg_init.h:219
void InitDone()
Definition: cfg_init.cc:288
IFMapAgentTable * cfg_logical_port_table_
Definition: cfg_init.h:207
IFMapAgentTable * cfg_firewall_policy_firewall_rule_table_
Definition: cfg_init.h:225
void CreateDBTables(DB *db)
Definition: cfg_init.cc:67
Agent * agent_
Definition: cfg_init.h:181
IFMapAgentTable * cfg_address_group_table_
Definition: cfg_init.h:224
AgentConfig(Agent *agent)
Definition: cfg_init.cc:46
IFMapAgentTable * cfg_port_tuple_table_
Definition: cfg_init.h:231
void Init()
Definition: cfg_init.cc:282
IFMapAgentTable * cfg_health_check_table_
Definition: cfg_init.h:213
IFMapAgentTable * cfg_physical_device_table_
Definition: cfg_init.h:212
IFMapAgentTable * cfg_vn_network_ipam_table_
Definition: cfg_init.h:202
IFMapAgentTable * cfg_qos_queue_table_
Definition: cfg_init.h:216
IFMapAgentTable * cfg_service_template_table_
Definition: cfg_init.h:205
IFMapAgentTable * cfg_project_table_
Definition: cfg_init.h:229
Definition: agent.h:361
void set_mirror_cfg_table(MirrorCfgTable *table)
Definition: agent.h:474
IFMapAgentStaleCleaner * ifmap_stale_cleaner() const
Definition: agent.h:1180
void set_ifmap_parser(IFMapAgentParser *parser)
Definition: agent.h:1176
void set_interface_mirror_cfg_table(IntfMirrorCfgTable *table)
Definition: agent.h:577
DB * db() const
Definition: agent.h:1121
void set_ifmap_stale_cleaner(IFMapAgentStaleCleaner *cl)
Definition: agent.h:1183
Definition: db.h:25
static IFMapTable * FindTable(DB *db, const std::string &element_type)
Definition: ifmap_table.cc:40
void IFMapAgentLinkTable_Init(DB *db, DBGraph *graph)
boost::shared_ptr< TraceBuffer< SandeshTrace > > SandeshTraceBufferPtr
Definition: sandesh_trace.h:19
SandeshTraceBufferPtr SandeshTraceBufferCreate(const std::string &buf_name, size_t buf_size, bool trace_enable=true)
Definition: sandesh_trace.h:47