OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cfg_init.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 #include <cmn/agent_cmn.h>
5 
6 #include <boost/property_tree/xml_parser.hpp>
7 #include <db/db_graph.h>
8 
9 #include <cmn/agent.h>
10 #include <cmn/agent_db.h>
11 
12 #include <bgp_schema_types.h>
13 
14 #include <cfg/cfg_init.h>
15 #include <cfg/cfg_filter.h>
16 #include <cfg/cfg_mirror.h>
17 
18 #include <oper/vn.h>
19 #include <oper/sg.h>
20 #include <oper/vm.h>
21 #include <oper/vrf.h>
22 #include <oper/nexthop.h>
23 #include <oper/interface_common.h>
24 #include <oper/mirror_table.h>
25 #include <oper/route_common.h>
26 #include <oper/operdb_init.h>
27 #include <oper/global_vrouter.h>
28 #include <oper/service_instance.h>
29 #include <oper/physical_device.h>
30 
31 #include <vgw/cfg_vgw.h>
32 #include <vgw/vgw.h>
33 #include <filter/acl.h>
34 
35 using namespace std;
36 using namespace autogen;
37 using namespace boost::property_tree;
38 using namespace boost::uuids;
39 using boost::optional;
40 
42 
44 
46  : agent_(agent) {
47  cfg_filter_ = std::unique_ptr<CfgFilter>(new CfgFilter(this));
48 
49  cfg_graph_ = std::unique_ptr<DBGraph>(new DBGraph());
50  cfg_mirror_table_ = std::unique_ptr<MirrorCfgTable>(new MirrorCfgTable(this));
51  agent_->set_mirror_cfg_table(cfg_mirror_table_.get());
52 
53  cfg_intf_mirror_table_ = std::unique_ptr<IntfMirrorCfgTable>
54  (new IntfMirrorCfgTable(this));
56 }
57 
59  cfg_filter_.reset();
60  cfg_parser_.reset();
61  cfg_graph_.reset();
62  cfg_mirror_table_.reset();
63  cfg_intf_mirror_table_.reset();
64 }
65 
67  // Create parser once we know the db
68  cfg_parser_ = std::unique_ptr<IFMapAgentParser>(new IFMapAgentParser(db));
69  vnc_cfg_Agent_ModuleInit(db, cfg_graph_.get());
70  vnc_cfg_Agent_ParserInit(db, cfg_parser_.get());
71  bgp_schema_Agent_ModuleInit(db, cfg_graph_.get());
72  bgp_schema_Agent_ParserInit(db, cfg_parser_.get());
76  new IFMapAgentStaleCleaner(db, cfg_graph_.get());
78 
80 }
81 
82 void AgentConfig::Register(const char *node_name, AgentDBTable *table,
83  int need_property_id) {
84 }
85 
87 
89  (IFMapTable::FindTable(agent_->db(), "virtual-machine-interface")));
91 
92  cfg_acl_table_ = (static_cast<IFMapAgentTable *>
93  (IFMapTable::FindTable(agent_->db(), "access-control-list")));
94  assert(cfg_acl_table_);
95 
96  cfg_vm_table_ = (static_cast<IFMapAgentTable *>
97  (IFMapTable::FindTable(agent_->db(), "virtual-machine")));
98  assert(cfg_vm_table_);
99 
100  cfg_vn_table_ = (static_cast<IFMapAgentTable *>
101  (IFMapTable::FindTable(agent_->db(), "virtual-network")));
102  assert(cfg_vn_table_);
103 
104  cfg_sg_table_ = (static_cast<IFMapAgentTable *>
105  (IFMapTable::FindTable(agent_->db(), "security-group")));
106  assert(cfg_sg_table_);
107 
108  cfg_vrf_table_ = (static_cast<IFMapAgentTable *>
109  (IFMapTable::FindTable(agent_->db(), "routing-instance")));
110  assert(cfg_vrf_table_);
111 
112  cfg_instanceip_table_ = (static_cast<IFMapAgentTable *>
113  (IFMapTable::FindTable(agent_->db(), "instance-ip")));
114  assert(cfg_instanceip_table_);
115 
116  cfg_floatingip_table_ = (static_cast<IFMapAgentTable *>
117  (IFMapTable::FindTable(agent_->db(), "floating-ip")));
118  assert(cfg_floatingip_table_);
119 
120  cfg_aliasip_table_ = (static_cast<IFMapAgentTable *>
121  (IFMapTable::FindTable(agent_->db(), "alias-ip")));
122  assert(cfg_aliasip_table_);
123 
125  (IFMapTable::FindTable(agent_->db(), "floating-ip-pool")));
127 
128  cfg_aliasip_pool_table_ = (static_cast<IFMapAgentTable *>
129  (IFMapTable::FindTable(agent_->db(), "alias-ip-pool")));
130  assert(cfg_aliasip_pool_table_);
131 
132  cfg_network_ipam_table_ = (static_cast<IFMapAgentTable *>
133  (IFMapTable::FindTable(agent_->db(), "network-ipam")));
134  assert(cfg_network_ipam_table_);
135 
138  "virtual-network-network-ipam")));
140 
141  cfg_vm_port_vrf_table_ = (static_cast<IFMapAgentTable *>
143  "virtual-machine-interface-routing-instance")));
144  assert(cfg_vm_port_vrf_table_);
145 
146  cfg_route_table_ = (static_cast<IFMapAgentTable *>
148  "interface-route-table")));
149  assert(cfg_route_table_);
150 
153  "service_instance")));
155 
158  "service-template")));
160 
163  "security_group")));
165 
166  cfg_subnet_table_ = (static_cast<IFMapAgentTable *>
168  "subnet")));
169  assert(cfg_route_table_);
170 
171  cfg_logical_port_table_ = (static_cast<IFMapAgentTable *>
173  "logical-interface")));
174  assert(cfg_logical_port_table_);
175 
178  "physical-router")));
180 
181  cfg_health_check_table_ = (static_cast<IFMapAgentTable *>
183  "service-health-check")));
184  assert(cfg_health_check_table_);
185 
186  cfg_qos_table_ = (static_cast<IFMapAgentTable *>
188  "qos-config")));
189  assert(cfg_qos_table_);
190 
191  cfg_global_qos_table_ = (static_cast<IFMapAgentTable *>
193  "global-qos-config")));
194  assert(cfg_global_qos_table_);
195 
196  cfg_qos_queue_table_ = (static_cast<IFMapAgentTable *>
198  "qos-queue")));
199  assert(cfg_qos_queue_table_);
200 
203  "forwarding-class")));
205 
206  cfg_bridge_domain_table_ = (static_cast<IFMapAgentTable *>
208  "bridge-domain")));
209  assert(cfg_bridge_domain_table_);
210 
213  "virtual-machine-interface-bridge-domain")));
215 
216  cfg_policy_set_table_ = (static_cast<IFMapAgentTable *>
218  "application-policy-set")));
219  assert(cfg_policy_set_table_);
220 
223  "firewall-policy")));
225 
226  cfg_firewall_rule_table_ = (static_cast<IFMapAgentTable *>
228  "firewall-rule")));
229  assert(cfg_firewall_rule_table_);
230 
231  cfg_service_group_table_ = (static_cast<IFMapAgentTable *>
233  "service-group")));
234  assert(cfg_service_group_table_);
235 
236  cfg_address_group_table_ = (static_cast<IFMapAgentTable *>
238  "address-group")));
239  assert(cfg_address_group_table_);
240 
242  (static_cast<IFMapAgentTable *>(IFMapTable::FindTable(agent_->db(),
243  "firewall-policy-firewall-rule")));
245 
247  (static_cast<IFMapAgentTable *>(IFMapTable::FindTable(agent_->db(),
248  "tag")));
249  assert(cfg_tag_table_);
250 
252  (static_cast<IFMapAgentTable *>(IFMapTable::FindTable(agent_->db(),
253  "application-policy-set-firewall-policy")));
255 
257  IFMapTable::FindTable(agent_->db(), "policy-management")));
259 
261  (static_cast<IFMapAgentTable *>(IFMapTable::FindTable(agent_->db(),
262  "project")));
263  assert(cfg_project_table_);
264 
265  cfg_slo_table_ = (static_cast<IFMapAgentTable *>
267  "security-logging-object")));
268  assert(cfg_slo_table_);
269 
270  cfg_port_tuple_table_ = (static_cast<IFMapAgentTable *>
272  "port-tuple")));
273  assert(cfg_port_tuple_table_);
274 
277  "multicast-policy")));
279 }
280 
282  cfg_filter_->Init();
283  cfg_mirror_table_->Init();
284  cfg_intf_mirror_table_->Init();
285 }
286 
288 }
289 
291  cfg_filter_->Shutdown();
292 
293  cfg_mirror_table_->Shutdown();
294  cfg_intf_mirror_table_->Shutdown();
295 
296  agent_->set_ifmap_parser(NULL);
297 
299  delete agent_->ifmap_stale_cleaner();
301 }
IFMapAgentTable * cfg_project_table_
Definition: cfg_init.h:228
IFMapAgentTable * cfg_aliasip_table_
Definition: cfg_init.h:197
IFMapAgentTable * cfg_qos_table_
Definition: cfg_init.h:213
IFMapAgentTable * cfg_service_template_table_
Definition: cfg_init.h:204
IFMapAgentTable * cfg_vn_network_ipam_table_
Definition: cfg_init.h:201
void IFMapAgentLinkTable_Init(DB *db, DBGraph *graph)
IFMapAgentTable * cfg_port_tuple_table_
Definition: cfg_init.h:230
IFMapAgentTable * cfg_instanceip_table_
Definition: cfg_init.h:195
void CreateDBTables(DB *db)
Definition: cfg_init.cc:66
std::unique_ptr< IntfMirrorCfgTable > cfg_intf_mirror_table_
Definition: cfg_init.h:185
IFMapAgentTable * cfg_vm_port_bridge_domain_table_
Definition: cfg_init.h:218
void set_interface_mirror_cfg_table(IntfMirrorCfgTable *table)
Definition: agent.h:574
IFMapAgentTable * cfg_physical_device_table_
Definition: cfg_init.h:211
DB * db() const
Definition: agent.h:1118
IFMapAgentTable * cfg_bridge_domain_table_
Definition: cfg_init.h:217
void set_ifmap_stale_cleaner(IFMapAgentStaleCleaner *cl)
Definition: agent.h:1180
IFMapAgentTable * cfg_floatingip_table_
Definition: cfg_init.h:196
IFMapAgentTable * cfg_aliasip_pool_table_
Definition: cfg_init.h:199
void set_mirror_cfg_table(MirrorCfgTable *table)
Definition: agent.h:471
IFMapAgentTable * cfg_slo_table_
Definition: cfg_init.h:229
void set_ifmap_parser(IFMapAgentParser *parser)
Definition: agent.h:1173
IFMapAgentTable * cfg_qos_queue_table_
Definition: cfg_init.h:215
virtual ~AgentConfig()
Definition: cfg_init.cc:58
IFMapAgentTable * cfg_forwarding_class_table_
Definition: cfg_init.h:216
boost::shared_ptr< TraceBuffer< SandeshTrace > > SandeshTraceBufferPtr
Definition: sandesh_trace.h:18
IFMapAgentTable * cfg_firewall_policy_table_
Definition: cfg_init.h:220
IFMapAgentTable * cfg_policy_set_firewall_policy_table_
Definition: cfg_init.h:226
IFMapAgentTable * cfg_logical_port_table_
Definition: cfg_init.h:206
std::unique_ptr< CfgFilter > cfg_filter_
Definition: cfg_init.h:181
IFMapAgentTable * cfg_vm_table_
Definition: cfg_init.h:190
IFMapAgentTable * cfg_firewall_policy_firewall_rule_table_
Definition: cfg_init.h:224
Definition: db.h:24
IFMapAgentTable * cfg_vm_port_vrf_table_
Definition: cfg_init.h:202
IFMapAgentTable * cfg_network_ipam_table_
Definition: cfg_init.h:200
IFMapAgentTable * cfg_service_instance_table_
Definition: cfg_init.h:209
IFMapAgentTable * cfg_address_group_table_
Definition: cfg_init.h:223
std::unique_ptr< DBGraph > cfg_graph_
Definition: cfg_init.h:183
Agent * agent_
Definition: cfg_init.h:180
Definition: agent.h:358
IFMapAgentTable * cfg_route_table_
Definition: cfg_init.h:203
IFMapAgentTable * cfg_multicast_policy_table_
Definition: cfg_init.h:231
IFMapAgentTable * cfg_service_group_table_
Definition: cfg_init.h:222
IFMapAgentTable * cfg_subnet_table_
Definition: cfg_init.h:205
AgentConfig(Agent *agent)
Definition: cfg_init.cc:45
IFMapAgentTable * cfg_sg_table_
Definition: cfg_init.h:192
IFMapAgentTable * cfg_policy_management_table_
Definition: cfg_init.h:227
void RegisterDBClients(DB *db)
Definition: cfg_init.cc:86
IFMapAgentStaleCleaner * ifmap_stale_cleaner() const
Definition: agent.h:1177
IFMapAgentTable * cfg_acl_table_
Definition: cfg_init.h:193
IFMapAgentTable * cfg_policy_set_table_
Definition: cfg_init.h:219
IFMapAgentTable * cfg_firewall_rule_table_
Definition: cfg_init.h:221
IFMapAgentTable * cfg_health_check_table_
Definition: cfg_init.h:212
void IFMapAgentSandeshInit(DB *db, IFMapAgentParser *parser)
void InitDone()
Definition: cfg_init.cc:287
IFMapAgentTable * cfg_global_qos_table_
Definition: cfg_init.h:214
IFMapAgentTable * cfg_vm_interface_table_
Definition: cfg_init.h:189
static IFMapTable * FindTable(DB *db, const std::string &element_type)
Definition: ifmap_table.cc:39
SandeshTraceBufferPtr CfgTraceBuf
void Init()
Definition: cfg_init.cc:281
IFMapAgentTable * cfg_security_group_table_
Definition: cfg_init.h:210
void Register(const char *node_name, AgentDBTable *table, int need_property_id)
Definition: cfg_init.cc:82
IFMapAgentTable * cfg_floatingip_pool_table_
Definition: cfg_init.h:198
std::unique_ptr< MirrorCfgTable > cfg_mirror_table_
Definition: cfg_init.h:184
void Shutdown()
Definition: cfg_init.cc:290
IFMapAgentTable * cfg_vrf_table_
Definition: cfg_init.h:194
IFMapAgentTable * cfg_tag_table_
Definition: cfg_init.h:225
IFMapAgentTable * cfg_vn_table_
Definition: cfg_init.h:191
std::unique_ptr< IFMapAgentParser > cfg_parser_
Definition: cfg_init.h:182
SandeshTraceBufferPtr SandeshTraceBufferCreate(const std::string &buf_name, size_t buf_size, bool trace_enable=true)
Definition: sandesh_trace.h:46