MCPcopy Create free account
hub / github.com/Icinga/icinga2 / SetupMaster

Method SetupMaster

lib/cli/nodesetupcommand.cpp:98–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96}
97
98int NodeSetupCommand::SetupMaster(const boost::program_options::variables_map& vm)
99{
100 /* Ignore not required parameters */
101 if (vm.count("ticket"))
102 Log(LogWarning, "cli", "Master for Node setup: Ignoring --ticket");
103
104 if (vm.count("endpoint"))
105 Log(LogWarning, "cli", "Master for Node setup: Ignoring --endpoint");
106
107 if (vm.count("trustedcert"))
108 Log(LogWarning, "cli", "Master for Node setup: Ignoring --trustedcert");
109
110 String cn = Utility::GetFQDN();
111
112 if (vm.count("cn"))
113 cn = vm["cn"].as<std::string>();
114
115 /* Setup command hardcodes this as FQDN */
116 String endpointName = cn;
117
118 /* Allow to specify zone name. */
119 String zoneName = "master";
120
121 if (vm.count("zone"))
122 zoneName = vm["zone"].as<std::string>();
123
124 /* check whether the user wants to generate a new certificate or not */
125 String existingPath = ApiListener::GetCertsDir() + "/" + cn + ".crt";
126
127 Log(LogInformation, "cli")
128 << "Checking in existing certificates for common name '" << cn << "'...";
129
130 if (Utility::PathExists(existingPath)) {
131 Log(LogWarning, "cli")
132 << "Certificate '" << existingPath << "' for CN '" << cn << "' already exists. Not generating new certificate.";
133 } else {
134 Log(LogInformation, "cli")
135 << "Certificates not yet generated. Running 'api setup' now.";
136
137 ApiSetupUtility::SetupMasterCertificates(cn);
138 }
139
140 Log(LogInformation, "cli", "Generating master configuration for Icinga 2.");
141 ApiSetupUtility::SetupMasterApiUser();
142
143 if (!FeatureUtility::CheckFeatureEnabled("api")) {
144 ApiSetupUtility::SetupMasterEnableApi();
145 } else {
146 Log(LogInformation, "cli")
147 << "'api' feature already enabled.\n";
148 }
149
150 /* write zones.conf and update with zone + endpoint information */
151 Log(LogInformation, "cli", "Generating zone and object configuration.");
152
153 std::vector<String> globalZones {};
154 if (!vm.count("no-default-global-zones")) {
155 globalZones = {"global-templates", "director-global"};

Callers

nothing calls this directly

Calls 12

LogClass · 0.85
PathExistsFunction · 0.85
findFunction · 0.85
RandomStringFunction · 0.85
countMethod · 0.80
SplitMethod · 0.80
StringClass · 0.50
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
insertMethod · 0.45
CommitMethod · 0.45

Tested by

no test coverage detected