| 256 | } |
| 257 | |
| 258 | int NodeSetupCommand::SetupNode(const boost::program_options::variables_map& vm) |
| 259 | { |
| 260 | /* require at least one endpoint. Ticket is optional. */ |
| 261 | if (!vm.count("endpoint")) { |
| 262 | Log(LogCritical, "cli", "You need to specify at least one endpoint (--endpoint)."); |
| 263 | return 1; |
| 264 | } |
| 265 | |
| 266 | if (!vm.count("zone")) { |
| 267 | Log(LogCritical, "cli", "You need to specify the local zone (--zone)."); |
| 268 | return 1; |
| 269 | } |
| 270 | |
| 271 | /* Deprecation warnings. TODO: Remove in 2.10.0. */ |
| 272 | if (vm.count("master_zone")) |
| 273 | Log(LogWarning, "cli", "The 'master_zone' parameter has been deprecated. Use 'parent_zone' instead."); |
| 274 | if (vm.count("master_host")) |
| 275 | Log(LogWarning, "cli", "The 'master_host' parameter has been deprecated. Use 'parent_host' instead."); |
| 276 | |
| 277 | String ticket; |
| 278 | |
| 279 | if (vm.count("ticket")) |
| 280 | ticket = vm["ticket"].as<std::string>(); |
| 281 | |
| 282 | if (ticket.IsEmpty()) { |
| 283 | Log(LogInformation, "cli") |
| 284 | << "Requesting certificate without a ticket."; |
| 285 | } else { |
| 286 | Log(LogInformation, "cli") |
| 287 | << "Requesting certificate with ticket '" << ticket << "'."; |
| 288 | } |
| 289 | |
| 290 | /* Decide whether to directly connect to the parent node for CSR signing, or leave it to the user. */ |
| 291 | bool connectToParent = false; |
| 292 | String parentHost; |
| 293 | String parentPort = "5665"; |
| 294 | std::shared_ptr<X509> trustedParentCert; |
| 295 | |
| 296 | /* TODO: remove master_host in 2.10.0. */ |
| 297 | if (!vm.count("master_host") && !vm.count("parent_host")) { |
| 298 | connectToParent = false; |
| 299 | |
| 300 | Log(LogWarning, "cli") |
| 301 | << "Node to master/satellite connection setup skipped. Please configure your parent node to\n" |
| 302 | << "connect to this node by setting the 'host' attribute for the node Endpoint object.\n"; |
| 303 | } else { |
| 304 | connectToParent = true; |
| 305 | |
| 306 | String parentHostInfo; |
| 307 | |
| 308 | if (vm.count("parent_host")) |
| 309 | parentHostInfo = vm["parent_host"].as<std::string>(); |
| 310 | else if (vm.count("master_host")) /* TODO: Remove in 2.10.0. */ |
| 311 | parentHostInfo = vm["master_host"].as<std::string>(); |
| 312 | |
| 313 | std::vector<String> tokens = parentHostInfo.Split(","); |
| 314 | |
| 315 | if (tokens.size() == 1 || tokens.size() == 2) |
nothing calls this directly
no test coverage detected