Class: VagrantPlugins::Openstack::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/vagrant-openstack-provider/config.rb', line 133

def initialize
  @api_key = UNSET_VALUE
  @openstack_region = UNSET_VALUE
  @openstack_compute_url = UNSET_VALUE
  @openstack_auth_url = UNSET_VALUE
  @flavor = UNSET_VALUE
  @image = UNSET_VALUE
  @rackconnect = UNSET_VALUE
  @availability_zone = UNSET_VALUE
  @tenant_name = UNSET_VALUE
  @server_name = UNSET_VALUE
  @username = UNSET_VALUE
  @disk_config = UNSET_VALUE
  @network = UNSET_VALUE
  @rsync_includes = []
  @keypair_name = UNSET_VALUE
  @ssh_username = UNSET_VALUE
  @ssh_timeout = UNSET_VALUE
  @floating_ip = UNSET_VALUE
  @sync_method = UNSET_VALUE
end

Instance Attribute Details

#api_keyString

The API key to access Openstack.

Returns:

  • (String)


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

def api_key
  @api_key
end

#availability_zoneObject

Specify the availability zone in which to create the instance



82
83
84
# File 'lib/vagrant-openstack-provider/config.rb', line 82

def availability_zone
  @availability_zone
end

#disk_configObject

The disk configuration value.

* AUTO -   The server is built with a single partition the size of the target flavor disk. The file system is automatically adjusted to fit the entire partition.
           This keeps things simple and automated. AUTO is valid only for images and servers with a single partition that use the EXT3 file system.
           This is the default setting for applicable Openstack base images.

* MANUAL - The server is built using whatever partition scheme and file system is in the source image. If the target flavor disk is larger,
           the remaining disk space is left unpartitioned. This enables images to have non-EXT3 file systems, multiple partitions,
           and so on, and enables you to manage the disk configuration.

This defaults to MANUAL



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

def disk_config
  @disk_config
end

#flavorObject

The flavor of server to launch, either the ID or name. This can also be a regular expression to partially match a name.



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

def flavor
  @flavor
end

#floating_ipString

The floating IP address from the IP pool which will be assigned to the instance.

Returns:

  • (String)


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

def floating_ip
  @floating_ip
end

#imageObject

The name or ID of the image to use. This can also be a regular expression to partially match a name.



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

def image
  @image
end

#key_nameString

Alternately, if a keypair were already uploaded to Openstack, the key name could be provided.

Returns:

  • (String)


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

def key_name
  @key_name
end

#keypair_nameString

The name of the keypair to use.

Returns:

  • (String)


92
93
94
# File 'lib/vagrant-openstack-provider/config.rb', line 92

def keypair_name
  @keypair_name
end

#metadataHash

A Hash of metadata that will be sent to the instance for configuration

Returns:

  • (Hash)


64
65
66
# File 'lib/vagrant-openstack-provider/config.rb', line 64

def 
  
end

#networkString

Network configurations for the instance

Returns:

  • (String)


45
46
47
# File 'lib/vagrant-openstack-provider/config.rb', line 45

def network
  @network
end

#openstack_auth_urlObject

Note:

Currently, you must authenticate against the UK authenication endpoint to access the London Data center. Hopefully this method makes the experience more seemless for users of the UK cloud.



185
186
187
188
189
190
191
# File 'lib/vagrant-openstack-provider/config.rb', line 185

def openstack_auth_url
  if (@openstack_auth_url.nil? || @openstack_auth_url == UNSET_VALUE) && lon_region?
    Fog::Openstack::UK_AUTH_ENDPOINT
  else
    @openstack_auth_url
  end
end

#openstack_compute_urlObject

The compute_url to access Openstack. If nil, it will default to DFW. (formerly know as ‘endpoint’)

expected to be a string url - ‘dfw.servers.api.openstackcloud.com/v2’ ‘ord.servers.api.openstackcloud.com/v2’ ‘lon.servers.api.openstackcloud.com/v2

alternatively, can use constants if you require ‘fog/openstack’ in your Vagrantfile Fog::Compute::OpenstackV2::DFW_ENDPOINT Fog::Compute::OpenstackV2::ORD_ENDPOINT Fog::Compute::OpenstackV2::LON_ENDPOINT

Users should preference the openstack_region setting over openstack_compute_url



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

def openstack_compute_url
  @openstack_compute_url
end

#openstack_regionObject

The region to access Openstack. If nil, it will default to DFW. (formerly know as ‘endpoint’)

expected to be a symbol - :dfw (default), :ord, :lon

Users should preference the openstack_region setting over openstack_compute_url



18
19
20
# File 'lib/vagrant-openstack-provider/config.rb', line 18

def openstack_region
  @openstack_region
end

#rackconnectBoolean

The option that indicates RackConnect usage or not.

Returns:

  • (Boolean)


69
70
71
# File 'lib/vagrant-openstack-provider/config.rb', line 69

def rackconnect
  @rackconnect
end

#rsync_includesArray

Opt files/directories in to the rsync operation performed by this provider

Returns:

  • (Array)


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

def rsync_includes
  @rsync_includes
end

#server_nameObject

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



79
80
81
# File 'lib/vagrant-openstack-provider/config.rb', line 79

def server_name
  @server_name
end

#ssh_timeoutInteger

The SSH timeout use after server creation. If server startup is too long the timeout value can be increase with this variable. Default is 60 seconds

Returns:

  • (Integer)


104
105
106
# File 'lib/vagrant-openstack-provider/config.rb', line 104

def ssh_timeout
  @ssh_timeout
end

#ssh_usernameString

The SSH username to use with this OpenStack instance. This overrides the config.ssh.username variable.

Returns:

  • (String)


98
99
100
# File 'lib/vagrant-openstack-provider/config.rb', line 98

def ssh_username
  @ssh_username
end

#sync_methodString

Sync folder method. Can be either “rsync” or “none”

Returns:

  • (String)


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

def sync_method
  @sync_method
end

#tenant_nameObject

The name of the openstack project on witch the vm will be created.



74
75
76
# File 'lib/vagrant-openstack-provider/config.rb', line 74

def tenant_name
  @tenant_name
end

#usernameString

The username to access Openstack.

Returns:

  • (String)


87
88
89
# File 'lib/vagrant-openstack-provider/config.rb', line 87

def username
  @username
end

Instance Method Details

#finalize!Object



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/vagrant-openstack-provider/config.rb', line 155

def finalize!
  @api_key = nil if @api_key == UNSET_VALUE
  @openstack_region = nil if @openstack_region == UNSET_VALUE
  @openstack_compute_url = nil if @openstack_compute_url == UNSET_VALUE
  @openstack_auth_url = nil if @openstack_auth_url == UNSET_VALUE
  @flavor = /m1.tiny/ if @flavor == UNSET_VALUE # TODO No default value
  @image = /cirros/ if @image == UNSET_VALUE    # TODO No default value
  @rackconnect = nil if @rackconnect == UNSET_VALUE
  @availability_zone = nil if @availability_zone == UNSET_VALUE
  @tenant_name = nil if @tenant_name == UNSET_VALUE
  @server_name = nil if @server_name == UNSET_VALUE
   = nil if  == UNSET_VALUE
  @network = nil if @network == UNSET_VALUE
  @username = nil if @username == UNSET_VALUE
  @disk_config = nil if @disk_config == UNSET_VALUE
  @rsync_includes = nil if @rsync_includes.empty?
  @floating_ip = nil if @floating_ip == UNSET_VALUE
  @sync_method = "rsync" if @sync_method == UNSET_VALUE

  # Keypair defaults to nil
  @keypair_name = nil if @keypair_name == UNSET_VALUE

  # The SSH values by default are nil, and the top-level config
  # `config.ssh` values are used.
  @ssh_username = nil if @ssh_username == UNSET_VALUE
  @ssh_timeout = 60 if @ssh_timeout == UNSET_VALUE
end

#rsync_include(inc) ⇒ Object



193
194
195
# File 'lib/vagrant-openstack-provider/config.rb', line 193

def rsync_include(inc)
  @rsync_includes << inc
end

#validate(machine) ⇒ Object



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/vagrant-openstack-provider/config.rb', line 197

def validate(machine)
  errors = _detected_errors

  errors << I18n.t("vagrant_openstack.config.api_key required") if !@api_key
  errors << I18n.t("vagrant_openstack.config.username required") if !@username
  errors << I18n.t("vagrant_openstack.config.keypair_name required") if !@keypair_name

  {
    :openstack_compute_url => @openstack_compute_url,
    :openstack_auth_url => @openstack_auth_url
  }.each_pair do |key, value|
    errors << I18n.t("vagrant_openstack.config.invalid_uri", :key => key, :uri => value) unless value.nil? || valid_uri?(value)
  end

  { "Openstack Provider" => errors }
end