mirror of https://github.com/Icinga/icinga2.git
Use initializer lists instead of std::vector::push_back
This commit is contained in:
parent
ebc11d41a5
commit
2e87c280ed
|
@ -574,10 +574,7 @@ Process::Arguments Process::PrepareCommand(const Value& command)
|
|||
#ifdef _WIN32
|
||||
return command;
|
||||
#else /* _WIN32 */
|
||||
args.push_back("sh");
|
||||
args.push_back("-c");
|
||||
args.push_back(command);
|
||||
return args;
|
||||
return { "sh", "-c", command };
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -159,12 +159,7 @@ int NodeSetupCommand::SetupMaster(const boost::program_options::variables_map& v
|
|||
/* write zones.conf and update with zone + endpoint information */
|
||||
Log(LogInformation, "cli", "Generating zone and object configuration.");
|
||||
|
||||
std::vector<String> globalZones;
|
||||
|
||||
globalZones.push_back("global-templates");
|
||||
globalZones.push_back("director-global");
|
||||
|
||||
NodeUtility::GenerateNodeMasterIcingaConfig(globalZones);
|
||||
NodeUtility::GenerateNodeMasterIcingaConfig({ "global-templates", "director-global" });
|
||||
|
||||
/* update the ApiListener config - SetupMaster() will always enable it */
|
||||
Log(LogInformation, "cli", "Updating the APIListener feature.");
|
||||
|
@ -362,17 +357,13 @@ int NodeSetupCommand::SetupNode(const boost::program_options::variables_map& vm,
|
|||
/* disable the notifications feature */
|
||||
Log(LogInformation, "cli", "Disabling the Notification feature.");
|
||||
|
||||
std::vector<std::string> disable;
|
||||
disable.push_back("notification");
|
||||
FeatureUtility::DisableFeatures(disable);
|
||||
FeatureUtility::DisableFeatures({ "notification" });
|
||||
|
||||
/* enable the ApiListener config */
|
||||
|
||||
Log(LogInformation, "cli", "Updating the ApiListener feature.");
|
||||
|
||||
std::vector<std::string> enable;
|
||||
enable.push_back("api");
|
||||
FeatureUtility::EnableFeatures(enable);
|
||||
FeatureUtility::EnableFeatures({ "api" });
|
||||
|
||||
String apipath = FeatureUtility::GetFeaturesAvailablePath() + "/api.conf";
|
||||
NodeUtility::CreateBackupFile(apipath);
|
||||
|
@ -427,12 +418,7 @@ int NodeSetupCommand::SetupNode(const boost::program_options::variables_map& vm,
|
|||
|
||||
Log(LogInformation, "cli", "Generating zone and object configuration.");
|
||||
|
||||
std::vector<String> globalZones;
|
||||
|
||||
globalZones.push_back("global-templates");
|
||||
globalZones.push_back("director-global");
|
||||
|
||||
NodeUtility::GenerateNodeIcingaConfig(vm["endpoint"].as<std::vector<std::string> >(), globalZones);
|
||||
NodeUtility::GenerateNodeIcingaConfig(vm["endpoint"].as<std::vector<std::string> >(), { "global-templates", "director-global" });
|
||||
|
||||
/* update constants.conf with NodeName = CN */
|
||||
if (cn != Utility::GetFQDN()) {
|
||||
|
|
|
@ -457,15 +457,11 @@ wizard_ticket:
|
|||
/* disable the notifications feature on client nodes */
|
||||
Log(LogInformation, "cli", "Disabling the Notification feature.");
|
||||
|
||||
std::vector<std::string> disable;
|
||||
disable.push_back("notification");
|
||||
FeatureUtility::DisableFeatures(disable);
|
||||
FeatureUtility::DisableFeatures({ "notification" });
|
||||
|
||||
Log(LogInformation, "cli", "Enabling the ApiListener feature.");
|
||||
|
||||
std::vector<std::string> enable;
|
||||
enable.push_back("api");
|
||||
FeatureUtility::EnableFeatures(enable);
|
||||
FeatureUtility::EnableFeatures({ "api" });
|
||||
|
||||
String apiConfPath = FeatureUtility::GetFeaturesAvailablePath() + "/api.conf";
|
||||
NodeUtility::CreateBackupFile(apiConfPath);
|
||||
|
@ -503,12 +499,7 @@ wizard_ticket:
|
|||
/* apilistener config */
|
||||
Log(LogInformation, "cli", "Generating local zones.conf.");
|
||||
|
||||
std::vector<String> globalZones;
|
||||
|
||||
globalZones.push_back("global-templates");
|
||||
globalZones.push_back("director-global");
|
||||
|
||||
NodeUtility::GenerateNodeIcingaConfig(endpoints, globalZones);
|
||||
NodeUtility::GenerateNodeIcingaConfig(endpoints, { "global-templates", "director-global" });
|
||||
|
||||
if (cn != Utility::GetFQDN()) {
|
||||
Log(LogWarning, "cli")
|
||||
|
@ -604,12 +595,7 @@ int NodeWizardCommand::MasterSetup(void) const
|
|||
else
|
||||
std::cout << "'api' feature already enabled.\n";
|
||||
|
||||
std::vector<String> globalZones;
|
||||
|
||||
globalZones.push_back("global-templates");
|
||||
globalZones.push_back("director-global");
|
||||
|
||||
NodeUtility::GenerateNodeMasterIcingaConfig(globalZones);
|
||||
NodeUtility::GenerateNodeMasterIcingaConfig({ "global-templates", "director-global" });
|
||||
|
||||
/* apilistener config */
|
||||
std::cout << ConsoleColorTag(Console_Bold)
|
||||
|
|
|
@ -31,10 +31,7 @@
|
|||
using namespace icinga;
|
||||
|
||||
INITIALIZE_ONCE([]() {
|
||||
std::vector<String> targets;
|
||||
targets.push_back("Host");
|
||||
targets.push_back("Service");
|
||||
ApplyRule::RegisterType("Dependency", targets);
|
||||
ApplyRule::RegisterType("Dependency", { "Host", "Service" });
|
||||
});
|
||||
|
||||
bool Dependency::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, const String& name, ScriptFrame& frame, const ApplyRule& rule)
|
||||
|
|
|
@ -31,10 +31,7 @@
|
|||
using namespace icinga;
|
||||
|
||||
INITIALIZE_ONCE([]() {
|
||||
std::vector<String> targets;
|
||||
targets.push_back("Host");
|
||||
targets.push_back("Service");
|
||||
ApplyRule::RegisterType("Notification", targets);
|
||||
ApplyRule::RegisterType("Notification", { "Host", "Service" });
|
||||
});
|
||||
|
||||
bool Notification::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, const String& name, ScriptFrame& frame, const ApplyRule& rule)
|
||||
|
|
|
@ -30,10 +30,7 @@
|
|||
using namespace icinga;
|
||||
|
||||
INITIALIZE_ONCE([]() {
|
||||
std::vector<String> targets;
|
||||
targets.push_back("Host");
|
||||
targets.push_back("Service");
|
||||
ApplyRule::RegisterType("ScheduledDowntime", targets);
|
||||
ApplyRule::RegisterType("ScheduledDowntime", { "Host", "Service" });
|
||||
});
|
||||
|
||||
bool ScheduledDowntime::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, const String& name, ScriptFrame& frame, const ApplyRule& rule)
|
||||
|
|
|
@ -30,9 +30,7 @@
|
|||
using namespace icinga;
|
||||
|
||||
INITIALIZE_ONCE([]() {
|
||||
std::vector<String> targets;
|
||||
targets.push_back("Host");
|
||||
ApplyRule::RegisterType("Service", targets);
|
||||
ApplyRule::RegisterType("Service", { "Host" });
|
||||
});
|
||||
|
||||
bool Service::EvaluateApplyRuleInstance(const Host::Ptr& host, const String& name, ScriptFrame& frame, const ApplyRule& rule)
|
||||
|
|
|
@ -39,11 +39,7 @@ void ApiClient::GetTypes(const TypesCompletionCallback& callback) const
|
|||
url->SetScheme("https");
|
||||
url->SetHost(m_Connection->GetHost());
|
||||
url->SetPort(m_Connection->GetPort());
|
||||
|
||||
std::vector<String> path;
|
||||
path.push_back("v1");
|
||||
path.push_back("types");
|
||||
url->SetPath(path);
|
||||
url->SetPath({ "v1", "types" });
|
||||
|
||||
try {
|
||||
std::shared_ptr<HttpRequest> req = m_Connection->NewRequest();
|
||||
|
@ -110,12 +106,7 @@ void ApiClient::GetObjects(const String& pluralType, const ObjectsCompletionCall
|
|||
url->SetScheme("https");
|
||||
url->SetHost(m_Connection->GetHost());
|
||||
url->SetPort(m_Connection->GetPort());
|
||||
|
||||
std::vector<String> path;
|
||||
path.push_back("v1");
|
||||
path.push_back("objects");
|
||||
path.push_back(pluralType);
|
||||
url->SetPath(path);
|
||||
url->SetPath({ "v1", "objects", pluralType });
|
||||
|
||||
std::map<String, std::vector<String> > params;
|
||||
|
||||
|
@ -236,12 +227,7 @@ void ApiClient::ExecuteScript(const String& session, const String& command, bool
|
|||
url->SetScheme("https");
|
||||
url->SetHost(m_Connection->GetHost());
|
||||
url->SetPort(m_Connection->GetPort());
|
||||
|
||||
std::vector<String> path;
|
||||
path.push_back("v1");
|
||||
path.push_back("console");
|
||||
path.push_back("execute-script");
|
||||
url->SetPath(path);
|
||||
url->SetPath({ "v1", "console", "execute-script" });
|
||||
|
||||
std::map<String, std::vector<String> > params;
|
||||
params["session"].push_back(session);
|
||||
|
@ -320,12 +306,7 @@ void ApiClient::AutocompleteScript(const String& session, const String& command,
|
|||
url->SetScheme("https");
|
||||
url->SetHost(m_Connection->GetHost());
|
||||
url->SetPort(m_Connection->GetPort());
|
||||
|
||||
std::vector<String> path;
|
||||
path.push_back("v1");
|
||||
path.push_back("console");
|
||||
path.push_back("auto-complete-script");
|
||||
url->SetPath(path);
|
||||
url->SetPath({ "v1", "console", "auto-complete-script" });
|
||||
|
||||
std::map<String, std::vector<String> > params;
|
||||
params["session"].push_back(session);
|
||||
|
|
Loading…
Reference in New Issue