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

Generated by: LCOV version 1.14