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.
46 47 48 49 50 51 52 53 54 |
# File 'lib/kitchen/binding/base.rb', line 46 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
40 41 42 |
# File 'lib/kitchen/binding/base.rb', line 40 def instance @instance end |
#state ⇒ Object
Returns the value of attribute state.
38 39 40 |
# File 'lib/kitchen/binding/base.rb', line 38 def state @state end |
Instance Method Details
#connect_command ⇒ Object
Returns the command that will log into a remote interactive ruby shell.
80 81 |
# File 'lib/kitchen/binding/base.rb', line 80 def connect_command end |
#install_command ⇒ String
Returns the command that will install the remote interactive ruby shell.
74 75 |
# File 'lib/kitchen/binding/base.rb', line 74 def install_command end |
#name ⇒ String
Returns the name of this transport, suitable for display in a CLI.
66 67 68 |
# File 'lib/kitchen/binding/base.rb', line 66 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.
88 89 90 |
# File 'lib/kitchen/binding/base.rb', line 88 def sudo(script) config[:sudo] ? "sudo -E #{script}" : script end |
#test_connection ⇒ true, false
Test a remote port’s connectivity.
and false otherwise
96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/kitchen/binding/base.rb', line 96 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 |