Class: MotherBrain::Upgrade::Manager

Inherits:
Object
  • Object
show all
Includes:
Celluloid, Logging
Defined in:
lib/mb/upgrade/manager.rb

Overview

Handles upgrading nodes in already environments.

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

#initializeManager

Returns a new instance of Manager.



19
20
21
# File 'lib/mb/upgrade/manager.rb', line 19

def initialize
  log.debug { "Upgrade Manager starting..." }
end

Class Method Details

.instanceCelluloid::Actor(Upgrade::Manager)

Returns:

Raises:

  • (Celluloid::DeadActorError)

    if Upgrade Manager has not been started



9
10
11
# File 'lib/mb/upgrade/manager.rb', line 9

def instance
  MB::Application[:upgrade_manager] or raise Celluloid::DeadActorError, "upgrade manager not running"
end

Instance Method Details

#async_upgrade(environment, plugin, options = {}) ⇒ JobTicket

Asynchronously upgrade an environment

Parameters:

  • environment (String)

    name of the environment to upgrade

  • plugin (MB::Plugin)

    plugin to use for performing the upgrade on the environment

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

    a customizable set of options

Options Hash (options):

  • component_versions (Hash)

    Hash of components and the versions to set them to

  • cookbook_versions (Hash)

    Hash of cookbooks and the versions to set them to

  • environment_attributes (Hash)

    any additional attributes to set on the environment

  • environment_attributes_file (String)

    any additional attributes to set on the environment via a json file

  • :force (Boolean)

    Force any locks to be overwritten

Returns:



42
43
44
45
46
47
48
# File 'lib/mb/upgrade/manager.rb', line 42

def async_upgrade(environment, plugin, options = {})
  job = Job.new(:upgrade)

  async(:upgrade, job, environment, plugin, options)

  job.ticket
end

#upgrade(job, environment, plugin, options = {}) ⇒ Job

Synchronously upgrade an environment

Parameters:

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

    name of the environment to upgrade

  • plugin (MB::Plugin)

    plugin to use for performing the upgrade on the environment

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

    a customizable set of options

Options Hash (options):

  • component_versions (Hash)

    Hash of components and the versions to set them to

  • cookbook_versions (Hash)

    Hash of cookbooks and the versions to set them to

  • environment_attributes (Hash)

    any additional attributes to set on the environment

  • environment_attributes_file (String)

    any additional attributes to set on the environment via a json file

  • :force (Boolean)

    Force any locks to be overwritten

Returns:



70
71
72
73
74
75
76
# File 'lib/mb/upgrade/manager.rb', line 70

def upgrade(job, environment, plugin, options = {})
  worker = Worker.new(job, environment.freeze, plugin.freeze, options.freeze)
  worker.run
ensure
  worker.terminate if worker && worker.alive?
  job.terminate if job && job.alive?
end