Class: Kitchen::Binding::Base
- Inherits:
-
Object
- Object
- Kitchen::Binding::Base
- Includes:
- Logging
- Defined in:
- lib/kitchen/binding/base.rb
Overview
Base class for a binding.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#instance ⇒ Object
Not required in edge.
-
#state ⇒ Object
Returns the value of attribute state.
Instance Method Summary collapse
-
#connect_command ⇒ Object
Returns the command that will log into a remote interactive ruby shell.
-
#initialize(config = {}) ⇒ Base
constructor
Create a new Binding object using the provided configuration data which will be merged with any default configuration.
-
#install_command ⇒ String
Returns the command that will install the remote interactive ruby shell.
-
#name ⇒ String
Returns the name of this transport, suitable for display in a CLI.
-
#sudo(script) ⇒ String
private
Conditionally prefixes a command with a sudo command.
-
#test_connection ⇒ true, false
Test a remote port’s connectivity.
Constructor Details
#initialize(config = {}) ⇒ Base
Create a new Binding object using the provided configuration data which will be merged with any default configuration.
43 44 45 46 47 48 49 50 51 |
# File 'lib/kitchen/binding/base.rb', line 43 def initialize(config = {}) # init_config(config) # Available in edge # Following not required in edge test-kitchen @config = LazyHash.new(config, self) self.class.defaults.each do |attr, value| @config[attr] = value unless @config.has_key?(attr) end end |
Instance Attribute Details
#instance ⇒ Object
Not required in edge
37 38 39 |
# File 'lib/kitchen/binding/base.rb', line 37 def instance @instance end |
#state ⇒ Object
Returns the value of attribute state.
35 36 37 |
# File 'lib/kitchen/binding/base.rb', line 35 def state @state end |
Instance Method Details
#connect_command ⇒ Object
Returns the command that will log into a remote interactive ruby shell.
77 78 |
# File 'lib/kitchen/binding/base.rb', line 77 def connect_command end |
#install_command ⇒ String
Returns the command that will install the remote interactive ruby shell.
71 72 |
# File 'lib/kitchen/binding/base.rb', line 71 def install_command end |
#name ⇒ String
Returns the name of this transport, suitable for display in a CLI.
63 64 65 |
# File 'lib/kitchen/binding/base.rb', line 63 def name self.class.name.split('::').last.downcase end |
#sudo(script) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Conditionally prefixes a command with a sudo command.
85 86 87 |
# File 'lib/kitchen/binding/base.rb', line 85 def sudo(script) config[:sudo] ? "sudo -E #{script}" : script end |
#test_connection ⇒ true, false
Test a remote port’s connectivity.
and false otherwise
93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/kitchen/binding/base.rb', line 93 def test_connection debug("Testing binding connection <#{hostname}:#{port}>") socket = TCPSocket.new(hostname, port) IO.select([socket], nil, nil, 5) true rescue *SOCKET_EXCEPTIONS, Errno::EPERM, Errno::ETIMEDOUT debug("No binding server detected") sleep config[:binding_timeout] || 2 false ensure socket && socket.close end |