MCPcopy Create free account
hub / github.com/Icinga/icinga2 / CreateConfigUpdate

Method CreateConfigUpdate

lib/icingadb/icingadb-objects.cpp:1759–1791  ·  view source on GitHub ↗

Creates a config update with computed checksums etc. * Writes attributes, customVars and checksums into the respective supplied vectors. Adds two values to each vector * (if applicable), first the key then the value. To use in a Redis command the command (e.g. HSET) and the key (e.g. * icinga:config:object:downtime) need to be prepended. There is nothing to indicate success or failure. */

Source from the content-addressed store, hash-verified

1757 * icinga:config:object:downtime) need to be prepended. There is nothing to indicate success or failure.
1758 */
1759void
1760IcingaDB::CreateConfigUpdate(const ConfigObject::Ptr& object, const QueryArgPair& redisKeyPair,
1761 std::map<RedisConnection::QueryArg, RedisConnection::Query>& hMSets, std::vector<Dictionary::Ptr>& runtimeUpdates, bool runtimeUpdate)
1762{
1763 /* TODO: This isn't essentially correct as we don't keep track of config objects ourselves. This would avoid duplicated config updates at startup.
1764 if (!runtimeUpdate && m_ConfigDumpInProgress)
1765 return;
1766 */
1767
1768 Dictionary::Ptr attr = new Dictionary;
1769
1770 if (!PrepareObject(object, attr))
1771 return;
1772
1773 InsertObjectDependencies(object, hMSets, runtimeUpdates, runtimeUpdate);
1774
1775 String objectKey = GetObjectIdentifier(object);
1776 auto& attrs (hMSets[redisKeyPair.ObjectKey]);
1777 auto& chksms (hMSets[redisKeyPair.ChecksumKey]);
1778
1779 attrs.emplace_back(objectKey);
1780 attrs.emplace_back(JsonEncode(attr));
1781
1782 String checksum = HashValue(attr);
1783 chksms.emplace_back(objectKey);
1784 chksms.emplace_back(JsonEncode(new Dictionary({{"checksum", checksum}})));
1785
1786 /* Send an update event to subscribers. */
1787 if (runtimeUpdate) {
1788 attr->Set("checksum", checksum);
1789 AddObjectDataToRuntimeUpdates(runtimeUpdates, objectKey, std::string(redisKeyPair.ObjectKey), attr);
1790 }
1791}
1792
1793void IcingaDB::SendConfigDelete(const ConfigObject::Ptr& object)
1794{

Callers

nothing calls this directly

Calls 1

SetMethod · 0.45

Tested by

no test coverage detected