Sha256: ecd35e962baf4b11f41c4e1662e9ce265b9c88dc12dd28cae7ccd71e13e3da32

Contents?: true

Size: 1.46 KB

Versions: 14

Compression:

Stored size: 1.46 KB

Contents

# frozen_string_literal: true

require 'logging'
require 'bolt/result'
require 'bolt/shell'
require 'bolt/transport/base'

module Bolt
  module Transport
    # A simple transport has a single connection per target and delegates its
    # operation to a target-specific shell.
    class Simple < Base
      def with_connection(_target)
        raise NotImplementedError, "with_connection() must be implemented by the transport class"
      end

      def connected?(target)
        with_connection(target) { true }
      rescue Bolt::Node::ConnectError
        false
      end

      def run_command(target, command, options = {})
        with_connection(target) do |conn|
          conn.shell.run_command(command, options)
        end
      end

      def upload(target, source, destination, options = {})
        with_connection(target) do |conn|
          conn.shell.upload(source, destination, options)
        end
      end

      def download(target, source, destination, options = {})
        with_connection(target) do |conn|
          conn.shell.download(source, destination, options)
        end
      end

      def run_script(target, script, arguments, options = {})
        with_connection(target) do |conn|
          conn.shell.run_script(script, arguments, options)
        end
      end

      def run_task(target, task, arguments, options = {})
        with_connection(target) do |conn|
          conn.shell.run_task(task, arguments, options)
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
bolt-2.32.0 lib/bolt/transport/simple.rb
bolt-2.31.0 lib/bolt/transport/simple.rb
bolt-2.30.0 lib/bolt/transport/simple.rb
bolt-2.29.0 lib/bolt/transport/simple.rb
bolt-2.28.0 lib/bolt/transport/simple.rb
bolt-2.27.0 lib/bolt/transport/simple.rb
bolt-2.26.0 lib/bolt/transport/simple.rb
bolt-2.25.0 lib/bolt/transport/simple.rb
bolt-2.24.1 lib/bolt/transport/simple.rb
bolt-2.24.0 lib/bolt/transport/simple.rb
bolt-2.23.0 lib/bolt/transport/simple.rb
bolt-2.22.0 lib/bolt/transport/simple.rb
bolt-2.21.0 lib/bolt/transport/simple.rb
bolt-2.20.0 lib/bolt/transport/simple.rb