<< pool_end_address);
}
- createUpdateOption4(server_selector, pool_id, option, true);
+ createUpdateOption4(server_selector, pool_id, option, false);
}
MySqlBinding::createTimestamp(option->getModificationTime())
};
- boost::scoped_ptr<MySqlTransaction> transaction;
- // Only start new transaction if specified to do so. This function may
- // be called from within an existing transaction in which case we
- // don't start the new one.
- if (!cascade_update) {
- transaction.reset(new MySqlTransaction(conn_));
- }
+ MySqlTransaction transaction(conn_);
OptionDescriptorPtr existing_option = getOption4(server_selector, pool_id,
option->option_->getType(),
insertOption4(server_selector, in_bindings);
}
- if (transaction) {
- transaction->commit();
- }
+ transaction.commit();
}
/// @brief Sends query to insert or update DHCP option in a shared network.
Subnet4Ptr subnet = test_subnets_[1];
cbptr_->createUpdateSubnet4(ServerSelector::ALL(), subnet);
+ {
+ SCOPED_TRACE("CREATE audit entry for a subnet");
+ testNewAuditEntry("dhcp4_subnet",
+ AuditEntry::ModificationType::CREATE,
+ "subnet set");
+ }
+
// Add an option into the pool.
const PoolPtr pool = subnet->getPool(Lease::TYPE_V4, IOAddress("192.0.2.10"));
ASSERT_TRUE(pool);
ASSERT_TRUE(returned_opt_boot_file_name.option_);
EXPECT_TRUE(returned_opt_boot_file_name.equals(*opt_boot_file_name));
+ {
+ SCOPED_TRACE("UPDATE audit entry for a subnet after adding an option "
+ "to the pool");
+ testNewAuditEntry("dhcp4_subnet",
+ AuditEntry::ModificationType::UPDATE,
+ "pool specific option set");
+ }
+
+
// Modify the option and update it in the database.
opt_boot_file_name->persistent_ = !opt_boot_file_name->persistent_;
cbptr_->createUpdateOption4(ServerSelector::ALL(),
ASSERT_TRUE(returned_opt_boot_file_name.option_);
EXPECT_TRUE(returned_opt_boot_file_name.equals(*opt_boot_file_name));
+ {
+ SCOPED_TRACE("UPDATE audit entry for a subnet when updating pool "
+ "specific option");
+ testNewAuditEntry("dhcp4_subnet",
+ AuditEntry::ModificationType::UPDATE,
+ "pool specific option set");
+ }
+
// Deleting an option with explicitly specified server tag should fail.
EXPECT_EQ(0, cbptr_->deleteOption4(ServerSelector::ONE("server1"),
pool->getFirstAddress(),
// Option should be gone.
EXPECT_FALSE(returned_pool2->getCfgOption()->get(DHCP4_OPTION_SPACE,
DHO_BOOT_FILE_NAME).option_);
+
+ {
+ SCOPED_TRACE("UPDATE audit entry for a subnet when deleting pool "
+ "specific option");
+ testNewAuditEntry("dhcp4_subnet",
+ AuditEntry::ModificationType::UPDATE,
+ "pool specific option deleted");
+ }
}
// This test verifies that shared network level option can be added,
IN option_id BIGINT(20) UNSIGNED,
IN subnet_id INT(10) UNSIGNED,
IN host_id INT(10) UNSIGNED,
- IN network_name VARCHAR(128))
+ IN network_name VARCHAR(128),
+ IN pool_id BIGINT(20))
BEGIN
- # This variable will hold shared network id that we will retrieve
- # by matching it name.
+ # These variables will hold shared network id and subnet id that
+ # we will select.
DECLARE snid VARCHAR(128);
+ DECLARE sid INT(10) UNSIGNED;
# Cascade transaction flag is set to 1 to prevent creation of
# the audit entries for the options when the options are
CALL createAuditEntryDHCP4('hosts', host_id, 1);
ELSEIF scope_id = 4 THEN
# If shared network specific option is added or modified,
- # created audit entry for the shared network which
+ # create audit entry for the shared network which
# indicates that it should be treated as the shared
# network update.
SELECT id INTO snid FROM dhcp4_shared_network WHERE name = network_name LIMIT 1;
CALL createAuditEntryDHCP4('dhcp4_shared_network', snid, 1);
+ ELSEIF scope_id = 5 THEN
+ # If pool specific option is added or modified, create
+ # audit entry for the subnet which this pool belongs to.
+ SELECT dhcp4_pool.subnet_id INTO sid FROM dhcp4_pool WHERE id = pool_id;
+ CALL createAuditEntryDHCP4('dhcp4_subnet', sid, 1);
END IF;
END IF;
END $$
FOR EACH ROW
BEGIN
CALL createOptionAuditDHCP4(0, NEW.scope_id, NEW.option_id, NEW.dhcp4_subnet_id,
- NEW.host_id, NEW.shared_network_name);
+ NEW.host_id, NEW.shared_network_name, NEW.pool_id);
END $$
DELIMITER ;
FOR EACH ROW
BEGIN
CALL createOptionAuditDHCP4(1, NEW.scope_id, NEW.option_id, NEW.dhcp4_subnet_id,
- NEW.host_id, NEW.shared_network_name);
+ NEW.host_id, NEW.shared_network_name, NEW.pool_id);
END $$
DELIMITER ;
FOR EACH ROW
BEGIN
CALL createOptionAuditDHCP4(2, OLD.scope_id, OLD.option_id, OLD.dhcp4_subnet_id,
- OLD.host_id, OLD.shared_network_name);
+ OLD.host_id, OLD.shared_network_name, OLD.pool_id);
END $$
DELIMITER ;