entry. If the client class previously had a resource assigned to it, and the
``class-update`` command is missing the resource, it is deleted from the server
configuration. If an incremental update of the class is desired, then this can
-be achieved by doing a `class-get <command-class-get_>`_ to get the full picture
+be achieved by doing a `class-get <command-class-get_>`_ to get the current state
of the client class, picking the client class out of the response, modifying it
to the required outcome, and then issuing the ``client-update`` command with the
resulting client class attached.
}
}
-But it can also take many more parameters, for example:
+It can also take many more parameters, for example:
.. code-block:: json
}
}
-But it can also take many more parameters, for example:
+It can also take many more parameters, for example:
.. code-block:: json
of the entry. If the host previously had a resource assigned to it, and the
``reservation-update`` command is missing the resource, it is deleted from the
database. If an incremental update of the host is desired, then this can be
-achieved by doing a ``reservation-get-by-id`` to get the full picture of the
+achieved by doing a ``reservation-get-by-id`` to get the current state of the
host, picking the host out of the response, modifying it to the required
outcome, and then issuing the ``reservation-update`` command with the resulting
host attached.
deleted from the lease database. If an incremental update of the lease is
desired, then this can be achieved by doing a
`lease4-get <command-lease4-get_>`_ / `lease6-get <command-lease6-get_>`_
-command to get the full picture of the lease, picking the lease out of the
+command to get the current state of the lease, picking the lease out of the
response, modifying it to the required outcome, and then issuing the
``lease4-update``/``lease6-update`` command with the resulting lease attached.
}
As with other update commands, this command overwrites all the contents of the
-entry. If the IPv4 subnet previously had a resource assigned to it, and the
+entry. If the IPv6 subnet previously had a resource assigned to it, and the
``subnet6-update`` command is missing the resource, it is deleted from the
server configuration. If an incremental update of the subnet is desired, then
this can be achieved with `subnet6-delta-add <command-subnet6-delta-add_>`_.
/// @brief lease4-add, lease6-add command handler
///
/// This command attempts to add a lease.
- /// It extracts the command name and arguments from the given Callouthandle,
+ /// It extracts the command name and arguments from the given CalloutHandle,
/// attempts to process them, and then set's the handle's "response"
/// argument accordingly.
///
/// @brief lease4-get, lease6-get command handler
///
/// This command attempts to retrieve a lease that match selected criteria.
- /// It extracts the command name and arguments from the given Callouthandle,
+ /// It extracts the command name and arguments from the given CalloutHandle,
/// attempts to process them, and then set's the handle's "response"
/// argument accordingly.
///
///
/// This command attempts to delete an IPv4 lease that match selected
/// criteria.
- /// It extracts the command name and arguments from the given Callouthandle,
+ /// It extracts the command name and arguments from the given CalloutHandle,
/// attempts to process them, and then set's the handle's "response"
/// argument accordingly. If the lease is deleted successfully, then a call
/// to @ref isc::dhcp::queueNCR() is issued, which to generate an
/// @brief lease6-del command handler
///
/// This command attempts to delete a lease that match selected criteria.
- /// It extracts the command name and arguments from the given Callouthandle,
+ /// It extracts the command name and arguments from the given CalloutHandle,
/// attempts to process them, and then set's the handle's "response"
/// argument accordingly. If the lease is deleted successfully, then a call
/// to @ref isc::dhcp::queueNCR() is issued, which to generate an
/// specified will replace existing lease. The only condition is that
/// the IP address must not change. If you want to change the IP address,
/// please use lease4-del and lease4-add instead.
- /// It extracts the command name and arguments from the given Callouthandle,
+ /// It extracts the command name and arguments from the given CalloutHandle,
/// attempts to process them, and then set's the handle's "response"
/// argument accordingly.
///
/// specified will replace existing lease. The only condition is that
/// the IP address must not change. If you want to change the IP address,
/// please use lease6-del and lease6-add instead.
- /// It extracts the command name and arguments from the given Callouthandle,
+ /// It extracts the command name and arguments from the given CalloutHandle,
/// attempts to process them, and then set's the handle's "response"
/// argument accordingly.
///
/// subnet. Currently the leases are removed from the database,
/// without any processing (like calling hooks or doing DDNS
/// cleanups).
- /// It extracts the command name and arguments from the given Callouthandle,
+ /// It extracts the command name and arguments from the given CalloutHandle,
/// attempts to process them, and then set's the handle's "response"
/// argument accordingly.
///
/// subnet. Currently the leases are removed from the database,
/// without any processing (like calling hooks or doing DDNS
/// cleanups).
- /// It extracts the command name and arguments from the given Callouthandle,
+ /// It extracts the command name and arguments from the given CalloutHandle,
/// attempts to process them, and then set's the handle's "response"
/// argument accordingly.
///
/// This command attempts to resend the DDNS updates for the IPv4 lease that
/// matches the selection criteria.
///
- /// It extracts the command name and arguments from the given Callouthandle,
+ /// It extracts the command name and arguments from the given CalloutHandle,
/// attempts to process them, and then set's the handle's "response"
/// argument accordingly.
///
/// This command attempts to resend the DDNS updates for the IPv6 lease that
/// matches the selection criteria.
///
- /// It extracts the command name and arguments from the given Callouthandle,
+ /// It extracts the command name and arguments from the given CalloutHandle,
/// attempts to process them, and then set's the handle's "response"
/// argument accordingly.
///
/// This commands attempts to write the lease database to a CSV file.
/// Currently it is supported only by the memfile database and
/// should be reserved to emergency situations.
- /// It extracts the command name and arguments from the given Callouthandle,
+ /// It extracts the command name and arguments from the given CalloutHandle,
/// attempts to process them, and then set's the handle's "response"
/// argument accordingly.
///
///
/// This command attempts to fetch lease4 statistics for one or
/// more subnets based upon subnet selection criteria (or lack thereof).
- /// It extracts the command name and arguments from the given Callouthandle,
+ /// It extracts the command name and arguments from the given CalloutHandle,
/// attempts to process them, and then set's the handle's "response"
/// arguments accordingly.
/// {
///
/// This command attempts to fetch lease6 statistics for one or
/// more subnets based upon subnet selection criteria (or lack thereof).
- /// It extracts the command name and arguments from the given Callouthandle,
+ /// It extracts the command name and arguments from the given CalloutHandle,
/// attempts to process them, and then set's the handle's "response"
/// argument accordingly.
/// {
std::string
parseCommand(ConstElementPtr& arg, ConstElementPtr command) {
if (!command) {
- isc_throw(CtrlChannelError, "No command specified");
+ isc_throw(CtrlChannelError, "no command specified");
}
if (command->getType() != Element::map) {
isc_throw(CtrlChannelError, "invalid command: expected toplevel entry to be a map, got "
/// @brief Attempts to update an existing host entry.
///
/// @param host the host up to date with the requested changes
- ///
- /// @return true if deletion was successful, false if the host was not there.
virtual void update(HostPtr const& host) = 0;
/// @brief Return backend type
/// @return Parameters of the backend.
virtual isc::db::DatabaseConnection::ParameterMap getParameters() const {
return (isc::db::DatabaseConnection::ParameterMap());
- };
+ }
/// @brief Commit Transactions
///
" is added to the configuration");
}
- // At least one subnet ID must be used
+ // At least one subnet ID must be used.
if (host->getIPv4SubnetID() == SUBNET_ID_UNUSED &&
host->getIPv6SubnetID() == SUBNET_ID_UNUSED) {
isc_throw(BadValue, "must not use both IPv4 and IPv6 subnet ids of"
const uint8_t* identifier_begin, const size_t identifier_len);
/// @brief Implements @ref BaseHostDataSource::update() for config hosts.
+ ///
+ /// Attempts to update an existing host entry.
+ ///
+ /// @param host the host up to date with the requested changes
void update(HostPtr const& host);
/// @brief Return backend type
const uint8_t* identifier_begin, const size_t identifier_len);
/// @brief Implements @ref BaseHostDataSource::update() for alternate sources.
+ ///
+ /// Attempts to update an existing host entry.
+ ///
+ /// @param host the host up to date with the requested changes
void update(HostPtr const& host);
/// @brief Return backend type
const asiolink::IOAddress& address) const;
/// @brief Implements @ref BaseHostDataSource::update() for MySQL.
+ ///
+ /// Attempts to update an existing host entry.
+ ///
+ /// @param host the host up to date with the requested changes
void update(HostPtr const& host);
/// @brief Return backend type
const asiolink::IOAddress& address) const;
/// @brief Implements @ref BaseHostDataSource::update() for PostgreSQL.
+ ///
+ /// Attempts to update an existing host entry.
+ ///
+ /// @param host the host up to date with the requested changes
void update(HostPtr const& host);
/// @brief Return backend type
MultiThreadingTest mt(true);
testUpdate();
}
+
/// @brief Test fixture class for validating @c HostMgr using
/// PostgreSQL as alternate host data source.
class PgSQLHostMgrTest : public HostMgrTest {
void
MemHostDataSource::update(HostPtr const& host) {
- for (auto h = store_.begin(); h != store_.end(); ++h) {
- if ((*h)->getHostId() == host->getHostId()) {
- store_.erase(h);
- break;
- }
+ bool deleted(false);
+ if (host->getIPv4SubnetID() != SUBNET_ID_UNUSED) {
+ vector<uint8_t> const& identifier(host->getIdentifier());
+ deleted = del4(host->getIPv4SubnetID(), host->getIdentifierType(), identifier.data(),
+ identifier.size());
+ } else if (host->getIPv6SubnetID() != SUBNET_ID_UNUSED) {
+ vector<uint8_t> const& identifier(host->getIdentifier());
+ deleted = del6(host->getIPv6SubnetID(), host->getIdentifierType(), identifier.data(),
+ identifier.size());
+ } else {
+ isc_throw(HostNotFound, "Mandatory 'subnet-id' parameter missing.");
+ }
+ if (!deleted) {
+ isc_throw(HostNotFound, "Host not updated (not found).");
}
store_.push_back(host);
}
const uint8_t* identifier_begin, const size_t identifier_len);
/// @brief Implements @ref BaseHostDataSource::update() for memory hosts.
+ ///
+ /// Attempts to update an existing host entry.
+ ///
+ /// @param host the host up to date with the requested changes
void update(HostPtr const& host);
/// @brief Return backend type
"This command adds a new host reservation. The reservation may include IPv4 addresses, IPv6 addresses, IPv6 prefixes, various identifiers, a class the client will be assigned to, DHCPv4 and DHCPv6 options, and more."
],
"cmd-comment": [
- "Note that ip-address, client-id, next-server, server-hostname, and boot-file-name are IPv4-specific. duid, ip-addresses, and prefixes are IPv6-specific."
+ "Note that ip-address, client-id, next-server, server-hostname, and boot-file-name are IPv4-specific. ip-addresses, and prefixes are IPv6-specific."
],
"cmd-syntax": [
"{",
" \"arguments\": {",
" \"reservation\": {",
" \"boot-file-name\": <string>,",
- " \"comment\": <string>,",
" \"client-id\": <string>,",
" \"circuit-id\": <string>,",
" \"duid\": <string>,",
{
"access": "write",
- "avail": "2.4.0",
+ "avail": "2.3.7",
"brief": [
"This command updates an existing host reservation. The reservation has to include host identifiers and a subnet identifier and may include IPv4 addresses, IPv6 addresses, IPv6 prefixes, various identifiers, a class the client will be assigned to, DHCPv4 and DHCPv6 options, and more."
],
"cmd-comment": [
- "Note that ip-address, client-id, next-server, server-hostname, and boot-file-name are IPv4-specific. duid, ip-addresses, and prefixes are IPv6-specific."
+ "Note that ip-address, client-id, next-server, server-hostname, and boot-file-name are IPv4-specific. ip-addresses, and prefixes are IPv6-specific."
],
"cmd-syntax": [
"{",
" \"arguments\": {",
" \"reservation\": {",
" \"boot-file-name\": <string>,",
- " \"comment\": <string>,",
" \"client-id\": <string>,",
" \"circuit-id\": <string>,",
" \"duid\": <string>,",