Class: VagrantPlugins::Filoo::Action::StartInstance
- Inherits:
-
Object
- Object
- VagrantPlugins::Filoo::Action::StartInstance
- Includes:
- CloudCompute
- Defined in:
- lib/vagrant_filoo/action/start_instance.rb
Constant Summary
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::DELETE_SERVER_TIMEOUT, 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
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ StartInstance
constructor
A new instance of StartInstance.
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) ⇒ StartInstance
Returns a new instance of StartInstance.
11 12 13 14 15 16 17 |
# File 'lib/vagrant_filoo/action/start_instance.rb', line 11 def initialize(app, env) @app = app @baseUrl =env[:machine].provider_config.filoo_api_entry_point @apiKey = env[:machine].provider_config.filoo_api_key @filooConfig = env[:machine].provider_config @logger = Log4r::Logger.new("vagrant_filoo::action::start_instance") end |
Instance Method Details
#call(env) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/vagrant_filoo/action/start_instance.rb', line 19 def call(env) env[:metrics] ||= {} vmid = env[:machine].id env[:result] = VagrantPlugins::Filoo::CloudCompute::startInstance(vmid, @baseUrl, @apiKey, @filooConfig) env[:ui].info("Machine #{vmid} successfully started with config") env[:ui].info( "#{JSON.pretty_generate(env[:result]).gsub!('{','').gsub!('}','').gsub!('"','').gsub!(',','').gsub!('[','').gsub!(']','')}") @logger.info("Time to instance ready: #{env[:metrics]["instance_ready_time"]}") if !env[:interrupted] env[:metrics]["instance_ssh_time"] = Util::Timer.time do # Wait for SSH to be ready. env[:ui].info(I18n.t("vagrant_filoo.waiting_for_ssh")) while true # If we're interrupted then just back out break if env[:interrupted] break if env[:machine].communicate.ready? sleep 2 end end @logger.info("Time for SSH ready: #{env[:metrics]["instance_ssh_time"]}") # Ready and booted! env[:ui].info(I18n.t("vagrant_filoo.ready")) end @app.call(env) end |