OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
config_manager.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Juniper Networks, Inc. All rights reserved.
3  */
4 #ifndef SRC_VNSW_AGENT_OPER_CONFIG_MANAGER_H_
5 #define SRC_VNSW_AGENT_OPER_CONFIG_MANAGER_H_
6 
7 /*****************************************************************************
8  * Implements change list for the oper table. Normally, the oper objects
9  * process configuration thru IFNodeToReq or IFLinkToReq callback methods.
10  *
11  * In scaled environments there can be large number of invocations to
12  * IFNodeToReq and IFLinkToReq APIs. The config processing routines are
13  * written to act on the latest version of configuration. So, an invocation
14  * of config routine will override all previous invocations. Ideally, we wnat
15  * to invoke the config callbacks only once after all configuraiton is
16  * received. However, we dont have any marker to identify end of configuration.
17  *
18  * The next best design we follow is to add the objects changed into a
19  * change list. The change-list is run from a task-trigger. The list can
20  * potentially compress multiple changes to a node
21  *
22  * The changelist should also take care of dependency between objects. For
23  * example, VMInterface has reference to VirtualNetwork. So, the change list
24  * for virtual-network should be invoked before VMInterface. The changelist
25  * should take of all dependencies.
26  *
27  * The changelist is implemented to objects
28  * security-group
29  * virtual-machine-interface
30  * logical-interfaces
31  * physical-device-vn
32  * physical-router
33  *****************************************************************************/
34 
35 #include <cmn/agent_cmn.h>
36 #include <cmn/agent_db.h>
37 #include <operdb_init.h>
39 
43 
44 class ConfigHelper {
45 public:
46  ConfigHelper(const ConfigManager *mgr, const Agent *agent);
47  virtual ~ConfigHelper() { }
48 
50  IFMapNode *node);
51  IFMapNode *FindLink(const char *type, IFMapNode *node);
52 
53 private:
56  const Agent *agent_;
58 };
59 
61 public:
62  // Number of changelist entries to pick in one run
63  const static uint32_t kIterationCount = 64;
64  const static uint32_t kMinTimeout = 1;
65  const static uint32_t kMaxTimeout = 10;
66 
68  virtual ~ConfigManager();
69 
70  void Init();
71  int Run();
72  bool TriggerRun();
73  bool TimerRun();
74  void Start();
75 
76  uint32_t Size() const;
77  uint32_t ProcessCount() const;
78  uint32_t timeout() const { return timeout_; }
79  std::string ProfileInfo() const;
80 
81  void AddVmiNode(IFMapNode *node);
82  uint32_t VmiNodeCount() const;
83 
86  void AddSgNode(IFMapNode *node);
87  void AddTagNode(IFMapNode *node);
88  void AddVnNode(IFMapNode *node);
89  void AddVrfNode(IFMapNode *node);
90  void AddVmNode(IFMapNode *node);
91  void AddQosConfigNode(IFMapNode *node);
92  void AddQosQueueNode(IFMapNode *node);
96  void AddNetworkIpamNode(IFMapNode *node);
97  void AddVirtualDnsNode(IFMapNode *node);
98  void AddGlobalVrouterNode(IFMapNode *node);
100  void AddVirtualRouterNode(IFMapNode *node);
101  uint32_t LogicalInterfaceNodeCount() const;
103  void AddMulticastPolicyNode(IFMapNode *node);
104 
105  void AddPhysicalDeviceNode(IFMapNode *node);
106  void AddPhysicalDeviceVn(const boost::uuids::uuid &dev,
107  const boost::uuids::uuid &vn);
108  void DelPhysicalDeviceVn(const boost::uuids::uuid &dev,
109  const boost::uuids::uuid &vn);
111  void AddBridgeDomainNode(IFMapNode *node);
112  void AddPolicySetNode(IFMapNode *node);
113  void AddProjectNode(IFMapNode *node);
114  uint32_t PhysicalDeviceVnCount() const;
115  bool CanUseNode(IFMapNode *node);
116  bool CanUseNode(IFMapNode *node, IFMapAgentTable *table);
117  bool SkipNode(IFMapNode *node);
118  bool SkipNode(IFMapNode *node, IFMapAgentTable *table);
120  const char *type);
121  void NodeResync(IFMapNode *node);
122  ConfigHelper *helper() const {return helper_.get();}
123 
124  Agent *agent() { return agent_; }
125 
126 private:
128  std::unique_ptr<TaskTrigger> trigger_;
130  uint32_t timeout_;
131 
132  std::unique_ptr<ConfigManagerNodeList> vmi_list_;
133  std::unique_ptr<ConfigManagerNodeList> physical_interface_list_;
134  std::unique_ptr<ConfigManagerNodeList> logical_interface_list_;
135  std::unique_ptr<ConfigManagerNodeList> device_list_;
136  std::unique_ptr<ConfigManagerNodeList> sg_list_;
137  std::unique_ptr<ConfigManagerNodeList> tag_list_;
138  std::unique_ptr<ConfigManagerNodeList> vn_list_;
139  std::unique_ptr<ConfigManagerNodeList> vrf_list_;
140  std::unique_ptr<ConfigManagerNodeList> vm_list_;
141  std::unique_ptr<ConfigManagerNodeList> hc_list_;
142  std::unique_ptr<ConfigManagerNodeList> qos_config_list_;
143  std::unique_ptr<ConfigManagerNodeList> qos_queue_list_;
144  std::unique_ptr<ConfigManagerNodeList> forwarding_class_list_;
145  std::unique_ptr<ConfigManagerDeviceVnList> device_vn_list_;
146  std::unique_ptr<ConfigManagerNodeList> bridge_domain_list_;
147  std::unique_ptr<ConfigManagerNodeList> slo_list_;
148  std::unique_ptr<ConfigManagerNodeList> policy_set_list_;
149  std::unique_ptr<ConfigManagerNodeList> mp_list_;
150 
151  // Lists of IFMapNodes without corresponding oper db-tables
152  std::unique_ptr<ConfigManagerNodeList> global_vrouter_list_;
153  std::unique_ptr<ConfigManagerNodeList> bgp_router_config_list_;
154  std::unique_ptr<ConfigManagerNodeList> virtual_router_list_;
155  std::unique_ptr<ConfigManagerNodeList> global_qos_config_list_;
156  std::unique_ptr<ConfigManagerNodeList> network_ipam_list_;
157  std::unique_ptr<ConfigManagerNodeList> virtual_dns_list_;
158  std::unique_ptr<ConfigManagerNodeList> global_system_config_list_;
159  std::unique_ptr<ConfigManagerNodeList> project_list_;
160 
162  boost::scoped_ptr<ConfigHelper> helper_;
164 };
165 
166 #endif // SRC_VNSW_AGENT_OPER_CONFIG_MANAGER_H_
virtual ~ConfigManager()
boost::scoped_ptr< ConfigHelper > helper_
IFMapAgentLinkTable * link_table_
void AddBgpRouterConfigNode(IFMapNode *node)
void AddNetworkIpamNode(IFMapNode *node)
std::unique_ptr< TaskTrigger > trigger_
ConfigHelper * helper() const
ConfigManager(Agent *agent)
std::unique_ptr< ConfigManagerNodeList > network_ipam_list_
void AddVirtualDnsNode(IFMapNode *node)
void AddHealthCheckServiceNode(IFMapNode *node)
uint32_t timeout_
std::unique_ptr< ConfigManagerNodeList > tag_list_
std::unique_ptr< ConfigManagerNodeList > qos_config_list_
uint32_t LogicalInterfaceNodeCount() const
void AddVrfNode(IFMapNode *node)
void AddPhysicalInterfaceNode(IFMapNode *node)
uint32_t PhysicalDeviceVnCount() const
static const uint32_t kMaxTimeout
std::unique_ptr< ConfigManagerNodeList > global_qos_config_list_
void AddGlobalQosConfigNode(IFMapNode *node)
void AddBridgeDomainNode(IFMapNode *node)
boost::uuids::uuid uuid
bool CanUseNode(IFMapNode *node)
void AddPhysicalDeviceVn(const boost::uuids::uuid &dev, const boost::uuids::uuid &vn)
void AddLogicalInterfaceNode(IFMapNode *node)
const ConfigManager * mgr_
static const uint32_t kIterationCount
std::unique_ptr< ConfigManagerNodeList > vmi_list_
std::string ProfileInfo() const
void AddVirtualRouterNode(IFMapNode *node)
DISALLOW_COPY_AND_ASSIGN(ConfigManager)
static const uint32_t kMinTimeout
uint32_t timeout() const
ConfigHelper(const ConfigManager *mgr, const Agent *agent)
Agent * agent()
IFMapNode * FindLink(const char *type, IFMapNode *node)
void AddForwardingClassNode(IFMapNode *node)
void AddGlobalVrouterNode(IFMapNode *node)
IFMapNode * FindAdjacentIFMapNode(IFMapNode *node, const char *type)
DISALLOW_COPY_AND_ASSIGN(ConfigHelper)
void AddQosQueueNode(IFMapNode *node)
void AddPhysicalDeviceNode(IFMapNode *node)
uint8_t type
Definition: load_balance.h:109
std::unique_ptr< ConfigManagerNodeList > vrf_list_
void AddSecurityLoggingObjectNode(IFMapNode *node)
Definition: agent.h:358
std::unique_ptr< ConfigManagerNodeList > forwarding_class_list_
void AddMulticastPolicyNode(IFMapNode *node)
std::unique_ptr< ConfigManagerNodeList > global_system_config_list_
uint32_t VmiNodeCount() const
uint32_t ProcessCount() const
void AddVmNode(IFMapNode *node)
IFMapNode * GetOtherAdjacentNode(IFMapLink *link, IFMapNode *node)
void AddProjectNode(IFMapNode *node)
void AddVmiNode(IFMapNode *node)
void AddGlobalSystemConfigNode(IFMapNode *node)
std::unique_ptr< ConfigManagerNodeList > bridge_domain_list_
std::unique_ptr< ConfigManagerNodeList > vm_list_
uint32_t Size() const
std::unique_ptr< ConfigManagerNodeList > virtual_router_list_
std::unique_ptr< ConfigManagerNodeList > global_vrouter_list_
std::unique_ptr< ConfigManagerNodeList > qos_queue_list_
std::unique_ptr< ConfigManagerNodeList > device_list_
virtual ~ConfigHelper()
std::unique_ptr< ConfigManagerNodeList > policy_set_list_
const Agent * agent_
std::unique_ptr< ConfigManagerDeviceVnList > device_vn_list_
std::unique_ptr< ConfigManagerNodeList > sg_list_
std::unique_ptr< ConfigManagerNodeList > virtual_dns_list_
std::unique_ptr< ConfigManagerNodeList > hc_list_
uint64_t process_config_count_[kMaxTimeout+1]
void AddQosConfigNode(IFMapNode *node)
std::unique_ptr< ConfigManagerNodeList > bgp_router_config_list_
void AddTagNode(IFMapNode *node)
std::unique_ptr< ConfigManagerNodeList > slo_list_
std::unique_ptr< ConfigManagerNodeList > vn_list_
std::unique_ptr< ConfigManagerNodeList > project_list_
std::unique_ptr< ConfigManagerNodeList > physical_interface_list_
void DelPhysicalDeviceVn(const boost::uuids::uuid &dev, const boost::uuids::uuid &vn)
Definition: timer.h:54
void AddSgNode(IFMapNode *node)
std::unique_ptr< ConfigManagerNodeList > logical_interface_list_
void AddVnNode(IFMapNode *node)
bool SkipNode(IFMapNode *node)
void NodeResync(IFMapNode *node)
void AddPolicySetNode(IFMapNode *node)
std::unique_ptr< ConfigManagerNodeList > mp_list_