X-Git-Url: https://granicus.if.org/sourcecode?a=blobdiff_plain;f=agent%2Fwindows-setup-agent%2FSetupWizard.cs;h=018b2ababd02e3050d748a43ddf3cc341f2716b6;hb=051b3ba9b7e465e0dc29231792be89a37a27c3e3;hp=1b068fc3f14b5985caef22ea9d2f4a8418736a22;hpb=f4a1747e145d4027be40ae3a95ef85ac8a86f07f;p=icinga2 diff --git a/agent/windows-setup-agent/SetupWizard.cs b/agent/windows-setup-agent/SetupWizard.cs index 1b068fc3f..018b2abab 100644 --- a/agent/windows-setup-agent/SetupWizard.cs +++ b/agent/windows-setup-agent/SetupWizard.cs @@ -54,8 +54,8 @@ namespace Icinga { foreach (ListViewItem lvi in lvwEndpoints.Items) { if (lvi.SubItems.Count > 1) { - host = lvi.SubItems[1].Text; - port = lvi.SubItems[2].Text; + host = lvi.SubItems[1].Text.Trim(); + port = lvi.SubItems[2].Text.Trim(); return true; } } @@ -176,9 +176,12 @@ namespace Icinga } SetRetrievalStatus(100); - - X509Certificate2 cert = new X509Certificate2(_TrustedFile); - Invoke((MethodInvoker)delegate { ShowCertificatePrompt(cert); }); + try { + X509Certificate2 cert = new X509Certificate2(_TrustedFile); + Invoke((MethodInvoker)delegate { ShowCertificatePrompt(cert); }); + } catch (Exception e) { + ShowErrorText("Failed to receive certificate: " + e.Message); + } } private void ConfigureService() @@ -194,21 +197,18 @@ namespace Icinga string master_host, master_port; GetMasterHostPort(out master_host, out master_port); - args += " --master_host " + Convert.ToString(master_host).Trim() - + "," + Convert.ToString(master_port).Trim(); + args += " --master_host " + master_host + "," + master_port; foreach (ListViewItem lvi in lvwEndpoints.Items) { - args += " --endpoint " + Convert.ToString(lvi.SubItems[0].Text).Trim(); + args += " --endpoint " + lvi.SubItems[0].Text.Trim(); - if (lvi.SubItems.Count > 1) { - args += "," + Convert.ToString(lvi.SubItems[1].Text).Trim() - + "," + Convert.ToString(lvi.SubItems[2].Text).Trim(); - } + if (lvi.SubItems.Count > 1) + args += "," + lvi.SubItems[1].Text.Trim() + "," + lvi.SubItems[2].Text.Trim(); } }); if (rdoListener.Checked) - args += " --listen ::," + Convert.ToString(txtListenerPort.Text).Trim(); + args += " --listen ::," + txtListenerPort.Text.Trim(); if (chkAcceptConfig.Checked) args += " --accept-config"; @@ -216,14 +216,21 @@ namespace Icinga if (chkAcceptCommands.Checked) args += " --accept-commands"; - string ticket = Convert.ToString(txtTicket.Text).Trim(); + string ticket = txtTicket.Text.Trim(); if (ticket.Length > 0) args += " --ticket \"" + ticket + "\""; args += " --trustedcert \"" + _TrustedFile + "\""; - args += " --cn \"" + Convert.ToString(txtInstanceName.Text).Trim() + "\""; - args += " --zone \"" + Convert.ToString(txtInstanceName.Text) + "\""; + args += " --cn \"" + txtInstanceName.Text.Trim() + "\""; + args += " --zone \"" + txtInstanceName.Text.Trim() + "\""; + + foreach (ListViewItem lvi in lvwGlobalZones.Items) { + args += " --global_zones " + lvi.SubItems[0].Text.Trim(); + } + + if (chkDisableConf.Checked) + args += " --disable-confd"; if (!RunProcess(Program.Icinga2InstallDir + "\\sbin\\icinga2.exe", "node setup" + args, @@ -234,7 +241,7 @@ namespace Icinga SetConfigureStatus(50, "Setting ACLs for the Icinga 2 directory..."); - string serviceUser = Convert.ToString(txtUser.Text).Trim(); + string serviceUser = txtUser.Text.Trim(); DirectoryInfo di = new DirectoryInfo(Program.Icinga2InstallDir); DirectorySecurity ds = di.GetAccessControl(); @@ -519,6 +526,62 @@ namespace Icinga lvwEndpoints.Items.Add(lvi2); } + + private void btnAddGlobalZone_Click(object sender, EventArgs e) + { + GlobalZonesInputBox gzib = new GlobalZonesInputBox(lvwGlobalZones.Items); + + if (gzib.ShowDialog(this) == DialogResult.Cancel) + return; + + ListViewItem lvi = new ListViewItem(); + lvi.Text = gzib.txtGlobalZoneName.Text; + + lvwGlobalZones.Items.Add(lvi); + } + + private void btnRemoveGlobalZone_Click(object sender, EventArgs e) + { + while (lvwGlobalZones.SelectedItems.Count > 0) { + lvwGlobalZones.Items.Remove(lvwGlobalZones.SelectedItems[0]); + } + } + + private void lvwGlobalZones_SelectedIndexChanged(object sender, EventArgs e) + { + btnEditGlobalZone.Enabled = lvwGlobalZones.SelectedItems.Count > 0; + btnRemoveGlobalZone.Enabled = lvwGlobalZones.SelectedItems.Count > 0; + } + + private void btnEditGlobalZone_Click(object sender, EventArgs e) + { + ListViewItem lvi = lvwGlobalZones.SelectedItems[0]; + GlobalZonesInputBox gzib = new GlobalZonesInputBox(lvwGlobalZones.Items); + + gzib.Text = "Edit Global Zone"; + gzib.txtGlobalZoneName.Text = lvi.SubItems[0].Text; + + if (gzib.ShowDialog(this) == DialogResult.Cancel) + return; + + lvwGlobalZones.Items.Remove(lvi); + + ListViewItem lvi2 = new ListViewItem(); + lvi2.Text = gzib.txtGlobalZoneName.Text; + + lvwGlobalZones.Items.Add(lvi2); + } + + private void checkBox1_CheckedChanged(object sender, EventArgs e) + { + + } + + private void SetupWizard_Load(object sender, EventArgs e) + { + this.MinimumSize = this.Size; + this.MaximumSize = this.Size; + } } }