Class: VagrantPlugins::Rimu::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::Rimu::Config
- Defined in:
- lib/vagrant-rimu/config.rb
Instance Attribute Summary collapse
-
#api_key ⇒ String
The API key for accessing Rimu.
-
#api_url ⇒ String
Rimu api url.
-
#billing_id ⇒ Fixnum
Set the billing id if you want to control how it is billed.
-
#control_panel ⇒ String
The control panel to install on the VPS.
-
#data_centre ⇒ String
Rimu data_centre DCDALLAS | DCLONDON | DCSYDNEY | DCBRISBANE | DCAUCKLAND | DCFRANKFURT.
-
#disk_space_2_mb ⇒ Fixnum
File system image size on secondary partition in MB Mostly not used.
-
#disk_space_mb ⇒ Fixnum
File system image size on primary partition in MB.
-
#distro_code ⇒ String
Rimu distribution to install.
-
#extra_ip_reason ⇒ String
The reason for requiring more than one IP address.
-
#host_name ⇒ String
The label you want to give the server.
-
#host_server_id ⇒ Fixnum
The host server on which to setup the server.
-
#memory_mb ⇒ Fixnum
Memory size in MB.
-
#minimal_init ⇒ bool
Do minimal setup work.
-
#num_ips ⇒ Fixnum
How many IPs you need.
-
#private_ips ⇒ String
This option is often used for customers wanting to setup a VPS with private IPs.
-
#root_password ⇒ String
The password to use when setting up the server.
-
#setup ⇒ Object
(also: #setup?)
Returns the value of attribute setup.
-
#vps_to_clone ⇒ Fixnum
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.
-
#vps_type ⇒ String
You can specify a vps_type LOW_CONTENTION | REGULAR | DEDICATED.
Instance Method Summary collapse
-
#finalize! ⇒ Object
rubocop:disable Metrics/AbcSize.
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #validate(machine) ⇒ Object
Constructor Details
#initialize ⇒ Config
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_key ⇒ String
The API key for accessing Rimu.
9 10 11 |
# File 'lib/vagrant-rimu/config.rb', line 9 def api_key @api_key end |
#api_url ⇒ String
Rimu api url.
14 15 16 |
# File 'lib/vagrant-rimu/config.rb', line 14 def api_url @api_url end |
#billing_id ⇒ Fixnum
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.
96 97 98 |
# File 'lib/vagrant-rimu/config.rb', line 96 def billing_id @billing_id end |
#control_panel ⇒ String
The control panel to install on the VPS. Currently only webmin is supported
65 66 67 |
# File 'lib/vagrant-rimu/config.rb', line 65 def control_panel @control_panel end |
#data_centre ⇒ String
Rimu data_centre DCDALLAS | DCLONDON | DCSYDNEY | DCBRISBANE | DCAUCKLAND | DCFRANKFURT
25 26 27 |
# File 'lib/vagrant-rimu/config.rb', line 25 def data_centre @data_centre end |
#disk_space_2_mb ⇒ Fixnum
File system image size on secondary partition in MB Mostly not used.
36 37 38 |
# File 'lib/vagrant-rimu/config.rb', line 36 def disk_space_2_mb @disk_space_2_mb end |
#disk_space_mb ⇒ Fixnum
File system image size on primary partition in MB
30 31 32 |
# File 'lib/vagrant-rimu/config.rb', line 30 def disk_space_mb @disk_space_mb end |
#distro_code ⇒ String
Rimu distribution to install
19 20 21 |
# File 'lib/vagrant-rimu/config.rb', line 19 def distro_code @distro_code end |
#extra_ip_reason ⇒ String
The reason for requiring more than one IP address. The number of IP addresses will be limited.
78 79 80 |
# File 'lib/vagrant-rimu/config.rb', line 78 def extra_ip_reason @extra_ip_reason end |
#host_name ⇒ String
The label you want to give the server. It will need to be a fully qualified domain name (FQDN).
53 54 55 |
# File 'lib/vagrant-rimu/config.rb', line 53 def host_name @host_name end |
#host_server_id ⇒ Fixnum
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.
107 108 109 |
# File 'lib/vagrant-rimu/config.rb', line 107 def host_server_id @host_server_id end |
#memory_mb ⇒ Fixnum
Memory size in MB
41 42 43 |
# File 'lib/vagrant-rimu/config.rb', line 41 def memory_mb @memory_mb end |
#minimal_init ⇒ bool
Do minimal setup work.
112 113 114 |
# File 'lib/vagrant-rimu/config.rb', line 112 def minimal_init @minimal_init end |
#num_ips ⇒ Fixnum
How many IPs you need. Typically 1.
83 84 85 |
# File 'lib/vagrant-rimu/config.rb', line 83 def num_ips @num_ips end |
#private_ips ⇒ String
This option is often used for customers wanting to setup a VPS with private IPs
89 90 91 |
# File 'lib/vagrant-rimu/config.rb', line 89 def private_ips @private_ips end |
#root_password ⇒ String
The password to use when setting up the server. If not provided, a random one will be set.
59 60 61 |
# File 'lib/vagrant-rimu/config.rb', line 59 def root_password @root_password end |
#setup ⇒ Object 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_clone ⇒ Fixnum
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.
72 73 74 |
# File 'lib/vagrant-rimu/config.rb', line 72 def vps_to_clone @vps_to_clone end |
#vps_type ⇒ String
You can specify a vps_type LOW_CONTENTION | REGULAR | DEDICATED
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.("#{key}", machine.env.root_path)) errors << I18n.t('vagrant_rimu.config.missing_private_key', key: "#{key}") else if !File.file?(File.("#{key}.pub", machine.env.root_path)) errors << I18n.t('vagrant_rimu.config.public_key', key: "#{key}.pub") end end end { 'Rimu Provider' => errors } end |