Class: VagrantPlugins::SoftLayer::Action::RebuildInstance

Inherits:
Object
  • Object
show all
Includes:
Util::Network, Util::Warden
Defined in:
lib/vagrant-softlayer/action/rebuild_instance.rb

Overview

This rebuilds the running instance.

Instance Method Summary collapse

Methods included from Util::Warden

#sl_warden

Methods included from Util::Network

#hostname, #ip_address, #ip_address_id, #ip_address_record, #ssh_keys

Constructor Details

#initialize(app, env) ⇒ RebuildInstance

Returns a new instance of RebuildInstance.



9
10
11
12
# File 'lib/vagrant-softlayer/action/rebuild_instance.rb', line 9

def initialize(app, env)
  @app    = app
  @logger = Log4r::Logger.new("vagrant_softlayer::action::rebuild_instance")
end

Instance Method Details

#call(env) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/vagrant-softlayer/action/rebuild_instance.rb', line 14

def call(env)
  env[:ui].info I18n.t("vagrant_softlayer.vm.rebuilding")

  # Wipe out provision sentinel file, we need to run provisioning after rebuild
  @logger.debug("Looking for provision sentinel file.")
  provision_file = env[:machine].data_dir.join("action_provision")
  if provision_file.file?
    @logger.debug("Removing provision sentinel file.")
    provision_file.delete
  end

  template = { "sshKeyIds" => ssh_keys(env, true) }
  template["customProvisionScriptUri"] = env[:machine].provider_config.post_install if env[:machine].provider_config.post_install
  
  sl_warden { env[:sl_machine].reloadOperatingSystem("FORCE", template) }
  
  @app.call(env)
end