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

Generated by: LCOV version 1.14