Class: VagrantPlugins::OpenNebulaProvider::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::OpenNebulaProvider::Config
- Defined in:
- lib/opennebula-provider/config.rb
Instance Attribute Summary collapse
-
#auth ⇒ Object
Returns the value of attribute auth.
-
#cpu ⇒ Object
Returns the value of attribute cpu.
-
#disk_size ⇒ Object
Returns the value of attribute disk_size.
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#memory ⇒ Object
Returns the value of attribute memory.
-
#os_tpl ⇒ Object
Returns the value of attribute os_tpl.
-
#password ⇒ Object
Returns the value of attribute password.
-
#resource_tpl ⇒ Object
Returns the value of attribute resource_tpl.
-
#template ⇒ Object
Returns the value of attribute template.
-
#template_id ⇒ Object
Returns the value of attribute template_id.
-
#template_name ⇒ Object
Returns the value of attribute template_name.
-
#title ⇒ Object
Returns the value of attribute title.
-
#user_variables ⇒ Object
Returns the value of attribute user_variables.
-
#username ⇒ Object
Returns the value of attribute username.
-
#vcpu ⇒ Object
Returns the value of attribute vcpu.
Instance Method Summary collapse
- #finalize! ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #validate(machine) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/opennebula-provider/config.rb', line 20 def initialize @endpoint = ENV['ONE_XMLRPC'] || ENV['ONE_ENDPOINT'] || UNSET_VALUE @auth = UNSET_VALUE @username = ENV['ONE_USER'] || UNSET_VALUE @password = ENV['ONE_PASSWORD'] || UNSET_VALUE @template_id = UNSET_VALUE @template_name = UNSET_VALUE @os_tpl = UNSET_VALUE @resource_tpl = UNSET_VALUE @title = UNSET_VALUE @memory = UNSET_VALUE @cpu = UNSET_VALUE @vcpu = UNSET_VALUE @disk_size = UNSET_VALUE @user_variables = UNSET_VALUE end |
Instance Attribute Details
#auth ⇒ Object
Returns the value of attribute auth.
5 6 7 |
# File 'lib/opennebula-provider/config.rb', line 5 def auth @auth end |
#cpu ⇒ Object
Returns the value of attribute cpu.
15 16 17 |
# File 'lib/opennebula-provider/config.rb', line 15 def cpu @cpu end |
#disk_size ⇒ Object
Returns the value of attribute disk_size.
17 18 19 |
# File 'lib/opennebula-provider/config.rb', line 17 def disk_size @disk_size end |
#endpoint ⇒ Object
Returns the value of attribute endpoint.
4 5 6 |
# File 'lib/opennebula-provider/config.rb', line 4 def endpoint @endpoint end |
#memory ⇒ Object
Returns the value of attribute memory.
14 15 16 |
# File 'lib/opennebula-provider/config.rb', line 14 def memory @memory end |
#os_tpl ⇒ Object
Returns the value of attribute os_tpl.
11 12 13 |
# File 'lib/opennebula-provider/config.rb', line 11 def os_tpl @os_tpl end |
#password ⇒ Object
Returns the value of attribute password.
7 8 9 |
# File 'lib/opennebula-provider/config.rb', line 7 def password @password end |
#resource_tpl ⇒ Object
Returns the value of attribute resource_tpl.
12 13 14 |
# File 'lib/opennebula-provider/config.rb', line 12 def resource_tpl @resource_tpl end |
#template ⇒ Object
Returns the value of attribute template.
8 9 10 |
# File 'lib/opennebula-provider/config.rb', line 8 def template @template end |
#template_id ⇒ Object
Returns the value of attribute template_id.
9 10 11 |
# File 'lib/opennebula-provider/config.rb', line 9 def template_id @template_id end |
#template_name ⇒ Object
Returns the value of attribute template_name.
10 11 12 |
# File 'lib/opennebula-provider/config.rb', line 10 def template_name @template_name end |
#title ⇒ Object
Returns the value of attribute title.
13 14 15 |
# File 'lib/opennebula-provider/config.rb', line 13 def title @title end |
#user_variables ⇒ Object
Returns the value of attribute user_variables.
18 19 20 |
# File 'lib/opennebula-provider/config.rb', line 18 def user_variables @user_variables end |
#username ⇒ Object
Returns the value of attribute username.
6 7 8 |
# File 'lib/opennebula-provider/config.rb', line 6 def username @username end |
#vcpu ⇒ Object
Returns the value of attribute vcpu.
16 17 18 |
# File 'lib/opennebula-provider/config.rb', line 16 def vcpu @vcpu end |
Instance Method Details
#finalize! ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/opennebula-provider/config.rb', line 37 def finalize! @endpoint = nil if @endpoint == UNSET_VALUE || @endpoint.empty? @auth = 'basic' if @auth == UNSET_VALUE @username = nil if @username == UNSET_VALUE @password = nil if @password == UNSET_VALUE @template_id = nil if @template_id == UNSET_VALUE @template_name = nil if @template_name == UNSET_VALUE if @template_id @template = @template_id elsif @template_name @template = @template_name elsif @template == UNSET_VALUE @template = nil end @resource_tpl = 'small' if @resource_tpl == UNSET_VALUE @title = nil if @title == UNSET_VALUE @memory = nil if @memory == UNSET_VALUE @vcpu = nil if @vcpu == UNSET_VALUE @cpu = nil if @cpu == UNSET_VALUE if @cpu && ! @vcpu @vcpu = @cpu end @disk_size = nil if @disk_size == UNSET_VALUE @user_variables = nil if @user_variables == UNSET_VALUE end |
#validate(machine) ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/opennebula-provider/config.rb', line 63 def validate(machine) errors = [] errors << I18n.t('opennebula_provider.config.endpoint') unless @endpoint errors << I18n.t('opennebula_provider.config.username') unless @username errors << I18n.t('opennebula_provider.config.password') unless @password errors << I18n.t('opennebula_provider.config.template') unless @template errors << I18n.t('opennebula_provider.config.title') unless @title { 'OpenNebula provider' => errors } end |