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: 259 389 66.6 %
Date: 2026-06-04 02:06:09 Functions: 44 70 62.9 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.14