Class: VagrantPlugins::ProviderIijGp::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/vagrant-iijgp/config.rb', line 24

def initialize
  @endpoint = UNSET_VALUE
  @access_key = UNSET_VALUE
  @secret_key = UNSET_VALUE
  @gp_service_code = UNSET_VALUE
  @gc_service_code = UNSET_VALUE
  @virtual_machine_type = UNSET_VALUE
  @os = UNSET_VALUE
  @ssh_public_key = UNSET_VALUE
  @label = UNSET_VALUE
  @vagrant_tweaks = UNSET_VALUE
  @api_max_retry_count = UNSET_VALUE
  @api_retry_wait = UNSET_VALUE
end

Instance Attribute Details

#access_keyObject

Returns the value of attribute access_key.



6
7
8
# File 'lib/vagrant-iijgp/config.rb', line 6

def access_key
  @access_key
end

#api_max_retry_countObject

Returns the value of attribute api_max_retry_count.



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

def api_max_retry_count
  @api_max_retry_count
end

#api_retry_waitObject

Returns the value of attribute api_retry_wait.



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

def api_retry_wait
  @api_retry_wait
end

#endpointObject

Returns the value of attribute endpoint.



4
5
6
# File 'lib/vagrant-iijgp/config.rb', line 4

def endpoint
  @endpoint
end

#gc_service_codeObject

Returns the value of attribute gc_service_code.



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

def gc_service_code
  @gc_service_code
end

#gp_service_codeObject

Returns the value of attribute gp_service_code.



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

def gp_service_code
  @gp_service_code
end

#labelObject

Returns the value of attribute label.



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

def label
  @label
end

#osObject

Returns the value of attribute os.



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

def os
  @os
end

#secret_keyObject

Returns the value of attribute secret_key.



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

def secret_key
  @secret_key
end

#ssh_public_keyObject

Returns the value of attribute ssh_public_key.



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

def ssh_public_key
  @ssh_public_key
end

#vagrant_tweaksObject

Returns the value of attribute vagrant_tweaks.



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

def vagrant_tweaks
  @vagrant_tweaks
end

#virtual_machine_typeObject

Returns the value of attribute virtual_machine_type.



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

def virtual_machine_type
  @virtual_machine_type
end

Instance Method Details

#finalize!Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/vagrant-iijgp/config.rb', line 39

def finalize!
  @endpoint = nil if @endpoint == UNSET_VALUE
  @access_key = ENV['IIJAPI_ACCESS_KEY'] if @access_key == UNSET_VALUE
  @secret_key = ENV['IIJAPI_SECRET_KEY'] if @secret_key == UNSET_VALUE

  @gc_service_code = nil if @gc_service_code == UNSET_VALUE

  @virtual_machine_type = 'V10' if @virtual_machine_type == UNSET_VALUE
  @os = 'CentOS6_64_U' if @os == UNSET_VALUE
  @ssh_public_key = nil if @ssh_public_key == UNSET_VALUE
  @label = nil if @label == UNSET_VALUE
  @vagrant_tweaks = :allow_root_notty_sudo if @vagrant_tweaks == UNSET_VALUE
  @api_max_retry_count = 10 if @api_max_retry_count == UNSET_VALUE
  @api_retry_wait = 60 if @api_retry_wait == UNSET_VALUE
end

#validate(machine) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/vagrant-iijgp/config.rb', line 55

def validate(machine)
  errors = _detected_errors

  unless @access_key
    errors << I18n.t("vagrant_iijgp.config.access_key_is_required")
  end

  unless @secret_key
    errors << I18n.t("vagrant_iijgp.config.secret_key_is_required")
  end

  unless @ssh_public_key
    errors << I18n.t("vagrant_iijgp.config.ssh_public_key_is_required")
  end

  if @gp_service_code.nil? or @gp_service_code == UNSET_VALUE
    errors << I18n.t("vagrant_iijgp.config.gp_service_code_is_required")
  end

  { "IIJ GP Provider" => errors }
end