From: Gunnar Beutner Date: Fri, 31 Oct 2014 10:53:44 +0000 (+0100) Subject: Rename --agent to --zone (for blacklist/whitelist) X-Git-Tag: v2.2.0~168 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5d7e30bb815e4cee80e1cad015f64cca737934dd;p=icinga2 Rename --agent to --zone (for blacklist/whitelist) fixes #7516 --- diff --git a/lib/cli/nodeaddcommand.cpp b/lib/cli/nodeaddcommand.cpp index 58c057a79..abc0d6fe2 100644 --- a/lib/cli/nodeaddcommand.cpp +++ b/lib/cli/nodeaddcommand.cpp @@ -35,12 +35,12 @@ REGISTER_CLICOMMAND("node/add", NodeAddCommand); String NodeAddCommand::GetDescription(void) const { - return "Add Icinga 2 agent."; + return "Add Icinga 2 node."; } String NodeAddCommand::GetShortDescription(void) const { - return "add agent"; + return "add node"; } 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. */ diff --git a/lib/cli/nodeaddcommand.hpp b/lib/cli/nodeaddcommand.hpp index fcb2badcc..d791fe24e 100644 --- a/lib/cli/nodeaddcommand.hpp +++ b/lib/cli/nodeaddcommand.hpp @@ -26,7 +26,7 @@ namespace icinga { /** - * The "agent add" command. + * The "node add" command. * * @ingroup cli */ diff --git a/lib/cli/nodeblackandwhitelistcommand.cpp b/lib/cli/nodeblackandwhitelistcommand.cpp index 3545c2c04..533c447a7 100644 --- a/lib/cli/nodeblackandwhitelistcommand.cpp +++ b/lib/cli/nodeblackandwhitelistcommand.cpp @@ -107,18 +107,16 @@ String BlackAndWhitelistCommand::GetShortDescription(void) const void BlackAndWhitelistCommand::InitParameters(boost::program_options::options_description& visibleDesc, boost::program_options::options_description& hiddenDesc) const { - visibleDesc.add_options() - ("agent", po::value(), "The name of the agent") - ("host", po::value(), "The name of the host") - ("service", po::value(), "The name of the service"); - - if (m_Command == BlackAndWhitelistCommandAdd) { - //TODO: call list functionality + if (m_Command == BlackAndWhitelistCommandAdd || m_Command == BlackAndWhitelistCommandRemove) { + visibleDesc.add_options() + ("zone", po::value(), "The name of the zone") + ("host", po::value(), "The name of the host") + ("service", po::value(), "The name of the service"); } } /** - * The entry point for the "agent " CLI command. + * The entry point for the "node " CLI command. * * @returns An exit status. */ @@ -133,10 +131,11 @@ int BlackAndWhitelistCommand::Run(const boost::program_options::variables_map& v } if (m_Command == BlackAndWhitelistCommandAdd) { - if (!vm.count("agent")) { - Log(LogCritical, "cli", "At least the agent name filter is required!"); + if (!vm.count("zone")) { + Log(LogCritical, "cli", "At least 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; @@ -147,26 +146,21 @@ int BlackAndWhitelistCommand::Run(const boost::program_options::variables_map& v if (vm.count("service")) service_filter = vm["service"].as(); - return NodeUtility::UpdateBlackAndWhiteList(m_Type, vm["agent"].as(), vm["host"].as(), service_filter); + return NodeUtility::UpdateBlackAndWhiteList(m_Type, vm["zone"].as(), vm["host"].as(), service_filter); } 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); } else if (m_Command == BlackAndWhitelistCommandRemove) { - if (!vm.count("agent")) { - Log(LogCritical, "cli", "At least the agent name filter is required!"); + if (!vm.count("zone")) { + 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!"); + Log(LogCritical, "cli", "The host name filter is required!"); return 1; } - String agent_filter = vm["agent"].as(); + String zone_filter = vm["zone"].as(); String host_filter = vm["host"].as(); String service_filter; @@ -174,7 +168,7 @@ int BlackAndWhitelistCommand::Run(const boost::program_options::variables_map& v service_filter = vm["service"].as(); } - return NodeUtility::RemoveBlackAndWhiteList(m_Type, vm["agent"].as(), vm["host"].as(), service_filter); + return NodeUtility::RemoveBlackAndWhiteList(m_Type, vm["zone"].as(), vm["host"].as(), service_filter); } diff --git a/lib/cli/nodelistcommand.cpp b/lib/cli/nodelistcommand.cpp index b55380d0d..0644ad650 100644 --- a/lib/cli/nodelistcommand.cpp +++ b/lib/cli/nodelistcommand.cpp @@ -36,23 +36,23 @@ REGISTER_CLICOMMAND("node/list", NodeListCommand); String NodeListCommand::GetDescription(void) const { - return "Lists all Icinga 2 agents."; + return "Lists all Icinga 2 nodes."; } String NodeListCommand::GetShortDescription(void) const { - return "lists all agents"; + return "lists all nodes"; } void NodeListCommand::InitParameters(boost::program_options::options_description& visibleDesc, boost::program_options::options_description& hiddenDesc) const { 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. */ diff --git a/lib/cli/nodelistcommand.hpp b/lib/cli/nodelistcommand.hpp index 02a37f2f0..e194c7824 100644 --- a/lib/cli/nodelistcommand.hpp +++ b/lib/cli/nodelistcommand.hpp @@ -26,7 +26,7 @@ namespace icinga { /** - * The "agent list" command. + * The "node list" command. * * @ingroup cli */ diff --git a/lib/cli/noderemovecommand.cpp b/lib/cli/noderemovecommand.cpp index df7bdb745..c1de7b92b 100644 --- a/lib/cli/noderemovecommand.cpp +++ b/lib/cli/noderemovecommand.cpp @@ -35,12 +35,12 @@ REGISTER_CLICOMMAND("node/remove", NodeRemoveCommand); String NodeRemoveCommand::GetDescription(void) const { - return "Removes Icinga 2 agent."; + return "Removes Icinga 2 node."; } String NodeRemoveCommand::GetShortDescription(void) const { - return "removes agent"; + return "removes node"; } std::vector 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. */ int NodeRemoveCommand::Run(const boost::program_options::variables_map& vm, const std::vector& ap) const { - BOOST_FOREACH(const String& agent, ap) { - NodeUtility::RemoveNode(agent); + BOOST_FOREACH(const String& node, ap) { + NodeUtility::RemoveNode(node); } return 0; diff --git a/lib/cli/noderemovecommand.hpp b/lib/cli/noderemovecommand.hpp index d3d539971..b41a6244f 100644 --- a/lib/cli/noderemovecommand.hpp +++ b/lib/cli/noderemovecommand.hpp @@ -26,7 +26,7 @@ namespace icinga { /** - * The "agent remove" command. + * The "node remove" command. * * @ingroup cli */ diff --git a/lib/cli/nodesetcommand.cpp b/lib/cli/nodesetcommand.cpp index 66afb36de..82e9e230a 100644 --- a/lib/cli/nodesetcommand.cpp +++ b/lib/cli/nodesetcommand.cpp @@ -35,12 +35,12 @@ REGISTER_CLICOMMAND("node/set", NodeSetCommand); String NodeSetCommand::GetDescription(void) const { - return "Set agent attribute(s)."; + return "Set node attribute(s)."; } String NodeSetCommand::GetShortDescription(void) const { - return "set agent attributes"; + return "set node attributes"; } 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. */ diff --git a/lib/cli/nodesetcommand.hpp b/lib/cli/nodesetcommand.hpp index f247c78cd..a8c2434fa 100644 --- a/lib/cli/nodesetcommand.hpp +++ b/lib/cli/nodesetcommand.hpp @@ -26,7 +26,7 @@ namespace icinga { /** - * The "agent set" command. + * The "node set" command. * * @ingroup cli */ diff --git a/lib/cli/nodesetupcommand.cpp b/lib/cli/nodesetupcommand.cpp index 08d5077d3..24ed78347 100644 --- a/lib/cli/nodesetupcommand.cpp +++ b/lib/cli/nodesetupcommand.cpp @@ -43,12 +43,12 @@ REGISTER_CLICOMMAND("node/setup", NodeSetupCommand); String NodeSetupCommand::GetDescription(void) const { - return "Sets up an Icinga 2 agent."; + return "Sets up an Icinga 2 node."; } String NodeSetupCommand::GetShortDescription(void) const { - return "set up agent"; + return "set up node"; } 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. */ diff --git a/lib/cli/nodesetupcommand.hpp b/lib/cli/nodesetupcommand.hpp index 251385b8b..47d094e31 100644 --- a/lib/cli/nodesetupcommand.hpp +++ b/lib/cli/nodesetupcommand.hpp @@ -26,7 +26,7 @@ namespace icinga { /** - * The "agent setup" command. + * The "node setup" command. * * @ingroup cli */ diff --git a/lib/cli/nodeupdateconfigcommand.cpp b/lib/cli/nodeupdateconfigcommand.cpp index 512f32418..bb897e804 100644 --- a/lib/cli/nodeupdateconfigcommand.cpp +++ b/lib/cli/nodeupdateconfigcommand.cpp @@ -38,12 +38,12 @@ REGISTER_CLICOMMAND("node/update-config", NodeUpdateConfigCommand); String NodeUpdateConfigCommand::GetDescription(void) const { - return "Update Icinga 2 agent config."; + return "Update Icinga 2 node config."; } String NodeUpdateConfigCommand::GetShortDescription(void) const { - return "update agent config"; + return "update node config"; } 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. */ @@ -77,7 +77,7 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm Dictionary::Ptr inventory = make_shared(); Log(LogInformation, "cli") - << "Updating agent configuration for "; + << "Updating node configuration for "; NodeUtility::PrintNodes(std::cout); @@ -85,31 +85,31 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm std::vector object_paths = RepositoryUtility::GetObjects(); - BOOST_FOREACH(const Dictionary::Ptr& agent, NodeUtility::GetNodes()) { - Dictionary::Ptr repository = agent->Get("repository"); - String zone = agent->Get("zone"); - String endpoint = agent->Get("endpoint"); - String agent_name = endpoint; + BOOST_FOREACH(const Dictionary::Ptr& node, NodeUtility::GetNodes()) { + Dictionary::Ptr repository = node->Get("repository"); + String zone = node->Get("zone"); + String endpoint = node->Get("endpoint"); + String node_name = endpoint; /* store existing structure in index */ - inventory->Set(endpoint, agent); + inventory->Set(endpoint, node); Dictionary::Ptr host_services = make_shared(); 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(); host_attrs->Set("__name", zone); host_attrs->Set("name", zone); host_attrs->Set("check_command", "cluster-zone"); Array::Ptr host_imports = make_shared(); - host_imports->Add("agent-host"); //default host agent template + host_imports->Add("node-host"); //default host node template host_attrs->Set("import", host_imports); if (!RepositoryUtility::AddObject(zone, "Host", host_attrs)) { 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); @@ -120,7 +120,7 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm if (host == "localhost") { 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; } @@ -138,10 +138,10 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm skip_host = true; /* check against black/whitelist before trying to add host */ - if (NodeUtility::CheckAgainstBlackAndWhiteList("blacklist", agent_name, host, Empty) && - !NodeUtility::CheckAgainstBlackAndWhiteList("whitelist", agent_name, host, Empty)) { + if (NodeUtility::CheckAgainstBlackAndWhiteList("blacklist", node_name, host, Empty) && + !NodeUtility::CheckAgainstBlackAndWhiteList("whitelist", node_name, host, Empty)) { 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; } @@ -159,12 +159,12 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm } Array::Ptr host_imports = make_shared(); - host_imports->Add("agent-host"); //default host agent template + host_imports->Add("node-host"); //default host node template host_attrs->Set("import", host_imports); if (!RepositoryUtility::AddObject(host, "Host", host_attrs)) { 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) && !NodeUtility::CheckAgainstBlackAndWhiteList("whitelist", endpoint, host, service)) { Log(LogWarning, "cli") - << "Service '" << service << "' on host '" << host << "' on agent '" - << agent_name << "' is blacklisted, but not whitelisted. Skipping."; + << "Service '" << service << "' on host '" << host << "' on node '" + << node_name << "' is blacklisted, but not whitelisted. Skipping."; skip_service = true; } @@ -213,23 +213,23 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm service_attrs->Set("zone", zone); Array::Ptr service_imports = make_shared(); - service_imports->Add("agent-service"); //default service agent template + service_imports->Add("node-service"); //default service node template service_attrs->Set("import", service_imports); if (!RepositoryUtility::AddObject(service, "Service", service_attrs)) { Log(LogCritical, "cli") - << "Cannot add agent host '" << host << "' to the config repository!\n"; + << "Cannot add node host '" << host << "' to the config repository!\n"; 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(); 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->Contains("host")) @@ -240,7 +240,7 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm if (!RepositoryUtility::AddObject(endpoint, "Endpoint", endpoint_attrs)) { 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(); @@ -251,20 +251,20 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm zone_attrs->Set("name", zone); 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; - if (!agent->Contains("parent_zone")) { + if (!node->Contains("parent_zone")) { Log(LogWarning, "cli") << "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 { - parent_zone = agent->Get("parent_zone"); + parent_zone = node->Get("parent_zone"); if (parent_zone.IsEmpty()) { Log(LogWarning, "cli") << "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)) { 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 */ - 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 */ - if (!inventory->Contains(old_agent_name)) { + /* check if the node was dropped */ + if (!inventory->Contains(old_node_name)) { 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 - Dictionary::Ptr old_agent = old_inventory->Get(old_agent_name); - Dictionary::Ptr old_agent_repository = old_agent->Get("repository"); + //TODO Remove an node and all of his hosts + Dictionary::Ptr old_node = old_inventory->Get(old_node_name); + Dictionary::Ptr old_node_repository = old_node->Get("repository"); - ObjectLock olock(old_agent_repository); - BOOST_FOREACH(const Dictionary::Pair& kv, old_agent_repository) { + ObjectLock olock(old_node_repository); + BOOST_FOREACH(const Dictionary::Pair& kv, old_node_repository) { String host = kv.first; Dictionary::Ptr host_attrs = make_shared(); @@ -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 } - String zone = old_agent->Get("zone"); - String endpoint = old_agent->Get("endpoint"); + String zone = old_node->Get("zone"); + String endpoint = old_node->Get("endpoint"); Dictionary::Ptr zone_attrs = make_shared(); zone_attrs->Set("name", zone); @@ -310,34 +310,34 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm endpoint_attrs->Set("name", endpoint); RepositoryUtility::RemoveObject(endpoint, "Endpoint", endpoint_attrs); } else { - /* get the current agent */ - Dictionary::Ptr new_agent = inventory->Get(old_agent_name); - Dictionary::Ptr new_agent_repository = new_agent->Get("repository"); + /* get the current node */ + Dictionary::Ptr new_node = inventory->Get(old_node_name); + Dictionary::Ptr new_node_repository = new_node->Get("repository"); - Dictionary::Ptr old_agent = old_inventory->Get(old_agent_name); - Dictionary::Ptr old_agent_repository = old_agent->Get("repository"); + Dictionary::Ptr old_node = old_inventory->Get(old_node_name); + Dictionary::Ptr old_node_repository = old_node->Get("repository"); - ObjectLock xlock(old_agent_repository); - BOOST_FOREACH(const Dictionary::Pair& kv, old_agent_repository) { + ObjectLock xlock(old_node_repository); + BOOST_FOREACH(const Dictionary::Pair& kv, old_node_repository) { String old_host = kv.first; if (old_host == "localhost") { 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; } /* check against black/whitelist before trying to remove host */ - if (NodeUtility::CheckAgainstBlackAndWhiteList("blacklist", old_agent_name, old_host, Empty) && - !NodeUtility::CheckAgainstBlackAndWhiteList("whitelist", old_agent_name, old_host, Empty)) { + if (NodeUtility::CheckAgainstBlackAndWhiteList("blacklist", old_node_name, old_host, Empty) && + !NodeUtility::CheckAgainstBlackAndWhiteList("whitelist", old_node_name, old_host, Empty)) { 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; } - if (!new_agent_repository->Contains(old_host)) { + if (!new_node_repository->Contains(old_host)) { 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(); host_attrs->Set("name", old_host); @@ -345,23 +345,23 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm } else { /* host exists, now check all services for this host */ 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); BOOST_FOREACH(const String& old_service, old_services) { /* check against black/whitelist before trying to remove service */ - if (NodeUtility::CheckAgainstBlackAndWhiteList("blacklist", old_agent_name, old_host, old_service) && - !NodeUtility::CheckAgainstBlackAndWhiteList("whitelist", old_agent_name, old_host, old_service)) { + if (NodeUtility::CheckAgainstBlackAndWhiteList("blacklist", old_node_name, old_host, old_service) && + !NodeUtility::CheckAgainstBlackAndWhiteList("whitelist", old_node_name, old_host, old_service)) { Log(LogWarning, "cli") - << "Service '" << old_service << "' on host '" << old_host << "' on agent '" - << old_agent_name << "' is blacklisted, but not whitelisted. Skipping."; + << "Service '" << old_service << "' on host '" << old_host << "' on node '" + << old_node_name << "' is blacklisted, but not whitelisted. Skipping."; continue; } if (!new_services->Contains(old_service)) { Log(LogInformation, "cli") << "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(); 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); std::cout << "\n"; diff --git a/lib/cli/nodeutility.cpp b/lib/cli/nodeutility.cpp index 3ef4223cd..074f6a30a 100644 --- a/lib/cli/nodeutility.cpp +++ b/lib/cli/nodeutility.cpp @@ -221,14 +221,14 @@ Dictionary::Ptr NodeUtility::LoadNodeFile(const String& node_file) return node; } -void NodeUtility::CollectNodes(const String& agent_file, std::vector& agents) +void NodeUtility::CollectNodes(const String& node_file, std::vector& nodes) { - Dictionary::Ptr agent = LoadNodeFile(agent_file); + Dictionary::Ptr node = LoadNodeFile(node_file); - if (!agent) + if (!node) return; - agents.push_back(agent); + nodes.push_back(node); } /* @@ -282,7 +282,7 @@ int NodeUtility::GenerateNodeIcingaConfig(const std::vector& endpoi 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::Ptr my_zone = make_shared(); @@ -295,7 +295,7 @@ int NodeUtility::GenerateNodeIcingaConfig(const std::vector& endpoi my_zone->Set("__name", nodename); my_zone->Set("__type", "Zone"); 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); /* store the local config */ @@ -314,7 +314,7 @@ int NodeUtility::GenerateNodeMasterIcingaConfig(const String& nodename) { Array::Ptr my_config = make_shared(); - /* store the local generated agent master configuration */ + /* store the local generated node master configuration */ Dictionary::Ptr my_master_endpoint = make_shared(); Dictionary::Ptr my_master_zone = make_shared(); Array::Ptr my_master_zone_members = make_shared(); @@ -326,7 +326,7 @@ int NodeUtility::GenerateNodeMasterIcingaConfig(const String& nodename) my_master_zone->Set("__name", "master"); 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); /* 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); 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 << " */\n\n"; @@ -411,7 +411,7 @@ Dictionary::Ptr NodeUtility::GetBlackAndWhiteList(const String& type) 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); @@ -423,22 +423,22 @@ int NodeUtility::UpdateBlackAndWhiteList(const String& type, const String& agent host_service->Set("service_filter", service_filter); } - if (lists->Contains(agent_filter)) { - Dictionary::Ptr stored_host_service = lists->Get(agent_filter); + if (lists->Contains(node_filter)) { + Dictionary::Ptr stored_host_service = lists->Get(node_filter); if (stored_host_service->Get("host_filter") == host_filter && service_filter.IsEmpty()) { 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; } else if (stored_host_service->Get("host_filter") == host_filter && stored_host_service->Get("service_filter") == service_filter) { 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."; return 1; } } - lists->Set(agent_filter, host_service); + lists->Set(node_filter, host_service); String list_path = GetBlackAndWhiteListPath(type); Utility::SaveJsonFile(list_path, lists); @@ -446,22 +446,22 @@ int NodeUtility::UpdateBlackAndWhiteList(const String& type, const String& agent 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); - if (lists->Contains(agent_filter)) { - Dictionary::Ptr host_service = lists->Get(agent_filter); + if (lists->Contains(node_filter)) { + Dictionary::Ptr host_service = lists->Get(node_filter); if (host_service->Get("host_filter") == host_filter && service_filter.IsEmpty()) { Log(LogInformation, "cli") - << "Found agent filter '" << agent_filter << "' with host filter '" << host_filter << "'. Removing from " << type << "."; - lists->Remove(agent_filter); + << "Found node filter '" << node_filter << "' with host filter '" << host_filter << "'. Removing from " << type << "."; + lists->Remove(node_filter); } else if (host_service->Get("host_filter") == host_filter && host_service->Get("service_filter") == service_filter) { 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 << "."; - lists->Remove(agent_filter); + lists->Remove(node_filter); } else { Log(LogCritical, "cli", "Cannot remove filter!"); return 1; @@ -485,17 +485,17 @@ int NodeUtility::PrintBlackAndWhiteList(std::ostream& fp, const String& type) ObjectLock olock(lists); BOOST_FOREACH(const Dictionary::Pair& kv, lists) { - String agent_filter = kv.first; + String node_filter = kv.first; 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"; } 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); @@ -504,7 +504,7 @@ bool NodeUtility::CheckAgainstBlackAndWhiteList(const String& type, const String ObjectLock olock(lists); BOOST_FOREACH(const Dictionary::Pair& kv, lists) { - String agent_filter = kv.first; + String node_filter = kv.first; Dictionary::Ptr host_service = kv.second; String host_filter = host_service->Get("host_filter"); String service_filter; @@ -513,12 +513,12 @@ bool NodeUtility::CheckAgainstBlackAndWhiteList(const String& type, const String service_filter = host_service->Get("service_filter"); 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 << "'."; - if (Utility::Match(agent_filter, agent)) { + if (Utility::Match(node_filter, node)) { Log(LogNotice, "cli") - << "Node '" << agent << "' matches filter '" << agent_filter << "'"; + << "Node '" << node << "' matches filter '" << node_filter << "'"; if (Utility::Match(host_filter, host)) { Log(LogNotice, "cli") diff --git a/lib/cli/nodeutility.hpp b/lib/cli/nodeutility.hpp index 514fc161a..65b30238f 100644 --- a/lib/cli/nodeutility.hpp +++ b/lib/cli/nodeutility.hpp @@ -56,26 +56,26 @@ public: static void UpdateConstant(const String& name, const String& value); - /* agent setup helpers */ + /* node setup helpers */ static int GenerateNodeIcingaConfig(const std::vector& endpoints, const String& nodename); static int GenerateNodeMasterIcingaConfig(const String& nodename); /* black/whitelist */ static String GetBlackAndWhiteListPath(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); - 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); 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: NodeUtility(void); static bool RemoveNodeFile(const String& path); - static Dictionary::Ptr LoadNodeFile(const String& agent_file); - static void CollectNodes(const String& agent_file, std::vector& agents); + static Dictionary::Ptr LoadNodeFile(const String& node_file); + static void CollectNodes(const String& node_file, std::vector& nodes); 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); diff --git a/lib/cli/nodewizardcommand.cpp b/lib/cli/nodewizardcommand.cpp index 676dcbd99..66bdbb436 100644 --- a/lib/cli/nodewizardcommand.cpp +++ b/lib/cli/nodewizardcommand.cpp @@ -42,12 +42,12 @@ REGISTER_CLICOMMAND("node/wizard", NodeWizardCommand); String NodeWizardCommand::GetDescription(void) const { - return "Wizard for Icinga 2 agent setup."; + return "Wizard for Icinga 2 node setup."; } String NodeWizardCommand::GetShortDescription(void) const { - return "wizard for agent setup"; + return "wizard for node setup"; } 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. */ @@ -82,7 +82,7 @@ int NodeWizardCommand::Run(const boost::program_options::variables_map& vm, cons //TODO: Add sort of bash completion to path input? - /* 0. master or agent setup? + /* 0. master or node setup? * 1. Ticket * 2. Master information for autosigning * 3. Trusted cert location @@ -98,9 +98,9 @@ int NodeWizardCommand::Run(const boost::program_options::variables_map& vm, cons */ 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); boost::algorithm::to_lower(answer); @@ -108,10 +108,10 @@ int NodeWizardCommand::Run(const boost::program_options::variables_map& vm, cons String choice = answer; if (choice.Contains("n")) - is_agent_setup = false; + is_node_setup = false; - if (is_agent_setup) { - /* agent setup part */ + if (is_node_setup) { + /* node setup part */ std::cout << "Starting the Node setup routine...\n"; /* CN */ @@ -130,7 +130,7 @@ int NodeWizardCommand::Run(const boost::program_options::variables_map& vm, cons 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; wizard_endpoint_loop_start: @@ -214,8 +214,8 @@ wizard_master_host: /* workaround for fetching the master cert */ String pki_path = PkiUtility::GetPkiPath(); - String agent_cert = pki_path + "/" + cn + ".crt"; - String agent_key = pki_path + "/" + cn + ".key"; + String node_cert = pki_path + "/" + cn + ".crt"; + String node_key = pki_path + "/" + cn + ".key"; //new-ca, new-cert PkiUtility::NewCa(); @@ -234,7 +234,7 @@ wizard_master_host: << "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") << "Failed to create new self-signed certificate for CN '" << cn << "'. Please try again."; return 1; @@ -258,13 +258,13 @@ wizard_master_host: Log(LogWarning, "cli") << "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") - << "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") - << "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"; @@ -287,7 +287,7 @@ wizard_master_host: 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") << "Failed to fetch trusted master certificate. Please try again."; return 1; @@ -310,7 +310,7 @@ wizard_ticket: 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") << "Failed to fetch signed certificate from master '" << master_host << ", " << master_port <<"'. Please try again."; @@ -318,9 +318,9 @@ wizard_ticket: } /* 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") - << "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 */ @@ -577,7 +577,7 @@ wizard_ticket: << "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" << "get in touch with the community at https://support.icinga.org" << std::endl;