LCOV - code coverage report
Current view: top level - vnsw/agent/cfg - cfg_init.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 170 172 98.8 %
Date: 2026-11-09 02:10:49 Functions: 8 9 88.9 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : 
      42             : void IFMapAgentSandeshInit(DB *, IFMapAgentParser *);
      43             : 
      44             : SandeshTraceBufferPtr CfgTraceBuf(SandeshTraceBufferCreate("Config", 2000));
      45             : 
      46           2 : AgentConfig::AgentConfig(Agent *agent)
      47           2 :         : agent_(agent) {
      48           2 :     cfg_filter_ = std::unique_ptr<CfgFilter>(new CfgFilter(this));
      49             : 
      50           2 :     cfg_graph_ = std::unique_ptr<DBGraph>(new DBGraph());
      51           2 :     cfg_mirror_table_ = std::unique_ptr<MirrorCfgTable>(new MirrorCfgTable(this));
      52           2 :     agent_->set_mirror_cfg_table(cfg_mirror_table_.get());
      53             : 
      54           4 :     cfg_intf_mirror_table_ = std::unique_ptr<IntfMirrorCfgTable>
      55           4 :        (new IntfMirrorCfgTable(this));
      56           2 :     agent_->set_interface_mirror_cfg_table(cfg_intf_mirror_table_.get());
      57           2 : }
      58             : 
      59           4 : AgentConfig::~AgentConfig() {
      60           2 :     cfg_filter_.reset();
      61           2 :     cfg_parser_.reset();
      62           2 :     cfg_graph_.reset();
      63           2 :     cfg_mirror_table_.reset();
      64           2 :     cfg_intf_mirror_table_.reset();
      65           4 : }
      66             : 
      67           2 : void AgentConfig::CreateDBTables(DB *db) {
      68             :     // Create parser once we know the db
      69           2 :     cfg_parser_ = std::unique_ptr<IFMapAgentParser>(new IFMapAgentParser(db));
      70           2 :     vnc_cfg_Agent_ModuleInit(db, cfg_graph_.get());
      71           2 :     vnc_cfg_Agent_ParserInit(db, cfg_parser_.get());
      72           2 :     bgp_schema_Agent_ModuleInit(db, cfg_graph_.get());
      73           2 :     bgp_schema_Agent_ParserInit(db, cfg_parser_.get());
      74           2 :     IFMapAgentLinkTable_Init(db, cfg_graph_.get());
      75           2 :     agent_->set_ifmap_parser(cfg_parser_.get());
      76             :     IFMapAgentStaleCleaner *cl =
      77           2 :         new IFMapAgentStaleCleaner(db, cfg_graph_.get());
      78           2 :     agent_->set_ifmap_stale_cleaner(cl);
      79             : 
      80           2 :     IFMapAgentSandeshInit(db, cfg_parser_.get());
      81           2 : }
      82             : 
      83           0 : void AgentConfig::Register(const char *node_name, AgentDBTable *table,
      84             :                            int need_property_id) {
      85           0 : }
      86             : 
      87           2 : void AgentConfig::RegisterDBClients(DB *db) {
      88             : 
      89           2 :     cfg_vm_interface_table_ = (static_cast<IFMapAgentTable *>
      90           2 :         (IFMapTable::FindTable(agent_->db(), "virtual-machine-interface")));
      91           2 :     assert(cfg_vm_interface_table_);
      92             : 
      93           2 :     cfg_acl_table_ = (static_cast<IFMapAgentTable *>
      94           2 :         (IFMapTable::FindTable(agent_->db(), "access-control-list")));
      95           2 :     assert(cfg_acl_table_);
      96             : 
      97           2 :     cfg_vm_table_ = (static_cast<IFMapAgentTable *>
      98           2 :         (IFMapTable::FindTable(agent_->db(), "virtual-machine")));
      99           2 :     assert(cfg_vm_table_);
     100             : 
     101           2 :     cfg_vn_table_ = (static_cast<IFMapAgentTable *>
     102           2 :         (IFMapTable::FindTable(agent_->db(), "virtual-network")));
     103           2 :     assert(cfg_vn_table_);
     104             : 
     105           2 :     cfg_sg_table_ = (static_cast<IFMapAgentTable *>
     106           2 :         (IFMapTable::FindTable(agent_->db(), "security-group")));
     107           2 :     assert(cfg_sg_table_);
     108             : 
     109           2 :     cfg_vrf_table_ = (static_cast<IFMapAgentTable *>
     110           2 :         (IFMapTable::FindTable(agent_->db(), "routing-instance")));
     111           2 :     assert(cfg_vrf_table_);
     112             : 
     113           2 :     cfg_instanceip_table_ = (static_cast<IFMapAgentTable *>
     114           2 :         (IFMapTable::FindTable(agent_->db(), "instance-ip")));
     115           2 :     assert(cfg_instanceip_table_);
     116             : 
     117           2 :     cfg_floatingip_table_ = (static_cast<IFMapAgentTable *>
     118           2 :         (IFMapTable::FindTable(agent_->db(), "floating-ip")));
     119           2 :     assert(cfg_floatingip_table_);
     120             : 
     121           2 :     cfg_aliasip_table_ = (static_cast<IFMapAgentTable *>
     122           2 :         (IFMapTable::FindTable(agent_->db(), "alias-ip")));
     123           2 :     assert(cfg_aliasip_table_);
     124             : 
     125           2 :     cfg_floatingip_pool_table_ = (static_cast<IFMapAgentTable *>
     126           2 :         (IFMapTable::FindTable(agent_->db(), "floating-ip-pool")));
     127           2 :     assert(cfg_floatingip_pool_table_);
     128             : 
     129           2 :     cfg_aliasip_pool_table_ = (static_cast<IFMapAgentTable *>
     130           2 :         (IFMapTable::FindTable(agent_->db(), "alias-ip-pool")));
     131           2 :     assert(cfg_aliasip_pool_table_);
     132             : 
     133           2 :     cfg_network_ipam_table_ = (static_cast<IFMapAgentTable *>
     134           2 :         (IFMapTable::FindTable(agent_->db(), "network-ipam")));
     135           2 :     assert(cfg_network_ipam_table_);
     136             : 
     137           2 :     cfg_vn_network_ipam_table_ = (static_cast<IFMapAgentTable *>
     138           2 :         (IFMapTable::FindTable(agent_->db(),
     139             :                                "virtual-network-network-ipam")));
     140           2 :     assert(cfg_vn_network_ipam_table_);
     141             : 
     142           2 :     cfg_vm_port_vrf_table_ = (static_cast<IFMapAgentTable *>
     143           2 :         (IFMapTable::FindTable(agent_->db(),
     144             :                                "virtual-machine-interface-routing-instance")));
     145           2 :     assert(cfg_vm_port_vrf_table_);
     146             : 
     147           2 :     cfg_route_table_ = (static_cast<IFMapAgentTable *>
     148           2 :          (IFMapTable::FindTable(agent_->db(),
     149             :                                "interface-route-table")));
     150           2 :     assert(cfg_route_table_);
     151             : 
     152           2 :     cfg_service_instance_table_ = (static_cast<IFMapAgentTable *>
     153           2 :          (IFMapTable::FindTable(agent_->db(),
     154             :                                "service_instance")));
     155           2 :     assert(cfg_service_instance_table_);
     156             : 
     157           2 :     cfg_service_template_table_ = (static_cast<IFMapAgentTable *>
     158           2 :          (IFMapTable::FindTable(agent_->db(),
     159             :                                "service-template")));
     160           2 :     assert(cfg_service_template_table_);
     161             : 
     162           2 :     cfg_security_group_table_ = (static_cast<IFMapAgentTable *>
     163           2 :          (IFMapTable::FindTable(agent_->db(),
     164             :                                "security_group")));
     165           2 :     assert(cfg_security_group_table_);
     166             : 
     167           2 :     cfg_subnet_table_ = (static_cast<IFMapAgentTable *>
     168           2 :                     (IFMapTable::FindTable(agent_->db(),
     169             :                       "subnet")));
     170           2 :     assert(cfg_route_table_);
     171             : 
     172           2 :     cfg_logical_port_table_ = (static_cast<IFMapAgentTable *>
     173           2 :                                 (IFMapTable::FindTable(agent_->db(),
     174             :                                                        "logical-interface")));
     175           2 :     assert(cfg_logical_port_table_);
     176             : 
     177           2 :     cfg_physical_device_table_ = (static_cast<IFMapAgentTable *>
     178           2 :                                 (IFMapTable::FindTable(agent_->db(),
     179             :                                                        "physical-router")));
     180           2 :     assert(cfg_physical_device_table_);
     181             : 
     182           2 :     cfg_health_check_table_ = (static_cast<IFMapAgentTable *>
     183           2 :                                 (IFMapTable::FindTable(agent_->db(),
     184             :                                                        "service-health-check")));
     185           2 :     assert(cfg_health_check_table_);
     186             : 
     187           2 :     cfg_qos_table_ = (static_cast<IFMapAgentTable *>
     188           2 :                       (IFMapTable::FindTable(agent_->db(),
     189             :                                              "qos-config")));
     190           2 :     assert(cfg_qos_table_);
     191             : 
     192           2 :     cfg_global_qos_table_ = (static_cast<IFMapAgentTable *>
     193           2 :                             (IFMapTable::FindTable(agent_->db(),
     194             :                                                    "global-qos-config")));
     195           2 :     assert(cfg_global_qos_table_);
     196             : 
     197           2 :     cfg_qos_queue_table_ = (static_cast<IFMapAgentTable *>
     198           2 :                             (IFMapTable::FindTable(agent_->db(),
     199             :                                                    "qos-queue")));
     200           2 :     assert(cfg_qos_queue_table_);
     201             : 
     202           2 :     cfg_forwarding_class_table_ = (static_cast<IFMapAgentTable *>
     203           2 :                             (IFMapTable::FindTable(agent_->db(),
     204             :                                                    "forwarding-class")));
     205           2 :     assert(cfg_forwarding_class_table_);
     206             : 
     207           2 :     cfg_bridge_domain_table_ = (static_cast<IFMapAgentTable *>
     208           2 :                                (IFMapTable::FindTable(agent_->db(),
     209             :                                                       "bridge-domain")));
     210           2 :     assert(cfg_bridge_domain_table_);
     211             : 
     212           2 :     cfg_vm_port_bridge_domain_table_ = (static_cast<IFMapAgentTable *>
     213           2 :                              (IFMapTable::FindTable(agent_->db(),
     214             :                                    "virtual-machine-interface-bridge-domain")));
     215           2 :     assert(cfg_vm_port_bridge_domain_table_);
     216             : 
     217           2 :     cfg_policy_set_table_ = (static_cast<IFMapAgentTable *>
     218           2 :                             (IFMapTable::FindTable(agent_->db(),
     219             :                                                    "application-policy-set")));
     220           2 :     assert(cfg_policy_set_table_);
     221             : 
     222           2 :     cfg_firewall_policy_table_ = (static_cast<IFMapAgentTable *>
     223           2 :                                  (IFMapTable::FindTable(agent_->db(),
     224             :                                                         "firewall-policy")));
     225           2 :     assert(cfg_firewall_policy_table_);
     226             : 
     227           2 :     cfg_firewall_rule_table_ = (static_cast<IFMapAgentTable *>
     228           2 :                                (IFMapTable::FindTable(agent_->db(),
     229             :                                                       "firewall-rule")));
     230           2 :     assert(cfg_firewall_rule_table_);
     231             : 
     232           2 :     cfg_service_group_table_ = (static_cast<IFMapAgentTable *>
     233           2 :                                (IFMapTable::FindTable(agent_->db(),
     234             :                                                       "service-group")));
     235           2 :     assert(cfg_service_group_table_);
     236             : 
     237           2 :     cfg_address_group_table_ = (static_cast<IFMapAgentTable *>
     238           2 :                                (IFMapTable::FindTable(agent_->db(),
     239             :                                                       "address-group")));
     240           2 :     assert(cfg_address_group_table_);
     241             : 
     242           2 :     cfg_firewall_policy_firewall_rule_table_ =
     243           2 :         (static_cast<IFMapAgentTable *>(IFMapTable::FindTable(agent_->db(),
     244             :                                         "firewall-policy-firewall-rule")));
     245           2 :     assert(cfg_firewall_policy_firewall_rule_table_);
     246             : 
     247           2 :     cfg_tag_table_ =
     248           2 :         (static_cast<IFMapAgentTable *>(IFMapTable::FindTable(agent_->db(),
     249             :                                                               "tag")));
     250           2 :     assert(cfg_tag_table_);
     251             : 
     252           2 :     cfg_policy_set_firewall_policy_table_ =
     253           2 :         (static_cast<IFMapAgentTable *>(IFMapTable::FindTable(agent_->db(),
     254             :                                   "application-policy-set-firewall-policy")));
     255           2 :     assert(cfg_policy_set_firewall_policy_table_);
     256             : 
     257           2 :     cfg_policy_management_table_ = (static_cast<IFMapAgentTable *>(
     258           2 :                 IFMapTable::FindTable(agent_->db(), "policy-management")));
     259           2 :     assert(cfg_policy_management_table_);
     260             : 
     261           2 :     cfg_project_table_ =
     262           2 :         (static_cast<IFMapAgentTable *>(IFMapTable::FindTable(agent_->db(),
     263             :                                                               "project")));
     264           2 :     assert(cfg_project_table_);
     265             : 
     266           2 :     cfg_slo_table_ = (static_cast<IFMapAgentTable *>
     267           2 :                             (IFMapTable::FindTable(agent_->db(),
     268             :                                                    "security-logging-object")));
     269           2 :     assert(cfg_slo_table_);
     270             : 
     271           2 :     cfg_port_tuple_table_ = (static_cast<IFMapAgentTable *>
     272           2 :                             (IFMapTable::FindTable(agent_->db(),
     273             :                                                    "port-tuple")));
     274           2 :     assert(cfg_port_tuple_table_);
     275             : 
     276           2 :     cfg_multicast_policy_table_ = (static_cast<IFMapAgentTable *>
     277           2 :                                 (IFMapTable::FindTable(agent_->db(),
     278             :                                         "multicast-policy")));
     279           2 :     assert(cfg_multicast_policy_table_);
     280           2 : }
     281             : 
     282           2 : void AgentConfig::Init() {
     283           2 :     cfg_filter_->Init();
     284           2 :     cfg_mirror_table_->Init();
     285           2 :     cfg_intf_mirror_table_->Init();
     286           2 : }
     287             : 
     288           2 : void AgentConfig::InitDone() {
     289           2 : }
     290             : 
     291           2 : void AgentConfig::Shutdown() {
     292           2 :     cfg_filter_->Shutdown();
     293             : 
     294           2 :     cfg_mirror_table_->Shutdown();
     295           2 :     cfg_intf_mirror_table_->Shutdown();
     296             : 
     297           2 :     agent_->set_ifmap_parser(NULL);
     298             : 
     299           2 :     agent_->ifmap_stale_cleaner()->Clear();
     300           2 :     delete agent_->ifmap_stale_cleaner();
     301           2 :     agent_->set_ifmap_stale_cleaner(NULL);
     302           2 : }

Generated by: LCOV version 1.14