Class: VagrantPlugins::GANETI::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/vagrant-ganeti/config.rb', line 158

def initialize()
  @rapi_user    	= UNSET_VALUE
  @rapi_pass 	= UNSET_VALUE
	@cluster        = UNSET_VALUE
  @version     	= 2
  @os_type      	= UNSET_VALUE
	@disk_template 	= UNSET_VALUE
	@disks 		= UNSET_VALUE
	@instance_name 	= UNSET_VALUE
	@mode		= UNSET_VALUE
	@nics 		= UNSET_VALUE
	@pnode 		= UNSET_VALUE
	@snode 		= UNSET_VALUE
	@iallocator 	= UNSET_VALUE
	@memory 	= UNSET_VALUE
	@vcpus 		= UNSET_VALUE
	@ip_check 	= UNSET_VALUE
	@name_check 	= UNSET_VALUE
	@boot_order 	= UNSET_VALUE
	@cdrom_image_path = UNSET_VALUE
	@nic_type	= UNSET_VALUE
	@disk_type	= UNSET_VALUE
	@cpu_type	= UNSET_VALUE
	@kernel_path 	= UNSET_VALUE
	@kernel_args 	= UNSET_VALUE
	@initrd_path	= UNSET_VALUE
	@root_path	= UNSET_VALUE
	@serial_console	= UNSET_VALUE
	@kvm_flag 	= UNSET_VALUE
  @__finalized 	= false
end

Instance Attribute Details

#boot_orderString

hvparam Configs

Returns:

  • (String)


106
107
108
# File 'lib/vagrant-ganeti/config.rb', line 106

def boot_order
  @boot_order
end

#cdrom_image_pathString

hvparam Configs

Returns:

  • (String)


111
112
113
# File 'lib/vagrant-ganeti/config.rb', line 111

def cdrom_image_path
  @cdrom_image_path
end

#clusterString

The Host Detail

Returns:

  • (String)


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

def cluster
  @cluster
end

#cpu_typeString

hvparam Configs

Returns:

  • (String)


126
127
128
# File 'lib/vagrant-ganeti/config.rb', line 126

def cpu_type
  @cpu_type
end

#disk_templateString

The name of the OS to use.

Returns:

  • (String)


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

def disk_template
  @disk_template
end

#disk_typeString

hvparam Configs

Returns:

  • (String)


121
122
123
# File 'lib/vagrant-ganeti/config.rb', line 121

def disk_type
  @disk_type
end

#disks{hash }

An array of hash of disk sizes

Returns:

  • ({hash })


46
47
48
# File 'lib/vagrant-ganeti/config.rb', line 46

def disks
  @disks
end

#hvparamString

hvparam Configs

Returns:

  • (String)


101
102
103
# File 'lib/vagrant-ganeti/config.rb', line 101

def hvparam
  @hvparam
end

#iallocatorString

The name of the Iallocatoy

Returns:

  • (String)


76
77
78
# File 'lib/vagrant-ganeti/config.rb', line 76

def iallocator
  @iallocator
end

#initrd_pathString

hvparam Configs

Returns:

  • (String)


141
142
143
# File 'lib/vagrant-ganeti/config.rb', line 141

def initrd_path
  @initrd_path
end

#instance_nameString

The name of the Instance

Returns:

  • (String)


51
52
53
# File 'lib/vagrant-ganeti/config.rb', line 51

def instance_name
  @instance_name
end

#instance_ready_timeoutFixnum

The timeout to wait for an instance to become ready.

Returns:

  • (Fixnum)


24
25
26
# File 'lib/vagrant-ganeti/config.rb', line 24

def instance_ready_timeout
  @instance_ready_timeout
end

#ip_checkBoolean

IP Check configuration

Returns:

  • (Boolean)


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

def ip_check
  @ip_check
end

#kernel_argsString

hvparam Configs

Returns:

  • (String)


136
137
138
# File 'lib/vagrant-ganeti/config.rb', line 136

def kernel_args
  @kernel_args
end

#kernel_pathString

hvparam Configs

Returns:

  • (String)


131
132
133
# File 'lib/vagrant-ganeti/config.rb', line 131

def kernel_path
  @kernel_path
end

#kvm_flagString

hvparam Configs

Returns:

  • (String)


156
157
158
# File 'lib/vagrant-ganeti/config.rb', line 156

def kvm_flag
  @kvm_flag
end

#memoryString

Memory Configurations in MB’s

Returns:

  • (String)


81
82
83
# File 'lib/vagrant-ganeti/config.rb', line 81

def memory
  @memory
end

#modeString

Mode of Creation

Returns:

  • (String)


56
57
58
# File 'lib/vagrant-ganeti/config.rb', line 56

def mode
  @mode
end

#name_checkBoolean

Name Check

Returns:

  • (Boolean)


91
92
93
# File 'lib/vagrant-ganeti/config.rb', line 91

def name_check
  @name_check
end

#nic_typeString

hvparam Configs

Returns:

  • (String)


116
117
118
# File 'lib/vagrant-ganeti/config.rb', line 116

def nic_type
  @nic_type
end

#nics{hash}

Network Configurations

Returns:

  • ({hash})


61
62
63
# File 'lib/vagrant-ganeti/config.rb', line 61

def nics
  @nics
end

#os_typeString

The name of the OS to use.

Returns:

  • (String)


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

def os_type
  @os_type
end

#pnodeString

The name of the Primary Node

Returns:

  • (String)


66
67
68
# File 'lib/vagrant-ganeti/config.rb', line 66

def pnode
  @pnode
end

#rapi_passString

The password for accessing GANETI.

Returns:

  • (String)


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

def rapi_pass
  @rapi_pass
end

#rapi_userString

The username for accessing GANETI.

Returns:

  • (String)


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

def rapi_user
  @rapi_user
end

#root_pathString

hvparam Configs

Returns:

  • (String)


146
147
148
# File 'lib/vagrant-ganeti/config.rb', line 146

def root_path
  @root_path
end

#serial_consoleString

hvparam Configs

Returns:

  • (String)


151
152
153
# File 'lib/vagrant-ganeti/config.rb', line 151

def serial_console
  @serial_console
end

#snodeString

The name of the Secondary Node for DRBD template

Returns:

  • (String)


71
72
73
# File 'lib/vagrant-ganeti/config.rb', line 71

def snode
  @snode
end

#vcpusString

VCPU configuration

Returns:

  • (String)


86
87
88
# File 'lib/vagrant-ganeti/config.rb', line 86

def vcpus
  @vcpus
end

#versionString

The version of the GANETI api to use

Returns:

  • (String)


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

def version
  @version
end

Instance Method Details

#finalize!Object



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# File 'lib/vagrant-ganeti/config.rb', line 190

def finalize!
  # Username and password for the Ganei RAPI must be set .
  @rapi_user     = nil if @rapi_user   == UNSET_VALUE
  @rapi_pass = nil  if @rapi_pass == UNSET_VALUE

  # host must be nil, since we can't default that
  @cluster = nil if @cluster == UNSET_VALUE

  # OS_NAME must be nil, since we can't default that
  @os_type = nil if @os_type == UNSET_VALUE

  # disk_template since we can't default that
  @disk_template = "plain" if @disk_template == UNSET_VALUE

  # disks must be nil, since we can't default that
  @disks = [{"size"=>"8000"}]  if @disks == UNSET_VALUE

  # instance_name must be nil, since we can't default that
  @instance_name = nil if @instance_name == UNSET_VALUE

  # mode must be nil, since we can't default that
  @mode = "create" if @mode == UNSET_VALUE

  # nics must be nil, since we can't default that
  @nics = nil if @nics == UNSET_VALUE

  # pnode must be nil, since we can't default that
  @pnode = nil if @pnode == UNSET_VALUE
  
	# snode must be nil, since we can't default that
  @snode = nil if @snode == UNSET_VALUE

  # iallocator Get default from ganeti cluster
  @iallocator = "__DEFAULT__" if @iallocator == UNSET_VALUE

  # memory must be nil, since we can't default that
  @memory = nil if @memory == UNSET_VALUE

  # vcpu must be nil, since we can't default that
  @vcpus = nil if @vcpus == UNSET_VALUE
	
  # ip_check defaults to True
  @ip_check = true if @ip_check == UNSET_VALUE

  # name_check defaults to True
  @name_check = true if @name_check == UNSET_VALUE
	
  # boot_order defaults to Nil
  @boot_order = nil if @boot_order == UNSET_VALUE
	
  # cdrom_image_path to Nil
  @cdrom_image_path= nil if @cdrom_image_path == UNSET_VALUE
	
  # nic_type defaults to nil
  @nic_type = nil if @nic_type == UNSET_VALUE
	
  # disk_type defaults to nil
  @disk_type = nil if @disk_type == UNSET_VALUE
	
  # cpu_type defaults to nil
  @cpu_type = nil if @cpu_type == UNSET_VALUE
		
  # kernel_path defaults to nil
  @kernel_path = nil if @kernel_path == UNSET_VALUE
  
	# kernel_args defaults to nil
  @kernel_args = nil if @kernel_args == UNSET_VALUE
  
  
	# initrd_path defaults to nil
  @initrd_path = nil if @initrd_path == UNSET_VALUE
	
	# root_path_path defaults to nil
  @root_path = nil if @root_path == UNSET_VALUE
	
	# serial_console defaults to nil
  @serial_console = nil if @serial_console == UNSET_VALUE

	# kvm_flag defaults to nil
  @kvm_flag = nil if @kvm_flag == UNSET_VALUE
	
	# Set the default timeout for waiting for an instance to be ready
  @instance_ready_timeout = 120 if @instance_ready_timeout == UNSET_VALUE

  @version = nil if @version == UNSET_VALUE

  
  # Mark that we finalized
  @__finalized = true
end

#get_configObject



298
299
300
301
302
303
304
# File 'lib/vagrant-ganeti/config.rb', line 298

def get_config()
  if !@__finalized
    raise "Configuration must be finalized before calling this method."
  end

  self
end

#validate(machine) ⇒ Object



282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/vagrant-ganeti/config.rb', line 282

def validate(machine)
  errors = _detected_errors

  errors << I18n.t("vagrant_ganeti.config.username_required") if @rapi_user.nil?
  errors << I18n.t("vagrant_ganeti.config.password_required") if @rapi_pass.nil?
	errors << I18n.t("vagrant_ganeti.config.host_required") if @cluster.nil?
	errors << I18n.t("vagrant_ganeti.config.os_name_required") if @os_type.nil?
	errors << I18n.t("vagrant_ganeti.config.disk_template_required") if @disk_template.nil?
  errors << I18n.t("vagrant_ganeti.config.disks_required") if @disks == nil
	errors << I18n.t("vagrant_ganeti.config.instance_name_required") if @instance_name.nil?
  errors << I18n.t("vagrant_ganeti.config.mode_required") if @mode.nil?
	errors << I18n.t("vagrant_ganeti.config.pnode_required") if @pnode.nil? and  @iallocator.nil?
	errors << I18n.t("vagrant_ganeti.config.snode_required") if @snode.nil? and  @disk_template == "drbd" and @iallocator.nil?
   	{ "GANETI Provider" => errors }

end