Class: VagrantPlugins::VMM::Action::Import

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-vmm/action/import.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ Import

Returns a new instance of Import.



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

def initialize(app, env)
  @app    = app
  @logger = Log4r::Logger.new("vagrant::VMM::import")
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
32
33
34
35
36
37
# File 'lib/vagrant-vmm/action/import.rb', line 14

def call(env)
  vmm_server_address = env[:machine].provider_config.vmm_server_address
  # generate options
  options = {
    vmm_server_address: vmm_server_address,
    proxy_server_address: env[:machine].provider_config.proxy_server_address,
    vm_name: env[:machine].config.vm.hostname,
    vm_template_name: env[:machine].provider_config.vm_template_name,
    vm_host_group_name: env[:machine].provider_config.vm_host_group_name,
    ad_server: env[:machine].provider_config.ad_server,
    ad_source_path: env[:machine].provider_config.ad_source_path,
    ad_target_path: env[:machine].provider_config.ad_target_path
  }

  #
  env[:ui].detail("Creating and registering VM in the VMM (#{vmm_server_address})...")
  if options[:ad_server] && options[:ad_source_path] && options[:ad_target_path]
    env[:ui].detail("  ..and moving it under #{options[:ad_target_path]} after it's created.")
  end
  server = env[:machine].provider.driver.import(options)
  env[:ui].detail("Successfully created the VM with name: #{server['name']}")
  env[:machine].id = server["id"]
  @app.call(env)
end