Class: Kitchen::Driver::Base
- Inherits:
-
Object
- Object
- Kitchen::Driver::Base
- Includes:
- Configurable, Logging
- Defined in:
- lib/kitchen/driver/base.rb
Overview
Base class for a driver.
Direct Known Subclasses
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
-
.kitchen_driver_api_version(version) ⇒ Object
Sets the API version for this driver.
-
.no_parallel_for(*methods) ⇒ Object
Registers certain driver actions that cannot be safely run concurrently in threads across multiple instances.
Instance Method Summary collapse
-
#cache_directory ⇒ Object
Cache directory that a driver could implement to inform the provisioner that it can leverage it internally.
-
#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.
-
#package(state) ⇒ Object
Package an instance.
Methods included from Logging
#banner, #debug, #error, #fatal, #info, #warn
Methods included from Configurable
#[], #bourne_shell?, #calculate_path, #config_keys, #diagnose, #diagnose_plugin, #finalize_config!, included, #name, #powershell_shell?, #remote_path_join, #unix_os?, #verify_dependencies, #windows_os?
Constructor Details
#initialize(config = {}) ⇒ Base
Creates a new Driver object using the provided configuration data which will be merged with any default configuration.
34 35 36 |
# File 'lib/kitchen/driver/base.rb', line 34 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.
62 63 64 |
# File 'lib/kitchen/driver/base.rb', line 62 def serial_actions @serial_actions end |
Class Method Details
.kitchen_driver_api_version(version) ⇒ Object
Sets the API version for this driver. If the driver does not set this
value, then nil
will be used and reported.
Sets the API version for this driver
115 116 117 |
# File 'lib/kitchen/driver/base.rb', line 115 def self.kitchen_driver_api_version(version) @api_version = version end |
.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.
83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/kitchen/driver/base.rb', line 83 def self.no_parallel_for(*methods) action_methods = [:create, :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
#cache_directory ⇒ Object
Cache directory that a driver could implement to inform the provisioner that it can leverage it internally
123 124 |
# File 'lib/kitchen/driver/base.rb', line 123 def cache_directory end |
#create(state) ⇒ Object
Creates an instance.
42 43 |
# File 'lib/kitchen/driver/base.rb', line 42 def create(state) # rubocop:disable Lint/UnusedMethodArgument end |
#destroy(state) ⇒ Object
Destroys an instance.
49 50 |
# File 'lib/kitchen/driver/base.rb', line 49 def destroy(state) # rubocop:disable Lint/UnusedMethodArgument end |
#package(state) ⇒ Object
Package an instance.
56 57 |
# File 'lib/kitchen/driver/base.rb', line 56 def package(state) # rubocop:disable Lint/UnusedMethodArgument end |