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

Generated by: LCOV version 1.14