Class: VagrantPlugins::OVirtProvider::Action::ConnectOVirt

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-ovirt4/action/connect_ovirt.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ ConnectOVirt



8
9
10
11
# File 'lib/vagrant-ovirt4/action/connect_ovirt.rb', line 8

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

Instance Method Details

#call(env) ⇒ Object



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

def call(env)

  # Get config options for ovirt provider.
  config = env[:machine].provider_config

  conn_attr = {}
  conn_attr[:url] = "#{config.url}"
  conn_attr[:username] = config.username if config.username
  conn_attr[:password] = config.password if config.password
  conn_attr[:debug] = config.debug if config.debug
  conn_attr[:insecure] = true if config.insecure

  @logger.info("Connecting to oVirt (#{config.url}) ...")
  OVirtProvider.ovirt_connection = OvirtSDK4::Connection.new(conn_attr)          
  OVirtProvider.vms_service = OVirtProvider.ovirt_connection.system_service.vms_service
  env[:connection] = OVirtProvider.ovirt_connection
  env[:vms_service] = OVirtProvider.vms_service

  @app.call(env)
end