/// <summary> /// Uses SSH command to start remote CM /// Will send back OnCmCommandComplete to all subscribed VM's /// </summary> /// <param name="host">The VibesHost to connect to</param> /// <param name="cm">The VibesCm to start</param> /// <param name="hashCode">The hash of the sending VM</param> public static void StartCm(VibesHost host, VibesCm cm, int hashCode) { ValidateParameters(host, cm); string sshCommand = SshCommands.StartRemoteCmCommand(host, cm); string sshResult = ExecuteSshCommand(host, sshCommand); OnCmCommandComplete(cm, sshResult.Contains("running") ? HttpStatusCode.OK : HttpStatusCode.ServiceUnavailable, hashCode: hashCode); }
/// <summary> /// USes SSH commands to start multiple remote CM's /// Will send back OnCmCommandCOmplete to all subscribed VM's for each applicable CM /// </summary> /// <param name="host">The VibesHost to connect to</param> /// <param name="cms">List of VibesCm's to start</param> /// <param name="hashCode">The hash of the sending VM</param> public static void StartCmMultiple(VibesHost host, List <VibesCm> cms, int hashCode) { ValidateParameters(host); List <(VibesCm, string command)> commands = new List <(VibesCm, string)>(); foreach (VibesCm cm in cms) { string sshCommand = SshCommands.StartRemoteCmCommand(host, cm); commands.Add((cm, sshCommand)); } var results = Task.Run(() => ExecuteMultipleSshCommand(host, commands)); foreach (var result in results.Result) { OnCmCommandComplete(result.cm, result.result.Contains("running") ? HttpStatusCode.OK : HttpStatusCode.ServiceUnavailable, hashCode: hashCode); } }