]> granicus.if.org Git - icinga2/commitdiff
Add accept config/commands option to node setup
authorJean-Marcel Flach <jean-marcel.flach@netways.de>
Fri, 27 Mar 2015 13:11:21 +0000 (14:11 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Mon, 20 Apr 2015 06:51:45 +0000 (08:51 +0200)
fixes #8803

agent/windows-setup-agent/SetupWizard.Designer.cs
agent/windows-setup-agent/SetupWizard.cs
lib/cli/nodesetupcommand.cpp
lib/cli/nodewizardcommand.cpp

index aaf9d97f25b963ae24066d6575eba61708b9ffe6..6245d5adc36f9a3b335294e2884a4d892f3db6d1 100644 (file)
@@ -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
                        // 
                        // 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);
                        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";
                        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;
                        this.tabError.ResumeLayout(false);
                        this.tabError.PerformLayout();
                        ((System.ComponentModel.ISupportInitialize)(this.picBanner)).EndInit();
+                       this.groupBox3.ResumeLayout(false);
+                       this.groupBox3.PerformLayout();
                        this.ResumeLayout(false);
 
                }
                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;
        }
 }
 
index 1b6bccc1f18ff8307ae62f4815b3e83aa35771a1..f550853f99a5095720a44a5ce669d1793c48756b 100644 (file)
@@ -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]);
                        }
-               }
+        }
        }
 }
index e0d1a38e089934d8d00360f3c4d2d60596e1254c..ea6b50d9c4576ee4d2a38a2b095b10be0b39464f 100644 (file)
@@ -64,6 +64,8 @@ void NodeSetupCommand::InitParameters(boost::program_options::options_descriptio
                ("ticket", po::value<std::string>(), "Generated ticket number for this request")
                ("trustedcert", po::value<std::string>(), "Trusted master certificate file")
                ("cn", po::value<std::string>(), "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"
index 77108a210c24567a17a57cbe7fccc19519e89518..970bd04b55f61e1b8a0f345d763096bbe22e9901 100644 (file)
@@ -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";