Class: VagrantPlugins::ArubaCloud::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/vagrant-arubacloud/config.rb', line 86

def initialize
  @arubacloud_username = UNSET_VALUE
  @arubacloud_password = UNSET_VALUE
  @url = UNSET_VALUE
  @reserved_status = UNSET_VALUE
  @reserved_list_owned = UNSET_VALUE
  @endpoint = UNSET_VALUE
  @server_name = UNSET_VALUE
  @template_id = UNSET_VALUE
  @package_id = UNSET_VALUE
  @service_type = UNSET_VALUE
  @cpu_number = UNSET_VALUE
  @ram_qty = UNSET_VALUE
  @hds = UNSET_VALUE
end

Instance Attribute Details

#arubacloud_passwordString

ArubaCloud Password

Returns:

  • (String)


26
27
28
# File 'lib/vagrant-arubacloud/config.rb', line 26

def arubacloud_password
  @arubacloud_password
end

#arubacloud_usernameString

ArubaCloud Username

Returns:

  • (String)


22
23
24
# File 'lib/vagrant-arubacloud/config.rb', line 22

def arubacloud_username
  @arubacloud_username
end

#cpu_numberInteger

Number of Virtual CPU to be assigned to the VM Pro VMWare: 1 < n < 8 Pro Hyper-V: 1 < n < 4

Returns:

  • (Integer)


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

def cpu_number
  @cpu_number
end

#endpointString

Ws EndPoint id : can be dc2,dc2,dc3,…dc8 (dc7 is not defined at this release)

Returns:

  • (String)


39
40
41
# File 'lib/vagrant-arubacloud/config.rb', line 39

def endpoint
  @endpoint
end

#hdsArray

Array containing hard disk Configuration Example configuration (size is expressed in GB): Hds = [=> 0, :size => 100, => 1, :size => 200] Hd type 0 is required because specify the first hard disk, max size per hd: 500 GB Hd type > 0 < 4 are 3 additional hard disks (optional)

Returns:

  • (Array)


84
85
86
# File 'lib/vagrant-arubacloud/config.rb', line 84

def hds
  @hds
end

#package_idString

The smart vm type expressed as String: ‘small’ ‘medium’ ‘large’ ‘extra large’

Returns:

  • (String)


57
58
59
# File 'lib/vagrant-arubacloud/config.rb', line 57

def package_id
  @package_id
end

#ram_qtyInteger

Amount of GB of RAM to be assigned to the VM n <= 16

Returns:

  • (Integer)


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

def ram_qty
  @ram_qty
end

#reserved_list_ownedObject

Returns the value of attribute reserved_list_owned.



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

def reserved_list_owned
  @reserved_list_owned
end

#reserved_statusObject

reserved for internal use



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

def reserved_status
  @reserved_status
end

#server_nameString

The name of the server. This defaults to the name of the machine defined by Vagrant (via ‘config.vm.define’), but can be override here.

Returns:

  • (String)


44
45
46
# File 'lib/vagrant-arubacloud/config.rb', line 44

def server_name
  @server_name
end

#service_typeInteger

Service Type expressed in ID [Integer]: 1 = Pro Hyper-V 2 = Pro VMWare 3 = Pro Hyper-V Low Cost 4 = Smart

Returns:

  • (Integer)


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

def service_type
  @service_type
end

#template_idInteger

The ID of the template to use, use vagrant arubacloud templates to obtain the complete list.

Returns:

  • (Integer)


49
50
51
# File 'lib/vagrant-arubacloud/config.rb', line 49

def template_id
  @template_id
end

#urlString

Ws EndPoint Url Expected to be the url of the web service to use

Returns:

  • (String)


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

def url
  @url
end

Instance Method Details

#finalize!Object



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/vagrant-arubacloud/config.rb', line 102

def finalize!
  @arubacloud_username = nil if @arubacloud_username == UNSET_VALUE
  @arubacloud_password = nil if @arubacloud_password == UNSET_VALUE
  @url = nil if @url == UNSET_VALUE
  @reserved_status = nil if @reserved_status = UNSET_VALUE
  @reserved_list_owned = nil if @reserved_list_owned = UNSET_VALUE
  @endpoint = nil if @endpoint == UNSET_VALUE
  @server_name = nil if @server_name == UNSET_VALUE
  @template_id = nil if @template_id == UNSET_VALUE
  @package_id = nil if @package_id == UNSET_VALUE
  @service_type = nil if @service_type == UNSET_VALUE
  @cpu_number = nil if @cpu_number == UNSET_VALUE
  @ram_qty = nil if @ram_qty == UNSET_VALUE
  @hds = nil if @hds == UNSET_VALUE
end

#validate(machine) ⇒ Object



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/vagrant-arubacloud/config.rb', line 118

def validate(machine)
  errors = _detected_errors

  # Global configurations needed by all service types
  errors << I18n.t('vagrant_arubacloud.config.arubacloud_username_required') unless @arubacloud_username
  errors << I18n.t('vagrant_arubacloud.config.arubacloud_password_required') unless @arubacloud_password
  errors << I18n.t('vagrant_arubacloud.config.template_id_required') unless @template_id
  errors << I18n.t('vagrant_arubacloud.config.service_type_required') unless @service_type

  errors << I18n.t('vagrant_arubacloud.config.ssh_password_required') unless machine.config.ssh.password

  #check if coded url or endpoint
  #if url not in table or dc wrong return error
  if (@url)
    if (DC_TABLES.key(@url))
      @endpoint = DC_TABLES.key(@url)
    else
      errors << I18n.t('vagrant_arubacloud.config.url_is_wrong')
    end
  else
    if (@endpoint)
      if DC_TABLES.key?(@endpoint.to_sym)
        @url = DC_TABLES[@endpoint.to_sym]
      else
        errors << I18n.t('vagrant_arubacloud.config.endpoint_is_wrong')
      end
    else
      @endpoint = DC_DEFAULT.to_sym
      @url = DC_TABLES[DC_DEFAULT.to_sym]
    end
  end

  if @service_type.eql? 4
    errors << I18n.t('vagrant_arubacloud.config.package_id_required') unless @package_id
  else
    errors << I18n.t('vagrant_arubacloud.config.cpu_number_required') unless @cpu_number
    errors << I18n.t('vagrant_arubacloud.config.ram_qty_required') unless @ram_qty
    if @hds
      errors << I18n.t('vagrant_arubacloud.config.hds_conf_must_be_array') unless @hds.kind_of?(Array)
    elsif
      errors << I18n.t('vagrant_arubacloud.config.hds_conf_required')
    end
  end
  {'ArubaCloud Provider' => errors}
end