Class: MotherBrain::Provisioner::Base

Inherits:
Object
  • Object
show all
Includes:
Celluloid, MB::Mixin::Services, Logging
Defined in:
lib/mb/provisioner.rb

Direct Known Subclasses

AWS

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logging

add_argument_header, dev, filename, #log_exception, logger, #logger, reset, set_logger, setup

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



138
139
140
# File 'lib/mb/provisioner.rb', line 138

def initialize(options = {})
  @options = options
end

Class Attribute Details

.provisioner_idSymbol (readonly)

The identifier for the Provisioner

Returns:

  • (Symbol)


109
110
111
# File 'lib/mb/provisioner.rb', line 109

def provisioner_id
  @provisioner_id
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



136
137
138
# File 'lib/mb/provisioner.rb', line 136

def options
  @options
end

Class Method Details

.register_provisioner(provisioner_id, options = {}) ⇒ Object

Parameters:

  • provisioner_id (#to_sym)


112
113
114
115
# File 'lib/mb/provisioner.rb', line 112

def register_provisioner(provisioner_id, options = {})
  @provisioner_id = provisioner_id.to_sym
  Provisioner.register(self, options)
end

.validate_create(created, manifest) ⇒ Object

Validate that the return created nodes contains the expected number of nodes and the proper instance types

Parameters:

Raises:



125
126
127
128
129
# File 'lib/mb/provisioner.rb', line 125

def validate_create(created, manifest)
  unless created.length == manifest.node_count
    raise UnexpectedProvisionCount.new(manifest.node_count, created.length)
  end
end

Instance Method Details

#down(job, environment_name, options = {}) ⇒ Boolean

Destroy a set of provisioned nodes

Parameters:

  • job (MB::Job)
  • environment_name (String)

    name of the set of nodes to destroy

  • options (Hash) (defaults to: {})

Returns:

  • (Boolean)

Raises:



181
182
183
# File 'lib/mb/provisioner.rb', line 181

def down(job, environment_name, options = {})
  raise AbstractFunction
end

#up(job, env_name, manifest, plugin, options = {}) ⇒ Array

Request a provisioner to generate a set of nodes described by the given manifest

Examples:

[
  {
    instance_type: "m1.large",
    public_hostname: "cloud-1.riotgames.com"
  },
  {
    instance_type: "m1.small",
    public_hostname: "cloud-2.riotgames.com"
  }
]

Parameters:

  • job (MB::Job)
  • env_name (String)

    name of the set of nodes to be created

  • manifest (MB::Provisioner::Manifest)

    manifest describing how many and what kind of nodes to create

  • plugin (MB::Plugin)
  • options (Hash) (defaults to: {})

Returns:

  • (Array)

    an array of hashes representing nodes generated of given sizes

Raises:



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

def up(job, env_name, manifest, plugin, options = {})
  raise AbstractFunction
end