lib/ztk/ssh.rb in ztk-1.4.4 vs lib/ztk/ssh.rb in ztk-1.4.5

- old
+ new

@@ -1,34 +1,15 @@ -################################################################################ -# -# Author: Zachary Patten <zachary@jovelabs.net> -# Copyright: Copyright (c) Zachary Patten -# License: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -################################################################################ -require "ostruct" -require "net/ssh" -require "net/ssh/proxy/command" -require "net/sftp" +require 'ostruct' +require 'net/ssh' +require 'net/ssh/proxy/command' +require 'net/sftp' module ZTK - # ZTK::SSH Error Class + # SSH Error Class # - # @author Zachary Patten <zachary@jovelabs.net> + # @author Zachary Patten <zachary AT jovelabs DOT com> class SSHError < Error; end # SSH Multi-function Class # # We can get a new instance of SSH like so: @@ -80,11 +61,11 @@ # # ssh.config do |config| # config.host_key_verify = true # end # - # @author Zachary Patten <zachary@jovelabs.net> + # @author Zachary Patten <zachary AT jovelabs DOT com> class SSH < ZTK::Base # Exit Signal Mappings EXIT_SIGNALS = { 1 => "SIGHUP", 2 => "SIGINT", @@ -151,17 +132,29 @@ # we should throw an exception if the exit status is not kosher. # @option configuration [Boolean] :forward_agent (true) Whether or not to # enable SSH agent forwarding. # @option configuration [String, Array<String>] :proxy_keys A single or # series of identity files to use for authentication with the proxy. + # @option options [Boolean] :ignore_exit_status (false) Whether or not + # we should ignore the exit status of the the process we spawn. By + # default we do not ignore the exit status and throw an exception if it is + # non-zero. + # @option options [Integer] :exit_code (0) The exit code we expect the + # process to return. This is ignore if *ignore_exit_status* is true. + # @option options [Boolean] :silence (false) Whether or not we should + # squelch the output of the process. The output will always go to the + # logging device supplied in the ZTK::UI object. The output is always + # available in the return value from the method additionally. def initialize(configuration={}) super({ :forward_agent => true, :compression => false, :user_known_hosts_file => '/dev/null', :timeout => 60, :ignore_exit_status => false, - :request_pty => true + :request_pty => true, + :exit_code => 0, + :silence => false }.merge(configuration)) config.ui.logger.debug { "config=#{config.send(:table).inspect}" } end # Starts an SSH session. Can also be used to get the Net::SSH object.