LCOV - code coverage report
Current view: top level - vnsw/agent/init - agent_init.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 12 28 42.9 %
Date: 2026-11-09 02:10:49 Functions: 12 28 42.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2014 Juniper Networks, Inc. All rights reserved.
       3             :  * Copyright Contributors to the OpenSDN project
       4             :  */
       5             : 
       6             : #ifndef vnsw_agent_init_agent_init_hpp
       7             : #define vnsw_agent_init_agent_init_hpp
       8             : 
       9             : #include <mutex>
      10             : 
      11             : #include <boost/program_options.hpp>
      12             : #include <init/agent_param.h>
      13             : 
      14             : class Agent;
      15             : class AgentParam;
      16             : class DiagTable;
      17             : class ServicesModule;
      18             : class PktModule;
      19             : class ResourceManager;
      20             : 
      21             : // The class to drive agent initialization. Does init of basic modules
      22             : // Daemons should derive from AgentInit class and tune / implement virtual
      23             : // methods
      24             : class AgentInit {
      25             : public:
      26             :     AgentInit();
      27             :     virtual ~AgentInit();
      28             : 
      29         387 :     Agent *agent() const { return agent_.get(); }
      30             : 
      31          36 :     AgentParam *agent_param() const { return agent_param_; }
      32           3 :     void set_agent_param(AgentParam *param) { agent_param_ = param; }
      33             : 
      34             :     // Process options
      35             :     virtual void ProcessOptions
      36             :         (const std::string &config_file, const std::string &program_name);
      37             :     // Platform specific inits
      38             :     void InitPlatform();
      39             : 
      40             :     // Kickstarts initialization
      41             :     virtual int Start(Logging &logging);
      42             : 
      43             :     // Initialize the agent factory based on platform
      44             :     virtual void FactoryInit() = 0;
      45             : 
      46             :     virtual std::string InstanceId();
      47             :     virtual std::string ModuleName();
      48             :     virtual int ModuleType();
      49             :     virtual std::string AgentName();
      50             : 
      51             :     // Init has two set of routines
      52             :     // - *Base routines that provide basic common initialization
      53             :     // - Another set of routines for platform specific initializations
      54             : 
      55             :     // Start method called from DBTable-task context
      56             :     virtual bool InitBase();
      57           3 :     virtual bool Init() { return true; }
      58             : 
      59             :     virtual void InitLoggingBase();
      60           3 :     virtual void InitLogging() { }
      61             : 
      62             :     // Init connection to collector if relavent config present
      63             :     virtual void InitCollectorBase();
      64           3 :     virtual void InitCollector() { }
      65             : 
      66             :     // Create modules. AgentInit creates Config, OperDB and Controller
      67             :     virtual void CreateModulesBase();
      68           0 :     virtual void CreateModules() { }
      69             : 
      70             :     // Create DBTables
      71             :     virtual void CreateDBTablesBase();
      72           3 :     virtual void CreateDBTables() { }
      73             : 
      74             :     // DBTable client registerations
      75             :     virtual void RegisterDBClientsBase();
      76           0 :     virtual void RegisterDBClients() { }
      77             : 
      78             :     // Module specific inits. Called after DBTable and DBTable clients are
      79             :     // created
      80             :     virtual void InitModulesBase();
      81           0 :     virtual void InitModules() { }
      82             : 
      83             :     // Create Route Peers
      84             :     virtual void CreatePeersBase();
      85           3 :     virtual void CreatePeers() { }
      86             : 
      87             :     // Create static VRFs. Fabric VRF is created by default
      88             :     virtual void CreateVrfBase();
      89           0 :     virtual void CreateVrf() { }
      90             : 
      91             :     // Create static nexthops including drop-nh and receive-nh
      92             :     virtual void CreateNextHopsBase();
      93           3 :     virtual void CreateNextHops() { }
      94             : 
      95             :     // Create static interfaces
      96             :     virtual void CreateInterfacesBase();
      97           0 :     virtual void CreateInterfaces() { }
      98             : 
      99             :     // Connect to controller. Should be called after IP address is known
     100             :     // for vhost0 interface
     101             :     virtual void ConnectToControllerBase();
     102           3 :     virtual void ConnectToController() { }
     103             : 
     104             :     virtual void InitDoneBase();
     105           0 :     virtual void InitDone() { }
     106             : 
     107             :     void CreateResourceManager();
     108             :     void SetResourceManagerReady();
     109             :     /////////////////////////////////////////////////////////////////////////
     110             :     // Shutdown routines
     111             :     /////////////////////////////////////////////////////////////////////////
     112             :     virtual void Shutdown();
     113             : 
     114             :     // Shutdown IO operations
     115             :     void IoShutdownBase();
     116           0 :     virtual void IoShutdown() { }
     117             : 
     118             :     // Flush all flows
     119             :     virtual void FlushFlowsBase();
     120           0 :     virtual void FlushFlows() { }
     121             : 
     122             :     // Shutdown VGW
     123             :     virtual void VgwShutdownBase();
     124           3 :     virtual void VgwShutdown() { }
     125             : 
     126             :     // Delete routes
     127             :     virtual void DeleteRoutesBase();
     128           3 :     virtual void DeleteRoutes() { }
     129             : 
     130             :     // Delete other DB Entries
     131             :     virtual void DeleteDBEntriesBase();
     132           0 :     virtual void DeleteDBEntries() { }
     133             : 
     134             :     // Shutdown services
     135             :     virtual void ServicesShutdownBase();
     136           0 :     virtual void ServicesShutdown() { }
     137             : 
     138             :     // Shutdown pkt interface
     139             :     virtual void PktShutdownBase();
     140           0 :     virtual void PktShutdown() { }
     141             : 
     142             :     // Shutdown agent profiling
     143             :     virtual void ProfileShutdownBase();
     144             : 
     145             :     // Shutdown other modules
     146             :     virtual void ModulesShutdownBase();
     147           0 :     virtual void ModulesShutdown() { }
     148             : 
     149             :     // Shutdown UVE
     150             :     virtual void UveShutdownBase();
     151           0 :     virtual void UveShutdown() { }
     152             : 
     153             :     // Shutdown Stats collector
     154             :     virtual void StatsCollectorShutdownBase();
     155           0 :     virtual void StatsCollectorShutdown() { }
     156             : 
     157             :     // Shutdown Flow collector
     158             :     virtual void FlowStatsCollectorShutdownBase();
     159           0 :     virtual void FlowStatsCollectorShutdown() { }
     160             : 
     161             :     // Shutdown KSync
     162             :     virtual void KSyncShutdownBase();
     163           0 :     virtual void KSyncShutdown() { }
     164             : 
     165             :     // Utility
     166             :     virtual void WaitForIdle() = 0;
     167             :     void WaitForDBEmpty();
     168             :     void DeleteVhost();
     169             : 
     170             : private:
     171             :     std::unique_ptr<Agent> agent_;
     172             :     AgentParam *agent_param_;
     173             : 
     174             :     std::mutex init_mutex_;
     175             :     std::unique_ptr<TaskTrigger> trigger_;
     176             : 
     177             :     std::unique_ptr<AgentStats> stats_;
     178             :     std::unique_ptr<AgentConfig> cfg_;
     179             :     std::unique_ptr<OperDB> oper_;
     180             : 
     181             :     bool enable_controller_;
     182             :     std::unique_ptr<VNController> controller_;
     183             :     std::unique_ptr<ResourceManager> resource_manager_;
     184             :     std::unique_ptr<EventNotifier> event_notifier_;
     185             : 
     186             :     DISALLOW_COPY_AND_ASSIGN(AgentInit);
     187             : };
     188             : 
     189             : #endif // vnsw_agent_init_agent_init_hpp

Generated by: LCOV version 1.14