Class: Kitchen::Driver::Base
- Inherits:
-
Object
- Object
- Kitchen::Driver::Base
- Includes:
- Configurable, Logging, ShellOut
- Defined in:
- lib/kitchen/driver/base.rb
Overview
Base class for a driver.
Class Attribute Summary collapse
-
.serial_actions ⇒ Array<Symbol>
readonly
An array of action method names that cannot be run concurrently and must be run in serial via a shared mutex.
Attributes included from Configurable
Class Method Summary collapse
-
.no_parallel_for(*methods) ⇒ Object
Registers certain driver actions that cannot be safely run concurrently in threads across multiple instances.
Instance Method Summary collapse
-
#converge(state) ⇒ Object
Converges a running instance.
-
#create(state) ⇒ Object
Creates an instance.
-
#destroy(state) ⇒ Object
Destroys an instance.
-
#initialize(config = {}) ⇒ Base
constructor
Creates a new Driver object using the provided configuration data which will be merged with any default configuration.
-
#login_command(state) ⇒ LoginCommand
Returns the shell command that will log into an instance.
-
#name ⇒ String
Returns the name of this driver, suitable for display in a CLI.
-
#setup(state) ⇒ Object
Sets up an instance.
-
#verify(state) ⇒ Object
Verifies a converged instance.
-
#verify_dependencies ⇒ Object
Performs whatever tests that may be required to ensure that this driver will be able to function in the current environment.
Methods included from Logging
#banner, #debug, #error, #fatal, #info, #warn
Methods included from Configurable
#[], #calculate_path, #config_keys, #diagnose, #finalize_config!, included
Constructor Details
#initialize(config = {}) ⇒ Base
Creates a new Driver object using the provided configuration data which will be merged with any default configuration.
40 41 42 |
# File 'lib/kitchen/driver/base.rb', line 40 def initialize(config = {}) init_config(config) end |
Class Attribute Details
.serial_actions ⇒ Array<Symbol> (readonly)
Returns an array of action method names that cannot be run concurrently and must be run in serial via a shared mutex.
109 110 111 |
# File 'lib/kitchen/driver/base.rb', line 109 def serial_actions @serial_actions end |
Class Method Details
.no_parallel_for(*methods) ⇒ Object
Registers certain driver actions that cannot be safely run concurrently in threads across multiple instances. Typically this might be used for create or destroy actions that use an underlying resource that cannot be used at the same time.
A shared mutex for this driver object will be used to synchronize all registered methods.
130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/kitchen/driver/base.rb', line 130 def self.no_parallel_for(*methods) action_methods = [:create, :converge, :setup, :verify, :destroy] Array(methods).each do |meth| next if action_methods.include?(meth) raise ClientError, "##{meth} is not a valid no_parallel_for method" end @serial_actions ||= [] @serial_actions += methods end |
Instance Method Details
#converge(state) ⇒ Object
Converges a running instance.
62 63 |
# File 'lib/kitchen/driver/base.rb', line 62 def converge(state) # rubocop:disable Lint/UnusedMethodArgument end |
#create(state) ⇒ Object
Creates an instance.
55 56 |
# File 'lib/kitchen/driver/base.rb', line 55 def create(state) # rubocop:disable Lint/UnusedMethodArgument end |
#destroy(state) ⇒ Object
Destroys an instance.
83 84 |
# File 'lib/kitchen/driver/base.rb', line 83 def destroy(state) # rubocop:disable Lint/UnusedMethodArgument end |
#login_command(state) ⇒ LoginCommand
Returns the shell command that will log into an instance.
92 93 94 |
# File 'lib/kitchen/driver/base.rb', line 92 def login_command(state) # rubocop:disable Lint/UnusedMethodArgument raise ActionFailed, "Remote login is not supported in this driver." end |
#name ⇒ String
Returns the name of this driver, suitable for display in a CLI.
47 48 49 |
# File 'lib/kitchen/driver/base.rb', line 47 def name self.class.name.split("::").last end |
#setup(state) ⇒ Object
Sets up an instance.
69 70 |
# File 'lib/kitchen/driver/base.rb', line 69 def setup(state) # rubocop:disable Lint/UnusedMethodArgument end |
#verify(state) ⇒ Object
Verifies a converged instance.
76 77 |
# File 'lib/kitchen/driver/base.rb', line 76 def verify(state) # rubocop:disable Lint/UnusedMethodArgument end |
#verify_dependencies ⇒ Object
Performs whatever tests that may be required to ensure that this driver will be able to function in the current environment. This may involve checking for the presence of certain directories, software installed, etc.
103 104 |
# File 'lib/kitchen/driver/base.rb', line 103 def verify_dependencies end |