Class: VagrantPlugins::Abiquo::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant_abiquo/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/vagrant_abiquo/config.rb', line 14

def initialize
  @abiquo_connection_data = UNSET_VALUE
  @virtualdatacenter      = UNSET_VALUE
  @virtualappliance       = UNSET_VALUE
  @template               = UNSET_VALUE
  @cpu_cores              = 0
  @ram_mb                 = 0
  @hwprofile              = UNSET_VALUE
  @network                = UNSET_VALUE
  @user_data              = UNSET_VALUE
end

Instance Attribute Details

#abiquo_connection_dataObject

Returns the value of attribute abiquo_connection_data.



4
5
6
# File 'lib/vagrant_abiquo/config.rb', line 4

def abiquo_connection_data
  @abiquo_connection_data
end

#cpu_coresObject

Returns the value of attribute cpu_cores.



7
8
9
# File 'lib/vagrant_abiquo/config.rb', line 7

def cpu_cores
  @cpu_cores
end

#hwprofileObject

Returns the value of attribute hwprofile.



9
10
11
# File 'lib/vagrant_abiquo/config.rb', line 9

def hwprofile
  @hwprofile
end

#networkObject

Returns the value of attribute network.



11
12
13
# File 'lib/vagrant_abiquo/config.rb', line 11

def network
  @network
end

#ram_mbObject

Returns the value of attribute ram_mb.



8
9
10
# File 'lib/vagrant_abiquo/config.rb', line 8

def ram_mb
  @ram_mb
end

#templateObject

Returns the value of attribute template.



10
11
12
# File 'lib/vagrant_abiquo/config.rb', line 10

def template
  @template
end

#user_dataObject

Returns the value of attribute user_data.



12
13
14
# File 'lib/vagrant_abiquo/config.rb', line 12

def user_data
  @user_data
end

#virtualapplianceObject

Returns the value of attribute virtualappliance.



6
7
8
# File 'lib/vagrant_abiquo/config.rb', line 6

def virtualappliance
  @virtualappliance
end

#virtualdatacenterObject

Returns the value of attribute virtualdatacenter.



5
6
7
# File 'lib/vagrant_abiquo/config.rb', line 5

def virtualdatacenter
  @virtualdatacenter
end

Instance Method Details

#finalize!Object



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_abiquo/config.rb', line 26

def finalize!
  @abiquo_connection_data = {} if @abiquo_connection_data == UNSET_VALUE
  @abiquo_connection_data[:abiquo_api_url] = ENV['ABQ_URL'] if @abiquo_connection_data[:abiquo_api_url].nil?
  @abiquo_connection_data[:abiquo_username] = ENV['ABQ_USER'] if @abiquo_connection_data[:abiquo_username].nil?
  @abiquo_connection_data[:abiquo_password] = ENV['ABQ_PASS'] if @abiquo_connection_data[:abiquo_password].nil?
  @abiquo_connection_data = nil if @abiquo_connection_data[:abiquo_api_url].nil?

  @virtualdatacenter = ENV['ABQ_VDC'] if @virtualdatacenter == UNSET_VALUE
  @virtualappliance = ENV['ABQ_VAPP'] if @virtualappliance == UNSET_VALUE
  @template = ENV['ABQ_TMPL'] if @template == UNSET_VALUE

  @cpu_cores = ENV['ABQ_CPU'] if @cpu_cores == 0
  @ram_mb = ENV['ABQ_RAM'] if @ram_mb == 0
  @ram_mb = nil if @ram_mb == 0
  @hwprofile = ENV['ABQ_HWPROFILE'] if @hwprofile == UNSET_VALUE

  @network = { ENV['ABQ_NET'] => ENV['ABQ_IP'] } if @network == UNSET_VALUE

  if @user_data == UNSET_VALUE
    # We will make sure the SSH key is injected.
    @user_data = "#!/bin/bash\necho \"vagrant_abiquo :: making sure SSH key gets injected.\""
  end
end

#validate(machine) ⇒ Object



50
51
52
53
54
55
56
57
58
# File 'lib/vagrant_abiquo/config.rb', line 50

def validate(machine)
  errors = []
  errors << I18n.t('vagrant_abiquo.config.abiquo_connection_data') if !@abiquo_connection_data
  errors << I18n.t('vagrant_abiquo.config.virtualdatacenter') if !@virtualdatacenter
  errors << I18n.t('vagrant_abiquo.config.template') if !@template
  errors << I18n.t('vagrant_abiquo.config.cpuhwprofile') if @cpu_cores.nil? and @hwprofile.nil?

  { 'Abiquo Provider' => errors }
end