示例#1
0
        /// <summary>
        /// Uses SSH command to stop 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 stop</param>
        /// <param name="hashCode">The hash of the sending VM</param>
        public static void StopCm(VibesHost host, VibesCm cm, int hashCode)
        {
            ValidateParameters(host, cm);
            string sshCommand = SshCommands.StopRemoteCmCommand(host, cm);
            string sshResult  = ExecuteSshCommand(host, sshCommand);

            OnCmCommandComplete(cm, sshResult.Contains("running") ? HttpStatusCode.OK : HttpStatusCode.ServiceUnavailable, hashCode: hashCode);
        }
示例#2
0
        /// <summary>
        /// Uses SSH commands to stop 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 stop</param>
        /// <param name="hashCode">The hash of the sending VM</param>
        public static void StopCmMultiple(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.StopRemoteCmCommand(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);
            }
        }