| 96 | } |
| 97 | |
| 98 | int 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"}; |
nothing calls this directly
no test coverage detected