Class: VagrantPlugins::Rimu::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/vagrant-rimu/config.rb', line 118

def initialize
  @api_key = UNSET_VALUE
  @api_url = UNSET_VALUE
  @distro_code = UNSET_VALUE
  @setup = UNSET_VALUE
  @disk_space_mb = UNSET_VALUE
  @disk_space_2_mb = UNSET_VALUE
  @memory_mb = UNSET_VALUE
  @vps_type = UNSET_VALUE
  @host_name = UNSET_VALUE
  @root_password = UNSET_VALUE
  @control_panel = UNSET_VALUE
  @vps_to_clone = UNSET_VALUE
  @extra_ip_reason = UNSET_VALUE
  @num_ips = UNSET_VALUE
  @private_ips = UNSET_VALUE
  @billing_id = UNSET_VALUE
  @host_server_id = UNSET_VALUE
  @minimal_init = UNSET_VALUE
  @data_centre = UNSET_VALUE
end

Instance Attribute Details

#api_keyString

The API key for accessing Rimu.

Returns:

  • (String)


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

def api_key
  @api_key
end

#api_urlString

Rimu api url.

Returns:

  • (String)


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

def api_url
  @api_url
end

#billing_idFixnum

Set the billing id if you want to control how it is billed. run ‘vagrant rimu billing-methods` to find what billing methods/ids you have setup on your account.

Returns:

  • (Fixnum)


96
97
98
# File 'lib/vagrant-rimu/config.rb', line 96

def billing_id
  @billing_id
end

#control_panelString

The control panel to install on the VPS. Currently only webmin is supported

Returns:

  • (String)


65
66
67
# File 'lib/vagrant-rimu/config.rb', line 65

def control_panel
  @control_panel
end

#data_centreString

Rimu data_centre DCDALLAS | DCLONDON | DCSYDNEY | DCBRISBANE | DCAUCKLAND | DCFRANKFURT

Returns:

  • (String)


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

def data_centre
  @data_centre
end

#disk_space_2_mbFixnum

File system image size on secondary partition in MB Mostly not used.

Returns:

  • (Fixnum)


36
37
38
# File 'lib/vagrant-rimu/config.rb', line 36

def disk_space_2_mb
  @disk_space_2_mb
end

#disk_space_mbFixnum

File system image size on primary partition in MB

Returns:

  • (Fixnum)


30
31
32
# File 'lib/vagrant-rimu/config.rb', line 30

def disk_space_mb
  @disk_space_mb
end

#distro_codeString

Rimu distribution to install

Returns:

  • (String)


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

def distro_code
  @distro_code
end

#extra_ip_reasonString

The reason for requiring more than one IP address. The number of IP addresses will be limited.

Returns:

  • (String)


78
79
80
# File 'lib/vagrant-rimu/config.rb', line 78

def extra_ip_reason
  @extra_ip_reason
end

#host_nameString

The label you want to give the server. It will need to be a fully qualified domain name (FQDN).

Returns:

  • (String)


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

def host_name
  @host_name
end

#host_server_idFixnum

The host server on which to setup the server. Typically you will want to leave this blank and let the API decide what is best/available.

An exception may be if you are a customer with a dedicated server that is a VPS host. And in that case you may want to force a VPS to be setup on a particular server of yours.

Returns:

  • (Fixnum)


107
108
109
# File 'lib/vagrant-rimu/config.rb', line 107

def host_server_id
  @host_server_id
end

#memory_mbFixnum

Memory size in MB

Returns:

  • (Fixnum)


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

def memory_mb
  @memory_mb
end

#minimal_initbool

Do minimal setup work.

Returns:

  • (bool)


112
113
114
# File 'lib/vagrant-rimu/config.rb', line 112

def minimal_init
  @minimal_init
end

#num_ipsFixnum

How many IPs you need. Typically 1.

Returns:

  • (Fixnum)


83
84
85
# File 'lib/vagrant-rimu/config.rb', line 83

def num_ips
  @num_ips
end

#private_ipsString

This option is often used for customers wanting to setup a VPS with private IPs

Returns:

  • (String)


89
90
91
# File 'lib/vagrant-rimu/config.rb', line 89

def private_ips
  @private_ips
end

#root_passwordString

The password to use when setting up the server. If not provided, a random one will be set.

Returns:

  • (String)


59
60
61
# File 'lib/vagrant-rimu/config.rb', line 59

def root_password
  @root_password
end

#setupObject Also known as: setup?

Returns the value of attribute setup.



114
115
116
# File 'lib/vagrant-rimu/config.rb', line 114

def setup
  @setup
end

#vps_to_cloneFixnum

Set this if you want the newly setup VPS to be a clone of another VPS The clone source VPS will be paused for a few seconds to a few minutes to take the snapshot.

Returns:

  • (Fixnum)


72
73
74
# File 'lib/vagrant-rimu/config.rb', line 72

def vps_to_clone
  @vps_to_clone
end

#vps_typeString

You can specify a vps_type LOW_CONTENTION | REGULAR | DEDICATED

Returns:

  • (String)


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

def vps_type
  @vps_type
end

Instance Method Details

#finalize!Object

rubocop:disable Metrics/AbcSize



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/vagrant-rimu/config.rb', line 141

def finalize!
  @api_key = ENV['RIMU_API_KEY'] if @api_key == UNSET_VALUE
  @api_url = ENV['RIMU_URL'] if @api_url == UNSET_VALUE
  @distro_code = "centos6.64" if @distro_code == UNSET_VALUE
  @disk_space_mb = 20000 if @disk_space_mb == UNSET_VALUE
  # @disk_space_mb = @disk_space_mb.to_i if @disk_space_mb.kind_of? String
  @disk_space_2_mb = nil if @disk_space_2_mb == UNSET_VALUE
  # @disk_space_2_mb = @disk_space_2_mb.to_i if @disk_space_2_mb.kind_of? String
  @memory_mb = 1024 if @memory_mb == UNSET_VALUE
  # @memory_mb = @memory_mb.to_i if @memory_mb.kind_of? String
  @vps_type = nil if @vps_type == UNSET_VALUE
  @host_name = nil if @host_name == UNSET_VALUE
  @root_password = nil if @root_password == UNSET_VALUE
  @control_panel = nil if @control_panel == UNSET_VALUE
  @vps_to_clone = nil if @vps_to_clone == UNSET_VALUE
  @extra_ip_reason = nil if @extra_ip_reason == UNSET_VALUE
  @num_ips = nil if @num_ips == UNSET_VALUE
  @private_ips = nil if @private_ips == UNSET_VALUE
  @billing_id = nil if @billing_id == UNSET_VALUE
  @host_server_id = nil if @host_server_id == UNSET_VALUE
  @minimal_init = nil if @minimal_init == UNSET_VALUE
  @data_centre = nil if @data_centre == UNSET_VALUE
  @setup = true if @setup == UNSET_VALUE
end

#validate(machine) ⇒ Object



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/vagrant-rimu/config.rb', line 166

def validate(machine)
  errors = []
  errors << I18n.t('vagrant_rimu.config.api_key') unless @api_key
  errors << I18n.t('vagrant_rimu.config.host_name') unless @host_name
  if @host_name
    errors << I18n.t('vagrant_rimu.config.invalid_host_name', {:host_name => @host_name}) \
      unless @host_name.match(/\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/)
  end

  key = machine.config.ssh.private_key_path
  key = key[0] if key.is_a?(Array)
  if !key
    errors << I18n.t('vagrant_rimu.config.private_key')
  else
    if !File.file?(File.expand_path("#{key}", machine.env.root_path))
      errors << I18n.t('vagrant_rimu.config.missing_private_key', key: "#{key}")
    else
      if !File.file?(File.expand_path("#{key}.pub", machine.env.root_path))
        errors << I18n.t('vagrant_rimu.config.public_key', key: "#{key}.pub")
      end
    end
  end

  { 'Rimu Provider' => errors }
end