2019-02-25 14:48:22 +01:00
|
|
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
2015-07-21 16:10:13 +02:00
|
|
|
|
|
|
|
#ifndef CONFIGMODULEUTILITY_H
|
|
|
|
#define CONFIGMODULEUTILITY_H
|
|
|
|
|
|
|
|
#include "remote/i2-remote.hpp"
|
|
|
|
#include "base/application.hpp"
|
|
|
|
#include "base/dictionary.hpp"
|
|
|
|
#include "base/process.hpp"
|
|
|
|
#include "base/string.hpp"
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace icinga
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper functions.
|
|
|
|
*
|
|
|
|
* @ingroup remote
|
|
|
|
*/
|
2017-12-31 07:22:16 +01:00
|
|
|
class ConfigPackageUtility
|
2015-07-21 16:10:13 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
2018-01-04 04:25:35 +01:00
|
|
|
static String GetPackageDir();
|
2015-07-21 16:10:13 +02:00
|
|
|
|
2015-08-28 17:58:29 +02:00
|
|
|
static void CreatePackage(const String& name);
|
|
|
|
static void DeletePackage(const String& name);
|
2018-01-04 04:25:35 +01:00
|
|
|
static std::vector<String> GetPackages();
|
2015-08-28 17:58:29 +02:00
|
|
|
static bool PackageExists(const String& name);
|
2015-07-21 16:10:13 +02:00
|
|
|
|
2017-11-30 08:36:35 +01:00
|
|
|
static String CreateStage(const String& packageName, const Dictionary::Ptr& files = nullptr);
|
2015-08-28 17:58:29 +02:00
|
|
|
static void DeleteStage(const String& packageName, const String& stageName);
|
|
|
|
static std::vector<String> GetStages(const String& packageName);
|
2019-04-16 16:37:38 +02:00
|
|
|
static String GetActiveStageFromFile(const String& packageName);
|
2015-08-28 17:58:29 +02:00
|
|
|
static String GetActiveStage(const String& packageName);
|
2019-04-16 16:37:38 +02:00
|
|
|
static void SetActiveStage(const String& packageName, const String& stageName);
|
2019-04-26 14:51:28 +02:00
|
|
|
static void SetActiveStageToFile(const String& packageName, const String& stageName);
|
2015-08-28 17:58:29 +02:00
|
|
|
static void ActivateStage(const String& packageName, const String& stageName);
|
2019-09-24 18:17:19 +02:00
|
|
|
static void AsyncTryActivateStage(const String& packageName, const String& stageName, bool activate, bool reload);
|
2015-07-21 16:10:13 +02:00
|
|
|
|
2015-08-28 17:58:29 +02:00
|
|
|
static std::vector<std::pair<String, bool> > GetFiles(const String& packageName, const String& stageName);
|
2015-07-21 16:10:13 +02:00
|
|
|
|
|
|
|
static bool ContainsDotDot(const String& path);
|
|
|
|
static bool ValidateName(const String& name);
|
|
|
|
|
2019-05-08 16:06:46 +02:00
|
|
|
static boost::mutex& GetStaticPackageMutex();
|
|
|
|
static boost::mutex& GetStaticActiveStageMutex();
|
2017-09-20 16:40:02 +02:00
|
|
|
|
2015-07-21 16:10:13 +02:00
|
|
|
private:
|
|
|
|
static void CollectDirNames(const String& path, std::vector<String>& dirs);
|
|
|
|
static void CollectPaths(const String& path, std::vector<std::pair<String, bool> >& paths);
|
|
|
|
|
2015-08-28 17:58:29 +02:00
|
|
|
static void WritePackageConfig(const String& packageName);
|
|
|
|
static void WriteStageConfig(const String& packageName, const String& stageName);
|
2015-07-21 16:10:13 +02:00
|
|
|
|
2019-09-24 18:17:19 +02:00
|
|
|
static void TryActivateStageCallback(const ProcessResult& pr, const String& packageName, const String& stageName, bool activate, bool reload);
|
2015-07-21 16:10:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIGMODULEUTILITY_H */
|