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

Generated by: LCOV version 1.14