2015-07-21 16:10:13 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Icinga 2 *
|
2017-01-10 15:54:22 +01:00
|
|
|
* Copyright (C) 2012-2017 Icinga Development Team (https://www.icinga.com/) *
|
2015-07-21 16:10:13 +02:00
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License *
|
|
|
|
* as published by the Free Software Foundation; either version 2 *
|
|
|
|
* of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the Free Software Foundation *
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#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
|
|
|
|
*/
|
2015-08-28 17:58:29 +02:00
|
|
|
class I2_REMOTE_API ConfigPackageUtility
|
2015-07-21 16:10:13 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
2015-08-28 17:58:29 +02:00
|
|
|
static String GetPackageDir(void);
|
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);
|
|
|
|
static std::vector<String> GetPackages(void);
|
|
|
|
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);
|
|
|
|
static String GetActiveStage(const String& packageName);
|
|
|
|
static void ActivateStage(const String& packageName, const String& stageName);
|
2017-09-03 16:15:40 +02:00
|
|
|
static void AsyncTryActivateStage(const String& packageName, const String& stageName, 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);
|
|
|
|
|
2017-09-20 16:40:02 +02:00
|
|
|
static boost::mutex& GetStaticMutex(void);
|
|
|
|
|
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
|
|
|
|
2017-09-03 16:15:40 +02:00
|
|
|
static void TryActivateStageCallback(const ProcessResult& pr, const String& packageName, const String& stageName, bool reload);
|
2015-07-21 16:10:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIGMODULEUTILITY_H */
|