2014-10-13 18:09:58 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Icinga 2 *
|
2016-01-12 08:29:59 +01:00
|
|
|
* Copyright (C) 2012-2016 Icinga Development Team (https://www.icinga.org/) *
|
2014-10-13 18:09:58 +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. *
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#include "cli/featuredisablecommand.hpp"
|
2014-10-18 19:31:52 +02:00
|
|
|
#include "cli/featureutility.hpp"
|
2014-10-19 14:21:12 +02:00
|
|
|
#include "base/logger.hpp"
|
2014-10-13 18:09:58 +02:00
|
|
|
|
|
|
|
using namespace icinga;
|
|
|
|
namespace po = boost::program_options;
|
|
|
|
|
|
|
|
REGISTER_CLICOMMAND("feature/disable", FeatureDisableCommand);
|
|
|
|
|
|
|
|
String FeatureDisableCommand::GetDescription(void) const
|
|
|
|
{
|
|
|
|
return "Disables specified Icinga 2 feature.";
|
|
|
|
}
|
|
|
|
|
|
|
|
String FeatureDisableCommand::GetShortDescription(void) const
|
|
|
|
{
|
|
|
|
return "disables specified feature";
|
|
|
|
}
|
|
|
|
|
2014-10-18 19:31:52 +02:00
|
|
|
std::vector<String> FeatureDisableCommand::GetPositionalSuggestions(const String& word) const
|
2014-10-13 18:09:58 +02:00
|
|
|
{
|
2014-10-21 18:35:43 +02:00
|
|
|
return FeatureUtility::GetFieldCompletionSuggestions(word, false);
|
2014-10-13 18:09:58 +02:00
|
|
|
}
|
|
|
|
|
2014-10-24 13:15:21 +02:00
|
|
|
int FeatureDisableCommand::GetMinArguments(void) const
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int FeatureDisableCommand::GetMaxArguments(void) const
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-10-24 15:29:46 +02:00
|
|
|
ImpersonationLevel FeatureDisableCommand::GetImpersonationLevel(void) const
|
|
|
|
{
|
|
|
|
return ImpersonateRoot;
|
|
|
|
}
|
|
|
|
|
2014-10-13 18:09:58 +02:00
|
|
|
/**
|
|
|
|
* The entry point for the "feature disable" CLI command.
|
|
|
|
*
|
|
|
|
* @returns An exit status.
|
|
|
|
*/
|
|
|
|
int FeatureDisableCommand::Run(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap) const
|
|
|
|
{
|
2014-10-15 08:45:58 +02:00
|
|
|
if (ap.empty()) {
|
|
|
|
Log(LogCritical, "cli", "Cannot disable feature(s). Name(s) are missing!");
|
|
|
|
return 0;
|
|
|
|
}
|
2014-10-13 18:09:58 +02:00
|
|
|
|
2014-10-21 18:35:43 +02:00
|
|
|
return FeatureUtility::DisableFeatures(ap);
|
2014-10-13 18:09:58 +02:00
|
|
|
}
|