mirror of https://github.com/Icinga/icinga2.git
Merge pull request #5710 from mcktr/feature/add-global-zones-during-wizard
Include default global zones during node wizard/setup
This commit is contained in:
commit
3cb92bb900
|
@ -159,7 +159,12 @@ int NodeSetupCommand::SetupMaster(const boost::program_options::variables_map& v
|
||||||
/* write zones.conf and update with zone + endpoint information */
|
/* write zones.conf and update with zone + endpoint information */
|
||||||
Log(LogInformation, "cli", "Generating zone and object configuration.");
|
Log(LogInformation, "cli", "Generating zone and object configuration.");
|
||||||
|
|
||||||
NodeUtility::GenerateNodeMasterIcingaConfig();
|
std::vector<String> globalZones;
|
||||||
|
|
||||||
|
globalZones.push_back("global-templates");
|
||||||
|
globalZones.push_back("director-global");
|
||||||
|
|
||||||
|
NodeUtility::GenerateNodeMasterIcingaConfig(globalZones);
|
||||||
|
|
||||||
/* update the ApiListener config - SetupMaster() will always enable it */
|
/* update the ApiListener config - SetupMaster() will always enable it */
|
||||||
Log(LogInformation, "cli", "Updating the APIListener feature.");
|
Log(LogInformation, "cli", "Updating the APIListener feature.");
|
||||||
|
@ -419,7 +424,12 @@ int NodeSetupCommand::SetupNode(const boost::program_options::variables_map& vm,
|
||||||
|
|
||||||
Log(LogInformation, "cli", "Generating zone and object configuration.");
|
Log(LogInformation, "cli", "Generating zone and object configuration.");
|
||||||
|
|
||||||
NodeUtility::GenerateNodeIcingaConfig(vm["endpoint"].as<std::vector<std::string> >());
|
std::vector<String> globalZones;
|
||||||
|
|
||||||
|
globalZones.push_back("global-templates");
|
||||||
|
globalZones.push_back("director-global");
|
||||||
|
|
||||||
|
NodeUtility::GenerateNodeIcingaConfig(vm["endpoint"].as<std::vector<std::string> >(), globalZones);
|
||||||
|
|
||||||
/* update constants.conf with NodeName = CN */
|
/* update constants.conf with NodeName = CN */
|
||||||
if (cn != Utility::GetFQDN()) {
|
if (cn != Utility::GetFQDN()) {
|
||||||
|
|
|
@ -47,7 +47,7 @@ using namespace icinga;
|
||||||
* Node Setup helpers
|
* Node Setup helpers
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int NodeUtility::GenerateNodeIcingaConfig(const std::vector<std::string>& endpoints)
|
int NodeUtility::GenerateNodeIcingaConfig(const std::vector<std::string>& endpoints, const std::vector<String>& globalZones)
|
||||||
{
|
{
|
||||||
Array::Ptr my_config = new Array();
|
Array::Ptr my_config = new Array();
|
||||||
|
|
||||||
|
@ -111,6 +111,16 @@ int NodeUtility::GenerateNodeIcingaConfig(const std::vector<std::string>& endpoi
|
||||||
|
|
||||||
my_zone->Set("endpoints", my_zone_members);
|
my_zone->Set("endpoints", my_zone_members);
|
||||||
|
|
||||||
|
for (const String& globalzone : globalZones) {
|
||||||
|
Dictionary::Ptr myGlobalZone = new Dictionary();
|
||||||
|
|
||||||
|
myGlobalZone->Set("__name", globalzone);
|
||||||
|
myGlobalZone->Set("__type", "Zone");
|
||||||
|
myGlobalZone->Set("global", true);
|
||||||
|
|
||||||
|
my_config->Add(myGlobalZone);
|
||||||
|
}
|
||||||
|
|
||||||
/* store the local config */
|
/* store the local config */
|
||||||
my_config->Add(my_endpoint);
|
my_config->Add(my_endpoint);
|
||||||
my_config->Add(my_zone);
|
my_config->Add(my_zone);
|
||||||
|
@ -123,13 +133,14 @@ int NodeUtility::GenerateNodeIcingaConfig(const std::vector<std::string>& endpoi
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int NodeUtility::GenerateNodeMasterIcingaConfig(void)
|
int NodeUtility::GenerateNodeMasterIcingaConfig(const std::vector<String>& globalZones)
|
||||||
{
|
{
|
||||||
Array::Ptr my_config = new Array();
|
Array::Ptr my_config = new Array();
|
||||||
|
|
||||||
/* store the local generated node master configuration */
|
/* store the local generated node master configuration */
|
||||||
Dictionary::Ptr my_master_endpoint = new Dictionary();
|
Dictionary::Ptr my_master_endpoint = new Dictionary();
|
||||||
Dictionary::Ptr my_master_zone = new Dictionary();
|
Dictionary::Ptr my_master_zone = new Dictionary();
|
||||||
|
|
||||||
Array::Ptr my_master_zone_members = new Array();
|
Array::Ptr my_master_zone_members = new Array();
|
||||||
|
|
||||||
my_master_endpoint->Set("__name", new ConfigIdentifier("NodeName"));
|
my_master_endpoint->Set("__name", new ConfigIdentifier("NodeName"));
|
||||||
|
@ -145,6 +156,16 @@ int NodeUtility::GenerateNodeMasterIcingaConfig(void)
|
||||||
my_config->Add(my_master_endpoint);
|
my_config->Add(my_master_endpoint);
|
||||||
my_config->Add(my_master_zone);
|
my_config->Add(my_master_zone);
|
||||||
|
|
||||||
|
for (const String& globalzone : globalZones) {
|
||||||
|
Dictionary::Ptr myGlobalZone = new Dictionary();
|
||||||
|
|
||||||
|
myGlobalZone->Set("__name", globalzone);
|
||||||
|
myGlobalZone->Set("__type", "Zone");
|
||||||
|
myGlobalZone->Set("global", true);
|
||||||
|
|
||||||
|
my_config->Add(myGlobalZone);
|
||||||
|
}
|
||||||
|
|
||||||
/* write the newly generated configuration */
|
/* write the newly generated configuration */
|
||||||
String zones_path = Application::GetSysconfDir() + "/icinga2/zones.conf";
|
String zones_path = Application::GetSysconfDir() + "/icinga2/zones.conf";
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,8 @@ public:
|
||||||
static void UpdateConstant(const String& name, const String& value);
|
static void UpdateConstant(const String& name, const String& value);
|
||||||
|
|
||||||
/* node setup helpers */
|
/* node setup helpers */
|
||||||
static int GenerateNodeIcingaConfig(const std::vector<std::string>& endpoints);
|
static int GenerateNodeIcingaConfig(const std::vector<std::string>& endpoints, const std::vector<String>& globalZones);
|
||||||
static int GenerateNodeMasterIcingaConfig(void);
|
static int GenerateNodeMasterIcingaConfig(const std::vector<String>& globalZones);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NodeUtility(void);
|
NodeUtility(void);
|
||||||
|
|
|
@ -498,7 +498,12 @@ wizard_ticket:
|
||||||
/* apilistener config */
|
/* apilistener config */
|
||||||
Log(LogInformation, "cli", "Generating local zones.conf.");
|
Log(LogInformation, "cli", "Generating local zones.conf.");
|
||||||
|
|
||||||
NodeUtility::GenerateNodeIcingaConfig(endpoints);
|
std::vector<String> globalZones;
|
||||||
|
|
||||||
|
globalZones.push_back("global-templates");
|
||||||
|
globalZones.push_back("director-global");
|
||||||
|
|
||||||
|
NodeUtility::GenerateNodeIcingaConfig(endpoints, globalZones);
|
||||||
|
|
||||||
if (cn != Utility::GetFQDN()) {
|
if (cn != Utility::GetFQDN()) {
|
||||||
Log(LogWarning, "cli")
|
Log(LogWarning, "cli")
|
||||||
|
@ -594,7 +599,12 @@ int NodeWizardCommand::MasterSetup(void) const
|
||||||
else
|
else
|
||||||
std::cout << "'api' feature already enabled.\n";
|
std::cout << "'api' feature already enabled.\n";
|
||||||
|
|
||||||
NodeUtility::GenerateNodeMasterIcingaConfig();
|
std::vector<String> globalZones;
|
||||||
|
|
||||||
|
globalZones.push_back("global-templates");
|
||||||
|
globalZones.push_back("director-global");
|
||||||
|
|
||||||
|
NodeUtility::GenerateNodeMasterIcingaConfig(globalZones);
|
||||||
|
|
||||||
/* apilistener config */
|
/* apilistener config */
|
||||||
std::cout << ConsoleColorTag(Console_Bold)
|
std::cout << ConsoleColorTag(Console_Bold)
|
||||||
|
|
Loading…
Reference in New Issue