Class: VagrantPlugins::Filoo::Action::TerminateInstance

Inherits:
Object
  • Object
show all
Includes:
CloudCompute
Defined in:
lib/vagrant_filoo/action/terminate_instance.rb

Overview

This starts a stopped instance.

Constant Summary collapse

DELETE_SERVER_TIMEOUT =
30

Constants included from CloudCompute

CloudCompute::ADD_NIC_RESOURCE, CloudCompute::CREATE_SERVER_RESOURCE, CloudCompute::CREATE_SERVER_TIMEOUT, CloudCompute::DEFAULT_TIMEOUT, CloudCompute::DELETE_NIC_RESOURCE, CloudCompute::DELETE_SERVER_RESOURCE, CloudCompute::IMAGES_RESOURCE, CloudCompute::LIST_NIC_RESOURCE, CloudCompute::LIST_SERVER_RESOURCE, CloudCompute::LOGGER, CloudCompute::SERVERSTATUS_RESOURCE, CloudCompute::SHOWJOB_RESOURCE, CloudCompute::START_INSTANCE_TIMEOUT, CloudCompute::START_RESOURCE, CloudCompute::STOP_INSTANCE_TIMEOUT, CloudCompute::STOP_RESOURCE, CloudCompute::VALID_CPU_COUNTS, CloudCompute::VALID_RAM, CloudCompute::VALID_TYPES

Instance Method Summary collapse

Methods included from CloudCompute

addNic, call, call4JobId, checkServerParams, checkServerStatus, compareServerStatus, createBody, createBoundary, createPartFromParam, createServer, deleteNic, deleteServer, doHttpCall, getAutoInstallImages, getServerStatus, getServers, hashAutoInstallListFromImageList, hashFromServerList, listNic, requestJobStatusWithResult, startInstance, stopInstance, waitJobDone

Constructor Details

#initialize(app, env) ⇒ TerminateInstance

Returns a new instance of TerminateInstance.



9
10
11
12
13
# File 'lib/vagrant_filoo/action/terminate_instance.rb', line 9

def initialize(app, env)
  @app = app
  @baseUrl = env[:machine].provider_config.filoo_api_entry_point
  @apiKey = env[:machine].provider_config.filoo_api_key
end

Instance Method Details

#call(env) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/vagrant_filoo/action/terminate_instance.rb', line 15

def call(env)
  vmid = env[:machine].id
  env[:result] = VagrantPlugins::Filoo::CloudCompute::deleteServer(vmid, @baseUrl, @apiKey)
  env[:ui].info("Machine #{env[:machine].id} successfully terminated")
  env[:machine].id = nil
  @app.call(env)
end