LCOV - code coverage report
Current view: top level - vnsw/agent/oper - config_manager.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 254 389 65.3 %
Date: 2026-11-30 02:00:48 Functions: 43 70 61.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2015 Juniper Networks, Inc. All rights reserved.
       3             :  * Copyright Contributors to the OpenSDN project
       4             :  */
       5             : 
       6             : #include <boost/uuid/uuid_io.hpp>
       7             : #include <boost/scoped_ptr.hpp>
       8             : #include <vnc_cfg_types.h>
       9             : #include <base/util.h>
      10             : #include <db/db_partition.h>
      11             : 
      12             : #include <ifmap/ifmap_node.h>
      13             : #include <ifmap/ifmap_link.h>
      14             : #include <ifmap/ifmap_agent_table.h>
      15             : #include <cmn/agent_cmn.h>
      16             : #include <oper/operdb_init.h>
      17             : #include <oper/ifmap_dependency_manager.h>
      18             : #include <oper/config_manager.h>
      19             : 
      20             : #include <oper/interface_common.h>
      21             : #include <oper/health_check.h>
      22             : #include <oper/physical_device.h>
      23             : #include <oper/physical_device_vn.h>
      24             : #include <oper/vn.h>
      25             : #include <oper/vrf.h>
      26             : #include <oper/sg.h>
      27             : #include <oper/tag.h>
      28             : #include <oper/vm.h>
      29             : #include <oper/interface_common.h>
      30             : #include <oper/global_qos_config.h>
      31             : #include <oper/global_system_config.h>
      32             : #include <oper/qos_config.h>
      33             : #include <oper/vrouter.h>
      34             : #include <oper/global_vrouter.h>
      35             : #include <oper/bgp_router.h>
      36             : #include <oper/forwarding_class.h>
      37             : #include<oper/qos_queue.h>
      38             : #include <oper/bridge_domain.h>
      39             : #include <oper/security_logging_object.h>
      40             : #include <oper/multicast_policy.h>
      41             : #include <filter/policy_set.h>
      42             : #include <vector>
      43             : #include <string>
      44             : 
      45             : using std::string;
      46             : 
      47           1 : ConfigHelper::ConfigHelper(const ConfigManager *mgr,
      48           1 :                            const Agent *agent) :
      49           1 :     mgr_(mgr), link_table_(NULL), agent_(agent) {
      50           1 : }
      51             : 
      52           0 : IFMapNode *ConfigHelper::GetOtherAdjacentNode(IFMapLink *link,
      53             :                                               IFMapNode *node) {
      54           0 :     if (link->left() == node) return link->right();
      55           0 :     if (link->right() == node) return link->left();
      56           0 :     return NULL;
      57             : }
      58             : 
      59             : //Note: FindLink here checks for many-to-one node.
      60           0 : IFMapNode *ConfigHelper::FindLink(const char *type,
      61             :                                   IFMapNode *node) {
      62           0 :     IFMapLink *link = NULL;
      63           0 :     if (!link_table_) {
      64           0 :         link_table_ = static_cast<IFMapAgentLinkTable *>(agent_->db()->
      65           0 :                                   FindTable(IFMAP_AGENT_LINK_DB_NAME));
      66             :     }
      67             : 
      68           0 :     std::ostringstream key_with_node_in_right;
      69           0 :     key_with_node_in_right << type << ",," << node->ToString();
      70           0 :     link = link_table_->FindNextLink(key_with_node_in_right.str());
      71           0 :     if (link && (strcmp(link->metadata().c_str(), type) == 0))
      72           0 :         return GetOtherAdjacentNode(link, node);
      73             : 
      74           0 :     std::ostringstream key_with_node_in_left;
      75           0 :     key_with_node_in_left << type << "," << node->ToString() << ",";
      76           0 :     link = link_table_->FindNextLink(key_with_node_in_left.str());
      77           0 :     if (link && (strcmp(link->metadata().c_str(), type) == 0))
      78           0 :         return GetOtherAdjacentNode(link, node);
      79             : 
      80           0 :     return NULL;
      81           0 : }
      82             : 
      83             : class ConfigManagerNodeList {
      84             : public:
      85             :     struct Node {
      86         467 :         Node(IFMapDependencyManager::IFMapNodePtr state) : state_(state) { }
      87         754 :         ~Node() { }
      88             : 
      89             :         IFMapDependencyManager::IFMapNodePtr state_;
      90             :     };
      91             : 
      92             :     struct NodeCmp {
      93         420 :         bool operator() (const Node &lhs, const Node &rhs) const {
      94         420 :             return lhs.state_.get() < rhs.state_.get();
      95             :         }
      96             :     };
      97             :     typedef std::set<Node, NodeCmp> NodeList;
      98             :     typedef NodeList::iterator NodeListIterator;
      99             : 
     100          17 :     ConfigManagerNodeList(AgentDBTable *table) :
     101          34 :         table_(table), oper_ifmap_table_(NULL), enqueue_count_(0),
     102          17 :         process_count_(0) {
     103          17 :     }
     104             : 
     105           7 :     ConfigManagerNodeList(OperIFMapTable *table) :
     106          14 :         table_(NULL), oper_ifmap_table_(table), enqueue_count_(0),
     107           7 :         process_count_(0) {
     108           7 :     }
     109             : 
     110          24 :     ~ConfigManagerNodeList() {
     111          24 :         assert(list_.size() == 0);
     112          24 :     }
     113             : 
     114         467 :     bool Add(Agent *agent, ConfigManager *mgr, IFMapNode *node) {
     115         467 :         IFMapDependencyManager *dep = agent->oper_db()->dependency_manager();
     116         467 :         Node n(dep->SetState(node));
     117         467 :         list_.insert(n);
     118         467 :         enqueue_count_++;
     119         467 :         mgr->Start();
     120         467 :         return true;
     121         467 :     }
     122             : 
     123             :     bool Delete(Agent *agent, ConfigManager *mgr, IFMapNode *node) {
     124             :         IFMapDependencyManager *dep = agent->oper_db()->dependency_manager();
     125             :         IFMapNodeState *state = dep->IFMapNodeGet(node);
     126             :         if (state == NULL)
     127             :             return false;
     128             :         Node n(state);
     129             :         list_.erase(n);
     130             :         return true;
     131             :     }
     132             : 
     133        3816 :     uint32_t Process(uint32_t weight) {
     134        3816 :         uint32_t count = 0;
     135        3816 :         NodeListIterator it = list_.begin();
     136        4103 :         while (weight && (it != list_.end())) {
     137         287 :             NodeListIterator prev = it++;
     138         287 :             IFMapNodeState *state = prev->state_.get();
     139         287 :             IFMapNode *node = state->node();
     140             : 
     141         287 :             DBRequest req;
     142         287 :             boost::uuids::uuid id = state->uuid();
     143         287 :             if (table_) {
     144         276 :                 if (table_->ProcessConfig(node, req, id)) {
     145         142 :                     table_->Enqueue(&req);
     146             :                 }
     147             :             }
     148             : 
     149         287 :             if (oper_ifmap_table_) {
     150          11 :                 oper_ifmap_table_->ProcessConfig(node);
     151             :             }
     152             : 
     153         287 :             list_.erase(prev);
     154         287 :             weight--;
     155         287 :             count++;
     156         287 :             process_count_++;
     157         287 :         }
     158             : 
     159        3816 :         return count;
     160             :     }
     161             : 
     162        3339 :     uint32_t Size() const { return list_.size(); }
     163           0 :     uint32_t enqueue_count() const { return enqueue_count_; }
     164           0 :     uint32_t process_count() const { return process_count_; }
     165             : 
     166             : private:
     167             :     AgentDBTable *table_;
     168             :     OperIFMapTable *oper_ifmap_table_;
     169             :     NodeList list_;
     170             :     uint32_t enqueue_count_;
     171             :     uint32_t process_count_;
     172             :     DISALLOW_COPY_AND_ASSIGN(ConfigManagerNodeList);
     173             : };
     174             : 
     175             : class ConfigManagerDeviceVnList {
     176             : public:
     177             :     struct DeviceVnEntry {
     178           5 :         DeviceVnEntry(const boost::uuids::uuid &dev,
     179           5 :                       const boost::uuids::uuid &vn) : dev_(dev), vn_(vn) {
     180           5 :         }
     181             : 
     182           9 :         ~DeviceVnEntry() { }
     183             : 
     184             :         boost::uuids::uuid dev_;
     185             :         boost::uuids::uuid vn_;
     186             :     };
     187             : 
     188             :     struct DeviceVnEntryCmp {
     189           0 :         bool operator() (const DeviceVnEntry &lhs, const DeviceVnEntry &rhs) const {
     190           0 :             if (lhs.dev_ != rhs.dev_)
     191           0 :                 return lhs.dev_ < rhs.dev_;
     192             : 
     193           0 :             return lhs.vn_ < rhs.vn_;
     194             :         }
     195             :     };
     196             : 
     197             :     typedef std::set<DeviceVnEntry, DeviceVnEntryCmp> DeviceVnList;
     198             :     typedef DeviceVnList::iterator DeviceVnIterator;
     199             : 
     200           1 :     ConfigManagerDeviceVnList(PhysicalDeviceVnTable *table) :
     201           1 :         table_(table), enqueue_count_(0), process_count_(0) {
     202           1 :     }
     203             : 
     204           1 :     ~ConfigManagerDeviceVnList() {
     205           1 :         assert(list_.size() == 0);
     206           1 :     }
     207             : 
     208           4 :     bool Add(Agent *agent, ConfigManager *mgr, const boost::uuids::uuid &dev,
     209             :              const boost::uuids::uuid &vn) {
     210           4 :         list_.insert(DeviceVnEntry(dev, vn));
     211           4 :         enqueue_count_++;
     212           4 :         mgr->Start();
     213           4 :         return true;
     214             :     }
     215             : 
     216           1 :     bool Delete(Agent *agent, ConfigManager *mgr, const boost::uuids::uuid &dev,
     217             :                 const boost::uuids::uuid &vn) {
     218           1 :         list_.erase(DeviceVnEntry(dev, vn));
     219           1 :         return true;
     220             :     }
     221             : 
     222         159 :     uint32_t Process(uint32_t weight) {
     223         159 :         uint32_t count = 0;
     224         159 :         DeviceVnIterator it = list_.begin();
     225         163 :         while (weight && (it != list_.end())) {
     226           4 :             DeviceVnIterator prev = it++;
     227           4 :             DBRequest req;
     228           4 :             table_->ProcessConfig(prev->dev_, prev->vn_);
     229           4 :             list_.erase(prev);
     230           4 :             weight--;
     231           4 :             count++;
     232           4 :         }
     233         159 :         return count;
     234             :     }
     235             : 
     236         159 :     uint32_t Size() const { return list_.size(); }
     237             :     uint32_t enqueue_count() const { return enqueue_count_; }
     238           0 :     uint32_t process_count() const { return process_count_; }
     239             : 
     240             : private:
     241             :     PhysicalDeviceVnTable *table_;
     242             :     DeviceVnList list_;
     243             :     uint32_t enqueue_count_;
     244             :     uint32_t process_count_;
     245             :     DISALLOW_COPY_AND_ASSIGN(ConfigManagerDeviceVnList);
     246             : };
     247             : 
     248           1 : ConfigManager::ConfigManager(Agent *agent) :
     249           1 :     agent_(agent), trigger_(), timer_(NULL), timeout_(kMinTimeout) {
     250             : 
     251           1 :     int task_id = TaskScheduler::GetInstance()->GetTaskId("db::DBTable");
     252             :     trigger_.reset
     253           2 :         (new TaskTrigger(boost::bind(&ConfigManager::TriggerRun, this),
     254           1 :                          task_id, 0));
     255           1 :     timer_ = TimerManager::CreateTimer(*(agent->event_manager()->io_service()),
     256             :                                        "Config Manager", task_id, 0);
     257          11 :     for (uint32_t i = 0; i < kMaxTimeout; i++) {
     258          10 :         process_config_count_[i] = 0;
     259             :     }
     260           1 :     helper_.reset(new ConfigHelper(this, agent_));
     261           1 : }
     262             : 
     263           2 : ConfigManager::~ConfigManager() {
     264           1 :     timer_->Cancel();
     265           1 :     TimerManager::DeleteTimer(timer_);
     266           2 : }
     267             : 
     268           1 : void ConfigManager::Init() {
     269           1 :     AgentDBTable *intf_table = agent_->interface_table();
     270           1 :     vmi_list_.reset(new ConfigManagerNodeList(intf_table));
     271           1 :     physical_interface_list_.reset(new ConfigManagerNodeList(intf_table));
     272           1 :     logical_interface_list_.reset(new ConfigManagerNodeList(intf_table));
     273             : 
     274           1 :     device_list_.reset(new ConfigManagerNodeList
     275           1 :                        (agent_->physical_device_table()));
     276           1 :     sg_list_.reset(new ConfigManagerNodeList(agent_->sg_table()));
     277           1 :     tag_list_.reset(new ConfigManagerNodeList(agent_->tag_table()));
     278           1 :     vn_list_.reset(new ConfigManagerNodeList(agent_->vn_table()));
     279           1 :     vrf_list_.reset(new ConfigManagerNodeList(agent_->vrf_table()));
     280           1 :     vm_list_.reset(new ConfigManagerNodeList(agent_->vm_table()));
     281           1 :     hc_list_.reset(new ConfigManagerNodeList
     282           1 :                        (agent_->health_check_table()));
     283           1 :     bridge_domain_list_.reset(new ConfigManagerNodeList(
     284           1 :                                   agent_->bridge_domain_table()));
     285           1 :     policy_set_list_.reset(new ConfigManagerNodeList(
     286           1 :                                   agent_->policy_set_table()));
     287           1 :     qos_config_list_.reset(new ConfigManagerNodeList(agent_->qos_config_table()));
     288           1 :     device_vn_list_.reset(new ConfigManagerDeviceVnList
     289           1 :                           (agent_->physical_device_vn_table()));
     290           1 :     qos_queue_list_.reset(new ConfigManagerNodeList(agent_->qos_queue_table()));
     291           1 :     forwarding_class_list_.reset(new
     292           1 :             ConfigManagerNodeList(agent_->forwarding_class_table()));
     293           1 :     slo_list_.reset(new
     294           1 :             ConfigManagerNodeList(agent_->slo_table()));
     295           1 :     mp_list_.reset(new ConfigManagerNodeList(agent_->mp_table()));
     296             : 
     297           1 :     OperDB *oper_db = agent()->oper_db();
     298             :     global_vrouter_list_.reset
     299           1 :         (new ConfigManagerNodeList(oper_db->global_vrouter()));
     300             :     bgp_router_config_list_.reset
     301           1 :         (new ConfigManagerNodeList(oper_db->bgp_router_config()));
     302             :     virtual_router_list_.reset
     303           1 :         (new ConfigManagerNodeList(oper_db->vrouter()));
     304             :     global_qos_config_list_.reset
     305           1 :         (new ConfigManagerNodeList(oper_db->global_qos_config()));
     306             :     global_system_config_list_.reset
     307           1 :         (new ConfigManagerNodeList(oper_db->global_system_config()));
     308             :     network_ipam_list_.reset
     309           1 :         (new ConfigManagerNodeList(oper_db->network_ipam()));
     310           1 :     virtual_dns_list_.reset(new ConfigManagerNodeList(oper_db->virtual_dns()));
     311           1 : }
     312             : 
     313         159 : uint32_t ConfigManager::Size() const {
     314             :     return
     315         159 :         global_vrouter_list_->Size() +
     316         159 :         bgp_router_config_list_->Size() +
     317         159 :         virtual_router_list_->Size() +
     318         159 :         global_qos_config_list_->Size() +
     319         159 :         global_system_config_list_->Size() +
     320         159 :         network_ipam_list_->Size() + + +
     321         159 :         virtual_dns_list_->Size() +
     322         159 :         vmi_list_->Size() +
     323         159 :         physical_interface_list_->Size() +
     324         159 :         logical_interface_list_->Size() +
     325         159 :         device_list_->Size() +
     326         159 :         sg_list_->Size() +
     327         159 :         tag_list_->Size() +
     328         159 :         vn_list_->Size() +
     329         159 :         vrf_list_->Size() +
     330         159 :         vm_list_->Size() +
     331         159 :         hc_list_->Size() +
     332         159 :         device_vn_list_->Size() +
     333         159 :         qos_config_list_->Size() +
     334         159 :         bridge_domain_list_->Size() +
     335         159 :         policy_set_list_->Size() +
     336         159 :         mp_list_->Size();
     337             : }
     338             : 
     339           0 : uint32_t ConfigManager::ProcessCount() const {
     340             :     return
     341           0 :         global_vrouter_list_->process_count() +
     342           0 :         bgp_router_config_list_->process_count() +
     343           0 :         virtual_router_list_->process_count() +
     344           0 :         global_qos_config_list_->process_count() +
     345           0 :         global_system_config_list_->process_count() +
     346           0 :         network_ipam_list_->process_count() +
     347           0 :         virtual_dns_list_->process_count() +
     348           0 :         vmi_list_->process_count() +
     349           0 :         physical_interface_list_->process_count() +
     350           0 :         logical_interface_list_->process_count() +
     351           0 :         device_list_->process_count() +
     352           0 :         sg_list_->process_count() +
     353           0 :         tag_list_->process_count() +
     354           0 :         vn_list_->process_count() +
     355           0 :         vrf_list_->process_count() +
     356           0 :         vm_list_->process_count() +
     357           0 :         hc_list_->process_count() +
     358           0 :         device_vn_list_->process_count() +
     359           0 :         qos_config_list_->process_count() +
     360           0 :         policy_set_list_->process_count() +
     361           0 :         mp_list_->process_count();
     362             : }
     363             : 
     364         472 : void ConfigManager::Start() {
     365         472 :     if (agent_->ResourceManagerReady() == false) {
     366           0 :         return;
     367             :     }
     368             : 
     369         472 :     if (agent_->test_mode()) {
     370         472 :         trigger_->Set();
     371             :     } else {
     372           0 :         timeout_++;
     373           0 :         if (timeout_ > kMaxTimeout)
     374           0 :             timeout_ = kMaxTimeout;
     375           0 :         if (timer_->Idle())
     376           0 :             timer_->Start(timeout_, boost::bind(&ConfigManager::TimerRun,
     377             :                                                 this));
     378             :     }
     379             : }
     380             : 
     381           0 : bool ConfigManager::TimerRun() {
     382           0 :     int count = Run();
     383           0 :     process_config_count_[timeout_] += count;
     384             : 
     385           0 :     if (Size() == 0) {
     386           0 :         timeout_ = kMinTimeout;
     387           0 :         return false;
     388             :     }
     389             : 
     390           0 :     timeout_--;
     391           0 :     if (timeout_ <= kMinTimeout)
     392           0 :         timeout_ = kMinTimeout;
     393           0 :     timer_->Reschedule(timeout_);
     394           0 :     return true;
     395             : }
     396             : 
     397         159 : bool ConfigManager::TriggerRun() {
     398         159 :     Run();
     399         159 :     return (Size() == 0);
     400             : }
     401             : 
     402             : // Run the change-list
     403         159 : int ConfigManager::Run() {
     404         159 :     uint32_t max_count = kIterationCount;
     405         159 :     uint32_t count = 0;
     406             : 
     407         159 :     count += global_vrouter_list_->Process(max_count - count);
     408         159 :     count += bgp_router_config_list_->Process(max_count - count);
     409         159 :     count += virtual_router_list_->Process(max_count - count);
     410         159 :     count += global_qos_config_list_->Process(max_count - count);
     411         159 :     count += global_system_config_list_->Process(max_count - count);
     412         159 :     count += network_ipam_list_->Process(max_count - count);
     413         159 :     count += virtual_dns_list_->Process(max_count - count);
     414         159 :     count += sg_list_->Process(max_count - count);
     415         159 :     count += tag_list_->Process(max_count - count);
     416         159 :     count += physical_interface_list_->Process(max_count - count);
     417         159 :     count += qos_queue_list_->Process(max_count - count);
     418         159 :     count += forwarding_class_list_->Process(max_count - count);
     419         159 :     count += qos_config_list_->Process(max_count - count);
     420         159 :     count += vn_list_->Process(max_count - count);
     421         159 :     count += vm_list_->Process(max_count - count);
     422         159 :     count += vrf_list_->Process(max_count - count);
     423         159 :     count += bridge_domain_list_->Process(max_count - count);
     424         159 :     count += policy_set_list_->Process(max_count - count);
     425         159 :     count += logical_interface_list_->Process(max_count - count);
     426         159 :     count += hc_list_->Process(max_count - count);
     427         159 :     count += vmi_list_->Process(max_count - count);
     428         159 :     count += device_list_->Process(max_count - count);
     429         159 :     count += device_vn_list_->Process(max_count - count);
     430         159 :     count += slo_list_->Process(max_count - count);
     431         159 :     count += mp_list_->Process(max_count - count);
     432         159 :     return count;
     433             : }
     434             : 
     435         202 : void ConfigManager::AddVmiNode(IFMapNode *node) {
     436         202 :     vmi_list_->Add(agent_, this, node);
     437         202 : }
     438             : 
     439           0 : uint32_t ConfigManager::VmiNodeCount() const {
     440           0 :     return vmi_list_->Size();
     441             : }
     442             : 
     443          18 : void ConfigManager::AddLogicalInterfaceNode(IFMapNode *node) {
     444          18 :     logical_interface_list_->Add(agent_, this, node);
     445          18 : }
     446             : 
     447           0 : uint32_t ConfigManager::LogicalInterfaceNodeCount() const {
     448           0 :     return logical_interface_list_->Size();
     449             : }
     450             : 
     451           5 : void ConfigManager::AddPhysicalDeviceNode(IFMapNode *node) {
     452           5 :     device_list_->Add(agent_, this, node);
     453           5 : }
     454             : 
     455           0 : void ConfigManager::AddHealthCheckServiceNode(IFMapNode *node) {
     456           0 :     hc_list_->Add(agent_, this, node);
     457           0 : }
     458             : 
     459           0 : void ConfigManager::AddBridgeDomainNode(IFMapNode *node) {
     460           0 :     bridge_domain_list_->Add(agent_, this, node);
     461           0 : }
     462             : 
     463           0 : void ConfigManager::AddPolicySetNode(IFMapNode *node) {
     464           0 :     policy_set_list_->Add(agent_, this, node);
     465           0 : }
     466             : 
     467          18 : void ConfigManager::AddSgNode(IFMapNode *node) {
     468          18 :     sg_list_->Add(agent_, this, node);
     469          18 : }
     470             : 
     471           0 : void ConfigManager::AddTagNode(IFMapNode *node) {
     472           0 :     tag_list_->Add(agent_, this, node);
     473           0 : }
     474             : 
     475          79 : void ConfigManager::AddVnNode(IFMapNode *node) {
     476          79 :     vn_list_->Add(agent_, this, node);
     477          79 : }
     478             : 
     479          68 : void ConfigManager::AddVrfNode(IFMapNode *node) {
     480          68 :     vrf_list_->Add(agent_, this, node);
     481          68 : }
     482             : 
     483          54 : void ConfigManager::AddVmNode(IFMapNode *node) {
     484          54 :     vm_list_->Add(agent_, this, node);
     485          54 : }
     486             : 
     487           7 : void ConfigManager::AddPhysicalInterfaceNode(IFMapNode *node) {
     488           7 :     physical_interface_list_->Add(agent_, this, node);
     489           7 : }
     490             : 
     491           0 : void ConfigManager::AddQosConfigNode(IFMapNode *node) {
     492           0 :     qos_config_list_->Add(agent_, this, node);
     493           0 : }
     494             : 
     495           0 : void ConfigManager::AddForwardingClassNode(IFMapNode *node) {
     496           0 :     forwarding_class_list_->Add(agent_, this, node);
     497           0 : }
     498             : 
     499           0 : void ConfigManager::AddSecurityLoggingObjectNode(IFMapNode *node) {
     500           0 :     slo_list_->Add(agent_, this, node);
     501           0 : }
     502             : 
     503           0 : void ConfigManager::AddMulticastPolicyNode(IFMapNode *node) {
     504           0 :     mp_list_->Add(agent_, this, node);
     505           0 : }
     506             : 
     507           0 : void ConfigManager::AddQosQueueNode(IFMapNode *node) {
     508           0 :     qos_queue_list_->Add(agent_, this, node);
     509           0 : }
     510             : 
     511           4 : void ConfigManager::AddPhysicalDeviceVn(const boost::uuids::uuid &dev,
     512             :                                         const boost::uuids::uuid &vn) {
     513           4 :     device_vn_list_->Add(agent_, this, dev, vn);
     514           4 : }
     515             : 
     516           1 : void ConfigManager::DelPhysicalDeviceVn(const boost::uuids::uuid &dev,
     517             :                                         const boost::uuids::uuid &vn) {
     518           1 :     device_vn_list_->Delete(agent_, this, dev, vn);
     519           1 : }
     520           0 : uint32_t ConfigManager::PhysicalDeviceVnCount() const {
     521           0 :     return device_vn_list_->Size();
     522             : }
     523             : 
     524           0 : void ConfigManager::AddGlobalQosConfigNode(IFMapNode *node) {
     525           0 :     global_qos_config_list_->Add(agent_, this, node);
     526           0 : }
     527             : 
     528           0 : void ConfigManager::AddGlobalSystemConfigNode(IFMapNode *node) {
     529           0 :     global_system_config_list_->Add(agent_, this, node);
     530           0 : }
     531             : 
     532          15 : void ConfigManager::AddNetworkIpamNode(IFMapNode *node) {
     533          15 :     network_ipam_list_->Add(agent_, this, node);
     534          15 : }
     535             : 
     536           0 : void ConfigManager::AddVirtualDnsNode(IFMapNode *node) {
     537           0 :     virtual_dns_list_->Add(agent_, this, node);
     538           0 : }
     539             : 
     540           1 : void ConfigManager::AddGlobalVrouterNode(IFMapNode *node) {
     541           1 :     global_vrouter_list_->Add(agent_, this, node);
     542           1 : }
     543             : 
     544           0 : void ConfigManager::AddBgpRouterConfigNode(IFMapNode *node) {
     545           0 :     bgp_router_config_list_->Add(agent_, this, node);
     546           0 : }
     547             : 
     548           0 : void ConfigManager::AddVirtualRouterNode(IFMapNode *node) {
     549           0 :     virtual_router_list_->Add(agent_, this, node);
     550           0 : }
     551             : 
     552           0 : string ConfigManager::ProfileInfo() const {
     553             :     using std::setw;
     554             :     using std::endl;
     555             : 
     556           0 :     std::stringstream str;
     557             :     str << setw(16) << "CfgMgr"
     558           0 :         << " Queue" << setw(8) << Size()
     559           0 :         << " Timeout " << setw(8) << timeout()
     560           0 :         << " Process" << setw(8) << ProcessCount() << endl;
     561             :     str << setw(22)
     562           0 :         << " VMI-Q " << setw(8) << vmi_list_->Size()
     563           0 :         << " Enqueue " << setw(8) << vmi_list_->enqueue_count()
     564           0 :         << " Process" << setw(8) << vmi_list_->process_count() << endl;
     565             :     str << setw(22)
     566           0 :         << " LI-Q " << setw(8) << logical_interface_list_->Size()
     567           0 :         << " Enqueue " << setw(8) << logical_interface_list_->enqueue_count()
     568           0 :         << " Process" << setw(8) << logical_interface_list_->process_count() << endl;
     569           0 :     return str.str();
     570           0 : }
     571             : 
     572             : // When traversing graph, check if an IFMapNode can be used. Conditions are,
     573             : // - The node is not in deleted state
     574             : // - The node was notified earlier
     575         824 : bool ConfigManager::CanUseNode(IFMapNode *node) {
     576         824 :     if (node->IsDeleted()) {
     577           0 :         return false;
     578             :     }
     579             : 
     580             :     IFMapDependencyManager *dep =
     581         824 :         agent()->oper_db()->dependency_manager();
     582             : 
     583             :     // Table not managed by dependency manager. Node can be used
     584         824 :     if (dep->IsRegistered(node) == false)
     585         223 :         return true;
     586             : 
     587         601 :     IFMapNodeState *state = dep->IFMapNodeGet(node);
     588         601 :     if (state == NULL) {
     589             :         // State not set. Means, IFMapDependency manager manages the node
     590             :         // and has not seen the node yet. Node cannot be used.
     591          17 :         return false;
     592             :     }
     593             : 
     594        1168 :     if (state->notify() == false ||
     595         584 :         state->oper_db_request_enqueued() == false) {
     596           0 :         return false;
     597             :     }
     598             : 
     599         584 :     return true;
     600             : }
     601             : 
     602             : // When traversing graph, check if an IFMapNode can be used. Conditions are,
     603             : // - The node is not in deleted state
     604             : // - The node was notified earlier
     605             : // - The node is an entry in IFMapAgentTable specified
     606         792 : bool ConfigManager::CanUseNode(IFMapNode *node, IFMapAgentTable *table) {
     607         792 :     if (table != static_cast<IFMapAgentTable *>(node->table())) {
     608         730 :         return false;
     609             :     }
     610             : 
     611          62 :     return CanUseNode(node);
     612             : }
     613             : 
     614         762 : bool ConfigManager::SkipNode(IFMapNode *node) {
     615         762 :     return !CanUseNode(node);
     616             : }
     617             : 
     618         492 : bool ConfigManager::SkipNode(IFMapNode *node, IFMapAgentTable *table) {
     619         492 :     return !CanUseNode(node, table);
     620             : }
     621             : 
     622             : 
     623         131 : IFMapNode *ConfigManager::FindAdjacentIFMapNode(IFMapNode *node,
     624             :                                               const char *type) {
     625         131 :     IFMapAgentTable *table = static_cast<IFMapAgentTable *>(node->table());
     626         131 :     DBGraph *graph = table->GetGraph();
     627         131 :     assert(node->IsVertexValid());
     628         131 :     for (DBGraphVertex::adjacency_iterator iter = node->begin(graph);
     629         432 :          iter != node->end(graph); ++iter) {
     630         330 :         IFMapNode *adj_node = static_cast<IFMapNode *>(iter.operator->());
     631         330 :         if (SkipNode(adj_node)) {
     632           0 :             continue;
     633             :         }
     634         330 :         if (strcmp(adj_node->table()->Typename(), type) == 0) {
     635          29 :             return adj_node;
     636             :         }
     637             :     }
     638             : 
     639         102 :     return NULL;
     640             : }
     641             : 
     642           0 : void ConfigManager::NodeResync(IFMapNode *node) {
     643           0 :     IFMapDependencyManager *dep = agent_->oper_db()->dependency_manager();
     644           0 :     dep->PropogateNodeAndLinkChange(node);
     645           0 : }

Generated by: LCOV version 1.14