Class: Kitchen::Driver::Base

Inherits:
Object
  • Object
show all
Includes:
Logging, ShellOut
Defined in:
lib/kitchen/driver/base.rb

Overview

Base class for a driver.

Author:

Direct Known Subclasses

Dummy, SSHBase

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Base

Returns a new instance of Base.



41
42
43
44
45
46
# File 'lib/kitchen/driver/base.rb', line 41

def initialize(config = {})
  @config = LazyHash.new(config, self)
  self.class.defaults.each do |attr, value|
    @config[attr] = value unless @config.has_key?(attr)
  end
end

Class Attribute Details

.serial_actionsObject (readonly)

Returns the value of attribute serial_actions.



38
39
40
# File 'lib/kitchen/driver/base.rb', line 38

def serial_actions
  @serial_actions
end

Instance Attribute Details

#instanceObject

Returns the value of attribute instance.



35
36
37
# File 'lib/kitchen/driver/base.rb', line 35

def instance
  @instance
end

Instance Method Details

#[](attr) ⇒ Object

Provides hash-like access to configuration keys.

Parameters:

  • attr (Object)

    configuration key

Returns:

  • (Object)

    value at configuration key



65
66
67
# File 'lib/kitchen/driver/base.rb', line 65

def [](attr)
  config[attr]
end

#config_keysArray

Returns an array of configuration keys.

Returns:

  • (Array)

    array of configuration keys



72
73
74
# File 'lib/kitchen/driver/base.rb', line 72

def config_keys
  config.keys
end

#converge(state) ⇒ Object

Converges a running instance.

Parameters:

  • state (Hash)

    mutable instance and driver state

Raises:



86
# File 'lib/kitchen/driver/base.rb', line 86

def converge(state) ; end

#create(state) ⇒ Object

Creates an instance.

Parameters:

  • state (Hash)

    mutable instance and driver state

Raises:



80
# File 'lib/kitchen/driver/base.rb', line 80

def create(state) ; end

#destroy(state) ⇒ Object

Destroys an instance.

Parameters:

  • state (Hash)

    mutable instance and driver state

Raises:



104
# File 'lib/kitchen/driver/base.rb', line 104

def destroy(state) ; end

#diagnoseHash

Returns a Hash of configuration and other useful diagnostic information.

Returns:

  • (Hash)

    a diagnostic hash



128
129
130
131
132
# File 'lib/kitchen/driver/base.rb', line 128

def diagnose
  result = Hash.new
  config_keys.sort.each { |k| result[k] = config[k] }
  result
end

#login_command(state) ⇒ LoginCommand

Returns the shell command that will log into an instance.

Parameters:

  • state (Hash)

    mutable instance and driver state

Returns:

  • (LoginCommand)

    an object containing the array of command line tokens and exec options to be used in a fork/exec

Raises:



112
113
114
# File 'lib/kitchen/driver/base.rb', line 112

def (state)
  raise ActionFailed, "Remote login is not supported in this driver."
end

#nameString

Returns the name of this driver, suitable for display in a CLI.

Returns:

  • (String)

    name of this driver



57
58
59
# File 'lib/kitchen/driver/base.rb', line 57

def name
  self.class.name.split('::').last
end

#setup(state) ⇒ Object

Sets up an instance.

Parameters:

  • state (Hash)

    mutable instance and driver state

Raises:



92
# File 'lib/kitchen/driver/base.rb', line 92

def setup(state) ; end

#validate_config!Object



48
49
50
51
52
# File 'lib/kitchen/driver/base.rb', line 48

def validate_config!
  Array(self.class.validations).each do |tuple|
    tuple.last.call(tuple.first, config[tuple.first], self)
  end
end

#verify(state) ⇒ Object

Verifies a converged instance.

Parameters:

  • state (Hash)

    mutable instance and driver state

Raises:



98
# File 'lib/kitchen/driver/base.rb', line 98

def verify(state) ; end

#verify_dependenciesObject

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.

Raises:

  • (UserError)

    if the driver will not be able to perform or if a documented dependency is missing from the system



123
# File 'lib/kitchen/driver/base.rb', line 123

def verify_dependencies ; end