Commit dc1071d7 authored by Thomas Markwalder's avatar Thomas Markwalder

[3088] Initial implementation of d2::NameRemoveTransaction

Interrim check-in for 3088, which introduces the initial
implementation of d2:NameRemoveTransaction.  This class
implements the state model logic necessary for removing
DNS entries per RFC 4703.  The state model logic is
complete, what remains is the logic to build the actual
request messages.
parent 4895dc78
......@@ -65,6 +65,7 @@ b10_dhcp_ddns_SOURCES += d2_zone.cc d2_zone.h
b10_dhcp_ddns_SOURCES += dns_client.cc dns_client.h
b10_dhcp_ddns_SOURCES += labeled_value.cc labeled_value.h
b10_dhcp_ddns_SOURCES += nc_add.cc nc_add.h
b10_dhcp_ddns_SOURCES += nc_remove.cc nc_remove.h
b10_dhcp_ddns_SOURCES += nc_trans.cc nc_trans.h
b10_dhcp_ddns_SOURCES += state_model.cc state_model.h
......
......@@ -351,3 +351,90 @@ additions which were received and accepted by an appropriate DNS server.
This is an error message issued after DHCP_DDNS attempts to submit DNS mapping
entry additions have failed. The precise reason for the failure should be
documented in preceding log entries.
% DHCP_DDNS_FORWARD_REMOVE_ADDRS_BUILD_FAILURE A DNS udpate message to remove a forward DNS Address entry could not be constructed for this request: %1 reason: %2
This is an error message issued when an error occurs attempting to construct
the server bound packet requesting a forward address (A or AAAA) removal. This
is due to invalid data contained in the NameChangeRequest. The request will be
aborted. This is most likely a configuration issue.
% DHCP_DDNS_FORWARD_REMOVE_ADDRS_REJECTED DNS Server, %1, rejected a DNS update request to remove the forward address mapping for FQDN, %2, with an RCODE: %3
This is an error message issued when an update was rejected by the DNS server
it was sent to for the reason given by the RCODE. The rcode values are defined
in RFC 2136.
% DHCP_DDNS_FORWARD_REMOVE_ADDRS_IO_ERROR DHCP_DDNS encountered an IO error sending a forward mapping address removal for FQDN %1 to DNS server %2
This is an error message issued when a communication error occurs while
DHCP_DDNS is carrying out a forward address remove. The application will retry
against the same server or others as appropriate.
% DHCP_DDNS_FORWARD_REMOVE_ADDRS_RESP_CORRUPT DHCP_DDNS received a corrupt response from the DNS server, %1, while removing forward address mapping for FQDN, %2
This is an error message issued when the response received by DHCP_DDNS, to a
update request to remove a forward address mapping, is mangled or malformed.
The application will retry against the same server or others as appropriate.
% DHCP_DDNS_FORWARD_REMOVE_ADDRS_BAD_DNSCLIENT_STATUS DHCP_DDNS received an unknown DNSClient status: %1, while removing a forward address mapping for FQDN %2 to DNS server %3
This is an error message issued when DNSClient returns an unrecognized status
while DHCP_DDNS was removing a forward address mapping. The request will be
aborted. This is most likely a programmatic issue and should be reported.
% DHCP_DDNS_FORWARD_REMOVE_RRS_BUILD_FAILURE A DNS udpate message to remove forward DNS RR entries could not be constructed for this request: %1 reason: %2
This is an error message issued when an error occurs attempting to construct
the server bound packet requesting forward RR (DHCID RR) removal. This is due
to invalid data contained in the NameChangeRequest. The request will be aborted.This is most likely a configuration issue.
% DHCP_DDNS_FORWARD_REMOVE_RRS_REJECTED DNS Server, %1, rejected a DNS update request to remove forward RR entries for FQDN, %2, with an RCODE: %3
This is an error message issued when an update was rejected by the DNS server
it was sent to for the reason given by the RCODE. The rcode values are defined
in RFC 2136.
% DHCP_DDNS_FORWARD_REMOVE_RRS_IO_ERROR DHCP_DDNS encountered an IO error sending a forward RR removal for FQDN %1 to DNS server %2
This is an error message issued when a communication error occurs while
DHCP_DDNS is carrying out a forward RR remove. The application will retry
against the same server.
% DHCP_DDNS_FORWARD_REMOVE_RRS_RESP_CORRUPT DHCP_DDNS received a corrupt response from the DNS server, %1, while removing forward RRs for FQDN, %2
This is an error message issued when the response received by DHCP_DDNS, to a
update request to remove forward RRs mapping, is mangled or malformed.
The application will retry against the same server or others as appropriate.
% DHCP_DDNS_FORWARD_REMOVE_RRS_BAD_DNSCLIENT_STATUS DHCP_DDNS received an unknown DNSClient status: %1, while removing forward RRs for FQDN %2 to DNS server %3
This is an error message issued when DNSClient returns an unrecognized status
while DHCP_DDNS was removing forward RRs. The request will be aborted. This is
most likely a programmatic issue and should be reported.
% DHCP_DDNS_REVERSE_REMOVE_BUILD_FAILURE A DNS update message to remove a reverse DNS entry could not be constructed from this request: %1 reason: %2
This is an error message issued when an error occurs attempting to construct
the server bound packet requesting a reverse PTR removal. This is
due to invalid data contained in the NameChangeRequest. The request will be
aborted. This is most likely a configuration issue.
% DHCP_DDNS_REVERSE_REMOVE_REJECTED DNS Server, %1, rejected a DNS update request to remove the reverse mapping for FQDN, %2, with an RCODE: %3
This is an error message issued when an update was rejected by the DNS server
it was sent to for the reason given by the RCODE. The rcode values are defined
in RFC 2136.
% DHCP_DDNS_REVERSE_REMOVE_IO_ERROR DHCP_DDNS encountered an IO error sending a reverse mapping remove for FQDN %1 to DNS server %2
This is an error message issued when a communication error occurs while
DHCP_DDNS is carrying out a reverse address update. The application will
retry against the same server or others as appropriate.
% DHCP_DDNS_REVERSE_REMOVE_RESP_CORRUPT DHCP_DDNS received a corrupt response from the DNS server, %1, while removing reverse address mapping for FQDN, %2
This is an error message issued when the response received by DHCP_DDNS, to a
update request to remove a reverse address, is mangled or malformed.
The application will retry against the same server or others as appropriate.
% DHCP_DDNS_REVERSE_REMOVE_BAD_DNSCLIENT_STATUS DHCP_DDNS received an unknown DNSClient status: %1, while removing reverse address mapping for FQDN %2 to DNS server %3
This is an error message issued when DNSClient returns an unrecognized status
while DHCP_DDNS was removing a reverse address mapping. The request will be
aborted. This is most likely a programmatic issue and should be reported.
% DHCP_DDNS_REMOVE_SUCCEEDED DHCP_DDNS successfully removed the DNS mapping addition for this request: %1
This is a debug message issued after DHCP_DDNS has submitted DNS mapping
removals which were received and accepted by an appropriate DNS server.
% DHCP_DDNS_REMOVE_FAILED DHCP_DDNS failed attempting to make DNS mapping removals for this request: %1
This is an error message issued after DHCP_DDNS attempts to submit DNS mapping
entry removals have failed. There precise reason for the failure should be
documented in preceding log entries.
......@@ -54,7 +54,7 @@ NameAddTransaction::defineEvents() {
// Call superclass impl first.
NameChangeTransaction::defineEvents();
// Define NCT events.
// Define NameAddTransaction events.
defineEvent(FQDN_IN_USE_EVT, "FQDN_IN_USE_EVT");
defineEvent(FQDN_NOT_IN_USE_EVT, "FQDN_NOT_IN_USE_EVT");
}
......@@ -64,7 +64,7 @@ NameAddTransaction::verifyEvents() {
// Call superclass impl first.
NameChangeTransaction::verifyEvents();
// Verify NCT events.
// Verify NameAddTransaction events.
getEvent(FQDN_IN_USE_EVT);
getEvent(FQDN_NOT_IN_USE_EVT);
}
......@@ -74,7 +74,7 @@ NameAddTransaction::defineStates() {
// Call superclass impl first.
NameChangeTransaction::defineStates();
// Define the states.
// Define NameAddTransaction states.
defineState(READY_ST, "READY_ST",
boost::bind(&NameAddTransaction::readyHandler, this));
......@@ -105,7 +105,7 @@ NameAddTransaction::verifyStates() {
// Call superclass impl first.
NameChangeTransaction::verifyStates();
// Verify NCT states. This ensures that derivations provide the handlers.
// Verify NameAddTransaction states.
getState(ADDING_FWD_ADDRS_ST);
getState(REPLACING_FWD_ADDRS_ST);
getState(REPLACING_REV_PTRS_ST);
......@@ -541,6 +541,7 @@ void
NameAddTransaction::processAddFailedHandler() {
switch(getNextEvent()) {
case UPDATE_FAILED_EVT:
case NO_MORE_SERVERS_EVT:
LOG_ERROR(dctl_logger, DHCP_DDNS_ADD_FAILED).arg(getNcr()->toText());
setNcrStatus(dhcp_ddns::ST_FAILED);
endModel();
......
......@@ -34,9 +34,10 @@ public:
/// @brief Embodies the "life-cycle" required to carry out a DDNS Add update.
///
/// NameAddTransaction implements a state machine for adding (or replacing) a
/// forward DNS mapping. This state machine is based upon the processing logic
/// described in RFC 4703, Sections 5.3 and 5.4. That logic may be paraphrased
/// as follows:
/// forward and/or reverse DNS mapping. This state machine is based upon the
/// processing logic described in RFC 4703, Sections 5.3 and 5.4. That logic
/// may be paraphrased as follows:
///
/// @code
///
/// If the request includes a forward change:
......@@ -166,7 +167,7 @@ protected:
/// handler simply attempts to select the next server.
///
/// Transitions to:
/// - ADDING_REV_PTRS_ST with next event of SERVER_SELECTED upon successful
/// - ADDING_FWD_ADDRS_ST with next event of SERVER_SELECTED upon successful
/// server selection
///
/// - PROCESS_TRANS_FAILED with next event of NO_MORE_SERVERS_EVT upon
......@@ -329,7 +330,7 @@ protected:
/// - PROCESS_TRANS_OK_ST with a next event of UPDATE_OK_EVT upon
/// successful replacement.
///
/// - PROCESS_TRANS_FAILED_ST with a next event of UPDATE_OK_EVT If the
/// - PROCESS_TRANS_FAILED_ST with a next event of UPDATE_FAILED_EVT If the
/// DNS server rejected the update for any reason or the IO completed
/// with an unrecognized status.
///
......@@ -365,8 +366,10 @@ protected:
/// @brief State handler for PROCESS_TRANS_FAILED_ST.
///
/// Entered from:
/// - SELECTING_FWD_SERVER_ST with a next event of NO_MORE_SERVERS
/// - ADDING_FWD_ADDRS_ST with a next event of UPDATE_FAILED_EVT
/// - REPLACING_FWD_ADDRS_ST with a next event of UPDATE_FAILED_EVT
/// - SELECTING_REV_SERVER_ST with a next event of NO_MORE_SERVERS
/// - REPLACING_REV_PTRS_ST with a next event of UPDATE_FAILED_EVT
///
/// Sets the transaction status to indicate failure and ends
......
This diff is collapsed.
// Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#ifndef NC_REMOVE_H
#define NC_REMOVE_H
/// @file nc_remove.h This file defines the class NameRemoveTransaction.
#include <d2/nc_trans.h>
namespace isc {
namespace d2 {
/// @brief Thrown if the NameRemoveTransaction encounters a general error.
class NameRemoveTransactionError : public isc::Exception {
public:
NameRemoveTransactionError(const char* file, size_t line,
const char* what) :
isc::Exception(file, line, what) { };
};
/// @brief Embodies the "life-cycle" required to carry out a DDNS Remove update.
///
/// NameRemoveTransaction implements a state machine for removing a forward
/// and/or reverse DNS mappings. This state machine is based upon the processing
/// logic described in RFC 4703, Section 5.5. That logic may be paraphrased as
/// follows:
///
/// @code
///
/// If the request includes a forward change:
/// Select a forward server
/// Send the server a request to remove client's specific forward address RR
/// If it succeeds or the server responds with name no longer in use
/// Send a server a request to delete any other RRs for that FQDN, such
/// as the DHCID RR.
/// otherwise
/// abandon the update
///
/// If the request includes a reverse change:
/// Select a reverse server
/// Send a server a request to delete reverse entry (PTR RR)
///
/// @endcode
///
/// This class derives from NameChangeTransaction from which it inherits
/// states, events, and methods common to NameChangeRequest processing.
class NameRemoveTransaction : public NameChangeTransaction {
public:
//@{ Additional states needed for NameRemove state model.
/// @brief State that attempts to remove specific forward address record.
static const int REMOVING_FWD_ADDRS_ST = NCT_DERIVED_STATE_MIN + 1;
/// @brief State that attempts to remove any other forward RRs for the DHCID
static const int REMOVING_FWD_RRS_ST = NCT_DERIVED_STATE_MIN + 2;
/// @brief State that attempts to remove reverse PTR records
static const int REMOVING_REV_PTRS_ST = NCT_DERIVED_STATE_MIN + 3;
//@}
//@{ Additional events needed for NameRemove state model.
/// @brief Event sent when replace attempt to fails with address not in use.
/// @todo Currently none have been identified.
//@}
/// @brief Constructor
///
/// Instantiates an Remove transaction that is ready to be started.
///
/// @param io_service IO service to be used for IO processing
/// @param ncr is the NameChangeRequest to fulfill
/// @param forward_domain is the domain to use for forward DNS updates
/// @param reverse_domain is the domain to use for reverse DNS updates
///
/// @throw NameRemoveTransaction error if given request is not a CHG_REMOVE,
/// NameChangeTransaction error for base class construction errors.
NameRemoveTransaction(IOServicePtr& io_service,
dhcp_ddns::NameChangeRequestPtr& ncr,
DdnsDomainPtr& forward_domain,
DdnsDomainPtr& reverse_domain);
/// @brief Destructor
virtual ~NameRemoveTransaction();
protected:
/// @brief Removes events defined by NameRemoveTransaction to the event set.
///
/// Invokes NameChangeTransaction's implementation and then defines the
/// events unique to NCR Remove transaction processing.
///
/// @throw StateModelError if an event definition is invalid or a duplicate.
virtual void defineEvents();
/// @brief Validates the contents of the set of events.
///
/// Invokes NameChangeTransaction's implementation and then verifies the
/// Remove transaction's events.
///
/// @throw StateModelError if an event value is undefined.
virtual void verifyEvents();
/// @brief Removes states defined by NameRemoveTransaction to the state set.
///
/// Invokes NameChangeTransaction's implementation and then defines the
/// states unique to NCR Remove transaction processing.
///
/// @throw StateModelError if an state definition is invalid or a duplicate.
virtual void defineStates();
/// @brief Validates the contents of the set of states.
///
/// Invokes NameChangeTransaction's implementation and then verifies the
/// Remove transaction's states.
///
/// @throw StateModelError if an event value is undefined.
virtual void verifyStates();
/// @brief State handler for READY_ST.
///
/// Entered from:
/// - INIT_ST with next event of START_EVT
///
/// The READY_ST is the state the model transitions into when the inherited
/// method, startTransaction() is invoked. This handler, therefore, is the
/// entry point into the state model execution.h Its primary task is to
/// determine whether to start with a forward DNS change or a reverse DNS
/// change.
///
/// Transitions to:
/// - SELECTING_FWD_SERVER_ST with next event of SERVER_SELECT_ST if request
/// includes a forward change.
///
/// - SELECTING_REV_SERVER_ST with next event of SERVER_SELECT_ST if request
/// includes only a reverse change.
///
/// @throw NameRemoveTransactionError if upon entry next event is not
/// START_EVT.
void readyHandler();
/// @brief State handler for SELECTING_FWD_SERVER_ST.
///
/// Entered from:
/// - READY_ST with next event of SELECT_SERVER_EVT
/// - REMOVING_FWD_ADDRS_ST with next event of SERVER_IO_ERROR_EVT
///
/// Selects the server to be used from the forward domain for the forward
/// DNS update. If next event is SELECT_SERVER_EVT the handler initializes
/// the forward domain's server selection mechanism and then attempts to
/// select the next server. If next event is SERVER_IO_ERROR_EVT then the
/// handler simply attempts to select the next server.
///
/// Transitions to:
/// - REMOVING_FWD_ADDRS_ST with next event of SERVER_SELECTED upon
/// successful server selection
///
/// - PROCESS_TRANS_FAILED with next event of NO_MORE_SERVERS_EVT upon
/// failure to select a server
///
/// @throw NameRemoveTransactionError if upon entry next event is not
/// SELECT_SERVER_EVT or SERVER_IO_ERROR_EVT.
void selectingFwdServerHandler();
/// @brief State handler for SELECTING_REV_SERVER_ST.
///
/// Entered from:
/// - READY_ST with next event of SELECT_SERVER_EVT
/// - REMOVING_FWD_RRS_ST with next event of SELECT_SERVER_EVT
/// - REMOVING_REV_PTRS_ST with next event of SERVER_IO_ERROR_EVT
///
/// Selects the server to be used from the reverse domain for the reverse
/// DNS update. If next event is SELECT_SERVER_EVT the handler initializes
/// the reverse domain's server selection mechanism and then attempts to
/// select the next server. If next event is SERVER_IO_ERROR_EVT then the
/// handler simply attempts to select the next server.
///
/// Transitions to:
/// - REMOVING_REV_PTRS_ST with next event of SERVER_SELECTED upon
/// successful server selection
///
/// - PROCESS_TRANS_FAILED with next event of NO_MORE_SERVERS_EVT upon
/// failure to select a server
///
/// @throw NameRemoveTransactionError if upon entry next event is not
/// SELECT_SERVER_EVT or SERVER_IO_ERROR_EVT.
void selectingRevServerHandler();
/// @brief State handler for REMOVING_FWD_ADDRS_ST.
///
/// Entered from:
/// - SELECTING_FWD_SERVER with next event of SERVER_SELECTED_EVT
///
/// Attempts to remove the forward DNS entry for a given FQDN, provided
/// a DHCID RR exists which matches the requesting DHCID. If this is
/// first invocation of the handler after transitioning into this state,
/// any previous update request context is deleted. If next event
/// is SERVER_SELECTED_EVT, the handler builds the forward remove request,
/// schedules an asynchronous send via sendUpdate(), and returns. Note
/// that sendUpdate will post NOP_EVT as next event.
///
/// Posting the NOP_EVT will cause runModel() to suspend execution of
/// the state model thus affecting a "wait" for the update IO to complete.
/// Update completion occurs via the DNSClient callback operator() method
/// inherited from NameChangeTransaction. When invoked this callback will
/// post a next event of IO_COMPLETED_EVT and then invoke runModel which
/// resumes execution of the state model.
///
/// When the handler is invoked with a next event of IO_COMPELTED_EVT,
/// the DNS update status is checked and acted upon accordingly:
///
/// Transitions to:
/// - REMOVING_FWD_RRS_ST with next event of UPDATE_OK_EVT upon successful
/// removal or RCODE of indication FQDN is no longer in use (NXDOMAIN).
///
/// - PROCESS_TRANS_FAILED_ST with next event of UPDATE_FAILED_EVT if the
/// DNS server rejected the update for any reason or the IO completed
/// with an unrecognized status.
///
/// - RE-ENTER this state with next event of SERVER_SELECTED_EVT if
/// there was an IO error communicating with the server and the number of
/// per server retries has not been exhausted.
///
/// - SELECTING_FWD_SERVER_ST with next event of SERVER_IO_ERROR_EVT if
/// there was an IO error communicating with the server and the number of
/// per server retries has been exhausted.
///
/// @throw NameRemoveTransactionError if upon entry next event is not
/// SERVER_SELECTED_EVT or IO_COMPLETE_EVT
void removingFwdAddrsHandler();
/// @brief State handler for REMOVING_FWD_RRS_ST.
///
/// Entered from:
/// - REMOVING_FWD_ADDRS_ST with next event of UPDATE_OK_EVT
///
/// Attempts to delete any remaining RRs associated with the given FQDN
/// such as the DHCID RR. If this is first invocation of the handler after
/// transitioning into this state, any previous update request context is
/// deleted and the handler builds the forward remove request. It then
/// schedules an asynchronous send via sendUpdate(),
/// and returns. Note that sendUpdate will post NOP_EVT as the next event.
///
/// Posting the NOP_EVT will cause runModel() to suspend execution of
/// the state model thus affecting a "wait" for the update IO to complete.
/// Update completion occurs via the DNSClient callback operator() method
/// inherited from NameChangeTransaction. When invoked this callback will
/// post a next event of IO_COMPLETED_EVT and then invoke runModel which
/// resumes execution of the state model.
///
/// When the handler is invoked with a next event of IO_COMPELTED_EVT,
/// the DNS update status is checked and acted upon accordingly:
///
/// Transitions to:
/// - SELECTING_REV_SERVER_ST with a next event of SELECT_SERVER_EVT upon
/// successful completion and the request includes a reverse DNS update.
///
/// - PROCESS_TRANS_OK_ST with next event of UPDATE_OK_EVT upon successful
/// completion and the request does not include a reverse DNS update.
///
/// - PROCESS_TRANS_FAILED_ST with a next event of UPDATE_FAILED_EVT if the
/// DNS server rejected the update for any other reason or the IO completed
/// with an unrecognized status.
///
/// - RE-ENTER this state with a next event of SERVER_SELECTED_EVT if
/// there was an IO error communicating with the server and the number of
/// per server retries has not been exhausted.
///
/// - PROCESS_TRANS_FAILED_ST with a next event of SERVER_IO_ERROR_EVT if
/// there we have reached maximum number of retries without success on the
/// current server.
///
/// @note If we exhaust the IO retries for the current server due to IO
/// failures, we will abort the remaining updates. The rational is that
/// we are only in this state, if the remove of the forward address RR
/// succeeded (removingFwdAddrsHandler) on the current server so we should
/// not attempt another removal on a different server. This is perhaps a
/// point for discussion. @todo Should we go ahead with the reverse remove?
///
/// @throw NameRemoveTransactionError if upon entry next event is not:
/// UPDATE_OK_EVT or IO_COMPLETE_EVT
void removingFwdRRsHandler();
/// @brief State handler for REMOVING_REV_PTRS_ST.
///
/// Entered from:
/// - SELECTING_REV_SERVER_ST with a next event of SERVER_SELECTED_EVT
///
/// Attempts to delete a reverse DNS entry for a given FQDN. If this is
/// first invocation of the handler after transitioning into this state,
/// any previous update request context is deleted. If next event is
/// SERVER_SELECTED_EVT, the handler builds the reverse remove request,
/// schedules an asynchronous send via sendUpdate(), and then returns.
/// Note that sendUpdate will post NOP_EVT as next event.
///
/// Posting the NOP_EVT will cause runModel() to suspend execution of
/// the state model thus affecting a "wait" for the update IO to complete.
/// Update completion occurs via the DNSClient callback operator() method
/// inherited from NameChangeTransaction. When invoked this callback will
/// post a next event of IO_COMPLETED_EVT and then invoke runModel which
/// resumes execution of the state model.
///
/// When the handler is invoked with a next event of IO_COMPELTED_EVT,
/// the DNS update status is checked and acted upon accordingly:
///
/// Transitions to:
/// - PROCESS_TRANS_OK_ST with a next event of UPDATE_OK_EVT upon
/// successful completion.
///
/// - PROCESS_TRANS_FAILED_ST with a next event of UPDATE_FAILED_EVT If the
/// DNS server rejected the update for any reason or the IO completed
/// with an unrecognized status.
///
/// - RE-ENTER this state with a next event of SERVER_SELECTED_EVT if
/// there was an IO error communicating with the server and the number of
/// per server retries has not been exhausted.
///
/// - SELECTING_REV_SERVER_ST with next event of SERVER_IO_ERROR_EVT if
/// there was an IO error communicating with the server and the number of
/// per server retries has been exhausted.
///
/// @throw NameRemoveTransactionError if upon entry next event is not:
/// SERVER_SELECTED_EVT or IO_COMPLETED_EVT
void removingRevPtrsHandler();
/// @brief State handler for PROCESS_TRANS_OK_ST.
///
/// Entered from:
/// - REMOVING_FWD_RRS_ST with a next event of UPDATE_OK_EVT
/// - REMOVING_REV_PTRS_ST with a next event of UPDATE_OK_EVT
///
/// Sets the transaction action status to indicate success and ends
/// model execution.
///
/// Transitions to:
/// - END_ST with a next event of END_EVT.
///
/// @throw NameRemoveTransactionError if upon entry next event is not:
/// UPDATE_OK_EVT
void processRemoveOkHandler();
/// @brief State handler for PROCESS_TRANS_FAILED_ST.
///
/// Entered from:
/// - SELECTING_FWD_SERVER_ST with a next event of NO_MORE_SERVERS
/// - REMOVING_FWD_ADDRS_ST with a next event of UPDATE_FAILED_EVT
/// - REMOVING_FWD_RRS_ST with a next event of UPDATE_FAILED_EVT
/// - REMOVING_FWD_RRS_ST with a next event of SERVER_IO_ERROR_EVT
/// - SELECTING_REV_SERVER_ST with a next event of NO_MORE_SERVERS
/// - REMOVING_REV_PTRS_ST with a next event of UPDATE_FAILED_EVT
///
/// Sets the transaction status to indicate failure and ends
/// model execution.
///
/// Transitions to:
/// - END_ST with a next event of FAIL_EVT.
///
/// @throw NameRemoveTransactionError if upon entry next event is not:
/// UPDATE_FAILED_EVT
void processRemoveFailedHandler();
/// @brief Builds a DNS request to add an forward DNS entry for an FQDN
///
/// @todo - Method not implemented yet
///
/// @throw isc::NotImplemented
void buildRemoveFwdAddressRequest();
/// @brief Builds a DNS request to replace forward DNS entry for an FQDN
///
/// @todo - Method not implemented yet
///
/// @throw isc::NotImplemented
void buildRemoveFwdRRsRequest();
/// @brief Builds a DNS request to replace a reverse DNS entry for an FQDN
///
/// @todo - Method not implemented yet
///
/// @throw isc::NotImplemented
void buildRemoveRevPtrsRequest();
};
/// @brief Defines a pointer to a NameChangeTransaction.
typedef boost::shared_ptr<NameRemoveTransaction> NameRemoveTransactionPtr;
} // namespace isc::d2
} // namespace isc
#endif
......@@ -181,14 +181,14 @@ NameChangeTransaction::onModelFailure(const std::string& explanation) {
}
void
NameChangeTransaction::retryTransition(const int server_sel_state) {
NameChangeTransaction::retryTransition(const int fail_to_state) {
if (update_attempts_ < MAX_UPDATE_TRIES_PER_SERVER) {
// Re-enter the current state with same server selected.
transition(getCurrState(), SERVER_SELECTED_EVT);
} else {
// Transition to given server selection state if we are out
// Transition to given fail_to_state state if we are out
// of retries.
transition(server_sel_state, SERVER_IO_ERROR_EVT);
transition(fail_to_state, SERVER_IO_ERROR_EVT);
}
}
......
......@@ -280,7 +280,7 @@ protected:
/// @param server_sel_state State to transition to if maximum attempts
/// have been tried.
///
void retryTransition(const int server_sel_state);
void retryTransition(const int fail_to_state);
/// @brief Sets the update request packet to the given packet.
///
......
......@@ -67,6 +67,7 @@ d2_unittests_SOURCES += ../d2_zone.cc ../d2_zone.h
d2_unittests_SOURCES += ../dns_client.cc ../dns_client.h
d2_unittests_SOURCES += ../labeled_value.cc ../labeled_value.h
d2_unittests_SOURCES += ../nc_add.cc ../nc_add.h
d2_unittests_SOURCES += ../nc_remove.cc ../nc_remove.h
d2_unittests_SOURCES += ../nc_trans.cc ../nc_trans.h
d2_unittests_SOURCES += ../state_model.cc ../state_model.h
d2_unittests_SOURCES += d_test_stubs.cc d_test_stubs.h
......@@ -83,6 +84,7 @@ d2_unittests_SOURCES += d2_zone_unittests.cc
d2_unittests_SOURCES += dns_client_unittests.cc
d2_unittests_SOURCES += labeled_value_unittests.cc
d2_unittests_SOURCES += nc_add_unittests.cc
d2_unittests_SOURCES += nc_remove_unittests.cc
d2_unittests_SOURCES += nc_test_utils.cc nc_test_utils.h
d2_unittests_SOURCES += nc_trans_unittests.cc
d2_unittests_SOURCES += state_model_unittests.cc
......
......@@ -1419,8 +1419,7 @@ TEST_F(NameAddTransactionTest, replacingRevPtrsHandler_OtherRcode) {
name_add->fakeResponse(DNSClient::SUCCESS, dns::Rcode::REFUSED());
// Run replacingRevPtrsHandler again to process the response.
//EXPECT_NO_THROW(name_add->replacingRevPtrsHandler());
(name_add->replacingRevPtrsHandler());