]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1163] Clean up code
authorRazvan Becheriu <razvan@isc.org>
Tue, 22 Sep 2020 08:46:20 +0000 (11:46 +0300)
committerRazvan Becheriu <razvan@isc.org>
Tue, 22 Sep 2020 08:46:20 +0000 (11:46 +0300)
src/lib/dhcpsrv/cql_host_data_source.cc
src/lib/dhcpsrv/cql_host_data_source.h
src/share/api/reservation-get-page.json

index 849a21d2abecacd583abb50d7c9af553ae3ce5a2..e3ef27b28affcb854ede58e3f16fecbd7e51afbb 100644 (file)
@@ -334,11 +334,6 @@ public:
     static constexpr StatementTag GET_HOST_BY_IPV4_SUBNET_ID_LIMIT =
         "GET_HOST_BY_IPV4_SUBNET_ID_LIMIT";
 
-    // Retrieves host information along with the IPv4 options associated
-    // with it using a subnet identifier from host (paging).
-    static constexpr StatementTag GET_HOST_BY_IPV4_SUBNET_ID_KEY =
-        "GET_HOST_BY_IPV4_SUBNET_ID_KEY";
-
     // Retrieves host information along with the IPv4 options associated
     // with it using a subnet identifier from next host (paging).
     static constexpr StatementTag GET_HOST_BY_IPV4_SUBNET_ID_NEXT_KEY =
@@ -354,11 +349,6 @@ public:
     static constexpr StatementTag GET_HOST_BY_IPV6_SUBNET_ID_LIMIT =
         "GET_HOST_BY_IPV6_SUBNET_ID_LIMIT";
 
-    // Retrieves host information; IPv6 reservations and IPv6 options
-    // associated with it using subnet identifier from host (paging).
-    static constexpr StatementTag GET_HOST_BY_IPV6_SUBNET_ID_KEY =
-        "GET_HOST_BY_IPV6_SUBNET_ID_KEY";
-
     // Retrieves host information; IPv6 reservations and IPv6 options
     // associated with it using subnet identifier from next host (paging).
     static constexpr StatementTag GET_HOST_BY_IPV6_SUBNET_ID_NEXT_KEY =
@@ -510,8 +500,6 @@ constexpr StatementTag CqlHostExchange::GET_HOST_BY_IPV4_SUBNET_ID_LIMIT;
 constexpr StatementTag CqlHostExchange::GET_HOST_BY_IPV6_SUBNET_ID_LIMIT;
 constexpr StatementTag CqlHostExchange::GET_HOST_BY_IPV4_SUBNET_ID_NEXT_KEY;
 constexpr StatementTag CqlHostExchange::GET_HOST_BY_IPV6_SUBNET_ID_NEXT_KEY;
-constexpr StatementTag CqlHostExchange::GET_HOST_BY_IPV4_SUBNET_ID_KEY;
-constexpr StatementTag CqlHostExchange::GET_HOST_BY_IPV6_SUBNET_ID_KEY;
 constexpr StatementTag CqlHostExchange::GET_HOST_BY_IPV4_SUBNET_ID_PAGE;
 constexpr StatementTag CqlHostExchange::GET_HOST_BY_IPV6_SUBNET_ID_PAGE;
 constexpr StatementTag CqlHostExchange::GET_HOST_LIMIT;
@@ -1133,43 +1121,6 @@ StatementMap CqlHostExchange::tagged_statements_ = {
       "ALLOW FILTERING "
      }},
 
-    {GET_HOST_BY_IPV4_SUBNET_ID_KEY,
-     {GET_HOST_BY_IPV4_SUBNET_ID_KEY,
-      "SELECT "
-      "key, "
-      "id, "
-      "host_identifier, "
-      "host_identifier_type, "
-      "host_ipv4_subnet_id, "
-      "host_ipv6_subnet_id, "
-      "host_ipv4_address, "
-      "host_ipv4_next_server, "
-      "host_ipv4_server_hostname, "
-      "host_ipv4_boot_file_name, "
-      "auth_key, "
-      "hostname, "
-      "user_context, "
-      "host_ipv4_client_classes, "
-      "host_ipv6_client_classes, "
-      "reserved_ipv6_prefix_address, "
-      "reserved_ipv6_prefix_length, "
-      "reserved_ipv6_prefix_address_type, "
-      "iaid, "
-      "option_universe, "
-      "option_code, "
-      "option_value, "
-      "option_formatted_value, "
-      "option_space, "
-      "option_is_persistent, "
-      "option_client_class, "
-      "option_subnet_id, "
-      "option_user_context, "
-      "option_scope_id "
-      "FROM hosts "
-      "WHERE key = ? "
-      "ALLOW FILTERING "
-     }},
-
     {GET_HOST_BY_IPV4_SUBNET_ID_PAGE,
      {GET_HOST_BY_IPV4_SUBNET_ID_PAGE,
       "SELECT "
@@ -1286,43 +1237,6 @@ StatementMap CqlHostExchange::tagged_statements_ = {
       "ALLOW FILTERING "
      }},
 
-    {GET_HOST_BY_IPV6_SUBNET_ID_KEY,
-     {GET_HOST_BY_IPV6_SUBNET_ID_KEY,
-      "SELECT "
-      "key, "
-      "id, "
-      "host_identifier, "
-      "host_identifier_type, "
-      "host_ipv4_subnet_id, "
-      "host_ipv6_subnet_id, "
-      "host_ipv4_address, "
-      "host_ipv4_next_server, "
-      "host_ipv4_server_hostname, "
-      "host_ipv4_boot_file_name, "
-      "auth_key, "
-      "hostname, "
-      "user_context, "
-      "host_ipv4_client_classes, "
-      "host_ipv6_client_classes, "
-      "reserved_ipv6_prefix_address, "
-      "reserved_ipv6_prefix_length, "
-      "reserved_ipv6_prefix_address_type, "
-      "iaid, "
-      "option_universe, "
-      "option_code, "
-      "option_value, "
-      "option_formatted_value, "
-      "option_space, "
-      "option_is_persistent, "
-      "option_client_class, "
-      "option_subnet_id, "
-      "option_user_context, "
-      "option_scope_id "
-      "FROM hosts "
-      "WHERE key = ? "
-      "ALLOW FILTERING "
-     }},
-
     {GET_HOST_BY_IPV6_SUBNET_ID_PAGE,
      {GET_HOST_BY_IPV6_SUBNET_ID_PAGE,
       "SELECT "
@@ -2433,20 +2347,6 @@ protected:
     virtual ConstHostCollection getHostCollectionPage6(uint64_t lower_host_id,
                                                        size_t count = 0) const;
 
-    /// @brief Retrieves a host by key.
-    ///
-    /// @param key identifier of the host
-    ///
-    /// @return a host for the specific key
-    virtual ConstHostPtr getHostByKey4(uint64_t key) const;
-
-    /// @brief Retrieves a host by key.
-    ///
-    /// @param key identifier of the host
-    ///
-    /// @return a host for the specific key
-    virtual ConstHostPtr getHostByKey6(uint64_t key) const;
-
     /// @brief Retrieves a host by key.
     ///
     /// @param key identifier of the host
@@ -3144,56 +3044,6 @@ CqlHostDataSourceImpl::getHostCollection(StatementTag statement_tag,
     return (result_collection);
 }
 
-ConstHostPtr
-CqlHostDataSourceImpl::getHostByKey4(uint64_t key) const {
-    // Bind to array.
-    AnyArray where_values;
-    cass_int64_t key_data = static_cast<cass_int64_t>(key);
-    where_values.add(&key_data);
-
-    // Run statement.
-    ConstHostCollection collection =
-            getHostCollection(CqlHostExchange::GET_HOST_BY_IPV4_SUBNET_ID_KEY,
-                              where_values);
-
-    if (collection.empty()) {
-        return (ConstHostPtr());
-    }
-
-    if (collection.size() >= 2u) {
-        isc_throw(MultipleRecords, "CqlHostDataSourceImpl::getHost(): multiple records were "
-                  "found in the database where only one was expected for statement "
-                  << CqlHostExchange::GET_HOST_BY_IPV4_SUBNET_ID_KEY);
-    }
-
-    return (*collection.begin());
-}
-
-ConstHostPtr
-CqlHostDataSourceImpl::getHostByKey6(uint64_t key) const {
-    // Bind to array.
-    AnyArray where_values;
-    cass_int64_t key_data = static_cast<cass_int64_t>(key);
-    where_values.add(&key_data);
-
-    // Run statement.
-    ConstHostCollection collection =
-            getHostCollection(CqlHostExchange::GET_HOST_BY_IPV6_SUBNET_ID_KEY,
-                              where_values);
-
-    if (collection.empty()) {
-        return (ConstHostPtr());
-    }
-
-    if (collection.size() >= 2u) {
-        isc_throw(MultipleRecords, "CqlHostDataSourceImpl::getHost(): multiple records were "
-                  "found in the database where only one was expected for statement "
-                  << CqlHostExchange::GET_HOST_BY_IPV6_SUBNET_ID_KEY);
-    }
-
-    return (*collection.begin());
-}
-
 ConstHostPtr
 CqlHostDataSourceImpl::getHostByKey(uint64_t key) const {
     // Bind to array.
@@ -3232,7 +3082,7 @@ CqlHostDataSourceImpl::getHostCollectionPage4(const SubnetID& subnet_id,
             break;
         }
 
-        ConstHostPtr host = getHostByKey4(key);
+        ConstHostPtr host = getHostByKey(key);
         result_collection.push_back(host);
         lower_host_id = host->getHostId();
     }
@@ -3253,7 +3103,7 @@ CqlHostDataSourceImpl::getHostCollectionPage6(const SubnetID& subnet_id,
             break;
         }
 
-        ConstHostPtr host = getHostByKey6(key);
+        ConstHostPtr host = getHostByKey(key);
         result_collection.push_back(host);
         lower_host_id = host->getHostId();
     }
@@ -3293,7 +3143,7 @@ CqlHostDataSourceImpl::getHostCollectionPage6(uint64_t lower_host_id,
             break;
         }
 
-        ConstHostPtr host = getHostByKey6(key);
+        ConstHostPtr host = getHostByKey(key);
         result_collection.push_back(host);
         lower_host_id = host->getHostId();
     }
index 85297276dea638aa2f1895628e7190d4f104c39e..f72531230059b787576046322e21811702b2ff06 100644 (file)
@@ -262,8 +262,6 @@ public:
 
     /// @brief Returns range of hosts.
     ///
-    /// Not implemented.
-    ///
     /// @param source_index Index of the source (unused).
     /// @param lower_host_id Host identifier used as lower bound for the
     /// returned range.
@@ -277,8 +275,6 @@ public:
 
     /// @brief Returns range of hosts.
     ///
-    /// Not implemented.
-    ///
     /// @param source_index Index of the source (unused).
     /// @param lower_host_id Host identifier used as lower bound for the
     /// returned range.
index 28f4d50985f1e7c226dce4e3c3b70157748b16f8..6be2b52ff1ea4ce19a54b836a257c3d5fe1dc847 100644 (file)
@@ -5,7 +5,7 @@
         "This command retrieves all host reservations or host reservations for a specified subnet by page."
     ],
     "cmd-comment": [
-        "The page size limit is mandatory. The subnet-id is optional since version 1.9.0, The source-index and from host-id are optional and default to 0. Values to use to load the next page are returned in responses in a next map."
+        "The page size limit is mandatory. The subnet-id is optional since version 1.9.0. The source-index and from host-id are optional and default to 0. Values to use to load the next page are returned in responses in a next map."
     ],
     "cmd-syntax": [
         "{",