this.txtError = new System.Windows.Forms.TextBox();
this.lblError = new System.Windows.Forms.Label();
this.picBanner = new System.Windows.Forms.PictureBox();
+ this.colInstanceName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.tabFinish.SuspendLayout();
this.tabConfigure.SuspendLayout();
this.tabParameters.SuspendLayout();
// lvwEndpoints
//
this.lvwEndpoints.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
+ this.colInstanceName,
this.colHost,
this.colPort});
+ this.lvwEndpoints.FullRowSelect = true;
this.lvwEndpoints.Location = new System.Drawing.Point(11, 83);
this.lvwEndpoints.Name = "lvwEndpoints";
this.lvwEndpoints.Size = new System.Drawing.Size(500, 176);
// colHost
//
this.colHost.Text = "Host";
- this.colHost.Width = 300;
+ this.colHost.Width = 200;
//
// colPort
//
this.colPort.Text = "Port";
- this.colPort.Width = 120;
+ this.colPort.Width = 80;
//
// rdoNoMaster
//
this.picBanner.TabIndex = 1;
this.picBanner.TabStop = false;
//
+ // colInstanceName
+ //
+ this.colInstanceName.Text = "Instance Name";
+ this.colInstanceName.Width = 200;
+ //
// AgentWizard
//
this.AcceptButton = this.btnNext;
private System.Windows.Forms.Label lblError;
private System.Windows.Forms.TextBox txtTicket;
private System.Windows.Forms.Label lblTicket;
+ private System.Windows.Forms.ColumnHeader colInstanceName;
}
}
}
}
+ private bool GetMasterHostPort(out string host, out string port)
+ {
+ foreach (ListViewItem lvi in lvwEndpoints.Items) {
+ if (lvi.SubItems.Count > 1) {
+ host = lvi.SubItems[1].Text;
+ port = lvi.SubItems[2].Text;
+ return true;
+ }
+ }
+
+ host = null;
+ port = null;
+ return false;
+ }
+
private void EnableFeature(string feature)
{
using (FileStream fp = File.Open(Icinga2InstallDir + String.Format("\\etc\\icinga2\\features-enabled\\{0}.conf", feature), FileMode.Create)) {
args += " --master";
Invoke((MethodInvoker)delegate {
- args += " --master_host " + lvwEndpoints.Items[0].SubItems[0].Text + "," + lvwEndpoints.Items[0].SubItems[1].Text;
+ string master_host, master_port;
+ GetMasterHostPort(out master_host, out master_port);
+
+ args += " --master_host " + master_host + "," + master_port;
foreach (ListViewItem lvi in lvwEndpoints.Items) {
- args += " --endpoint " + lvi.SubItems[0].Text + "," + lvi.SubItems[1].Text;
+ args += " --endpoint " + lvi.SubItems[0].Text;
+
+ if (lvi.SubItems.Count > 1)
+ args += "," + lvi.SubItems[1].Text + "," + lvi.SubItems[2].Text;
}
});
"--scm-uninstall",
out output);
+ if (!RunProcess(Icinga2InstallDir + "\\sbin\\icinga2.exe",
+ "daemon --validate",
+ out output)) {
+ ShowErrorText(output);
+ return;
+ }
+
if (!RunProcess(Icinga2InstallDir + "\\sbin\\icinga2.exe",
"--scm-install daemon",
out output)) {
return;
}
- if (rdoNoMaster.Checked && lvwEndpoints.Items.Count == 0) {
- Warning("You need to add at least one master endpoint.");
- return;
+ if (rdoNoMaster.Checked) {
+ if (lvwEndpoints.Items.Count == 0) {
+ Warning("You need to add at least one master endpoint.");
+ return;
+ }
+
+ string host, port;
+ if (!GetMasterHostPort(out host, out port)) {
+ Warning("Please enter a remote host and port for at least one of your endpoints.");
+ return;
+ }
}
if (rdoListener.Checked && (txtListenerPort.Text == "")) {
if (tbcPages.SelectedTab == tabRetrieveCertificate) {
ListViewItem lvi = lvwEndpoints.Items[0];
- Thread thread = new Thread((ThreadStart)delegate { VerifyCertificate(lvi.SubItems[0].Text, lvi.SubItems[1].Text); });
+ string master_host, master_port;
+ GetMasterHostPort(out master_host, out master_port);
+
+ Thread thread = new Thread((ThreadStart)delegate { VerifyCertificate(master_host, master_port); });
thread.Start();
}
txtX509Issuer.Text = certificate.Issuer;
txtX509Subject.Text = certificate.Subject;
+ lvwX509Fields.Items.Clear();
+
AddCertificateField("Version", "V" + certificate.Version.ToString());
AddCertificateField("Serial number", certificate.SerialNumber);
AddCertificateField("Signature algorithm", certificate.SignatureAlgorithm.FriendlyName);
return;
ListViewItem lvi = new ListViewItem();
- lvi.Text = eib.txtHost.Text;
- lvi.SubItems.Add(eib.txtPort.Text);
+ lvi.Text = eib.txtInstanceName.Text;
+
+ if (eib.chkConnect.Checked) {
+ lvi.SubItems.Add(eib.txtHost.Text);
+ lvi.SubItems.Add(eib.txtPort.Text);
+ }
lvwEndpoints.Items.Add(lvi);
}
/// </summary>
private void InitializeComponent()
{
- this.components = new System.ComponentModel.Container();
this.btnOK = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.txtHost = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.lblHost = new System.Windows.Forms.Label();
this.lblPort = new System.Windows.Forms.Label();
- this.errErrorProvider = new System.Windows.Forms.ErrorProvider(this.components);
- ((System.ComponentModel.ISupportInitialize)(this.errErrorProvider)).BeginInit();
+ this.lblInstanceName = new System.Windows.Forms.Label();
+ this.txtInstanceName = new System.Windows.Forms.TextBox();
+ this.chkConnect = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// btnOK
//
- this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
- this.btnOK.Location = new System.Drawing.Point(150, 120);
+ this.btnOK.Location = new System.Drawing.Point(196, 171);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(75, 23);
- this.btnOK.TabIndex = 2;
+ this.btnOK.TabIndex = 4;
this.btnOK.Text = "OK";
this.btnOK.UseVisualStyleBackColor = true;
+ this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// btnCancel
//
this.btnCancel.CausesValidation = false;
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
- this.btnCancel.Location = new System.Drawing.Point(231, 120);
+ this.btnCancel.Location = new System.Drawing.Point(277, 171);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23);
- this.btnCancel.TabIndex = 3;
+ this.btnCancel.TabIndex = 5;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
//
// txtHost
//
- this.txtHost.Location = new System.Drawing.Point(55, 49);
+ this.txtHost.Enabled = false;
+ this.txtHost.Location = new System.Drawing.Point(101, 103);
this.txtHost.Name = "txtHost";
this.txtHost.Size = new System.Drawing.Size(251, 20);
- this.txtHost.TabIndex = 0;
- this.txtHost.Validating += new System.ComponentModel.CancelEventHandler(this.txtHost_Validating);
+ this.txtHost.TabIndex = 2;
//
// txtPort
//
- this.txtPort.Location = new System.Drawing.Point(55, 80);
+ this.txtPort.Enabled = false;
+ this.txtPort.Location = new System.Drawing.Point(101, 134);
this.txtPort.Name = "txtPort";
this.txtPort.Size = new System.Drawing.Size(100, 20);
- this.txtPort.TabIndex = 1;
+ this.txtPort.TabIndex = 3;
this.txtPort.Text = "5665";
- this.txtPort.Validating += new System.ComponentModel.CancelEventHandler(this.txtPort_Validating);
//
// label1
//
this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(17, 16);
+ this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(276, 13);
this.label1.TabIndex = 4;
// lblHost
//
this.lblHost.AutoSize = true;
- this.lblHost.Location = new System.Drawing.Point(17, 52);
+ this.lblHost.Location = new System.Drawing.Point(15, 106);
this.lblHost.Name = "lblHost";
this.lblHost.Size = new System.Drawing.Size(32, 13);
this.lblHost.TabIndex = 5;
// lblPort
//
this.lblPort.AutoSize = true;
- this.lblPort.Location = new System.Drawing.Point(20, 83);
+ this.lblPort.Location = new System.Drawing.Point(15, 137);
this.lblPort.Name = "lblPort";
this.lblPort.Size = new System.Drawing.Size(29, 13);
this.lblPort.TabIndex = 6;
this.lblPort.Text = "Port:";
//
- // errErrorProvider
+ // lblInstanceName
//
- this.errErrorProvider.ContainerControl = this;
+ this.lblInstanceName.AutoSize = true;
+ this.lblInstanceName.Location = new System.Drawing.Point(15, 41);
+ this.lblInstanceName.Name = "lblInstanceName";
+ this.lblInstanceName.Size = new System.Drawing.Size(82, 13);
+ this.lblInstanceName.TabIndex = 7;
+ this.lblInstanceName.Text = "Instance Name:";
+ //
+ // txtInstanceName
+ //
+ this.txtInstanceName.Location = new System.Drawing.Point(101, 37);
+ this.txtInstanceName.Name = "txtInstanceName";
+ this.txtInstanceName.Size = new System.Drawing.Size(251, 20);
+ this.txtInstanceName.TabIndex = 0;
+ //
+ // chkConnect
+ //
+ this.chkConnect.AutoSize = true;
+ this.chkConnect.Location = new System.Drawing.Point(18, 73);
+ this.chkConnect.Name = "chkConnect";
+ this.chkConnect.Size = new System.Drawing.Size(141, 17);
+ this.chkConnect.TabIndex = 1;
+ this.chkConnect.Text = "Connect to this endpoint";
+ this.chkConnect.UseVisualStyleBackColor = true;
+ this.chkConnect.CheckedChanged += new System.EventHandler(this.chkConnect_CheckedChanged);
//
// EndpointInputBox
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
- this.ClientSize = new System.Drawing.Size(326, 159);
+ this.ClientSize = new System.Drawing.Size(360, 202);
+ this.Controls.Add(this.chkConnect);
+ this.Controls.Add(this.txtInstanceName);
+ this.Controls.Add(this.lblInstanceName);
this.Controls.Add(this.lblPort);
this.Controls.Add(this.lblHost);
this.Controls.Add(this.label1);
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Add Endpoint";
- ((System.ComponentModel.ISupportInitialize)(this.errErrorProvider)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
private System.Windows.Forms.Label lblPort;
public System.Windows.Forms.TextBox txtHost;
public System.Windows.Forms.TextBox txtPort;
- private System.Windows.Forms.ErrorProvider errErrorProvider;
+ public System.Windows.Forms.TextBox txtInstanceName;
+ private System.Windows.Forms.Label lblInstanceName;
+ public System.Windows.Forms.CheckBox chkConnect;
}
}
\ No newline at end of file
InitializeComponent();
}
- private void txtHost_Validating(object sender, CancelEventArgs e)
+ private void Warning(string message)
{
- if (txtHost.Text.Length == 0) {
- e.Cancel = true;
- errErrorProvider.SetError(txtHost, "Please enter a host name.");
- }
+ MessageBox.Show(this, message, Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ }
+
+ private void chkConnect_CheckedChanged(object sender, EventArgs e)
+ {
+ txtHost.Enabled = chkConnect.Checked;
+ txtPort.Enabled = chkConnect.Checked;
}
- private void txtPort_Validating(object sender, CancelEventArgs e)
+ private void btnOK_Click(object sender, EventArgs e)
{
- if (txtPort.Text.Length == 0) {
- e.Cancel = true;
- errErrorProvider.SetError(txtPort, "Please enter a port.");
+ if (txtInstanceName.Text.Length == 0) {
+ Warning("Please enter an instance name.");
+ return;
}
+
+ if (chkConnect.Checked) {
+ if (txtHost.Text.Length == 0) {
+ Warning("Please enter a host name.");
+ return;
+ }
+
+ if (txtPort.Text.Length == 0) {
+ Warning("Please enter a port.");
+ return;
+ }
+ }
+
+ DialogResult = DialogResult.OK;
+ Close();
}
}
}
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
- <metadata name="errErrorProvider.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
- <value>22, 24</value>
- </metadata>
</root>
\ No newline at end of file
("zone", po::value<std::string>(), "The name of the local zone")
("master_zone", po::value<std::string>(), "The name of the master zone")
("master_host", po::value<std::string>(), "The name of the master host for auto-signing the csr")
- ("endpoint", po::value<std::vector<std::string> >(), "Connect to remote endpoint on host,port")
+ ("endpoint", po::value<std::vector<std::string> >(), "Connect to remote endpoint; syntax: cn,host,port")
("listen", po::value<std::string>(), "Listen on host,port")
("ticket", po::value<std::string>(), "Generated ticket number for this request")
("trustedcert", po::value<std::string>(), "Trusted master certificate file")
<< "Ignoring parameters: " << boost::algorithm::join(ap, " ");
}
- if (vm.count("master")) {
+ if (vm.count("master"))
return SetupMaster(vm, ap);
- } else {
+ else
return SetupAgent(vm, ap);
- }
-
- return 0;
}
int AgentSetupCommand::SetupMaster(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap)
int AgentSetupCommand::SetupAgent(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap)
{
- /* require ticket number (generated on master) */
+ /* require ticket number (generated on master) and at least one endpoint */
if (!vm.count("ticket")) {
Log(LogCritical, "cli")
return 1;
}
+ if (!vm.count("endpoint")) {
+ Log(LogCritical, "cli", "You need to specify at least one endpoint (--endpoint).");
+ return 1;
+ }
+
String ticket = vm["ticket"].as<std::string>();
Log(LogInformation, "cli")
Dictionary::Ptr my_master_endpoint = make_shared<Dictionary>();
- if (tokens.size() == 1 || tokens.size() == 2)
- my_master_endpoint->Set("host", tokens[0]);
+ if (tokens.size() > 1)
+ my_master_endpoint->Set("host", tokens[1]);
- if (tokens.size() == 2)
- my_master_endpoint->Set("port", tokens[1]);
+ if (tokens.size() > 2)
+ my_master_endpoint->Set("port", tokens[2]);
- my_master_endpoint->Set("__name", String(endpoint));
+ my_master_endpoint->Set("__name", tokens[0]);
my_master_endpoint->Set("__type", "Endpoint");
/* save endpoint in master zone */
- my_master_zone_members->Add(String(endpoint)); //find a better name
+ my_master_zone_members->Add(tokens[0]);
my_config->Add(my_master_endpoint);
}