Class: VagrantPlugins::Scaleway::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::Scaleway::Config
- Defined in:
- lib/vagrant-scaleway/config.rb
Instance Attribute Summary collapse
-
#bootscript ⇒ String
The bootscript ID.
-
#commercial_type ⇒ String
The type of the server to launch, such as ‘C1’.
-
#image ⇒ String
The image ID.
-
#name ⇒ String
The name of the server.
-
#organization ⇒ String
The organization ID.
-
#region ⇒ String
The name of the Scaleway region to create the server in.
-
#security_group ⇒ String
The security group ID to associate with the server.
-
#server_check_interval ⇒ Fixnum
The interval to wait for checking a server’s state.
-
#server_ready_timeout ⇒ Fixnum
The timeout to wait for a server to become ready.
-
#ssh_host_attribute ⇒ Symbol
Specifies which address to connect to with ssh.
-
#tags ⇒ Array<String>
Tags to apply to the server.
-
#token ⇒ String
The API token to access Scaleway.
-
#volumes ⇒ Array<Hash>
Volumes to be attached to the server.
Instance Method Summary collapse
- #finalize! ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/vagrant-scaleway/config.rb', line 82 def initialize @bootscript = UNSET_VALUE @commercial_type = UNSET_VALUE @image = UNSET_VALUE @name = UNSET_VALUE @organization = UNSET_VALUE @region = UNSET_VALUE @server_check_interval = UNSET_VALUE @server_ready_timeout = UNSET_VALUE @security_group = UNSET_VALUE @ssh_host_attribute = UNSET_VALUE @tags = [] @token = UNSET_VALUE @volumes = [] end |
Instance Attribute Details
#bootscript ⇒ String
The bootscript ID. If nil, the default bootscript for the image will be used.
8 9 10 |
# File 'lib/vagrant-scaleway/config.rb', line 8 def bootscript @bootscript end |
#commercial_type ⇒ String
The type of the server to launch, such as ‘C1’. Defaults to ‘C2S’.
13 14 15 |
# File 'lib/vagrant-scaleway/config.rb', line 13 def commercial_type @commercial_type end |
#image ⇒ String
The image ID.
18 19 20 |
# File 'lib/vagrant-scaleway/config.rb', line 18 def image @image end |
#name ⇒ String
The name of the server.
23 24 25 |
# File 'lib/vagrant-scaleway/config.rb', line 23 def name @name end |
#organization ⇒ String
The organization ID. It can also be configured with SCW_ORGANIZATION environment variable.
29 30 31 |
# File 'lib/vagrant-scaleway/config.rb', line 29 def organization @organization end |
#region ⇒ String
The name of the Scaleway region to create the server in. It can also be configured with SCW_REGION environment variable. Defaults to par1.
35 36 37 |
# File 'lib/vagrant-scaleway/config.rb', line 35 def region @region end |
#security_group ⇒ String
The security group ID to associate with the server. If nil, organization’s default security group will be used.
41 42 43 |
# File 'lib/vagrant-scaleway/config.rb', line 41 def security_group @security_group end |
#server_check_interval ⇒ Fixnum
The interval to wait for checking a server’s state. Defaults to 2 seconds.
47 48 49 |
# File 'lib/vagrant-scaleway/config.rb', line 47 def server_check_interval @server_check_interval end |
#server_ready_timeout ⇒ Fixnum
The timeout to wait for a server to become ready. Defaults to 120 seconds.
53 54 55 |
# File 'lib/vagrant-scaleway/config.rb', line 53 def server_ready_timeout @server_ready_timeout end |
#ssh_host_attribute ⇒ Symbol
Specifies which address to connect to with ssh. Must be one of:
- :public_ip_address
- :public_dns_name
- :private_ip_address
- :private_dns_name
This attribute also accepts an array of symbols.
64 65 66 |
# File 'lib/vagrant-scaleway/config.rb', line 64 def ssh_host_attribute @ssh_host_attribute end |
#tags ⇒ Array<String>
Tags to apply to the server.
69 70 71 |
# File 'lib/vagrant-scaleway/config.rb', line 69 def @tags end |
#token ⇒ String
The API token to access Scaleway. It can also be configured with SCW_TOKEN environment variable.
75 76 77 |
# File 'lib/vagrant-scaleway/config.rb', line 75 def token @token end |
#volumes ⇒ Array<Hash>
Volumes to be attached to the server.
80 81 82 |
# File 'lib/vagrant-scaleway/config.rb', line 80 def volumes @volumes end |
Instance Method Details
#finalize! ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/vagrant-scaleway/config.rb', line 98 def finalize! @bootscript = nil if @bootscript == UNSET_VALUE @commercial_type = 'C2S' if @commercial_type == UNSET_VALUE @image = '75c28f52-6c64-40fc-bb31-f53ca9d02de9' if @image == UNSET_VALUE if @name == UNSET_VALUE require 'securerandom' @name = "scw-#{SecureRandom.hex(3)}" end @organization = ENV['SCW_ORGANIZATION'] if @organization == UNSET_VALUE @region = (ENV['SCW_REGION'] || 'par1') if @region == UNSET_VALUE @server_check_interval = 2 if @server_check_interval == UNSET_VALUE @server_ready_timeout = 120 if @server_ready_timeout == UNSET_VALUE @security_group = nil if @security_group == UNSET_VALUE @ssh_host_attribute = nil if @ssh_host_attribute == UNSET_VALUE @token = ENV['SCW_TOKEN'] if @token == UNSET_VALUE @volumes = @volumes.map do |volume| if volume.key?(:id) { name: 'volume' }.merge(volume) else { name: 'volume', volume_type: 'l_ssd', organization: @organization }.merge(volume) end end end |