Browse Source

[3699] Added data tracing in the CfgHosts class.

Marcin Siodelski 10 years ago
parent
commit
32413af67c
2 changed files with 108 additions and 0 deletions
  1. 58 0
      src/lib/dhcpsrv/cfg_hosts.cc
  2. 50 0
      src/lib/dhcpsrv/hosts_messages.mes

+ 58 - 0
src/lib/dhcpsrv/cfg_hosts.cc

@@ -118,8 +118,17 @@ CfgHosts::getAllInternal(const std::vector<uint8_t>& identifier,
     // Append each Host object to the storage.
     for (HostContainerIndex0::iterator host = idx.lower_bound(t); host != idx.upper_bound(t);
          ++host) {
+        LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE_DETAIL_DATA,
+                  HOSTS_CFG_GET_ALL_IDENTIFIER_HOST)
+            .arg(identifier_text)
+            .arg((*host)->toText());
         storage.push_back(*host);
     }
+
+    // Log how many hosts found.
+    LOG_DEBUG(hosts_logger, HOSTS_DBG_RESULTS, HOSTS_CFG_GET_ALL_IDENTIFIER_COUNT)
+        .arg(identifier_text)
+        .arg(storage.size());
 }
 
 template<typename Storage>
@@ -157,8 +166,16 @@ CfgHosts::getAllInternal4(const IOAddress& address, Storage& storage) const {
     // Append each Host object to the storage.
     for (HostContainerIndex1::iterator host = r.first; host != r.second;
          ++host) {
+        LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE_DETAIL_DATA,
+                  HOSTS_CFG_GET_ALL_ADDRESS4_HOST)
+            .arg(address.toText())
+            .arg((*host)->toText());
         storage.push_back(*host);
     }
+
+    LOG_DEBUG(hosts_logger, HOSTS_DBG_RESULTS, HOSTS_CFG_GET_ALL_ADDRESS4_COUNT)
+        .arg(address.toText())
+        .arg(storage.size());
 }
 
 template<typename Storage>
@@ -178,8 +195,16 @@ CfgHosts::getAllInternal6(const IOAddress& address, Storage& storage) const {
     // Append each Host object to the storage.
     for (HostContainerIndex1::iterator host = r.first; host != r.second;
          ++host) {
+        LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE_DETAIL_DATA,
+                  HOSTS_CFG_GET_ALL_ADDRESS6_HOST)
+            .arg(address.toText())
+            .arg((*host)->toText());
         storage.push_back(*host);
     }
+
+    LOG_DEBUG(hosts_logger, HOSTS_DBG_RESULTS, HOSTS_CFG_GET_ALL_ADDRESS6_COUNT)
+        .arg(address.toText())
+        .arg(storage.size());
 }
 
 
@@ -208,6 +233,11 @@ CfgHosts::get4(const SubnetID& subnet_id, const IOAddress& address) const {
     for (ConstHostCollection::const_iterator host = hosts.begin();
          host != hosts.end(); ++host) {
         if ((*host)->getIPv4SubnetID() == subnet_id) {
+            LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE_DETAIL_DATA,
+                      HOSTS_CFG_GET_ONE_SUBNET_ID_ADDRESS4_HOST)
+                .arg(subnet_id)
+                .arg(address.toText())
+                .arg((*host)->toText());
             return (*host);
         }
     }
@@ -268,8 +298,15 @@ CfgHosts::getHostInternal6(const SubnetID& subnet_id,
     switch (storage.size()) {
     case 0:
         return (HostPtr());
+
     case 1:
+        LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE_DETAIL_DATA,
+                  HOSTS_CFG_GET_ONE_SUBNET_ID_ADDRESS6_HOST)
+            .arg(subnet_id)
+            .arg(address.toText())
+            .arg((*storage.begin())->toText());
         return (*storage.begin());
+
     default:
         isc_throw(DuplicateHost,  "more than one reservation found"
                   " for the host belonging to the subnet with id '"
@@ -303,8 +340,19 @@ CfgHosts::getAllInternal6(const SubnetID& subnet_id,
     // multiple addresses reserved, but for each (address, subnet_id) there should
     // be at most one host reserving it).
     for(HostContainer6Index1::iterator resrv = r.first; resrv != r.second; ++resrv) {
+        LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE_DETAIL_DATA,
+                  HOSTS_CFG_GET_ALL_SUBNET_ID_ADDRESS6_HOST)
+            .arg(subnet_id)
+            .arg(address.toText())
+            .arg(resrv->host_);
         storage.push_back(resrv->host_);
     }
+
+    LOG_DEBUG(hosts_logger, HOSTS_DBG_RESULTS,
+              HOSTS_CFG_GET_ALL_SUBNET_ID_ADDRESS6_COUNT)
+        .arg(subnet_id)
+        .arg(address.toText())
+        .arg(storage.size());
 }
 
 HostPtr
@@ -353,6 +401,16 @@ CfgHosts::getHostInternal(const SubnetID& subnet_id, const bool subnet6,
             }
         }
     }
+
+    if (host) {
+        LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE_DETAIL_DATA,
+                  HOSTS_CFG_GET_ONE_SUBNET_ID_HWADDR_DUID)
+            .arg(subnet_id)
+            .arg(hwaddr ? hwaddr->toText() : "(no-hwaddr)")
+            .arg(duid ? duid->toText() : "(no-duid)")
+            .arg(host->toText());
+    }
+
     return (host);
 }
 

+ 50 - 0
src/lib/dhcpsrv/hosts_messages.mes

@@ -24,11 +24,31 @@ This debug message is issued when retrieving all hosts, holding the
 reservation for the specific IPv4 address, from the configuration. The
 argument specifies the IPv4 address used to search the hosts.
 
+% HOSTS_CFG_GET_ALL_ADDRESS4_HOST using address %1 found host: %2
+This debug message is issued when found host with the reservation
+for the specified IPv4 addres. The arguments specify the IPv4 address
+and the detailed description of the host found.
+
+% HOSTS_CFG_GET_ALL_ADDRESS4_COUNT using address %1, found %2 host(s)
+This debug message logs the number of hosts found using the specified
+IPv4 address. The arguments specify the IPv4 address used and the number
+of hosts found respectively.
+
 % HOSTS_CFG_GET_ALL_ADDRESS6 get all hosts with reservations for IPv6 address %1
 This debug message is issued when retrieving all hosts, holding the
 reservation for the specific IPv6 address, from the configuration.
 The argument specifies the IPv6 address used to search the hosts.
 
+% HOSTS_CFG_GET_ALL_ADDRESS6_HOST using address %1 found host: %2
+This debug message is issued when found host with the reservation
+for the specified IPv6 addres. The arguments specify the IPv6 address
+and the detailed description of the host found.
+
+% HOSTS_CFG_GET_ALL_ADDRESS6_COUNT using address %1, found %2 host(s)
+This debug message logs the number of hosts found using the specified
+IPv4 address. The arguments specify the IPv6 address used and the number
+of hosts found respectively.
+
 % HOSTS_CFG_GET_ALL_HWADDR_DUID get all hosts with reservations for HWADDR %1 and DUID %2
 This debug message is issued when retrieving reservations for all hosts
 using specific HW address or DUID. The arguments specify the HW address and
@@ -39,27 +59,57 @@ This debug message is issued when retrieving reservations for all hosts
 identified by HW address or DUID. The argument holds both the identifier
 type and the value.
 
+% HOSTS_CFG_GET_ALL_IDENTIFIER_HOST using identifier: %1, found host: %2
+This debug message is issued when found host identified by the specific
+identifier. The arguments specify the identifier and the detailed
+description of the host found.
+
+% HOSTS_CFG_GET_ALL_IDENTIFIER_COUNT using identifier %1, found %2 host(s)
+This debug message logs the number of hosts found using the specified
+identifier. The arguments specify the identifier used and the number
+of hosts found respectively.
+
 % HOSTS_CFG_GET_ALL_SUBNET_ID_ADDRESS6 get all hosts with reservations for subnet id %1 and IPv6 address %2
 This debug message is issued when retrieving all hosts connected to
 the specific subnet and having the specific IPv6 address reserved.
 The arguments specify subnet id and IPv6 address respectively.
 
+% HOSTS_CFG_GET_ALL_SUBNET_ID_ADDRESS6_HOST using subnet id %1 and address %2, found host: %3
+This debug message include the details of the host found using the
+subnet id and address. The arguments specify subnet id, address and
+found host details respectively.
+
+% HOSTS_CFG_GET_ALL_SUBNET_ID_ADDRESS6_COUNT using subnet id %1 and address %2, found %3 host(s)
+This debug message include the details of the host found using the
+subnet id and address. The arguments specify subnet id, address and
+found host details respectively.
+
 % HOSTS_CFG_GET_ONE_SUBNET_ID_ADDRESS4 get one host with reservation for subnet id %1 and IPv4 address %2
 This debug message is issued when retrieving a host connected to the
 specific subnet and having the specific IPv4 address reserved. The
 arguments specify subnet id and IPv4 address respectively.
 
+% HOSTS_CFG_GET_ONE_SUBNET_ID_ADDRESS4_HOST using subnet id %1 and address %2, found host: %3
+This debug message logs the details of the host found using the
+subnet id and IPv4 address.
+
 % HOSTS_CFG_GET_ONE_SUBNET_ID_ADDRESS6 get one host with reservation for subnet id %1 and including IPv6 address %2
 This debug message is issued when retrieveing a host connected to the
 specific subnet and having the specific IPv6 address reserved. The
 arguments specify subnet id and IPv6 address respectively.
 
+% HOSTS_CFG_GET_ONE_SUBNET_ID_ADDRESS6_HOST using subnet id %1 and address %2, found host: %3
+This debug message logs the details of the host found using the
+subnet id and IPv6 address.
+
 % HOSTS_CFG_GET_ONE_SUBNET_ID_HWADDR_DUID get one host with %1 reservation for subnet id %2, HWADDR %3, DUID %4
 This debug message is issued when retrieving the host holding IPv4 or
 IPv6 reservations, which is connected to the specific subnet and is
 identified by the specific HW address or DUID. The first argument
 identifies if the IPv4 or IPv6 reservation is desired.
 
+% HOSTS_CFG_GET_ONE_SUBNET_ID_HWADDR_DUID_HOST using subnet id %1, HWADDR %2 and DUID %3, found host: %4
+
 % HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_HWADDR_DUID trying alternate source for host using subnet id %1, HWADDR %2, DUID%3
 This debug message is issued when the Host Manager doesn't find the
 host connected to the specific subnet and identified by the HW address