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: 0 389 0.0 %
Date: 2026-11-23 02:04:52 Functions: 0 70 0.0 %
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           0 : ConfigHelper::ConfigHelper(const ConfigManager *mgr,
      48           0 :                            const Agent *agent) :
      49           0 :     mgr_(mgr), link_table_(NULL), agent_(agent) {
      50           0 : }
      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           0 :         Node(IFMapDependencyManager::IFMapNodePtr state) : state_(state) { }
      87           0 :         ~Node() { }
      88             : 
      89             :         IFMapDependencyManager::IFMapNodePtr state_;
      90             :     };
      91             : 
      92             :     struct NodeCmp {
      93           0 :         bool operator() (const Node &lhs, const Node &rhs) const {
      94           0 :             return lhs.state_.get() < rhs.state_.get();
      95             :         }
      96             :     };
      97             :     typedef std::set<Node, NodeCmp> NodeList;
      98             :     typedef NodeList::iterator NodeListIterator;
      99             : 
     100           0 :     ConfigManagerNodeList(AgentDBTable *table) :
     101           0 :         table_(table), oper_ifmap_table_(NULL), enqueue_count_(0),
     102           0 :         process_count_(0) {
     103           0 :     }
     104             : 
     105           0 :     ConfigManagerNodeList(OperIFMapTable *table) :
     106           0 :         table_(NULL), oper_ifmap_table_(table), enqueue_count_(0),
     107           0 :         process_count_(0) {
     108           0 :     }
     109             : 
     110           0 :     ~ConfigManagerNodeList() {
     111           0 :         assert(list_.size() == 0);
     112           0 :     }
     113             : 
     114           0 :     bool Add(Agent *agent, ConfigManager *mgr, IFMapNode *node) {
     115           0 :         IFMapDependencyManager *dep = agent->oper_db()->dependency_manager();
     116           0 :         Node n(dep->SetState(node));
     117           0 :         list_.insert(n);
     118           0 :         enqueue_count_++;
     119           0 :         mgr->Start();
     120           0 :         return true;
     121           0 :     }
     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           0 :     uint32_t Process(uint32_t weight) {
     134           0 :         uint32_t count = 0;
     135           0 :         NodeListIterator it = list_.begin();
     136           0 :         while (weight && (it != list_.end())) {
     137           0 :             NodeListIterator prev = it++;
     138           0 :             IFMapNodeState *state = prev->state_.get();
     139           0 :             IFMapNode *node = state->node();
     140             : 
     141           0 :             DBRequest req;
     142           0 :             boost::uuids::uuid id = state->uuid();
     143           0 :             if (table_) {
     144           0 :                 if (table_->ProcessConfig(node, req, id)) {
     145           0 :                     table_->Enqueue(&req);
     146             :                 }
     147             :             }
     148             : 
     149           0 :             if (oper_ifmap_table_) {
     150           0 :                 oper_ifmap_table_->ProcessConfig(node);
     151             :             }
     152             : 
     153           0 :             list_.erase(prev);
     154           0 :             weight--;
     155           0 :             count++;
     156           0 :             process_count_++;
     157           0 :         }
     158             : 
     159           0 :         return count;
     160             :     }
     161             : 
     162           0 :     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           0 :         DeviceVnEntry(const boost::uuids::uuid &dev,
     179           0 :                       const boost::uuids::uuid &vn) : dev_(dev), vn_(vn) {
     180           0 :         }
     181             : 
     182           0 :         ~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           0 :     ConfigManagerDeviceVnList(PhysicalDeviceVnTable *table) :
     201           0 :         table_(table), enqueue_count_(0), process_count_(0) {
     202           0 :     }
     203             : 
     204           0 :     ~ConfigManagerDeviceVnList() {
     205           0 :         assert(list_.size() == 0);
     206           0 :     }
     207             : 
     208           0 :     bool Add(Agent *agent, ConfigManager *mgr, const boost::uuids::uuid &dev,
     209             :              const boost::uuids::uuid &vn) {
     210           0 :         list_.insert(DeviceVnEntry(dev, vn));
     211           0 :         enqueue_count_++;
     212           0 :         mgr->Start();
     213           0 :         return true;
     214             :     }
     215             : 
     216           0 :     bool Delete(Agent *agent, ConfigManager *mgr, const boost::uuids::uuid &dev,
     217             :                 const boost::uuids::uuid &vn) {
     218           0 :         list_.erase(DeviceVnEntry(dev, vn));
     219           0 :         return true;
     220             :     }
     221             : 
     222           0 :     uint32_t Process(uint32_t weight) {
     223           0 :         uint32_t count = 0;
     224           0 :         DeviceVnIterator it = list_.begin();
     225           0 :         while (weight && (it != list_.end())) {
     226           0 :             DeviceVnIterator prev = it++;
     227           0 :             DBRequest req;
     228           0 :             table_->ProcessConfig(prev->dev_, prev->vn_);
     229           0 :             list_.erase(prev);
     230           0 :             weight--;
     231           0 :             count++;
     232           0 :         }
     233           0 :         return count;
     234             :     }
     235             : 
     236           0 :     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           0 : ConfigManager::ConfigManager(Agent *agent) :
     249           0 :     agent_(agent), trigger_(), timer_(NULL), timeout_(kMinTimeout) {
     250             : 
     251           0 :     int task_id = TaskScheduler::GetInstance()->GetTaskId("db::DBTable");
     252             :     trigger_.reset
     253           0 :         (new TaskTrigger(boost::bind(&ConfigManager::TriggerRun, this),
     254           0 :                          task_id, 0));
     255           0 :     timer_ = TimerManager::CreateTimer(*(agent->event_manager()->io_service()),
     256             :                                        "Config Manager", task_id, 0);
     257           0 :     for (uint32_t i = 0; i < kMaxTimeout; i++) {
     258           0 :         process_config_count_[i] = 0;
     259             :     }
     260           0 :     helper_.reset(new ConfigHelper(this, agent_));
     261           0 : }
     262             : 
     263           0 : ConfigManager::~ConfigManager() {
     264           0 :     timer_->Cancel();
     265           0 :     TimerManager::DeleteTimer(timer_);
     266           0 : }
     267             : 
     268           0 : void ConfigManager::Init() {
     269           0 :     AgentDBTable *intf_table = agent_->interface_table();
     270           0 :     vmi_list_.reset(new ConfigManagerNodeList(intf_table));
     271           0 :     physical_interface_list_.reset(new ConfigManagerNodeList(intf_table));
     272           0 :     logical_interface_list_.reset(new ConfigManagerNodeList(intf_table));
     273             : 
     274           0 :     device_list_.reset(new ConfigManagerNodeList
     275           0 :                        (agent_->physical_device_table()));
     276           0 :     sg_list_.reset(new ConfigManagerNodeList(agent_->sg_table()));
     277           0 :     tag_list_.reset(new ConfigManagerNodeList(agent_->tag_table()));
     278           0 :     vn_list_.reset(new ConfigManagerNodeList(agent_->vn_table()));
     279           0 :     vrf_list_.reset(new ConfigManagerNodeList(agent_->vrf_table()));
     280           0 :     vm_list_.reset(new ConfigManagerNodeList(agent_->vm_table()));
     281           0 :     hc_list_.reset(new ConfigManagerNodeList
     282           0 :                        (agent_->health_check_table()));
     283           0 :     bridge_domain_list_.reset(new ConfigManagerNodeList(
     284           0 :                                   agent_->bridge_domain_table()));
     285           0 :     policy_set_list_.reset(new ConfigManagerNodeList(
     286           0 :                                   agent_->policy_set_table()));
     287           0 :     qos_config_list_.reset(new ConfigManagerNodeList(agent_->qos_config_table()));
     288           0 :     device_vn_list_.reset(new ConfigManagerDeviceVnList
     289           0 :                           (agent_->physical_device_vn_table()));
     290           0 :     qos_queue_list_.reset(new ConfigManagerNodeList(agent_->qos_queue_table()));
     291           0 :     forwarding_class_list_.reset(new
     292           0 :             ConfigManagerNodeList(agent_->forwarding_class_table()));
     293           0 :     slo_list_.reset(new
     294           0 :             ConfigManagerNodeList(agent_->slo_table()));
     295           0 :     mp_list_.reset(new ConfigManagerNodeList(agent_->mp_table()));
     296             : 
     297           0 :     OperDB *oper_db = agent()->oper_db();
     298             :     global_vrouter_list_.reset
     299           0 :         (new ConfigManagerNodeList(oper_db->global_vrouter()));
     300             :     bgp_router_config_list_.reset
     301           0 :         (new ConfigManagerNodeList(oper_db->bgp_router_config()));
     302             :     virtual_router_list_.reset
     303           0 :         (new ConfigManagerNodeList(oper_db->vrouter()));
     304             :     global_qos_config_list_.reset
     305           0 :         (new ConfigManagerNodeList(oper_db->global_qos_config()));
     306             :     global_system_config_list_.reset
     307           0 :         (new ConfigManagerNodeList(oper_db->global_system_config()));
     308             :     network_ipam_list_.reset
     309           0 :         (new ConfigManagerNodeList(oper_db->network_ipam()));
     310           0 :     virtual_dns_list_.reset(new ConfigManagerNodeList(oper_db->virtual_dns()));
     311           0 : }
     312             : 
     313           0 : uint32_t ConfigManager::Size() const {
     314             :     return
     315           0 :         global_vrouter_list_->Size() +
     316           0 :         bgp_router_config_list_->Size() +
     317           0 :         virtual_router_list_->Size() +
     318           0 :         global_qos_config_list_->Size() +
     319           0 :         global_system_config_list_->Size() +
     320           0 :         network_ipam_list_->Size() + + +
     321           0 :         virtual_dns_list_->Size() +
     322           0 :         vmi_list_->Size() +
     323           0 :         physical_interface_list_->Size() +
     324           0 :         logical_interface_list_->Size() +
     325           0 :         device_list_->Size() +
     326           0 :         sg_list_->Size() +
     327           0 :         tag_list_->Size() +
     328           0 :         vn_list_->Size() +
     329           0 :         vrf_list_->Size() +
     330           0 :         vm_list_->Size() +
     331           0 :         hc_list_->Size() +
     332           0 :         device_vn_list_->Size() +
     333           0 :         qos_config_list_->Size() +
     334           0 :         bridge_domain_list_->Size() +
     335           0 :         policy_set_list_->Size() +
     336           0 :         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           0 : void ConfigManager::Start() {
     365           0 :     if (agent_->ResourceManagerReady() == false) {
     366           0 :         return;
     367             :     }
     368             : 
     369           0 :     if (agent_->test_mode()) {
     370           0 :         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           0 : bool ConfigManager::TriggerRun() {
     398           0 :     Run();
     399           0 :     return (Size() == 0);
     400             : }
     401             : 
     402             : // Run the change-list
     403           0 : int ConfigManager::Run() {
     404           0 :     uint32_t max_count = kIterationCount;
     405           0 :     uint32_t count = 0;
     406             : 
     407           0 :     count += global_vrouter_list_->Process(max_count - count);
     408           0 :     count += bgp_router_config_list_->Process(max_count - count);
     409           0 :     count += virtual_router_list_->Process(max_count - count);
     410           0 :     count += global_qos_config_list_->Process(max_count - count);
     411           0 :     count += global_system_config_list_->Process(max_count - count);
     412           0 :     count += network_ipam_list_->Process(max_count - count);
     413           0 :     count += virtual_dns_list_->Process(max_count - count);
     414           0 :     count += sg_list_->Process(max_count - count);
     415           0 :     count += tag_list_->Process(max_count - count);
     416           0 :     count += physical_interface_list_->Process(max_count - count);
     417           0 :     count += qos_queue_list_->Process(max_count - count);
     418           0 :     count += forwarding_class_list_->Process(max_count - count);
     419           0 :     count += qos_config_list_->Process(max_count - count);
     420           0 :     count += vn_list_->Process(max_count - count);
     421           0 :     count += vm_list_->Process(max_count - count);
     422           0 :     count += vrf_list_->Process(max_count - count);
     423           0 :     count += bridge_domain_list_->Process(max_count - count);
     424           0 :     count += policy_set_list_->Process(max_count - count);
     425           0 :     count += logical_interface_list_->Process(max_count - count);
     426           0 :     count += hc_list_->Process(max_count - count);
     427           0 :     count += vmi_list_->Process(max_count - count);
     428           0 :     count += device_list_->Process(max_count - count);
     429           0 :     count += device_vn_list_->Process(max_count - count);
     430           0 :     count += slo_list_->Process(max_count - count);
     431           0 :     count += mp_list_->Process(max_count - count);
     432           0 :     return count;
     433             : }
     434             : 
     435           0 : void ConfigManager::AddVmiNode(IFMapNode *node) {
     436           0 :     vmi_list_->Add(agent_, this, node);
     437           0 : }
     438             : 
     439           0 : uint32_t ConfigManager::VmiNodeCount() const {
     440           0 :     return vmi_list_->Size();
     441             : }
     442             : 
     443           0 : void ConfigManager::AddLogicalInterfaceNode(IFMapNode *node) {
     444           0 :     logical_interface_list_->Add(agent_, this, node);
     445           0 : }
     446             : 
     447           0 : uint32_t ConfigManager::LogicalInterfaceNodeCount() const {
     448           0 :     return logical_interface_list_->Size();
     449             : }
     450             : 
     451           0 : void ConfigManager::AddPhysicalDeviceNode(IFMapNode *node) {
     452           0 :     device_list_->Add(agent_, this, node);
     453           0 : }
     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           0 : void ConfigManager::AddSgNode(IFMapNode *node) {
     468           0 :     sg_list_->Add(agent_, this, node);
     469           0 : }
     470             : 
     471           0 : void ConfigManager::AddTagNode(IFMapNode *node) {
     472           0 :     tag_list_->Add(agent_, this, node);
     473           0 : }
     474             : 
     475           0 : void ConfigManager::AddVnNode(IFMapNode *node) {
     476           0 :     vn_list_->Add(agent_, this, node);
     477           0 : }
     478             : 
     479           0 : void ConfigManager::AddVrfNode(IFMapNode *node) {
     480           0 :     vrf_list_->Add(agent_, this, node);
     481           0 : }
     482             : 
     483           0 : void ConfigManager::AddVmNode(IFMapNode *node) {
     484           0 :     vm_list_->Add(agent_, this, node);
     485           0 : }
     486             : 
     487           0 : void ConfigManager::AddPhysicalInterfaceNode(IFMapNode *node) {
     488           0 :     physical_interface_list_->Add(agent_, this, node);
     489           0 : }
     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           0 : void ConfigManager::AddPhysicalDeviceVn(const boost::uuids::uuid &dev,
     512             :                                         const boost::uuids::uuid &vn) {
     513           0 :     device_vn_list_->Add(agent_, this, dev, vn);
     514           0 : }
     515             : 
     516           0 : void ConfigManager::DelPhysicalDeviceVn(const boost::uuids::uuid &dev,
     517             :                                         const boost::uuids::uuid &vn) {
     518           0 :     device_vn_list_->Delete(agent_, this, dev, vn);
     519           0 : }
     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           0 : void ConfigManager::AddNetworkIpamNode(IFMapNode *node) {
     533           0 :     network_ipam_list_->Add(agent_, this, node);
     534           0 : }
     535             : 
     536           0 : void ConfigManager::AddVirtualDnsNode(IFMapNode *node) {
     537           0 :     virtual_dns_list_->Add(agent_, this, node);
     538           0 : }
     539             : 
     540           0 : void ConfigManager::AddGlobalVrouterNode(IFMapNode *node) {
     541           0 :     global_vrouter_list_->Add(agent_, this, node);
     542           0 : }
     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           0 : bool ConfigManager::CanUseNode(IFMapNode *node) {
     576           0 :     if (node->IsDeleted()) {
     577           0 :         return false;
     578             :     }
     579             : 
     580             :     IFMapDependencyManager *dep =
     581           0 :         agent()->oper_db()->dependency_manager();
     582             : 
     583             :     // Table not managed by dependency manager. Node can be used
     584           0 :     if (dep->IsRegistered(node) == false)
     585           0 :         return true;
     586             : 
     587           0 :     IFMapNodeState *state = dep->IFMapNodeGet(node);
     588           0 :     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           0 :         return false;
     592             :     }
     593             : 
     594           0 :     if (state->notify() == false ||
     595           0 :         state->oper_db_request_enqueued() == false) {
     596           0 :         return false;
     597             :     }
     598             : 
     599           0 :     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           0 : bool ConfigManager::CanUseNode(IFMapNode *node, IFMapAgentTable *table) {
     607           0 :     if (table != static_cast<IFMapAgentTable *>(node->table())) {
     608           0 :         return false;
     609             :     }
     610             : 
     611           0 :     return CanUseNode(node);
     612             : }
     613             : 
     614           0 : bool ConfigManager::SkipNode(IFMapNode *node) {
     615           0 :     return !CanUseNode(node);
     616             : }
     617             : 
     618           0 : bool ConfigManager::SkipNode(IFMapNode *node, IFMapAgentTable *table) {
     619           0 :     return !CanUseNode(node, table);
     620             : }
     621             : 
     622             : 
     623           0 : IFMapNode *ConfigManager::FindAdjacentIFMapNode(IFMapNode *node,
     624             :                                               const char *type) {
     625           0 :     IFMapAgentTable *table = static_cast<IFMapAgentTable *>(node->table());
     626           0 :     DBGraph *graph = table->GetGraph();
     627           0 :     assert(node->IsVertexValid());
     628           0 :     for (DBGraphVertex::adjacency_iterator iter = node->begin(graph);
     629           0 :          iter != node->end(graph); ++iter) {
     630           0 :         IFMapNode *adj_node = static_cast<IFMapNode *>(iter.operator->());
     631           0 :         if (SkipNode(adj_node)) {
     632           0 :             continue;
     633             :         }
     634           0 :         if (strcmp(adj_node->table()->Typename(), type) == 0) {
     635           0 :             return adj_node;
     636             :         }
     637             :     }
     638             : 
     639           0 :     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