Sha256: 0f5f7b7a35bda4dd2d76de83e845c229c3ed56f5b1c8e92ddebdc8c1739b1c94

Contents?: true

Size: 1.8 KB

Versions: 40

Compression:

Stored size: 1.8 KB

Contents

module Vagrant
  module Communication
    # The base class for any classes that provide an API for communicating
    # with the virtual machine.
    #
    # There are various stages that require Vagrant to copy files or
    # run commands on the target system, and communication classes provide
    # the abstraction necessary to perform these tasks, via SSH or some
    # other mechanism.
    #
    # Any subclasses of this class **must** implement all of the methods
    # below.
    class Base
      # Checks if the target machine is ready for communication.
      #
      # @return [Boolean]
      def ready?
      end

      # Upload a file to the virtual machine.
      #
      # @param [String] from Path to a file to upload.
      # @param [String] to Path to where to save this file.
      def upload(from, to)
      end

      # Execute a command on the remote machine.
      #
      # @param [String] command Command to execute.
      # @yield [type, data] Realtime output of the command being executed.
      # @yieldparam [String] type Type of the output, `:stdout`, `:stderr`, etc.
      # @yieldparam [String] data Data for the given output.
      # @return [Integer] Exit code of the command.
      def execute(command, opts=nil)
      end

      # Execute a comand with super user privileges.
      #
      # See #execute for parameter information.
      def sudo(command, opts=nil)
      end

      # Executes a command and returns a boolean statement if it was successful
      # or not.
      #
      # This is implemented by default as expecting `execute` to return 0.
      def test(command, opts=nil)
        # Disable error checking no matter what
        opts = (opts || {}).merge(:error_check => false)

        # Successful if the exit status is 0
        execute(command, opts) == 0
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 6 rubygems

Version Path
bmhatfield-vagrant-1.0.10 lib/vagrant/communication/base.rb
bmhatfield-vagrant-1.0.9 lib/vagrant/communication/base.rb
bmhatfield-vagrant-1.0.8 lib/vagrant/communication/base.rb
bmhatfield-vagrant-1.0.7 lib/vagrant/communication/base.rb
vagrantup-1.0.7 lib/vagrant/communication/base.rb
vagrantup-1.0.6 lib/vagrant/communication/base.rb
vagrantup-1.0.5 lib/vagrant/communication/base.rb
vagrantup-1.0.4 lib/vagrant/communication/base.rb
vagrantup-1.0.3 lib/vagrant/communication/base.rb
vagrantup-1.0.2 lib/vagrant/communication/base.rb
vagrantup-1.0.1 lib/vagrant/communication/base.rb
vagrantup-1.0.0 lib/vagrant/communication/base.rb
vagrantup-0.9.99.2 lib/vagrant/communication/base.rb
vagrantup-0.9.99.1 lib/vagrant/communication/base.rb
vagrantup-0.9.7 lib/vagrant/communication/base.rb
vagrantup-0.9.6 lib/vagrant/communication/base.rb
vagrantup-0.9.5 lib/vagrant/communication/base.rb
vagrantup-0.9.4 lib/vagrant/communication/base.rb
vagrantup-0.9.3 lib/vagrant/communication/base.rb
vagrantup-0.9.2 lib/vagrant/communication/base.rb