Class: VagrantPlugins::Vultr::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::Vultr::Config
- Defined in:
- lib/vagrant-vultr/config.rb
Instance Attribute Summary collapse
-
#enable_ipv6 ⇒ Object
Returns the value of attribute enable_ipv6.
-
#enable_private_network ⇒ Object
Returns the value of attribute enable_private_network.
-
#hostname ⇒ Object
Returns the value of attribute hostname.
-
#label ⇒ Object
Returns the value of attribute label.
-
#os ⇒ Object
Returns the value of attribute os.
-
#plan ⇒ Object
Returns the value of attribute plan.
-
#region ⇒ Object
Returns the value of attribute region.
-
#snapshot ⇒ Object
Returns the value of attribute snapshot.
-
#ssh_key ⇒ Object
Returns the value of attribute ssh_key.
-
#startup_script ⇒ Object
Returns the value of attribute startup_script.
-
#tag ⇒ Object
Returns the value of attribute tag.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #finalize! ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #validate(machine) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/vagrant-vultr/config.rb', line 18 def initialize @token = UNSET_VALUE @region = UNSET_VALUE @os = UNSET_VALUE @snapshot = UNSET_VALUE @plan = UNSET_VALUE @enable_ipv6 = UNSET_VALUE @enable_private_network = UNSET_VALUE @label = UNSET_VALUE @tag = UNSET_VALUE @hostname = UNSET_VALUE @timeout = UNSET_VALUE @ssh_key = UNSET_VALUE @startup_script = UNSET_VALUE end |
Instance Attribute Details
#enable_ipv6 ⇒ Object
Returns the value of attribute enable_ipv6.
9 10 11 |
# File 'lib/vagrant-vultr/config.rb', line 9 def enable_ipv6 @enable_ipv6 end |
#enable_private_network ⇒ Object
Returns the value of attribute enable_private_network.
10 11 12 |
# File 'lib/vagrant-vultr/config.rb', line 10 def enable_private_network @enable_private_network end |
#hostname ⇒ Object
Returns the value of attribute hostname.
13 14 15 |
# File 'lib/vagrant-vultr/config.rb', line 13 def hostname @hostname end |
#label ⇒ Object
Returns the value of attribute label.
11 12 13 |
# File 'lib/vagrant-vultr/config.rb', line 11 def label @label end |
#os ⇒ Object
Returns the value of attribute os.
6 7 8 |
# File 'lib/vagrant-vultr/config.rb', line 6 def os @os end |
#plan ⇒ Object
Returns the value of attribute plan.
8 9 10 |
# File 'lib/vagrant-vultr/config.rb', line 8 def plan @plan end |
#region ⇒ Object
Returns the value of attribute region.
5 6 7 |
# File 'lib/vagrant-vultr/config.rb', line 5 def region @region end |
#snapshot ⇒ Object
Returns the value of attribute snapshot.
7 8 9 |
# File 'lib/vagrant-vultr/config.rb', line 7 def snapshot @snapshot end |
#ssh_key ⇒ Object
Returns the value of attribute ssh_key.
15 16 17 |
# File 'lib/vagrant-vultr/config.rb', line 15 def ssh_key @ssh_key end |
#startup_script ⇒ Object
Returns the value of attribute startup_script.
16 17 18 |
# File 'lib/vagrant-vultr/config.rb', line 16 def startup_script @startup_script end |
#tag ⇒ Object
Returns the value of attribute tag.
12 13 14 |
# File 'lib/vagrant-vultr/config.rb', line 12 def tag @tag end |
#timeout ⇒ Object
Returns the value of attribute timeout.
14 15 16 |
# File 'lib/vagrant-vultr/config.rb', line 14 def timeout @timeout end |
#token ⇒ Object
Returns the value of attribute token.
4 5 6 |
# File 'lib/vagrant-vultr/config.rb', line 4 def token @token end |
Instance Method Details
#finalize! ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/vagrant-vultr/config.rb', line 34 def finalize! @token = ENV['VULTR_TOKEN'] if @token == UNSET_VALUE @region = 'Seattle' if @region == UNSET_VALUE @os = 'Ubuntu 14.04 x64' if @os == UNSET_VALUE && @snapshot == UNSET_VALUE @plan = '768 MB RAM,15 GB SSD,1.00 TB BW' if @plan == UNSET_VALUE @snapshot = nil if @snapshot == UNSET_VALUE @enable_ipv6 = 'no' if @enable_ipv6 == UNSET_VALUE @enable_private_network = 'no' if @enable_private_network == UNSET_VALUE @label = '' if @label == UNSET_VALUE @tag = '' if @tag == UNSET_VALUE @hostname = '' if @hostname == UNSET_VALUE @script = '' if @script == UNSET_VALUE @timeout = 300 if @timeout == UNSET_VALUE @ssh_key = 'vagrant' if @ssh_key == UNSET_VALUE @startup_script = '' if @startup_script == UNSET_VALUE end |
#validate(machine) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/vagrant-vultr/config.rb', line 51 def validate(machine) errors = [] key = machine.config.ssh.private_key_path key = key.first if key.is_a?(Array) if !key errors << 'You have to specify config.ssh.private_key_path.' elsif !File.file?(File.("#{key}.pub", machine.env.root_path)) errors << "Cannot find SSH public key: #{key}.pub." end if both_os_and_snapshot_provided? errors << 'You have to specify one of provider.os or provider.snapshot.' end {'vultr' => errors} end |