Rename --agent to --zone (for blacklist/whitelist)

fixes #7516
This commit is contained in:
Gunnar Beutner 2014-10-31 11:53:44 +01:00
parent 79f1711a61
commit 5d7e30bb81
15 changed files with 163 additions and 169 deletions

View File

@ -35,12 +35,12 @@ REGISTER_CLICOMMAND("node/add", NodeAddCommand);
String NodeAddCommand::GetDescription(void) const String NodeAddCommand::GetDescription(void) const
{ {
return "Add Icinga 2 agent."; return "Add Icinga 2 node.";
} }
String NodeAddCommand::GetShortDescription(void) const String NodeAddCommand::GetShortDescription(void) const
{ {
return "add agent"; return "add node";
} }
int NodeAddCommand::GetMinArguments(void) const int NodeAddCommand::GetMinArguments(void) const
@ -49,7 +49,7 @@ int NodeAddCommand::GetMinArguments(void) const
} }
/** /**
* The entry point for the "agent add" CLI command. * The entry point for the "node add" CLI command.
* *
* @returns An exit status. * @returns An exit status.
*/ */

View File

@ -26,7 +26,7 @@ namespace icinga
{ {
/** /**
* The "agent add" command. * The "node add" command.
* *
* @ingroup cli * @ingroup cli
*/ */

View File

@ -107,18 +107,16 @@ String BlackAndWhitelistCommand::GetShortDescription(void) const
void BlackAndWhitelistCommand::InitParameters(boost::program_options::options_description& visibleDesc, void BlackAndWhitelistCommand::InitParameters(boost::program_options::options_description& visibleDesc,
boost::program_options::options_description& hiddenDesc) const boost::program_options::options_description& hiddenDesc) const
{ {
visibleDesc.add_options() if (m_Command == BlackAndWhitelistCommandAdd || m_Command == BlackAndWhitelistCommandRemove) {
("agent", po::value<std::string>(), "The name of the agent") visibleDesc.add_options()
("host", po::value<std::string>(), "The name of the host") ("zone", po::value<std::string>(), "The name of the zone")
("service", po::value<std::string>(), "The name of the service"); ("host", po::value<std::string>(), "The name of the host")
("service", po::value<std::string>(), "The name of the service");
if (m_Command == BlackAndWhitelistCommandAdd) {
//TODO: call list functionality
} }
} }
/** /**
* The entry point for the "agent <whitelist/blacklist> <add/remove/list>" CLI command. * The entry point for the "node <whitelist/blacklist> <add/remove/list>" CLI command.
* *
* @returns An exit status. * @returns An exit status.
*/ */
@ -133,10 +131,11 @@ int BlackAndWhitelistCommand::Run(const boost::program_options::variables_map& v
} }
if (m_Command == BlackAndWhitelistCommandAdd) { if (m_Command == BlackAndWhitelistCommandAdd) {
if (!vm.count("agent")) { if (!vm.count("zone")) {
Log(LogCritical, "cli", "At least the agent name filter is required!"); Log(LogCritical, "cli", "At least the zone name filter is required!");
return 1; return 1;
} }
if (!vm.count("host")) { if (!vm.count("host")) {
Log(LogCritical, "cli", "At least the host name filter is required!"); Log(LogCritical, "cli", "At least the host name filter is required!");
return 1; return 1;
@ -147,26 +146,21 @@ int BlackAndWhitelistCommand::Run(const boost::program_options::variables_map& v
if (vm.count("service")) if (vm.count("service"))
service_filter = vm["service"].as<std::string>(); service_filter = vm["service"].as<std::string>();
return NodeUtility::UpdateBlackAndWhiteList(m_Type, vm["agent"].as<std::string>(), vm["host"].as<std::string>(), service_filter); return NodeUtility::UpdateBlackAndWhiteList(m_Type, vm["zone"].as<std::string>(), vm["host"].as<std::string>(), service_filter);
} else if (m_Command == BlackAndWhitelistCommandList) { } else if (m_Command == BlackAndWhitelistCommandList) {
if (vm.count("agent") || vm.count("host") || vm.count("service")) {
Log(LogCritical, "cli", "List command does not take any arguments!");
return 1;
}
return NodeUtility::PrintBlackAndWhiteList(std::cout, m_Type); return NodeUtility::PrintBlackAndWhiteList(std::cout, m_Type);
} else if (m_Command == BlackAndWhitelistCommandRemove) { } else if (m_Command == BlackAndWhitelistCommandRemove) {
if (!vm.count("agent")) { if (!vm.count("zone")) {
Log(LogCritical, "cli", "At least the agent name filter is required!"); Log(LogCritical, "cli", "The zone name filter is required!");
return 1;
}
if (!vm.count("host")) {
Log(LogCritical, "cli", "At least the host name filter is required!");
return 1; return 1;
} }
String agent_filter = vm["agent"].as<std::string>(); if (!vm.count("host")) {
Log(LogCritical, "cli", "The host name filter is required!");
return 1;
}
String zone_filter = vm["zone"].as<std::string>();
String host_filter = vm["host"].as<std::string>(); String host_filter = vm["host"].as<std::string>();
String service_filter; String service_filter;
@ -174,7 +168,7 @@ int BlackAndWhitelistCommand::Run(const boost::program_options::variables_map& v
service_filter = vm["service"].as<std::string>(); service_filter = vm["service"].as<std::string>();
} }
return NodeUtility::RemoveBlackAndWhiteList(m_Type, vm["agent"].as<std::string>(), vm["host"].as<std::string>(), service_filter); return NodeUtility::RemoveBlackAndWhiteList(m_Type, vm["zone"].as<std::string>(), vm["host"].as<std::string>(), service_filter);
} }

View File

@ -36,23 +36,23 @@ REGISTER_CLICOMMAND("node/list", NodeListCommand);
String NodeListCommand::GetDescription(void) const String NodeListCommand::GetDescription(void) const
{ {
return "Lists all Icinga 2 agents."; return "Lists all Icinga 2 nodes.";
} }
String NodeListCommand::GetShortDescription(void) const String NodeListCommand::GetShortDescription(void) const
{ {
return "lists all agents"; return "lists all nodes";
} }
void NodeListCommand::InitParameters(boost::program_options::options_description& visibleDesc, void NodeListCommand::InitParameters(boost::program_options::options_description& visibleDesc,
boost::program_options::options_description& hiddenDesc) const boost::program_options::options_description& hiddenDesc) const
{ {
visibleDesc.add_options() visibleDesc.add_options()
("batch", "list agents in json"); ("batch", "list nodes in json");
} }
/** /**
* The entry point for the "agent list" CLI command. * The entry point for the "node list" CLI command.
* *
* @returns An exit status. * @returns An exit status.
*/ */

View File

@ -26,7 +26,7 @@ namespace icinga
{ {
/** /**
* The "agent list" command. * The "node list" command.
* *
* @ingroup cli * @ingroup cli
*/ */

View File

@ -35,12 +35,12 @@ REGISTER_CLICOMMAND("node/remove", NodeRemoveCommand);
String NodeRemoveCommand::GetDescription(void) const String NodeRemoveCommand::GetDescription(void) const
{ {
return "Removes Icinga 2 agent."; return "Removes Icinga 2 node.";
} }
String NodeRemoveCommand::GetShortDescription(void) const String NodeRemoveCommand::GetShortDescription(void) const
{ {
return "removes agent"; return "removes node";
} }
std::vector<String> NodeRemoveCommand::GetPositionalSuggestions(const String& word) const std::vector<String> NodeRemoveCommand::GetPositionalSuggestions(const String& word) const
@ -59,14 +59,14 @@ int NodeRemoveCommand::GetMaxArguments(void) const
} }
/** /**
* The entry point for the "agent remove" CLI command. * The entry point for the "node remove" CLI command.
* *
* @returns An exit status. * @returns An exit status.
*/ */
int NodeRemoveCommand::Run(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap) const int NodeRemoveCommand::Run(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap) const
{ {
BOOST_FOREACH(const String& agent, ap) { BOOST_FOREACH(const String& node, ap) {
NodeUtility::RemoveNode(agent); NodeUtility::RemoveNode(node);
} }
return 0; return 0;

View File

@ -26,7 +26,7 @@ namespace icinga
{ {
/** /**
* The "agent remove" command. * The "node remove" command.
* *
* @ingroup cli * @ingroup cli
*/ */

View File

@ -35,12 +35,12 @@ REGISTER_CLICOMMAND("node/set", NodeSetCommand);
String NodeSetCommand::GetDescription(void) const String NodeSetCommand::GetDescription(void) const
{ {
return "Set agent attribute(s)."; return "Set node attribute(s).";
} }
String NodeSetCommand::GetShortDescription(void) const String NodeSetCommand::GetShortDescription(void) const
{ {
return "set agent attributes"; return "set node attributes";
} }
void NodeSetCommand::InitParameters(boost::program_options::options_description& visibleDesc, void NodeSetCommand::InitParameters(boost::program_options::options_description& visibleDesc,
@ -58,7 +58,7 @@ int NodeSetCommand::GetMinArguments(void) const
} }
/** /**
* The entry point for the "agent set" CLI command. * The entry point for the "node set" CLI command.
* *
* @returns An exit status. * @returns An exit status.
*/ */

View File

@ -26,7 +26,7 @@ namespace icinga
{ {
/** /**
* The "agent set" command. * The "node set" command.
* *
* @ingroup cli * @ingroup cli
*/ */

View File

@ -43,12 +43,12 @@ REGISTER_CLICOMMAND("node/setup", NodeSetupCommand);
String NodeSetupCommand::GetDescription(void) const String NodeSetupCommand::GetDescription(void) const
{ {
return "Sets up an Icinga 2 agent."; return "Sets up an Icinga 2 node.";
} }
String NodeSetupCommand::GetShortDescription(void) const String NodeSetupCommand::GetShortDescription(void) const
{ {
return "set up agent"; return "set up node";
} }
void NodeSetupCommand::InitParameters(boost::program_options::options_description& visibleDesc, void NodeSetupCommand::InitParameters(boost::program_options::options_description& visibleDesc,
@ -84,7 +84,7 @@ ImpersonationLevel NodeSetupCommand::GetImpersonationLevel(void) const
} }
/** /**
* The entry point for the "agent setup" CLI command. * The entry point for the "node setup" CLI command.
* *
* @returns An exit status. * @returns An exit status.
*/ */

View File

@ -26,7 +26,7 @@ namespace icinga
{ {
/** /**
* The "agent setup" command. * The "node setup" command.
* *
* @ingroup cli * @ingroup cli
*/ */

View File

@ -38,12 +38,12 @@ REGISTER_CLICOMMAND("node/update-config", NodeUpdateConfigCommand);
String NodeUpdateConfigCommand::GetDescription(void) const String NodeUpdateConfigCommand::GetDescription(void) const
{ {
return "Update Icinga 2 agent config."; return "Update Icinga 2 node config.";
} }
String NodeUpdateConfigCommand::GetShortDescription(void) const String NodeUpdateConfigCommand::GetShortDescription(void) const
{ {
return "update agent config"; return "update node config";
} }
ImpersonationLevel NodeUpdateConfigCommand::GetImpersonationLevel(void) const ImpersonationLevel NodeUpdateConfigCommand::GetImpersonationLevel(void) const
@ -52,7 +52,7 @@ ImpersonationLevel NodeUpdateConfigCommand::GetImpersonationLevel(void) const
} }
/** /**
* The entry point for the "agent update-config" CLI command. * The entry point for the "node update-config" CLI command.
* *
* @returns An exit status. * @returns An exit status.
*/ */
@ -77,7 +77,7 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm
Dictionary::Ptr inventory = make_shared<Dictionary>(); Dictionary::Ptr inventory = make_shared<Dictionary>();
Log(LogInformation, "cli") Log(LogInformation, "cli")
<< "Updating agent configuration for "; << "Updating node configuration for ";
NodeUtility::PrintNodes(std::cout); NodeUtility::PrintNodes(std::cout);
@ -85,31 +85,31 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm
std::vector<String> object_paths = RepositoryUtility::GetObjects(); std::vector<String> object_paths = RepositoryUtility::GetObjects();
BOOST_FOREACH(const Dictionary::Ptr& agent, NodeUtility::GetNodes()) { BOOST_FOREACH(const Dictionary::Ptr& node, NodeUtility::GetNodes()) {
Dictionary::Ptr repository = agent->Get("repository"); Dictionary::Ptr repository = node->Get("repository");
String zone = agent->Get("zone"); String zone = node->Get("zone");
String endpoint = agent->Get("endpoint"); String endpoint = node->Get("endpoint");
String agent_name = endpoint; String node_name = endpoint;
/* store existing structure in index */ /* store existing structure in index */
inventory->Set(endpoint, agent); inventory->Set(endpoint, node);
Dictionary::Ptr host_services = make_shared<Dictionary>(); Dictionary::Ptr host_services = make_shared<Dictionary>();
Log(LogInformation, "cli") Log(LogInformation, "cli")
<< "Repository for agent '" << endpoint << "' does not contain a health check host. Adding host '" << zone << "'."; << "Repository for node '" << endpoint << "' does not contain a health check host. Adding host '" << zone << "'.";
Dictionary::Ptr host_attrs = make_shared<Dictionary>(); Dictionary::Ptr host_attrs = make_shared<Dictionary>();
host_attrs->Set("__name", zone); host_attrs->Set("__name", zone);
host_attrs->Set("name", zone); host_attrs->Set("name", zone);
host_attrs->Set("check_command", "cluster-zone"); host_attrs->Set("check_command", "cluster-zone");
Array::Ptr host_imports = make_shared<Array>(); Array::Ptr host_imports = make_shared<Array>();
host_imports->Add("agent-host"); //default host agent template host_imports->Add("node-host"); //default host node template
host_attrs->Set("import", host_imports); host_attrs->Set("import", host_imports);
if (!RepositoryUtility::AddObject(zone, "Host", host_attrs)) { if (!RepositoryUtility::AddObject(zone, "Host", host_attrs)) {
Log(LogCritical, "cli") Log(LogCritical, "cli")
<< "Cannot add agent host '" << zone << "' to the config repository!\n"; << "Cannot add node host '" << zone << "' to the config repository!\n";
} }
ObjectLock olock(repository); ObjectLock olock(repository);
@ -120,7 +120,7 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm
if (host == "localhost") { if (host == "localhost") {
Log(LogWarning, "cli") Log(LogWarning, "cli")
<< "Ignoring host '" << host << "'. Please make sure to configure a unique name on your agent '" << agent_name << "'."; << "Ignoring host '" << host << "'. Please make sure to configure a unique name on your node '" << node_name << "'.";
continue; continue;
} }
@ -138,10 +138,10 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm
skip_host = true; skip_host = true;
/* check against black/whitelist before trying to add host */ /* check against black/whitelist before trying to add host */
if (NodeUtility::CheckAgainstBlackAndWhiteList("blacklist", agent_name, host, Empty) && if (NodeUtility::CheckAgainstBlackAndWhiteList("blacklist", node_name, host, Empty) &&
!NodeUtility::CheckAgainstBlackAndWhiteList("whitelist", agent_name, host, Empty)) { !NodeUtility::CheckAgainstBlackAndWhiteList("whitelist", node_name, host, Empty)) {
Log(LogWarning, "cli") Log(LogWarning, "cli")
<< "Host '" << host << "' on agent '" << agent_name << "' is blacklisted, but not whitelisted. Skipping."; << "Host '" << host << "' on node '" << node_name << "' is blacklisted, but not whitelisted. Skipping.";
skip_host = true; skip_host = true;
} }
@ -159,12 +159,12 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm
} }
Array::Ptr host_imports = make_shared<Array>(); Array::Ptr host_imports = make_shared<Array>();
host_imports->Add("agent-host"); //default host agent template host_imports->Add("node-host"); //default host node template
host_attrs->Set("import", host_imports); host_attrs->Set("import", host_imports);
if (!RepositoryUtility::AddObject(host, "Host", host_attrs)) { if (!RepositoryUtility::AddObject(host, "Host", host_attrs)) {
Log(LogCritical, "cli") Log(LogCritical, "cli")
<< "Cannot add agent host '" << host << "' to the config repository!\n"; << "Cannot add node host '" << host << "' to the config repository!\n";
} }
} }
@ -195,8 +195,8 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm
if (NodeUtility::CheckAgainstBlackAndWhiteList("blacklist", endpoint, host, service) && if (NodeUtility::CheckAgainstBlackAndWhiteList("blacklist", endpoint, host, service) &&
!NodeUtility::CheckAgainstBlackAndWhiteList("whitelist", endpoint, host, service)) { !NodeUtility::CheckAgainstBlackAndWhiteList("whitelist", endpoint, host, service)) {
Log(LogWarning, "cli") Log(LogWarning, "cli")
<< "Service '" << service << "' on host '" << host << "' on agent '" << "Service '" << service << "' on host '" << host << "' on node '"
<< agent_name << "' is blacklisted, but not whitelisted. Skipping."; << node_name << "' is blacklisted, but not whitelisted. Skipping.";
skip_service = true; skip_service = true;
} }
@ -213,23 +213,23 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm
service_attrs->Set("zone", zone); service_attrs->Set("zone", zone);
Array::Ptr service_imports = make_shared<Array>(); Array::Ptr service_imports = make_shared<Array>();
service_imports->Add("agent-service"); //default service agent template service_imports->Add("node-service"); //default service node template
service_attrs->Set("import", service_imports); service_attrs->Set("import", service_imports);
if (!RepositoryUtility::AddObject(service, "Service", service_attrs)) { if (!RepositoryUtility::AddObject(service, "Service", service_attrs)) {
Log(LogCritical, "cli") Log(LogCritical, "cli")
<< "Cannot add agent host '" << host << "' to the config repository!\n"; << "Cannot add node host '" << host << "' to the config repository!\n";
continue; continue;
} }
} }
} }
/* write a new zone and endpoint for the agent */ /* write a new zone and endpoint for the node */
Dictionary::Ptr endpoint_attrs = make_shared<Dictionary>(); Dictionary::Ptr endpoint_attrs = make_shared<Dictionary>();
endpoint_attrs->Set("__name", endpoint); endpoint_attrs->Set("__name", endpoint);
endpoint_attrs->Set("name", endpoint); endpoint_attrs->Set("name", endpoint);
Dictionary::Ptr settings = agent->Get("settings"); Dictionary::Ptr settings = node->Get("settings");
if (settings) { if (settings) {
if (settings->Contains("host")) if (settings->Contains("host"))
@ -240,7 +240,7 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm
if (!RepositoryUtility::AddObject(endpoint, "Endpoint", endpoint_attrs)) { if (!RepositoryUtility::AddObject(endpoint, "Endpoint", endpoint_attrs)) {
Log(LogCritical, "cli") Log(LogCritical, "cli")
<< "Cannot add agent endpoint '" << endpoint << "' to the config repository!\n"; << "Cannot add node endpoint '" << endpoint << "' to the config repository!\n";
} }
Dictionary::Ptr zone_attrs = make_shared<Dictionary>(); Dictionary::Ptr zone_attrs = make_shared<Dictionary>();
@ -251,20 +251,20 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm
zone_attrs->Set("name", zone); zone_attrs->Set("name", zone);
zone_attrs->Set("endpoints", zone_members); zone_attrs->Set("endpoints", zone_members);
String agent_parent_zone = "master"; //hardcode the name String node_parent_zone = "master"; //hardcode the name
String parent_zone; String parent_zone;
if (!agent->Contains("parent_zone")) { if (!node->Contains("parent_zone")) {
Log(LogWarning, "cli") Log(LogWarning, "cli")
<< "Node '" << endpoint << "' does not have any parent zone defined. Using 'master' as default. Please verify the generated configuration."; << "Node '" << endpoint << "' does not have any parent zone defined. Using 'master' as default. Please verify the generated configuration.";
parent_zone = agent_parent_zone; parent_zone = node_parent_zone;
} else { } else {
parent_zone = agent->Get("parent_zone"); parent_zone = node->Get("parent_zone");
if (parent_zone.IsEmpty()) { if (parent_zone.IsEmpty()) {
Log(LogWarning, "cli") Log(LogWarning, "cli")
<< "Node '" << endpoint << "' does not have any parent zone defined. Using 'master' as default. Please verify the generated configuration."; << "Node '" << endpoint << "' does not have any parent zone defined. Using 'master' as default. Please verify the generated configuration.";
parent_zone = agent_parent_zone; parent_zone = node_parent_zone;
} }
} }
@ -272,26 +272,26 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm
if (!RepositoryUtility::AddObject(zone, "Zone", zone_attrs)) { if (!RepositoryUtility::AddObject(zone, "Zone", zone_attrs)) {
Log(LogCritical, "cli") Log(LogCritical, "cli")
<< "Cannot add agent zone '" << zone << "' to the config repository!\n"; << "Cannot add node zone '" << zone << "' to the config repository!\n";
} }
} }
/* check if there are objects inside the old_inventory which do not exist anymore */ /* check if there are objects inside the old_inventory which do not exist anymore */
BOOST_FOREACH(const Dictionary::Pair& old_agent_objs, old_inventory) { BOOST_FOREACH(const Dictionary::Pair& old_node_objs, old_inventory) {
String old_agent_name = old_agent_objs.first; String old_node_name = old_node_objs.first;
/* check if the agent was dropped */ /* check if the node was dropped */
if (!inventory->Contains(old_agent_name)) { if (!inventory->Contains(old_node_name)) {
Log(LogInformation, "cli") Log(LogInformation, "cli")
<< "Node update found old agent '" << old_agent_name << "'. Removing it and all of its hosts/services."; << "Node update found old node '" << old_node_name << "'. Removing it and all of its hosts/services.";
//TODO Remove an agent and all of his hosts //TODO Remove an node and all of his hosts
Dictionary::Ptr old_agent = old_inventory->Get(old_agent_name); Dictionary::Ptr old_node = old_inventory->Get(old_node_name);
Dictionary::Ptr old_agent_repository = old_agent->Get("repository"); Dictionary::Ptr old_node_repository = old_node->Get("repository");
ObjectLock olock(old_agent_repository); ObjectLock olock(old_node_repository);
BOOST_FOREACH(const Dictionary::Pair& kv, old_agent_repository) { BOOST_FOREACH(const Dictionary::Pair& kv, old_node_repository) {
String host = kv.first; String host = kv.first;
Dictionary::Ptr host_attrs = make_shared<Dictionary>(); Dictionary::Ptr host_attrs = make_shared<Dictionary>();
@ -299,8 +299,8 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm
RepositoryUtility::RemoveObject(host, "Host", host_attrs); //this removes all services for this host as well RepositoryUtility::RemoveObject(host, "Host", host_attrs); //this removes all services for this host as well
} }
String zone = old_agent->Get("zone"); String zone = old_node->Get("zone");
String endpoint = old_agent->Get("endpoint"); String endpoint = old_node->Get("endpoint");
Dictionary::Ptr zone_attrs = make_shared<Dictionary>(); Dictionary::Ptr zone_attrs = make_shared<Dictionary>();
zone_attrs->Set("name", zone); zone_attrs->Set("name", zone);
@ -310,34 +310,34 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm
endpoint_attrs->Set("name", endpoint); endpoint_attrs->Set("name", endpoint);
RepositoryUtility::RemoveObject(endpoint, "Endpoint", endpoint_attrs); RepositoryUtility::RemoveObject(endpoint, "Endpoint", endpoint_attrs);
} else { } else {
/* get the current agent */ /* get the current node */
Dictionary::Ptr new_agent = inventory->Get(old_agent_name); Dictionary::Ptr new_node = inventory->Get(old_node_name);
Dictionary::Ptr new_agent_repository = new_agent->Get("repository"); Dictionary::Ptr new_node_repository = new_node->Get("repository");
Dictionary::Ptr old_agent = old_inventory->Get(old_agent_name); Dictionary::Ptr old_node = old_inventory->Get(old_node_name);
Dictionary::Ptr old_agent_repository = old_agent->Get("repository"); Dictionary::Ptr old_node_repository = old_node->Get("repository");
ObjectLock xlock(old_agent_repository); ObjectLock xlock(old_node_repository);
BOOST_FOREACH(const Dictionary::Pair& kv, old_agent_repository) { BOOST_FOREACH(const Dictionary::Pair& kv, old_node_repository) {
String old_host = kv.first; String old_host = kv.first;
if (old_host == "localhost") { if (old_host == "localhost") {
Log(LogWarning, "cli") Log(LogWarning, "cli")
<< "Ignoring host '" << old_host << "'. Please make sure to configure a unique name on your agent '" << old_agent << "'."; << "Ignoring host '" << old_host << "'. Please make sure to configure a unique name on your node '" << old_node << "'.";
continue; continue;
} }
/* check against black/whitelist before trying to remove host */ /* check against black/whitelist before trying to remove host */
if (NodeUtility::CheckAgainstBlackAndWhiteList("blacklist", old_agent_name, old_host, Empty) && if (NodeUtility::CheckAgainstBlackAndWhiteList("blacklist", old_node_name, old_host, Empty) &&
!NodeUtility::CheckAgainstBlackAndWhiteList("whitelist", old_agent_name, old_host, Empty)) { !NodeUtility::CheckAgainstBlackAndWhiteList("whitelist", old_node_name, old_host, Empty)) {
Log(LogWarning, "cli") Log(LogWarning, "cli")
<< "Host '" << old_agent << "' on agent '" << old_agent << "' is blacklisted, but not whitelisted. Skipping."; << "Host '" << old_node << "' on node '" << old_node << "' is blacklisted, but not whitelisted. Skipping.";
continue; continue;
} }
if (!new_agent_repository->Contains(old_host)) { if (!new_node_repository->Contains(old_host)) {
Log(LogInformation, "cli") Log(LogInformation, "cli")
<< "Node update found old host '" << old_host << "' on agent '" << old_agent_name << "'. Removing it."; << "Node update found old host '" << old_host << "' on node '" << old_node_name << "'. Removing it.";
Dictionary::Ptr host_attrs = make_shared<Dictionary>(); Dictionary::Ptr host_attrs = make_shared<Dictionary>();
host_attrs->Set("name", old_host); host_attrs->Set("name", old_host);
@ -345,23 +345,23 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm
} else { } else {
/* host exists, now check all services for this host */ /* host exists, now check all services for this host */
Array::Ptr old_services = kv.second; Array::Ptr old_services = kv.second;
Array::Ptr new_services = new_agent_repository->Get(old_host); Array::Ptr new_services = new_node_repository->Get(old_host);
ObjectLock ylock(old_services); ObjectLock ylock(old_services);
BOOST_FOREACH(const String& old_service, old_services) { BOOST_FOREACH(const String& old_service, old_services) {
/* check against black/whitelist before trying to remove service */ /* check against black/whitelist before trying to remove service */
if (NodeUtility::CheckAgainstBlackAndWhiteList("blacklist", old_agent_name, old_host, old_service) && if (NodeUtility::CheckAgainstBlackAndWhiteList("blacklist", old_node_name, old_host, old_service) &&
!NodeUtility::CheckAgainstBlackAndWhiteList("whitelist", old_agent_name, old_host, old_service)) { !NodeUtility::CheckAgainstBlackAndWhiteList("whitelist", old_node_name, old_host, old_service)) {
Log(LogWarning, "cli") Log(LogWarning, "cli")
<< "Service '" << old_service << "' on host '" << old_host << "' on agent '" << "Service '" << old_service << "' on host '" << old_host << "' on node '"
<< old_agent_name << "' is blacklisted, but not whitelisted. Skipping."; << old_node_name << "' is blacklisted, but not whitelisted. Skipping.";
continue; continue;
} }
if (!new_services->Contains(old_service)) { if (!new_services->Contains(old_service)) {
Log(LogInformation, "cli") Log(LogInformation, "cli")
<< "Node update found old service '" << old_service << "' on host '" << old_host << "Node update found old service '" << old_service << "' on host '" << old_host
<< "' on agent '" << old_agent_name << "'. Removing it."; << "' on node '" << old_node_name << "'. Removing it.";
Dictionary::Ptr service_attrs = make_shared<Dictionary>(); Dictionary::Ptr service_attrs = make_shared<Dictionary>();
service_attrs->Set("name", old_service); service_attrs->Set("name", old_service);
@ -374,7 +374,7 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm
} }
} }
Log(LogInformation, "cli", "Committing agent configuration."); Log(LogInformation, "cli", "Committing node configuration.");
RepositoryUtility::PrintChangeLog(std::cout); RepositoryUtility::PrintChangeLog(std::cout);
std::cout << "\n"; std::cout << "\n";

View File

@ -221,14 +221,14 @@ Dictionary::Ptr NodeUtility::LoadNodeFile(const String& node_file)
return node; return node;
} }
void NodeUtility::CollectNodes(const String& agent_file, std::vector<Dictionary::Ptr>& agents) void NodeUtility::CollectNodes(const String& node_file, std::vector<Dictionary::Ptr>& nodes)
{ {
Dictionary::Ptr agent = LoadNodeFile(agent_file); Dictionary::Ptr node = LoadNodeFile(node_file);
if (!agent) if (!node)
return; return;
agents.push_back(agent); nodes.push_back(node);
} }
/* /*
@ -282,7 +282,7 @@ int NodeUtility::GenerateNodeIcingaConfig(const std::vector<std::string>& endpoi
my_config->Add(my_master_zone); my_config->Add(my_master_zone);
/* store the local generated agent configuration */ /* store the local generated node configuration */
Dictionary::Ptr my_endpoint = make_shared<Dictionary>(); Dictionary::Ptr my_endpoint = make_shared<Dictionary>();
Dictionary::Ptr my_zone = make_shared<Dictionary>(); Dictionary::Ptr my_zone = make_shared<Dictionary>();
@ -295,7 +295,7 @@ int NodeUtility::GenerateNodeIcingaConfig(const std::vector<std::string>& endpoi
my_zone->Set("__name", nodename); my_zone->Set("__name", nodename);
my_zone->Set("__type", "Zone"); my_zone->Set("__type", "Zone");
my_zone->Set("parent", master_zone_name); //set the master zone as parent my_zone->Set("parent", master_zone_name); //set the master zone as parent
my_zone->Set("//this is the local agent", nodename); my_zone->Set("//this is the local node", nodename);
my_zone->Set("endpoints", my_zone_members); my_zone->Set("endpoints", my_zone_members);
/* store the local config */ /* store the local config */
@ -314,7 +314,7 @@ int NodeUtility::GenerateNodeMasterIcingaConfig(const String& nodename)
{ {
Array::Ptr my_config = make_shared<Array>(); Array::Ptr my_config = make_shared<Array>();
/* store the local generated agent master configuration */ /* store the local generated node master configuration */
Dictionary::Ptr my_master_endpoint = make_shared<Dictionary>(); Dictionary::Ptr my_master_endpoint = make_shared<Dictionary>();
Dictionary::Ptr my_master_zone = make_shared<Dictionary>(); Dictionary::Ptr my_master_zone = make_shared<Dictionary>();
Array::Ptr my_master_zone_members = make_shared<Array>(); Array::Ptr my_master_zone_members = make_shared<Array>();
@ -326,7 +326,7 @@ int NodeUtility::GenerateNodeMasterIcingaConfig(const String& nodename)
my_master_zone->Set("__name", "master"); my_master_zone->Set("__name", "master");
my_master_zone->Set("__type", "Zone"); my_master_zone->Set("__type", "Zone");
my_master_zone->Set("//this is the local agent master named ", "master"); my_master_zone->Set("//this is the local node master named ", "master");
my_master_zone->Set("endpoints", my_master_zone_members); my_master_zone->Set("endpoints", my_master_zone_members);
/* store the local config */ /* store the local config */
@ -360,7 +360,7 @@ bool NodeUtility::WriteNodeConfigObjects(const String& filename, const Array::Pt
std::ofstream fp(tempPath.CStr(), std::ofstream::out | std::ostream::trunc); std::ofstream fp(tempPath.CStr(), std::ofstream::out | std::ostream::trunc);
fp << "/*\n"; fp << "/*\n";
fp << " * Generated by Icinga 2 agent setup commands\n"; fp << " * Generated by Icinga 2 node setup commands\n";
fp << " * on " << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S %z", Utility::GetTime()) << "\n"; fp << " * on " << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S %z", Utility::GetTime()) << "\n";
fp << " */\n\n"; fp << " */\n\n";
@ -411,7 +411,7 @@ Dictionary::Ptr NodeUtility::GetBlackAndWhiteList(const String& type)
return lists; return lists;
} }
int NodeUtility::UpdateBlackAndWhiteList(const String& type, const String& agent_filter, const String& host_filter, const String& service_filter) int NodeUtility::UpdateBlackAndWhiteList(const String& type, const String& node_filter, const String& host_filter, const String& service_filter)
{ {
Dictionary::Ptr lists = GetBlackAndWhiteList(type); Dictionary::Ptr lists = GetBlackAndWhiteList(type);
@ -423,22 +423,22 @@ int NodeUtility::UpdateBlackAndWhiteList(const String& type, const String& agent
host_service->Set("service_filter", service_filter); host_service->Set("service_filter", service_filter);
} }
if (lists->Contains(agent_filter)) { if (lists->Contains(node_filter)) {
Dictionary::Ptr stored_host_service = lists->Get(agent_filter); Dictionary::Ptr stored_host_service = lists->Get(node_filter);
if (stored_host_service->Get("host_filter") == host_filter && service_filter.IsEmpty()) { if (stored_host_service->Get("host_filter") == host_filter && service_filter.IsEmpty()) {
Log(LogWarning, "cli") Log(LogWarning, "cli")
<< "Found agent filter '" << agent_filter << "' with host filter '" << host_filter << "'. Bailing out."; << "Found node filter '" << node_filter << "' with host filter '" << host_filter << "'. Bailing out.";
return 1; return 1;
} else if (stored_host_service->Get("host_filter") == host_filter && stored_host_service->Get("service_filter") == service_filter) { } else if (stored_host_service->Get("host_filter") == host_filter && stored_host_service->Get("service_filter") == service_filter) {
Log(LogWarning, "cli") Log(LogWarning, "cli")
<< "Found agent filter '" << agent_filter << "' with host filter '" << host_filter << "' and service filter '" << "Found node filter '" << node_filter << "' with host filter '" << host_filter << "' and service filter '"
<< service_filter << "'. Bailing out."; << service_filter << "'. Bailing out.";
return 1; return 1;
} }
} }
lists->Set(agent_filter, host_service); lists->Set(node_filter, host_service);
String list_path = GetBlackAndWhiteListPath(type); String list_path = GetBlackAndWhiteListPath(type);
Utility::SaveJsonFile(list_path, lists); Utility::SaveJsonFile(list_path, lists);
@ -446,22 +446,22 @@ int NodeUtility::UpdateBlackAndWhiteList(const String& type, const String& agent
return 0; return 0;
} }
int NodeUtility::RemoveBlackAndWhiteList(const String& type, const String& agent_filter, const String& host_filter, const String& service_filter) int NodeUtility::RemoveBlackAndWhiteList(const String& type, const String& node_filter, const String& host_filter, const String& service_filter)
{ {
Dictionary::Ptr lists = GetBlackAndWhiteList(type); Dictionary::Ptr lists = GetBlackAndWhiteList(type);
if (lists->Contains(agent_filter)) { if (lists->Contains(node_filter)) {
Dictionary::Ptr host_service = lists->Get(agent_filter); Dictionary::Ptr host_service = lists->Get(node_filter);
if (host_service->Get("host_filter") == host_filter && service_filter.IsEmpty()) { if (host_service->Get("host_filter") == host_filter && service_filter.IsEmpty()) {
Log(LogInformation, "cli") Log(LogInformation, "cli")
<< "Found agent filter '" << agent_filter << "' with host filter '" << host_filter << "'. Removing from " << type << "."; << "Found node filter '" << node_filter << "' with host filter '" << host_filter << "'. Removing from " << type << ".";
lists->Remove(agent_filter); lists->Remove(node_filter);
} else if (host_service->Get("host_filter") == host_filter && host_service->Get("service_filter") == service_filter) { } else if (host_service->Get("host_filter") == host_filter && host_service->Get("service_filter") == service_filter) {
Log(LogInformation, "cli") Log(LogInformation, "cli")
<< "Found agent filter '" << agent_filter << "' with host filter '" << host_filter << "' and service filter '" << "Found node filter '" << node_filter << "' with host filter '" << host_filter << "' and service filter '"
<< service_filter << "'. Removing from " << type << "."; << service_filter << "'. Removing from " << type << ".";
lists->Remove(agent_filter); lists->Remove(node_filter);
} else { } else {
Log(LogCritical, "cli", "Cannot remove filter!"); Log(LogCritical, "cli", "Cannot remove filter!");
return 1; return 1;
@ -485,17 +485,17 @@ int NodeUtility::PrintBlackAndWhiteList(std::ostream& fp, const String& type)
ObjectLock olock(lists); ObjectLock olock(lists);
BOOST_FOREACH(const Dictionary::Pair& kv, lists) { BOOST_FOREACH(const Dictionary::Pair& kv, lists) {
String agent_filter = kv.first; String node_filter = kv.first;
Dictionary::Ptr host_service = kv.second; Dictionary::Ptr host_service = kv.second;
fp << "Node " << type << ": '" << agent_filter << "' Host: '" fp << "Node " << type << ": '" << node_filter << "' Host: '"
<< host_service->Get("host_filter") << "' Service: '" << host_service->Get("service_filter") << "'.\n"; << host_service->Get("host_filter") << "' Service: '" << host_service->Get("service_filter") << "'.\n";
} }
return 0; return 0;
} }
bool NodeUtility::CheckAgainstBlackAndWhiteList(const String& type, const String& agent, const String& host, const String& service) bool NodeUtility::CheckAgainstBlackAndWhiteList(const String& type, const String& node, const String& host, const String& service)
{ {
Dictionary::Ptr lists = GetBlackAndWhiteList(type); Dictionary::Ptr lists = GetBlackAndWhiteList(type);
@ -504,7 +504,7 @@ bool NodeUtility::CheckAgainstBlackAndWhiteList(const String& type, const String
ObjectLock olock(lists); ObjectLock olock(lists);
BOOST_FOREACH(const Dictionary::Pair& kv, lists) { BOOST_FOREACH(const Dictionary::Pair& kv, lists) {
String agent_filter = kv.first; String node_filter = kv.first;
Dictionary::Ptr host_service = kv.second; Dictionary::Ptr host_service = kv.second;
String host_filter = host_service->Get("host_filter"); String host_filter = host_service->Get("host_filter");
String service_filter; String service_filter;
@ -513,12 +513,12 @@ bool NodeUtility::CheckAgainstBlackAndWhiteList(const String& type, const String
service_filter = host_service->Get("service_filter"); service_filter = host_service->Get("service_filter");
Log(LogInformation, "cli") Log(LogInformation, "cli")
<< "Checking Node '" << agent << "' =~ '" << agent_filter << "', host '" << host << "' =~ '" << host_filter << "Checking Node '" << node << "' =~ '" << node_filter << "', host '" << host << "' =~ '" << host_filter
<< "', service '" << service << "' =~ '" << service_filter << "'."; << "', service '" << service << "' =~ '" << service_filter << "'.";
if (Utility::Match(agent_filter, agent)) { if (Utility::Match(node_filter, node)) {
Log(LogNotice, "cli") Log(LogNotice, "cli")
<< "Node '" << agent << "' matches filter '" << agent_filter << "'"; << "Node '" << node << "' matches filter '" << node_filter << "'";
if (Utility::Match(host_filter, host)) { if (Utility::Match(host_filter, host)) {
Log(LogNotice, "cli") Log(LogNotice, "cli")

View File

@ -56,26 +56,26 @@ public:
static void UpdateConstant(const String& name, const String& value); static void UpdateConstant(const String& name, const String& value);
/* agent setup helpers */ /* node setup helpers */
static int GenerateNodeIcingaConfig(const std::vector<std::string>& endpoints, const String& nodename); static int GenerateNodeIcingaConfig(const std::vector<std::string>& endpoints, const String& nodename);
static int GenerateNodeMasterIcingaConfig(const String& nodename); static int GenerateNodeMasterIcingaConfig(const String& nodename);
/* black/whitelist */ /* black/whitelist */
static String GetBlackAndWhiteListPath(const String& type); static String GetBlackAndWhiteListPath(const String& type);
static Dictionary::Ptr GetBlackAndWhiteList(const String& type); static Dictionary::Ptr GetBlackAndWhiteList(const String& type);
static int UpdateBlackAndWhiteList(const String& type, const String& agent_filter, static int UpdateBlackAndWhiteList(const String& type, const String& node_filter,
const String& host_filter, const String& service_filter); const String& host_filter, const String& service_filter);
static int RemoveBlackAndWhiteList(const String& type, const String& agent_filter, static int RemoveBlackAndWhiteList(const String& type, const String& node_filter,
const String& host_filter, const String& service_filter); const String& host_filter, const String& service_filter);
static int PrintBlackAndWhiteList(std::ostream& fp, const String& type); static int PrintBlackAndWhiteList(std::ostream& fp, const String& type);
static bool CheckAgainstBlackAndWhiteList(const String& type, const String& agent, const String& host, const String& service); static bool CheckAgainstBlackAndWhiteList(const String& type, const String& node, const String& host, const String& service);
private: private:
NodeUtility(void); NodeUtility(void);
static bool RemoveNodeFile(const String& path); static bool RemoveNodeFile(const String& path);
static Dictionary::Ptr LoadNodeFile(const String& agent_file); static Dictionary::Ptr LoadNodeFile(const String& node_file);
static void CollectNodes(const String& agent_file, std::vector<Dictionary::Ptr>& agents); static void CollectNodes(const String& node_file, std::vector<Dictionary::Ptr>& nodes);
static void SerializeObject(std::ostream& fp, const String& name, const String& type, const Dictionary::Ptr& object); static void SerializeObject(std::ostream& fp, const String& name, const String& type, const Dictionary::Ptr& object);
static void FormatValue(std::ostream& fp, const Value& val); static void FormatValue(std::ostream& fp, const Value& val);

View File

@ -42,12 +42,12 @@ REGISTER_CLICOMMAND("node/wizard", NodeWizardCommand);
String NodeWizardCommand::GetDescription(void) const String NodeWizardCommand::GetDescription(void) const
{ {
return "Wizard for Icinga 2 agent setup."; return "Wizard for Icinga 2 node setup.";
} }
String NodeWizardCommand::GetShortDescription(void) const String NodeWizardCommand::GetShortDescription(void) const
{ {
return "wizard for agent setup"; return "wizard for node setup";
} }
ImpersonationLevel NodeWizardCommand::GetImpersonationLevel(void) const ImpersonationLevel NodeWizardCommand::GetImpersonationLevel(void) const
@ -61,7 +61,7 @@ int NodeWizardCommand::GetMaxArguments(void) const
} }
/** /**
* The entry point for the "agent wizard" CLI command. * The entry point for the "node wizard" CLI command.
* *
* @returns An exit status. * @returns An exit status.
*/ */
@ -82,7 +82,7 @@ int NodeWizardCommand::Run(const boost::program_options::variables_map& vm, cons
//TODO: Add sort of bash completion to path input? //TODO: Add sort of bash completion to path input?
/* 0. master or agent setup? /* 0. master or node setup?
* 1. Ticket * 1. Ticket
* 2. Master information for autosigning * 2. Master information for autosigning
* 3. Trusted cert location * 3. Trusted cert location
@ -98,9 +98,9 @@ int NodeWizardCommand::Run(const boost::program_options::variables_map& vm, cons
*/ */
std::string answer; std::string answer;
bool is_agent_setup = true; bool is_node_setup = true;
std::cout << "Please specify if this is an agent setup ('no' installs a master setup) [Y/n]: "; std::cout << "Please specify if this is an node setup ('no' installs a master setup) [Y/n]: ";
std::getline (std::cin, answer); std::getline (std::cin, answer);
boost::algorithm::to_lower(answer); boost::algorithm::to_lower(answer);
@ -108,10 +108,10 @@ int NodeWizardCommand::Run(const boost::program_options::variables_map& vm, cons
String choice = answer; String choice = answer;
if (choice.Contains("n")) if (choice.Contains("n"))
is_agent_setup = false; is_node_setup = false;
if (is_agent_setup) { if (is_node_setup) {
/* agent setup part */ /* node setup part */
std::cout << "Starting the Node setup routine...\n"; std::cout << "Starting the Node setup routine...\n";
/* CN */ /* CN */
@ -130,7 +130,7 @@ int NodeWizardCommand::Run(const boost::program_options::variables_map& vm, cons
String endpoint_buffer; String endpoint_buffer;
std::cout << "Please specify the master endpoint(s) this agent should connect to:\n"; std::cout << "Please specify the master endpoint(s) this node should connect to:\n";
String master_endpoint_name; String master_endpoint_name;
wizard_endpoint_loop_start: wizard_endpoint_loop_start:
@ -214,8 +214,8 @@ wizard_master_host:
/* workaround for fetching the master cert */ /* workaround for fetching the master cert */
String pki_path = PkiUtility::GetPkiPath(); String pki_path = PkiUtility::GetPkiPath();
String agent_cert = pki_path + "/" + cn + ".crt"; String node_cert = pki_path + "/" + cn + ".crt";
String agent_key = pki_path + "/" + cn + ".key"; String node_key = pki_path + "/" + cn + ".key";
//new-ca, new-cert //new-ca, new-cert
PkiUtility::NewCa(); PkiUtility::NewCa();
@ -234,7 +234,7 @@ wizard_master_host:
<< "Cannot set ownership for user '" << user << "' group '" << group << "' on file '" << pki_path << "'. Verify it yourself!"; << "Cannot set ownership for user '" << user << "' group '" << group << "' on file '" << pki_path << "'. Verify it yourself!";
} }
if (PkiUtility::NewCert(cn, agent_key, Empty, agent_cert) > 0) { if (PkiUtility::NewCert(cn, node_key, Empty, node_cert) > 0) {
Log(LogCritical, "cli") Log(LogCritical, "cli")
<< "Failed to create new self-signed certificate for CN '" << cn << "'. Please try again."; << "Failed to create new self-signed certificate for CN '" << cn << "'. Please try again.";
return 1; return 1;
@ -258,13 +258,13 @@ wizard_master_host:
Log(LogWarning, "cli") Log(LogWarning, "cli")
<< "Cannot set ownership for user '" << user << "' group '" << group << "' on file '" << ca_key << "'. Verify it yourself!"; << "Cannot set ownership for user '" << user << "' group '" << group << "' on file '" << ca_key << "'. Verify it yourself!";
} }
if (!Utility::SetFileOwnership(agent_cert, user, group)) { if (!Utility::SetFileOwnership(node_cert, user, group)) {
Log(LogWarning, "cli") Log(LogWarning, "cli")
<< "Cannot set ownership for user '" << user << "' group '" << group << "' on file '" << agent_cert << "'. Verify it yourself!"; << "Cannot set ownership for user '" << user << "' group '" << group << "' on file '" << node_cert << "'. Verify it yourself!";
} }
if (!Utility::SetFileOwnership(agent_key, user, group)) { if (!Utility::SetFileOwnership(node_key, user, group)) {
Log(LogWarning, "cli") Log(LogWarning, "cli")
<< "Cannot set ownership for user '" << user << "' group '" << group << "' on file '" << agent_key << "'. Verify it yourself!"; << "Cannot set ownership for user '" << user << "' group '" << group << "' on file '" << node_key << "'. Verify it yourself!";
} }
String target_ca = pki_path + "/ca.crt"; String target_ca = pki_path + "/ca.crt";
@ -287,7 +287,7 @@ wizard_master_host:
String trusted_cert = PkiUtility::GetPkiPath() + "/trusted-master.crt"; String trusted_cert = PkiUtility::GetPkiPath() + "/trusted-master.crt";
if (PkiUtility::SaveCert(master_host, master_port, agent_key, agent_cert, trusted_cert) > 0) { if (PkiUtility::SaveCert(master_host, master_port, node_key, node_cert, trusted_cert) > 0) {
Log(LogCritical, "cli") Log(LogCritical, "cli")
<< "Failed to fetch trusted master certificate. Please try again."; << "Failed to fetch trusted master certificate. Please try again.";
return 1; return 1;
@ -310,7 +310,7 @@ wizard_ticket:
std::cout << "Processing self-signed certificate request. Ticket '" << ticket << "'.\n"; std::cout << "Processing self-signed certificate request. Ticket '" << ticket << "'.\n";
if (PkiUtility::RequestCertificate(master_host, master_port, agent_key, agent_cert, ca, trusted_cert, ticket) > 0) { if (PkiUtility::RequestCertificate(master_host, master_port, node_key, node_cert, ca, trusted_cert, ticket) > 0) {
Log(LogCritical, "cli") Log(LogCritical, "cli")
<< "Failed to fetch signed certificate from master '" << master_host << ", " << "Failed to fetch signed certificate from master '" << master_host << ", "
<< master_port <<"'. Please try again."; << master_port <<"'. Please try again.";
@ -318,9 +318,9 @@ wizard_ticket:
} }
/* fix permissions (again) when updating the signed certificate */ /* fix permissions (again) when updating the signed certificate */
if (!Utility::SetFileOwnership(agent_cert, user, group)) { if (!Utility::SetFileOwnership(node_cert, user, group)) {
Log(LogWarning, "cli") Log(LogWarning, "cli")
<< "Cannot set ownership for user '" << user << "' group '" << group << "' on file '" << agent_cert << "'. Verify it yourself!"; << "Cannot set ownership for user '" << user << "' group '" << group << "' on file '" << node_cert << "'. Verify it yourself!";
} }
/* apilistener config */ /* apilistener config */
@ -577,7 +577,7 @@ wizard_ticket:
<< "Edit the api feature config file '" << apipath << "' and set a secure 'ticket_salt' attribute."; << "Edit the api feature config file '" << apipath << "' and set a secure 'ticket_salt' attribute.";
} }
std::cout << "Now restart your Icinga 2 agent to finish the installation!\n"; std::cout << "Now restart your Icinga 2 to finish the installation!\n";
std::cout << "If you encounter problems or bugs, please do not hesitate to\n" std::cout << "If you encounter problems or bugs, please do not hesitate to\n"
<< "get in touch with the community at https://support.icinga.org" << std::endl; << "get in touch with the community at https://support.icinga.org" << std::endl;