Class: VagrantPlugins::TerraformProvider::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-terraform/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/vagrant-terraform/config.rb', line 30

def initialize
  @api_url           = UNSET_VALUE
  @api_token_id      = UNSET_VALUE
  @api_token_secret  = UNSET_VALUE
  @vga           = UNSET_VALUE
  @insecure          = UNSET_VALUE
  @debug             = UNSET_VALUE
  @vmname            = UNSET_VALUE
  @template          = UNSET_VALUE
  @disk_size         = UNSET_VALUE
  @storage_domain    = UNSET_VALUE
  @cpu_cores         = UNSET_VALUE
  @memory_size       = UNSET_VALUE
  @target_node       = UNSET_VALUE
  @onboot            = UNSET_VALUE
  @description       = UNSET_VALUE
  @nameserver        = UNSET_VALUE
  @searchdomain      = UNSET_VALUE
  @os_type           = UNSET_VALUE
  @full_clone        = UNSET_VALUE
  @serial_port       = UNSET_VALUE
end

Instance Attribute Details

#api_token_idObject

Returns the value of attribute api_token_id.



10
11
12
# File 'lib/vagrant-terraform/config.rb', line 10

def api_token_id
  @api_token_id
end

#api_token_secretObject

Returns the value of attribute api_token_secret.



11
12
13
# File 'lib/vagrant-terraform/config.rb', line 11

def api_token_secret
  @api_token_secret
end

#api_urlObject

Returns the value of attribute api_url.



9
10
11
# File 'lib/vagrant-terraform/config.rb', line 9

def api_url
  @api_url
end

#cpu_coresObject

Returns the value of attribute cpu_cores.



19
20
21
# File 'lib/vagrant-terraform/config.rb', line 19

def cpu_cores
  @cpu_cores
end

#debugObject

Returns the value of attribute debug.



14
15
16
# File 'lib/vagrant-terraform/config.rb', line 14

def debug
  @debug
end

#descriptionObject

Returns the value of attribute description.



23
24
25
# File 'lib/vagrant-terraform/config.rb', line 23

def description
  @description
end

#disk_sizeObject

Returns the value of attribute disk_size.



17
18
19
# File 'lib/vagrant-terraform/config.rb', line 17

def disk_size
  @disk_size
end

#disksObject (readonly)

Returns the value of attribute disks.



7
8
9
# File 'lib/vagrant-terraform/config.rb', line 7

def disks
  @disks
end

#full_cloneObject

Returns the value of attribute full_clone.



27
28
29
# File 'lib/vagrant-terraform/config.rb', line 27

def full_clone
  @full_clone
end

#insecureObject

Returns the value of attribute insecure.



13
14
15
# File 'lib/vagrant-terraform/config.rb', line 13

def insecure
  @insecure
end

#memory_sizeObject

Returns the value of attribute memory_size.



20
21
22
# File 'lib/vagrant-terraform/config.rb', line 20

def memory_size
  @memory_size
end

#nameserverObject

Returns the value of attribute nameserver.



24
25
26
# File 'lib/vagrant-terraform/config.rb', line 24

def nameserver
  @nameserver
end

#onbootObject

Returns the value of attribute onboot.



22
23
24
# File 'lib/vagrant-terraform/config.rb', line 22

def onboot
  @onboot
end

#os_typeObject

Returns the value of attribute os_type.



26
27
28
# File 'lib/vagrant-terraform/config.rb', line 26

def os_type
  @os_type
end

#searchdomainObject

Returns the value of attribute searchdomain.



25
26
27
# File 'lib/vagrant-terraform/config.rb', line 25

def searchdomain
  @searchdomain
end

#serial_portObject

Returns the value of attribute serial_port.



28
29
30
# File 'lib/vagrant-terraform/config.rb', line 28

def serial_port
  @serial_port
end

#storage_domainObject

Returns the value of attribute storage_domain.



18
19
20
# File 'lib/vagrant-terraform/config.rb', line 18

def storage_domain
  @storage_domain
end

#target_nodeObject

Returns the value of attribute target_node.



21
22
23
# File 'lib/vagrant-terraform/config.rb', line 21

def target_node
  @target_node
end

#templateObject

Returns the value of attribute template.



16
17
18
# File 'lib/vagrant-terraform/config.rb', line 16

def template
  @template
end

#vgaObject

Returns the value of attribute vga.



12
13
14
# File 'lib/vagrant-terraform/config.rb', line 12

def vga
  @vga
end

#vmnameObject

Returns the value of attribute vmname.



15
16
17
# File 'lib/vagrant-terraform/config.rb', line 15

def vmname
  @vmname
end

Instance Method Details

#finalize!Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/vagrant-terraform/config.rb', line 53

def finalize!
  @api_url = nil if @api_url == UNSET_VALUE
  @api_token_id = nil if @api_token_id == UNSET_VALUE
  @api_token_secret = nil if @api_token_secret == UNSET_VALUE
  @vga = 'virtio' if @vga == UNSET_VALUE
  @insecure = false if @insecure == UNSET_VALUE
  @debug = false if @debug == UNSET_VALUE
  @vmname = nil if @vmname == UNSET_VALUE
  @template = nil if @template == UNSET_VALUE
  @disk_size = nil if @disk_size == UNSET_VALUE
  @storage_domain = nil if @storage_domain == UNSET_VALUE
  @cpu_cores = 1 if @cpu_cores == UNSET_VALUE
  @memory_size = '512 MiB' if @memory_size == UNSET_VALUE
  @target_node = nil if @target_node == UNSET_VALUE
  @onboot = false if @onboot == UNSET_VALUE
  @description = '' if @description == UNSET_VALUE
  @nameserver = '' if @nameserver == UNSET_VALUE
  @searchdomain = '' if @searchdomain == UNSET_VALUE
  @os_type = 'l26' if @os_type == UNSET_VALUE
  @full_clone = true if @full_clone == UNSET_VALUE
  @serial_port = false if @serial_port == UNSET_VALUE

  unless disk_size.nil?
    begin
      @disk_size = Filesize.from(@disk_size).to_f('B').to_i
    rescue ArgumentError
      raise "Not able to parse 'disk_size' #{@disk_size}."
    end
  end

  begin
    @memory_size = Filesize.from(@memory_size).to_f('B').to_i
  rescue ArgumentError
    raise "Not able to parse `memory_size`."
  end
end