/// <summary> /// Actually executes the command on the node. /// </summary> /// <param name="node">The target node.</param> private void Execute(SshProxy <NodeDefinition> node) { var status = this.ToString(); // Limit the node status to a maximum of 80 characters. For strings // longer than this, we're going to scan backwards from character 80 // until we find a space and then truncate the string at the space // so the status will look nice. if (status.Length > 80) { var pos = 80 - "...".Length; // Leave space for "..." for (; pos > 0; pos--) { if (status[pos] == ' ') { break; } } if (pos > 0) { status = status.Substring(0, pos) + "..."; } else { // Fallback on the chance that a long status has no spaces // before the break. status = status.Substring(0, 77) + "..."; } } node.Status = status; if (commandBundle.Count == 0) { // We can execute the command directly if we're // not uploading any files. if (isDocker) { node.DockerCommand(commandBundle.Command, commandBundle.Args); } else if (Sudo) { node.SudoCommand(commandBundle.Command, commandBundle.Args); } else { throw new NotImplementedException(); } } else { if (isDocker) { throw new NotImplementedException(); } else if (Sudo) { node.SudoCommand(commandBundle); } else { throw new NotImplementedException(); } } StatusPause(); node.Status = string.Empty; }