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

Generated by: LCOV version 1.14