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
}
/**
- * The entry point for the "agent add" CLI command.
+ * The entry point for the "node add" CLI command.
*
* @returns An exit status.
*/
{
/**
- * The "agent add" command.
+ * The "node add" command.
*
* @ingroup cli
*/
void BlackAndWhitelistCommand::InitParameters(boost::program_options::options_description& visibleDesc,
boost::program_options::options_description& hiddenDesc) const
{
- visibleDesc.add_options()
- ("agent", po::value<std::string>(), "The name of the agent")
- ("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
+ if (m_Command == BlackAndWhitelistCommandAdd || m_Command == BlackAndWhitelistCommandRemove) {
+ visibleDesc.add_options()
+ ("zone", po::value<std::string>(), "The name of the zone")
+ ("host", po::value<std::string>(), "The name of the host")
+ ("service", po::value<std::string>(), "The name of the service");
}
}
/**
- * 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.
*/
}
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;
if (vm.count("service"))
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) {
-
- 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<std::string>();
+ String zone_filter = vm["zone"].as<std::string>();
String host_filter = vm["host"].as<std::string>();
String service_filter;
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);
}
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.
*/
{
/**
- * The "agent list" command.
+ * The "node list" command.
*
* @ingroup cli
*/
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<String> NodeRemoveCommand::GetPositionalSuggestions(const String& word) 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<std::string>& ap) const
{
- BOOST_FOREACH(const String& agent, ap) {
- NodeUtility::RemoveNode(agent);
+ BOOST_FOREACH(const String& node, ap) {
+ NodeUtility::RemoveNode(node);
}
return 0;
{
/**
- * The "agent remove" command.
+ * The "node remove" command.
*
* @ingroup cli
*/
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,
}
/**
- * The entry point for the "agent set" CLI command.
+ * The entry point for the "node set" CLI command.
*
* @returns An exit status.
*/
{
/**
- * The "agent set" command.
+ * The "node set" command.
*
* @ingroup cli
*/
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,
}
/**
- * The entry point for the "agent setup" CLI command.
+ * The entry point for the "node setup" CLI command.
*
* @returns An exit status.
*/
{
/**
- * The "agent setup" command.
+ * The "node setup" command.
*
* @ingroup cli
*/
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
}
/**
- * The entry point for the "agent update-config" CLI command.
+ * The entry point for the "node update-config" CLI command.
*
* @returns An exit status.
*/
Dictionary::Ptr inventory = make_shared<Dictionary>();
Log(LogInformation, "cli")
- << "Updating agent configuration for ";
+ << "Updating node configuration for ";
NodeUtility::PrintNodes(std::cout);
std::vector<String> 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<Dictionary>();
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>();
host_attrs->Set("__name", zone);
host_attrs->Set("name", zone);
host_attrs->Set("check_command", "cluster-zone");
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);
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);
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;
}
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;
}
}
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);
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";
}
}
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;
}
service_attrs->Set("zone", zone);
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);
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<Dictionary>();
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"))
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<Dictionary>();
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;
}
}
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<Dictionary>();
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<Dictionary>();
zone_attrs->Set("name", zone);
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<Dictionary>();
host_attrs->Set("name", old_host);
} 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<Dictionary>();
service_attrs->Set("name", old_service);
}
}
- Log(LogInformation, "cli", "Committing agent configuration.");
+ Log(LogInformation, "cli", "Committing node configuration.");
RepositoryUtility::PrintChangeLog(std::cout);
std::cout << "\n";
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;
- agents.push_back(agent);
+ nodes.push_back(node);
}
/*
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_zone = make_shared<Dictionary>();
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 */
{
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_zone = make_shared<Dictionary>();
Array::Ptr my_master_zone_members = make_shared<Array>();
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 */
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";
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);
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);
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;
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);
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;
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")
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 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<Dictionary::Ptr>& agents);
+ static Dictionary::Ptr LoadNodeFile(const String& node_file);
+ 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 FormatValue(std::ostream& fp, const Value& val);
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
}
/**
- * The entry point for the "agent wizard" CLI command.
+ * The entry point for the "node wizard" CLI command.
*
* @returns An exit status.
*/
//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
*/
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);
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 */
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:
/* 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();
<< "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;
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";
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;
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.";
}
/* 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 */
<< "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;