Class: VagrantPlugins::Filoo::Action::CreateServer
- Inherits:
-
Object
- Object
- VagrantPlugins::Filoo::Action::CreateServer
- Defined in:
- lib/vagrant_filoo/action/create_server.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ CreateServer
constructor
A new instance of CreateServer.
Constructor Details
#initialize(app, env) ⇒ CreateServer
Returns a new instance of CreateServer.
10 11 12 13 14 |
# File 'lib/vagrant_filoo/action/create_server.rb', line 10 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
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/vagrant_filoo/action/create_server.rb', line 16 def call(env) if (env[:images].nil?) raise Errors::ImagesNotLoaded end config = env[:machine].provider_config if env[:images][config.cd_image_name].nil? raise VagrantPlugins::Filoo::Errors::ConfigError, message: "Filoo Configuration parameter 'cd_image_name' with value #{config.cd_image_name} references not a filoo image that has autoinstall flag set. Please use one of the folowing image names #{env[:images].keys.join(' | ')}" end imageId = "#{env[:images][config.cd_image_name]}".to_i env[:ui].info("vagrant_filoo creating_instance") env[:ui].info(" -- Type: #{config.type}") env[:ui].info(" -- CPUs: #{config.cpu}") env[:ui].info(" -- Ram: #{config.ram}") env[:ui].info(" -- Image Id: #{imageId}") env[:ui].info(" -- Image Name: #{config.cd_image_name}") env[:result] = VagrantPlugins::Filoo::CloudCompute::createServer(@baseUrl, @apiKey, config, imageId) env[:machine].id = env[:result]["vmid"] env[:ui].info(" -- Server created with config") env[:ui].info(" -- Server created with config") env[:ui].info( "#{JSON.pretty_generate(env[:result]).gsub!('{','').gsub!('}','').gsub!('"','').gsub!(',','').gsub!('[','').gsub!(']','')}") @app.call(env) end |