2019-02-25 08:48:22 -05:00
|
|
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
2014-10-17 09:13:17 -04:00
|
|
|
|
2015-06-24 08:13:54 -04:00
|
|
|
#ifndef NODEUTILITY_H
|
|
|
|
|
#define NODEUTILITY_H
|
2014-10-17 12:55:34 -04:00
|
|
|
|
|
|
|
|
#include "base/i2-base.hpp"
|
2015-02-26 05:04:57 -05:00
|
|
|
#include "cli/i2-cli.hpp"
|
2014-10-18 15:06:28 -04:00
|
|
|
#include "base/dictionary.hpp"
|
2014-10-21 15:33:21 -04:00
|
|
|
#include "base/array.hpp"
|
|
|
|
|
#include "base/value.hpp"
|
2014-10-18 15:06:28 -04:00
|
|
|
#include "base/string.hpp"
|
2014-10-21 07:54:56 -04:00
|
|
|
#include <vector>
|
2014-10-17 09:13:17 -04:00
|
|
|
|
|
|
|
|
namespace icinga
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @ingroup cli
|
|
|
|
|
*/
|
2017-12-31 01:22:16 -05:00
|
|
|
class NodeUtility
|
2014-10-17 12:55:34 -04:00
|
|
|
{
|
2014-10-17 09:13:17 -04:00
|
|
|
public:
|
2018-01-03 22:25:35 -05:00
|
|
|
static String GetConstantsConfPath();
|
2018-04-06 13:18:19 -04:00
|
|
|
static String GetZonesConfPath();
|
2017-11-28 07:38:53 -05:00
|
|
|
|
2018-04-06 13:18:19 -04:00
|
|
|
static bool CreateBackupFile(const String& target, bool isPrivate = false);
|
2014-10-22 09:29:54 -04:00
|
|
|
|
2014-10-31 06:38:16 -04:00
|
|
|
static bool WriteNodeConfigObjects(const String& filename, const Array::Ptr& objects);
|
2014-10-21 15:33:21 -04:00
|
|
|
|
2018-08-23 16:08:02 -04:00
|
|
|
static bool GetConfigurationIncludeState(const String& value, bool recursive);
|
2018-05-08 10:06:10 -04:00
|
|
|
static bool UpdateConfiguration(const String& value, bool include, bool recursive);
|
2014-10-23 09:05:12 -04:00
|
|
|
static void UpdateConstant(const String& name, const String& value);
|
2014-10-22 13:27:21 -04:00
|
|
|
|
2014-10-31 06:53:44 -04:00
|
|
|
/* node setup helpers */
|
2018-04-06 13:18:19 -04:00
|
|
|
static int GenerateNodeIcingaConfig(const String& endpointName, const String& zoneName,
|
|
|
|
|
const String& parentZoneName, const std::vector<std::string>& endpoints,
|
|
|
|
|
const std::vector<String>& globalZones);
|
2018-04-06 11:29:37 -04:00
|
|
|
static int GenerateNodeMasterIcingaConfig(const String& endpointName, const String& zoneName,
|
|
|
|
|
const std::vector<String>& globalZones);
|
2014-10-22 09:29:54 -04:00
|
|
|
|
2014-10-17 12:55:34 -04:00
|
|
|
private:
|
2018-01-03 22:25:35 -05:00
|
|
|
NodeUtility();
|
2014-10-21 15:33:21 -04:00
|
|
|
|
2015-11-25 11:41:03 -05:00
|
|
|
static void SerializeObject(std::ostream& fp, const Dictionary::Ptr& object);
|
2014-10-17 09:13:17 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-24 08:13:54 -04:00
|
|
|
#endif /* NODEUTILITY_H */
|