/// <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); }
/// <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); } }