From: Jean-Marcel Flach Date: Fri, 27 Mar 2015 13:11:21 +0000 (+0100) Subject: Add accept config/commands option to node setup X-Git-Tag: v2.3.4~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=44a4a442a0a99449cde27d9b96be88044974fdce;p=icinga2 Add accept config/commands option to node setup fixes #8803 --- diff --git a/agent/windows-setup-agent/SetupWizard.Designer.cs b/agent/windows-setup-agent/SetupWizard.Designer.cs index aaf9d97f2..6245d5adc 100644 --- a/agent/windows-setup-agent/SetupWizard.Designer.cs +++ b/agent/windows-setup-agent/SetupWizard.Designer.cs @@ -75,6 +75,9 @@ this.txtError = new System.Windows.Forms.TextBox(); this.lblError = new System.Windows.Forms.Label(); this.picBanner = new System.Windows.Forms.PictureBox(); + this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.chkAcceptCommands = new System.Windows.Forms.CheckBox(); + this.chkAcceptConfig = new System.Windows.Forms.CheckBox(); this.tabFinish.SuspendLayout(); this.tabConfigure.SuspendLayout(); this.tabParameters.SuspendLayout(); @@ -86,6 +89,7 @@ this.grpX509Fields.SuspendLayout(); this.tabError.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.picBanner)).BeginInit(); + this.groupBox3.SuspendLayout(); this.SuspendLayout(); // // btnBack @@ -170,6 +174,7 @@ // // tabParameters // + this.tabParameters.Controls.Add(this.groupBox3); this.tabParameters.Controls.Add(this.txtTicket); this.tabParameters.Controls.Add(this.lblTicket); this.tabParameters.Controls.Add(this.txtInstanceName); @@ -224,7 +229,7 @@ this.groupBox2.Controls.Add(this.rdoListener); this.groupBox2.Location = new System.Drawing.Point(8, 359); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(601, 111); + this.groupBox2.Size = new System.Drawing.Size(294, 111); this.groupBox2.TabIndex = 2; this.groupBox2.TabStop = false; this.groupBox2.Text = "TCP Listener"; @@ -554,6 +559,37 @@ this.picBanner.TabIndex = 1; this.picBanner.TabStop = false; // + // groupBox3 + // + this.groupBox3.Controls.Add(this.chkAcceptConfig); + this.groupBox3.Controls.Add(this.chkAcceptCommands); + this.groupBox3.Location = new System.Drawing.Point(308, 359); + this.groupBox3.Name = "groupBox3"; + this.groupBox3.Size = new System.Drawing.Size(301, 111); + this.groupBox3.TabIndex = 5; + this.groupBox3.TabStop = false; + this.groupBox3.Text = "Advanced Settings"; + // + // chkAcceptCommands + // + this.chkAcceptCommands.AutoSize = true; + this.chkAcceptCommands.Location = new System.Drawing.Point(9, 24); + this.chkAcceptCommands.Name = "chkAcceptCommands"; + this.chkAcceptCommands.Size = new System.Drawing.Size(171, 17); + this.chkAcceptCommands.TabIndex = 0; + this.chkAcceptCommands.Text = "Accept commands from master"; + this.chkAcceptCommands.UseVisualStyleBackColor = true; + // + // chkAcceptConfig + // + this.chkAcceptConfig.AutoSize = true; + this.chkAcceptConfig.Location = new System.Drawing.Point(9, 47); + this.chkAcceptConfig.Name = "chkAcceptConfig"; + this.chkAcceptConfig.Size = new System.Drawing.Size(190, 17); + this.chkAcceptConfig.TabIndex = 1; + this.chkAcceptConfig.Text = "Accept config updates from master"; + this.chkAcceptConfig.UseVisualStyleBackColor = true; + // // SetupWizard // this.AcceptButton = this.btnNext; @@ -592,6 +628,8 @@ this.tabError.ResumeLayout(false); this.tabError.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.picBanner)).EndInit(); + this.groupBox3.ResumeLayout(false); + this.groupBox3.PerformLayout(); this.ResumeLayout(false); } @@ -644,6 +682,9 @@ private System.Windows.Forms.TextBox txtTicket; private System.Windows.Forms.Label lblTicket; private System.Windows.Forms.ColumnHeader colInstanceName; + private System.Windows.Forms.GroupBox groupBox3; + private System.Windows.Forms.CheckBox chkAcceptConfig; + private System.Windows.Forms.CheckBox chkAcceptCommands; } } diff --git a/agent/windows-setup-agent/SetupWizard.cs b/agent/windows-setup-agent/SetupWizard.cs index 1b6bccc1f..f550853f9 100644 --- a/agent/windows-setup-agent/SetupWizard.cs +++ b/agent/windows-setup-agent/SetupWizard.cs @@ -222,6 +222,12 @@ namespace Icinga if (rdoListener.Checked) args += " --listen ::," + txtListenerPort.Text; + if (chkAcceptConfig.Checked) + args += " --accept-config"; + + if (chkAcceptCommands.Checked) + args += " --accept-commands"; + args += " --ticket " + txtTicket.Text; args += " --trustedcert " + _TrustedFile; args += " --cn " + txtInstanceName.Text; @@ -502,6 +508,6 @@ namespace Icinga while (lvwEndpoints.SelectedItems.Count > 0) { lvwEndpoints.Items.Remove(lvwEndpoints.SelectedItems[0]); } - } + } } } diff --git a/lib/cli/nodesetupcommand.cpp b/lib/cli/nodesetupcommand.cpp index e0d1a38e0..ea6b50d9c 100644 --- a/lib/cli/nodesetupcommand.cpp +++ b/lib/cli/nodesetupcommand.cpp @@ -64,6 +64,8 @@ void NodeSetupCommand::InitParameters(boost::program_options::options_descriptio ("ticket", po::value(), "Generated ticket number for this request") ("trustedcert", po::value(), "Trusted master certificate file") ("cn", po::value(), "The certificate's common name") + ("accept-config", "Accept config from master") + ("accept-commands", "Accept commands from master") ("master", "Use setup for a master instance"); } @@ -114,6 +116,12 @@ int NodeSetupCommand::SetupMaster(const boost::program_options::variables_map& v if (vm.count("trustedcert")) Log(LogWarning, "cli", "Master for Node setup: Ignoring --trustedcert"); + if (vm.count("accept-config")) + Log(LogWarning, "cli", "Master for Node setup: Ignoring --accept-config"); + + if (vm.count("accept-commands")) + Log(LogWarning, "cli", "Master for Node setup: Ignoring --accept-commands"); + /* Generate a new CA, if not already existing */ Log(LogInformation, "cli", "Generating new CA."); @@ -455,6 +463,15 @@ int NodeSetupCommand::SetupNode(const boost::program_options::variables_map& vm, if (tokens.size() > 1) fp << " bind_port = " << tokens[1] << "\n"; } + if (vm.count("accept-config")) + fp << "accept_config = true\n"; + else + fp << "accept_config = false\n"; + + if (vm.count("accept-commands")) + fp << "accept_commands = true\n"; + else + fp << "accept_commands = false\n"; fp << "\n" << " ticket_salt = TicketSalt\n" diff --git a/lib/cli/nodewizardcommand.cpp b/lib/cli/nodewizardcommand.cpp index 77108a210..970bd04b5 100644 --- a/lib/cli/nodewizardcommand.cpp +++ b/lib/cli/nodewizardcommand.cpp @@ -99,6 +99,7 @@ int NodeWizardCommand::Run(const boost::program_options::variables_map& vm, cons std::string answer; bool is_node_setup = true; + /* master or node setup */ std::cout << ConsoleColorTag(Console_Bold) << "Please specify if this is a satellite setup " << "('n' installs a master setup)" << ConsoleColorTag(Console_Normal) << " [Y/n]: "; std::getline (std::cin, answer); @@ -335,6 +336,20 @@ wizard_ticket: String bind_port = answer; bind_port.Trim(); + std::cout << ConsoleColorTag(Console_Bold) << "Accept config from master?" << ConsoleColorTag(Console_Normal) << " [y/N]: "; + std::getline(std::cin, answer); + boost::algorithm::to_lower(answer); + choice = answer; + + String accept_config = (choice.Contains("y") || choice.Contains("j")) ? "true" : "false"; + + std::cout << ConsoleColorTag(Console_Bold) << "Accept commands from master?" << ConsoleColorTag(Console_Normal) << " [y/N]: "; + std::getline(std::cin, answer); + boost::algorithm::to_lower(answer); + choice = answer; + + String accept_commands = (choice.Contains("y") || choice.Contains("j")) ? "true" : "false"; + /* disable the notifications feature on client nodes */ Log(LogInformation, "cli", "Disabling the Notification feature."); @@ -362,7 +377,9 @@ wizard_ticket: << "object ApiListener \"api\" {\n" << " cert_path = SysconfDir + \"/icinga2/pki/\" + NodeName + \".crt\"\n" << " key_path = SysconfDir + \"/icinga2/pki/\" + NodeName + \".key\"\n" - << " ca_path = SysconfDir + \"/icinga2/pki/ca.crt\"\n"; + << " ca_path = SysconfDir + \"/icinga2/pki/ca.crt\"\n" + << " accept_config = " << accept_config << '\n' + << " accept_commands = " << accept_commands << '\n'; if (!bind_host.IsEmpty()) fp << " bind_host = \"" << bind_host << "\"\n";