예제 #1
0
        /// <summary>
        /// Get hosts file from specified host
        /// </summary>
        /// <param name="host">The host to query</param>
        /// <param name="hashCode">The hash of the sending VM</param>
        public static void GetHostsFile(VibesHost host, int hashCode)
        {
            ValidateParameters(host);
            string        sshCommand = SshCommands.EchoRemoteHostsFile();
            Task <string> sshResult  = Task.Run(() => ExecuteSshCommand(host, sshCommand));

            OnCmCommandComplete(host, sshResult.Result, hashCode: hashCode);
        }
예제 #2
0
        /// <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);
        }
예제 #3
0
        /// <summary>
        /// Gets deployment.properties from specified CM
        /// </summary>
        /// <param name="host">The host on which the CM is installed</param>
        /// <param name="cm">The CM to query</param>
        /// <param name="hashCode">The hash of the sending VM</param>
        public static void GetCmParams(VibesHost host, VibesCm cm, int hashCode)
        {
            ValidateParameters(host, cm);
            string        sshCommand = SshCommands.EchoCmProperties(cm);
            Task <string> sshResult  = Task.Run(() => ExecuteSshCommand(host, sshCommand));

            OnCmCommandComplete(host, cm, sshResult.Result, hashCode: hashCode);
        }
예제 #4
0
        /// <summary>
        /// Switch hosts file on the specified host
        /// </summary>
        /// <param name="host">The host to swittch hosts file on</param>
        /// <param name="indMoveToProd">True if moving from hlcint to prod, false for opposite</param>
        public static void SwitchHostsFile(VibesHost host, bool indMoveToProd, int hashCode)
        {
            ValidateParameters(host, null);
            string sshCommand = SshCommands.SwitchRemoteHostsFile(host, indMoveToProd);

            Task.Run(() =>
            {
                ExecuteSshCommand(host, sshCommand);
                // Get hostsfile after switch
                GetHostsFile(host, hashCode);
            });
        }
예제 #5
0
        /// <summary>
        /// Uses bash sed command to edit deployment properties file
        /// Will send back OnCmCommandCOmplete to all subscribed VM's
        /// </summary>
        /// <param name="host">The VibesHost to conenct to</param>
        /// <param name="cm">The VibesCm to edit</param>
        /// <param name="paramToEdit">The text pattern to find</param>
        /// <param name="paramToReplace">The text pattern to replace with</param>
        /// <param name="hashCode">The hash of the sending VM</param>
        public static void AlterCm(VibesHost host, VibesCm cm, string paramToEdit, string paramToReplace, int hashCode)
        {
            ValidateParameters(host, cm);
            if (string.IsNullOrEmpty(paramToEdit) || string.IsNullOrEmpty(paramToReplace))
            {
                throw new ArgumentNullException($"Attempted to alter CM {cm.CmResourceName} without parameters to add/remove");
            }

            string sshCommand = SshCommands.AlterRemoteCmCommand(host, cm, paramToEdit, paramToReplace);

            ExecuteSshCommand(host, sshCommand);

            OnCmCommandComplete(cm, HttpStatusCode.NoContent, hashCode: hashCode);
        }
예제 #6
0
        /// <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);
            }
        }
예제 #7
0
        /// <summary>
        /// Gets deployment.properties for a list of supplied CM's
        /// </summary>
        /// <param name="host">The host on which the CM is installed</param>
        /// <param name="cms">The CM to query</param>
        /// <param name="hashCode">The has of the sending VM</param>
        public static void GetAllCmParams(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.EchoCmProperties(cm);
                commands.Add((cm, sshCommand));
            }
            var results = Task.Run(() => ExecuteMultipleSshCommand(host, commands));

            foreach (var result in results.Result)
            {
                OnCmCommandComplete(result.host, result.cm, result.result, hashCode: hashCode);
            }
        }
예제 #8
0
        /// <summary>
        /// Uses bash sed command to edit multiple deployment properties files
        /// Will send back OnCmCommandCOmplete to all subscribed VM's for each applicable CM
        /// </summary>
        /// <param name="host">The VibesHost to conenct to</param>
        /// <param name="cm">The VibesCm to edit</param>
        /// <param name="paramToEdit">The text pattern to find</param>
        /// <param name="paramToReplace">The text pattern to replace with</param>
        /// <param name="hashCode">The hash of the sending VM</param>
        public static void AlterCmMultiple(VibesHost host, List <VibesCm> cms, int hashCode)
        {
            ValidateParameters(host);
            List <(VibesCm, string command)> commands = new List <(VibesCm, string)>();

            foreach (VibesCm cm in cms)
            {
                foreach (DeploymentProperty propertyToChange in cm.DeploymentProperties)
                {
                    if (string.IsNullOrEmpty(propertyToChange.SearchPattern) || string.IsNullOrEmpty(propertyToChange.ReplacePattern))
                    {
                        continue;
                    }
                    string sshCommand = SshCommands.AlterRemoteCmCommand(host, cm, propertyToChange.SearchPattern, propertyToChange.ReplacePattern);
                    commands.Add((cm, sshCommand));
                }
            }
            var results = Task.Run(() => ExecuteMultipleSshCommand(host, commands));

            foreach (var result in results.Result)
            {
                OnCmCommandComplete(result.cm, HttpStatusCode.NoContent, hashCode: hashCode);
            }
        }