Merge pull request #543 from cheng--zhang/CP-12769

CP-12769: Send credential only when HealthCheckService is running.
This commit is contained in:
Mihaela Stoica 2015-07-15 09:12:43 +01:00
commit 8e8c7c4b13
4 changed files with 11 additions and 3 deletions

View File

@ -36,6 +36,7 @@ using System;
using System.IO.Pipes; using System.IO.Pipes;
using System.IO; using System.IO;
using System.Text; using System.Text;
using System.ServiceProcess;
namespace XenAdmin.Actions namespace XenAdmin.Actions
{ {
@ -64,8 +65,14 @@ namespace XenAdmin.Actions
return EncryptionUtils.ProtectForLocalMachine(String.Join(SEPARATOR.ToString(), new[] { Host, username, passwordSecret })); return EncryptionUtils.ProtectForLocalMachine(String.Join(SEPARATOR.ToString(), new[] { Host, username, passwordSecret }));
} }
private const string CALLHOMESERVICENAME = "XenHealthSvc";
protected override void Run() protected override void Run()
{ {
ServiceController sc = new ServiceController(CALLHOMESERVICENAME);
if (sc.Status != ServiceControllerStatus.Running)
return;
NamedPipeClientStream pipeClient = new NamedPipeClientStream(".", CallHomeSettings.HEALTH_CHECK_PIPE, PipeDirection.Out); NamedPipeClientStream pipeClient = new NamedPipeClientStream(".", CallHomeSettings.HEALTH_CHECK_PIPE, PipeDirection.Out);
int retryCount = 120; int retryCount = 120;
do do

View File

@ -50,6 +50,7 @@
<RequiredTargetFramework>3.5</RequiredTargetFramework> <RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference> </Reference>
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Web.Extensions" /> <Reference Include="System.Web.Extensions" />
<Reference Include="System.Web.Services" /> <Reference Include="System.Web.Services" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />

View File

@ -35,7 +35,7 @@
// //
this.XenServerHealthCheckInstaller.Description = "Citrix XenServer Health Check"; this.XenServerHealthCheckInstaller.Description = "Citrix XenServer Health Check";
this.XenServerHealthCheckInstaller.DisplayName = "Citrix XenServer Health Check"; this.XenServerHealthCheckInstaller.DisplayName = "Citrix XenServer Health Check";
this.XenServerHealthCheckInstaller.ServiceName = "Citrix XenServer Health Check"; this.XenServerHealthCheckInstaller.ServiceName = "XenHealthSvc";
this.XenServerHealthCheckInstaller.StartType = System.ServiceProcess.ServiceStartMode.Automatic; this.XenServerHealthCheckInstaller.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
this.XenServerHealthCheckInstaller.AfterInstall += new System.Configuration.Install.InstallEventHandler(this.XenServerHealthCheckInstaller_AfterInstall); this.XenServerHealthCheckInstaller.AfterInstall += new System.Configuration.Install.InstallEventHandler(this.XenServerHealthCheckInstaller_AfterInstall);
// //

View File

@ -104,12 +104,12 @@ namespace XenServerHealthCheck
List<ServerInfo> servers = ServerListHelper.instance.GetServerList(); List<ServerInfo> servers = ServerListHelper.instance.GetServerList();
foreach (ServerInfo server in servers) foreach (ServerInfo server in servers)
{ {
if (server.task != null && (!server.task.IsCompleted || !server.task.IsCanceled || !server.task.IsFaulted)) if (server.task != null && !(server.task.IsCompleted || server.task.IsCanceled || server.task.IsFaulted))
canStop = false; canStop = false;
} }
if(canStop == false) if(canStop == false)
Thread.Sleep(1000); Thread.Sleep(1000);
} while (canStop != true); } while (canStop == false);
} }
public void OnTimer(object sender, System.Timers.ElapsedEventArgs args) public void OnTimer(object sender, System.Timers.ElapsedEventArgs args)