diff options
author | Marcin Siodelski <marcin@isc.org> | 2019-01-28 20:14:59 +0100 |
---|---|---|
committer | Marcin Siodelski <marcin@isc.org> | 2019-01-30 10:18:59 +0100 |
commit | 84d9d7a40155cab5ed14f63f5734a7e53b13b4cf (patch) | |
tree | 6905e24b9afc86662a24c1119e3f08ec07768844 /src/hooks/dhcp | |
parent | [#396,!205] Use microsec precision for the CB tables. (diff) | |
download | kea-84d9d7a40155cab5ed14f63f5734a7e53b13b4cf.tar.xz kea-84d9d7a40155cab5ed14f63f5734a7e53b13b4cf.zip |
[#396,!205] Audit revision timestamp is set by Kea.
Diffstat (limited to 'src/hooks/dhcp')
-rw-r--r-- | src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc | 28 | ||||
-rw-r--r-- | src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc | 6 | ||||
-rw-r--r-- | src/hooks/dhcp/mysql_cb/mysql_cb_impl.h | 3 | ||||
-rw-r--r-- | src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc | 3 |
4 files changed, 22 insertions, 18 deletions
diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc index b89ff68932..02bedf31ef 100644 --- a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc +++ b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc @@ -755,8 +755,7 @@ public: // no new audit revisions are created in any subsequent calls. ScopedAuditRevision audit_revision(this, MySqlConfigBackendDHCPv4Impl::CREATE_AUDIT_REVISION, - server_selector, - "subnet set", true); + server_selector, "subnet set", true); try { @@ -872,8 +871,7 @@ public: ScopedAuditRevision audit_revision(this, MySqlConfigBackendDHCPv4Impl::CREATE_AUDIT_REVISION, - server_selector, - log_message, cascade_delete); + server_selector, log_message, cascade_delete); auto count = deleteFromTable(index, server_selector, operation, keys...); @@ -1166,8 +1164,7 @@ public: ScopedAuditRevision audit_revision(this, MySqlConfigBackendDHCPv4Impl::CREATE_AUDIT_REVISION, - server_selector, - "shared network set", true); + server_selector, "shared network set", true); try { @@ -1281,8 +1278,7 @@ public: ScopedAuditRevision audit_revision(this, MySqlConfigBackendDHCPv4Impl::CREATE_AUDIT_REVISION, - server_selector, - "global option set", false); + server_selector, "global option set", false); if (existing_option) { in_bindings.push_back(MySqlBinding::createString(tag)); @@ -1352,8 +1348,8 @@ public: ScopedAuditRevision audit_revision(this, MySqlConfigBackendDHCPv4Impl::CREATE_AUDIT_REVISION, - server_selector, - "subnet specific option set", cascade_update); + server_selector, "subnet specific option set", + cascade_update); if (existing_option) { in_bindings.push_back(MySqlBinding::createString(tag)); @@ -1441,8 +1437,8 @@ public: ScopedAuditRevision audit_revision(this, MySqlConfigBackendDHCPv4Impl::CREATE_AUDIT_REVISION, - server_selector, - "pool specific option set", cascade_update); + server_selector, "pool specific option set", + cascade_update); if (existing_option) { in_bindings.push_back(MySqlBinding::createString(tag)); @@ -1512,8 +1508,7 @@ public: ScopedAuditRevision audit_revision(this, MySqlConfigBackendDHCPv4Impl::CREATE_AUDIT_REVISION, - server_selector, - "shared network specific option set", + server_selector, "shared network specific option set", cascade_update); if (existing_option) { @@ -1837,8 +1832,7 @@ public: ScopedAuditRevision audit_revision(this, MySqlConfigBackendDHCPv4Impl::CREATE_AUDIT_REVISION, - server_selector, - "option definition set", + server_selector, "option definition set", true); if (existing_definition) { @@ -2053,7 +2047,7 @@ TaggedStatementArray; /// retrieve data from the database. TaggedStatementArray tagged_statements = { { { MySqlConfigBackendDHCPv4Impl::CREATE_AUDIT_REVISION, - "CALL createAuditRevisionDHCP4(?, ?, ?)" + "CALL createAuditRevisionDHCP4(?, ?, ?, ?)" }, // Select global parameter by name. diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc b/src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc index ff104bc5cb..29cc777440 100644 --- a/src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc +++ b/src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc @@ -32,7 +32,9 @@ ScopedAuditRevision::ScopedAuditRevision(MySqlConfigBackendImpl* impl, const std::string& log_message, bool cascade_transaction) : impl_(impl) { - impl_->createAuditRevision(index, server_selector, log_message, + impl_->createAuditRevision(index, server_selector, + boost::posix_time::microsec_clock::local_time(), + log_message, cascade_transaction); } @@ -86,6 +88,7 @@ MySqlConfigBackendImpl::~MySqlConfigBackendImpl() { void MySqlConfigBackendImpl::createAuditRevision(const int index, const ServerSelector& server_selector, + const boost::posix_time::ptime& audit_ts, const std::string& log_message, const bool cascade_transaction) { // Do not touch existing audit revision in case of the cascade update. @@ -97,6 +100,7 @@ MySqlConfigBackendImpl::createAuditRevision(const int index, "audit revision"); MySqlBindingCollection in_bindings = { + MySqlBinding::createTimestamp(audit_ts), MySqlBinding::createString(tag), MySqlBinding::createString(log_message), MySqlBinding::createInteger<uint8_t>(static_cast<uint8_t>(cascade_transaction)) diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_impl.h b/src/hooks/dhcp/mysql_cb/mysql_cb_impl.h index 0955595302..e9d891cc0d 100644 --- a/src/hooks/dhcp/mysql_cb/mysql_cb_impl.h +++ b/src/hooks/dhcp/mysql_cb/mysql_cb_impl.h @@ -171,6 +171,8 @@ public: /// /// @param index query index. /// @param server_selector Server selector. + /// @param audit_ts Timestamp to be associated with the audit + /// revision. /// @param log_message log message to be used for the audit revision. /// @param cascade_transaction Boolean value indicating whether the /// configuration modification is performed as part of the ownining @@ -179,6 +181,7 @@ public: /// audit entry for the owning element should be created. void createAuditRevision(const int index, const db::ServerSelector& server_selector, + const boost::posix_time::ptime& audit_ts, const std::string& log_message, const bool cascade_transaction); diff --git a/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc b/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc index b434bb3d4a..aa556d3815 100644 --- a/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc +++ b/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc @@ -296,6 +296,9 @@ public: timestamps_["tomorrow"] = timestamps_["today"] + boost::posix_time::hours(24); } + /// @brief Logs audit entries in the @c audit_entries_ member. + /// + /// This function is called in case of an error. std::string logExistingAuditEntries() { std::ostringstream s; |