Class: Souffle::Provisioner::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/souffle/provisioner/node.rb

Overview

The node provisioning statemachine.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node, max_failures = 3) ⇒ Node

Creates a new node provisioner state machine.

Parameters:

  • node (Souffle::Node)

    The node to manage.

  • max_failures (Fixnum) (defaults to: 3)

    The maximum number of failures.



83
84
85
86
87
88
# File 'lib/souffle/provisioner/node.rb', line 83

def initialize(node, max_failures=3)
  @time_used = 0
  @node = node
  @max_failures = max_failures
  super() # NOTE: This is here to initialize state_machine.
end

Instance Attribute Details

#time_usedObject

Returns the value of attribute time_used.



5
6
7
# File 'lib/souffle/provisioner/node.rb', line 5

def time_used
  @time_used
end

Instance Method Details

#bootObject

Boots up the node and waits for ssh.



97
98
99
100
# File 'lib/souffle/provisioner/node.rb', line 97

def boot
  Souffle::Log.info "#{@node.log_prefix} Booting node..."
  provider.boot(@node)
end

#createObject

Creates the node from an api or command.



91
92
93
94
# File 'lib/souffle/provisioner/node.rb', line 91

def create
  Souffle::Log.info "#{@node.log_prefix} Creating a new node..."
  provider.create_node(@node)
end

#error_handlerObject

Handles any



156
157
158
# File 'lib/souffle/provisioner/node.rb', line 156

def error_handler
  Souffle::Log.info "#{@node.log_prefix} Handling node error..."
end

#format_deviceObject

Formats a device to the configured filesystem.



115
116
117
118
# File 'lib/souffle/provisioner/node.rb', line 115

def format_device
  Souffle::Log.info "#{@node.log_prefix} Formatting the device..."
  provider.format_device(@node)
end

#killObject

Kills the node entirely.



144
145
146
147
# File 'lib/souffle/provisioner/node.rb', line 144

def kill
  Souffle::Log.info "#{@node.log_prefix} Killing node..."
  provider.kill(@node)
end

#kill_and_recreateObject

Kills the node and restarts the creation loop.



150
151
152
153
# File 'lib/souffle/provisioner/node.rb', line 150

def kill_and_recreate
  Souffle::Log.info "#{@node.log_prefix} Recreating node..."
  provider.kill_and_recreate(@node)
end

#node_provisionedObject

Notifies the system that the current node has completed provisioning.



138
139
140
141
# File 'lib/souffle/provisioner/node.rb', line 138

def node_provisioned
  Souffle::Log.info "#{@node.log_prefix} Node provisioned."
  system_provisioner.node_provisioned
end

#partition_deviceObject

Partitions the soon to be raid device.



109
110
111
112
# File 'lib/souffle/provisioner/node.rb', line 109

def partition_device
  Souffle::Log.info "#{@node.log_prefix} Partitioning the device..."
  provider.partition(@node)
end

#providerObject

Helper function for the node’s system provider.



161
162
163
# File 'lib/souffle/provisioner/node.rb', line 161

def provider
  @node.provider
end

#provisionObject

Provisions the given node with a chef/chef-solo run.



132
133
134
135
# File 'lib/souffle/provisioner/node.rb', line 132

def provision
  Souffle::Log.info "#{@node.log_prefix} Provisioning node..."
  provider.provision(@node)
end

#readyObject

Notify the logger when the node is ready for provisioning.



127
128
129
# File 'lib/souffle/provisioner/node.rb', line 127

def ready
  Souffle::Log.info "#{@node.log_prefix} Is ready for provisioning..."
end

#setup_mdadmObject

Installs and sets up mdadm.



103
104
105
106
# File 'lib/souffle/provisioner/node.rb', line 103

def setup_mdadm
  Souffle::Log.info "#{@node.log_prefix} Setting up mdadm..."
  provider.setup_mdadm(@node)
end

#setup_raidObject

Sets up raid to the configured raid-level.



121
122
123
124
# File 'lib/souffle/provisioner/node.rb', line 121

def setup_raid
  Souffle::Log.info "#{@node.log_prefix} Setting up raid..."
  provider.setup_raid(@node)
end

#system_provisionerObject

Helper function for the system provisioner.



166
167
168
# File 'lib/souffle/provisioner/node.rb', line 166

def system_provisioner
  @node.system.provisioner
end