Class: VagrantPlugins::Scaleway::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/vagrant-scaleway/config.rb', line 77

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
end

Instance Attribute Details

#bootscriptString

The bootscript ID. If nil, the default bootscript for the image will be used.

Returns:

  • (String)


8
9
10
# File 'lib/vagrant-scaleway/config.rb', line 8

def bootscript
  @bootscript
end

#commercial_typeString

The type of the server to launch, such as ‘C1’. Defaults to ‘C2S’.

Returns:

  • (String)


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

def commercial_type
  @commercial_type
end

#imageString

The image ID.

Returns:

  • (String)


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

def image
  @image
end

#nameString

The name of the server.

Returns:

  • (String)


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

def name
  @name
end

#organizationString

The organization ID. It can also be configured with SCW_ORGANIZATION environment variable.

Returns:

  • (String)


29
30
31
# File 'lib/vagrant-scaleway/config.rb', line 29

def organization
  @organization
end

#regionString

The name of the Scaleway region to create the server in. It can also be configured with SCW_REGION environment variable. Defaults to par1.

Returns:

  • (String)


35
36
37
# File 'lib/vagrant-scaleway/config.rb', line 35

def region
  @region
end

#security_groupString

The security group ID to associate with the server. If nil, organization’s default security group will be used.

Returns:

  • (String)


41
42
43
# File 'lib/vagrant-scaleway/config.rb', line 41

def security_group
  @security_group
end

#server_check_intervalFixnum

The interval to wait for checking a server’s state. Defaults to 2 seconds.

Returns:

  • (Fixnum)


47
48
49
# File 'lib/vagrant-scaleway/config.rb', line 47

def server_check_interval
  @server_check_interval
end

#server_ready_timeoutFixnum

The timeout to wait for a server to become ready. Defaults to 120 seconds.

Returns:

  • (Fixnum)


53
54
55
# File 'lib/vagrant-scaleway/config.rb', line 53

def server_ready_timeout
  @server_ready_timeout
end

#ssh_host_attributeSymbol

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.

Returns:

  • (Symbol)


64
65
66
# File 'lib/vagrant-scaleway/config.rb', line 64

def ssh_host_attribute
  @ssh_host_attribute
end

#tagsArray

Tags to apply to the server.

Returns:

  • (Array)


69
70
71
# File 'lib/vagrant-scaleway/config.rb', line 69

def tags
  @tags
end

#tokenString

The API token to access Scaleway. It can also be configured with SCW_TOKEN environment variable.

Returns:

  • (String)


75
76
77
# File 'lib/vagrant-scaleway/config.rb', line 75

def token
  @token
end

Instance Method Details

#finalize!Object



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/vagrant-scaleway/config.rb', line 92

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
end