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

Generated by: LCOV version 1.14