Skip to content

Commit

Permalink
checking if XenServerVssProvider service exists before restart
Browse files Browse the repository at this point in the history
  • Loading branch information
Kashi Reddy committed Jan 7, 2013
1 parent 2262827 commit 6147bc0
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/Rackspace.Cloud.Server.Agent/Commands/XentoolsUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
// under the License.

using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using Rackspace.Cloud.Server.Agent.Actions;
using Rackspace.Cloud.Server.Agent.Configuration;
using Rackspace.Cloud.Server.Agent.Interfaces;
Expand Down Expand Up @@ -67,8 +69,9 @@ public ExecutableResult Execute(string value)
{Constants.XenToolsSetupExecutablePath,
String.Format("/S /norestart /D={0}", Constants.XenToolsPath)}
});
_serviceRestarter.Restart("xensvc");
_serviceRestarter.Restart("XenServerVssProvider");
_serviceRestarter.Restart("xensvc");
if (DoesServiceExist("XenServerVssProvider"))
_serviceRestarter.Restart("XenServerVssProvider");
Statics.ShouldPollXenStore = true;
return new ExecutableResult();
}
Expand All @@ -82,7 +85,13 @@ public ExecutableResult Execute(string value)
{
_finalizer.Finalize(new List<string>{Constants.XenToolsUnzipPath,Constants.XenToolsReleasePackage});
}
}

public static bool DoesServiceExist(string serviceName)
{
var services = ServiceController.GetServices();
var service = services.FirstOrDefault(s => s.ServiceName.Equals(serviceName, StringComparison.InvariantCultureIgnoreCase));
return service != null;
}

}
}

0 comments on commit 6147bc0

Please sign in to comment.