if (vm.count("cn"))
cn = vm["cn"].as<std::string>();
+ /* Setup command hardcodes this as FQDN */
+ String endpointName = cn;
+
+ /* Allow to specify zone name. */
+ String zoneName = "master";
+
+ if (vm.count("zone"))
+ zoneName = vm["zone"].as<std::string>();
+
/* check whether the user wants to generate a new certificate or not */
String existingPath = ApiListener::GetCertsDir() + "/" + cn + ".crt";
globalZones.insert(globalZones.end(), setupGlobalZones.begin(), setupGlobalZones.end());
- NodeUtility::GenerateNodeMasterIcingaConfig(globalZones);
+ /* Generate master configuration. */
+ NodeUtility::GenerateNodeMasterIcingaConfig(endpointName, zoneName, globalZones);
- /* update the ApiListener config - SetupMaster() will always enable it */
+ /* Update the ApiListener config. */
Log(LogInformation, "cli", "Updating the APIListener feature.");
String apipath = FeatureUtility::GetFeaturesAvailablePath() + "/api.conf";
return 0;
}
-int NodeUtility::GenerateNodeMasterIcingaConfig(const std::vector<String>& globalZones)
+int NodeUtility::GenerateNodeMasterIcingaConfig(const String& endpointName, const String& zoneName,
+ const std::vector<String>& globalZones)
{
Array::Ptr my_config = new Array();
/* store the local generated node master configuration */
my_config->Add(new Dictionary({
- { "__name", new ConfigIdentifier("NodeName") },
+ { "__name", endpointName },
{ "__type", "Endpoint" }
}));
my_config->Add(new Dictionary({
- { "__name", new ConfigIdentifier("ZoneName") },
+ { "__name", zoneName },
{ "__type", "Zone" },
- { "endpoints", new Array({ new ConfigIdentifier("NodeName") }) }
+ { "endpoints", new Array({ endpointName }) }
}));
for (const String& globalzone : globalZones) {
/* node setup helpers */
static int GenerateNodeIcingaConfig(const std::vector<std::string>& endpoints, const std::vector<String>& globalZones);
- static int GenerateNodeMasterIcingaConfig(const std::vector<String>& globalZones);
+ static int GenerateNodeMasterIcingaConfig(const String& endpointName, const String& zoneName,
+ const std::vector<String>& globalZones);
private:
NodeUtility();
std::cout << ConsoleColorTag(Console_Bold)
<< "Generating master configuration for Icinga 2.\n"
<< ConsoleColorTag(Console_Normal);
+
ApiSetupUtility::SetupMasterApiUser();
if (!FeatureUtility::CheckFeatureEnabled("api"))
else
std::cout << "'api' feature already enabled.\n";
+ /* Setup command hardcodes this as FQDN */
+ String endpointName = cn;
+
+ /* Different zone name. */
+ std::cout << "\nMaster zone name [master]: ";
+ std::getline(std::cin, answer);
+
+ if (answer.empty())
+ answer = "master";
+
+ String zoneName = answer;
+ zoneName = zoneName.Trim();
+
+ /* Global zones. */
std::vector<String> globalZones { "global-templates", "director-global" };
std::cout << "\nDo you want to specify additional global zones? [y/N]: ";
} else
Log(LogInformation, "cli", "No additional global Zones have been specified");
- NodeUtility::GenerateNodeMasterIcingaConfig(globalZones);
+ /* Generate master configuration. */
+ NodeUtility::GenerateNodeMasterIcingaConfig(endpointName, zoneName, globalZones);
/* apilistener config */
std::cout << ConsoleColorTag(Console_Bold)