vagrant-openstack-provider-illuin 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +22 -0
  3. data/.rubocop.yml +40 -0
  4. data/CHANGELOG.md +276 -0
  5. data/Gemfile +22 -0
  6. data/RELEASE.md +15 -0
  7. data/Rakefile +25 -0
  8. data/Vagrantfile +20 -0
  9. data/dummy.box +0 -0
  10. data/example_box/README.md +13 -0
  11. data/example_box/metadata.json +3 -0
  12. data/functional_tests/Vagrantfile +58 -0
  13. data/functional_tests/keys/vagrant-openstack +27 -0
  14. data/functional_tests/keys/vagrant-openstack.pub +1 -0
  15. data/functional_tests/run_tests.sh +142 -0
  16. data/lib/vagrant-openstack-provider.rb +29 -0
  17. data/lib/vagrant-openstack-provider/action.rb +344 -0
  18. data/lib/vagrant-openstack-provider/action/abstract_action.rb +22 -0
  19. data/lib/vagrant-openstack-provider/action/connect_openstack.rb +60 -0
  20. data/lib/vagrant-openstack-provider/action/create_server.rb +184 -0
  21. data/lib/vagrant-openstack-provider/action/create_stack.rb +76 -0
  22. data/lib/vagrant-openstack-provider/action/delete_server.rb +53 -0
  23. data/lib/vagrant-openstack-provider/action/delete_stack.rb +73 -0
  24. data/lib/vagrant-openstack-provider/action/message.rb +19 -0
  25. data/lib/vagrant-openstack-provider/action/provision.rb +60 -0
  26. data/lib/vagrant-openstack-provider/action/read_ssh_info.rb +74 -0
  27. data/lib/vagrant-openstack-provider/action/read_state.rb +43 -0
  28. data/lib/vagrant-openstack-provider/action/resume.rb +24 -0
  29. data/lib/vagrant-openstack-provider/action/snapshot_cleanup.rb +32 -0
  30. data/lib/vagrant-openstack-provider/action/snapshot_delete.rb +32 -0
  31. data/lib/vagrant-openstack-provider/action/snapshot_list.rb +22 -0
  32. data/lib/vagrant-openstack-provider/action/snapshot_restore.rb +29 -0
  33. data/lib/vagrant-openstack-provider/action/snapshot_save.rb +51 -0
  34. data/lib/vagrant-openstack-provider/action/start_server.rb +24 -0
  35. data/lib/vagrant-openstack-provider/action/stop_server.rb +25 -0
  36. data/lib/vagrant-openstack-provider/action/suspend.rb +24 -0
  37. data/lib/vagrant-openstack-provider/action/sync_folders.rb +138 -0
  38. data/lib/vagrant-openstack-provider/action/wait_active.rb +33 -0
  39. data/lib/vagrant-openstack-provider/action/wait_stop.rb +33 -0
  40. data/lib/vagrant-openstack-provider/cap/snapshot_list.rb +15 -0
  41. data/lib/vagrant-openstack-provider/catalog/openstack_catalog.rb +90 -0
  42. data/lib/vagrant-openstack-provider/client/cinder.rb +39 -0
  43. data/lib/vagrant-openstack-provider/client/domain.rb +163 -0
  44. data/lib/vagrant-openstack-provider/client/glance.rb +65 -0
  45. data/lib/vagrant-openstack-provider/client/heat.rb +49 -0
  46. data/lib/vagrant-openstack-provider/client/http_utils.rb +116 -0
  47. data/lib/vagrant-openstack-provider/client/keystone.rb +128 -0
  48. data/lib/vagrant-openstack-provider/client/neutron.rb +48 -0
  49. data/lib/vagrant-openstack-provider/client/nova.rb +303 -0
  50. data/lib/vagrant-openstack-provider/client/openstack.rb +59 -0
  51. data/lib/vagrant-openstack-provider/client/request_logger.rb +23 -0
  52. data/lib/vagrant-openstack-provider/client/rest_utils.rb +28 -0
  53. data/lib/vagrant-openstack-provider/command/abstract_command.rb +51 -0
  54. data/lib/vagrant-openstack-provider/command/flavor_list.rb +24 -0
  55. data/lib/vagrant-openstack-provider/command/floatingip_list.rb +32 -0
  56. data/lib/vagrant-openstack-provider/command/image_list.rb +29 -0
  57. data/lib/vagrant-openstack-provider/command/main.rb +52 -0
  58. data/lib/vagrant-openstack-provider/command/network_list.rb +25 -0
  59. data/lib/vagrant-openstack-provider/command/openstack_command.rb +16 -0
  60. data/lib/vagrant-openstack-provider/command/reset.rb +20 -0
  61. data/lib/vagrant-openstack-provider/command/subnet_list.rb +22 -0
  62. data/lib/vagrant-openstack-provider/command/utils.rb +22 -0
  63. data/lib/vagrant-openstack-provider/command/volume_list.rb +25 -0
  64. data/lib/vagrant-openstack-provider/config.rb +498 -0
  65. data/lib/vagrant-openstack-provider/config/http.rb +39 -0
  66. data/lib/vagrant-openstack-provider/config_resolver.rb +334 -0
  67. data/lib/vagrant-openstack-provider/errors.rb +187 -0
  68. data/lib/vagrant-openstack-provider/logging.rb +39 -0
  69. data/lib/vagrant-openstack-provider/plugin.rb +58 -0
  70. data/lib/vagrant-openstack-provider/provider.rb +50 -0
  71. data/lib/vagrant-openstack-provider/utils.rb +36 -0
  72. data/lib/vagrant-openstack-provider/version.rb +15 -0
  73. data/lib/vagrant-openstack-provider/version_checker.rb +76 -0
  74. data/locales/en.yml +412 -0
  75. data/spec/vagrant-openstack-provider/action/connect_openstack_spec.rb +770 -0
  76. data/spec/vagrant-openstack-provider/action/create_server_spec.rb +260 -0
  77. data/spec/vagrant-openstack-provider/action/create_stack_spec.rb +99 -0
  78. data/spec/vagrant-openstack-provider/action/delete_server_spec.rb +89 -0
  79. data/spec/vagrant-openstack-provider/action/delete_stack_spec.rb +63 -0
  80. data/spec/vagrant-openstack-provider/action/message_spec.rb +33 -0
  81. data/spec/vagrant-openstack-provider/action/provision_spec.rb +97 -0
  82. data/spec/vagrant-openstack-provider/action/read_ssh_info_spec.rb +201 -0
  83. data/spec/vagrant-openstack-provider/action/read_state_spec.rb +81 -0
  84. data/spec/vagrant-openstack-provider/action/resume_server_spec.rb +49 -0
  85. data/spec/vagrant-openstack-provider/action/start_server_spec.rb +49 -0
  86. data/spec/vagrant-openstack-provider/action/stop_server_spec.rb +49 -0
  87. data/spec/vagrant-openstack-provider/action/suspend_server_spec.rb +49 -0
  88. data/spec/vagrant-openstack-provider/action/sync_folders_spec.rb +155 -0
  89. data/spec/vagrant-openstack-provider/action/wait_active_spec.rb +53 -0
  90. data/spec/vagrant-openstack-provider/action/wait_stop_spec.rb +53 -0
  91. data/spec/vagrant-openstack-provider/action_spec.rb +120 -0
  92. data/spec/vagrant-openstack-provider/client/cinder_spec.rb +129 -0
  93. data/spec/vagrant-openstack-provider/client/glance_spec.rb +145 -0
  94. data/spec/vagrant-openstack-provider/client/heat_spec.rb +130 -0
  95. data/spec/vagrant-openstack-provider/client/keystone_spec.rb +226 -0
  96. data/spec/vagrant-openstack-provider/client/neutron_spec.rb +173 -0
  97. data/spec/vagrant-openstack-provider/client/nova_spec.rb +760 -0
  98. data/spec/vagrant-openstack-provider/client/utils_spec.rb +176 -0
  99. data/spec/vagrant-openstack-provider/command/flavor_list_spec.rb +43 -0
  100. data/spec/vagrant-openstack-provider/command/floatingip_list_spec.rb +74 -0
  101. data/spec/vagrant-openstack-provider/command/image_list_spec.rb +95 -0
  102. data/spec/vagrant-openstack-provider/command/network_list_spec.rb +65 -0
  103. data/spec/vagrant-openstack-provider/command/reset_spec.rb +24 -0
  104. data/spec/vagrant-openstack-provider/command/subnet_list_spec.rb +45 -0
  105. data/spec/vagrant-openstack-provider/command/volume_list_spec.rb +40 -0
  106. data/spec/vagrant-openstack-provider/config_resolver_spec.rb +879 -0
  107. data/spec/vagrant-openstack-provider/config_spec.rb +414 -0
  108. data/spec/vagrant-openstack-provider/e2e_spec.rb.save +27 -0
  109. data/spec/vagrant-openstack-provider/provider_spec.rb +13 -0
  110. data/spec/vagrant-openstack-provider/spec_helper.rb +37 -0
  111. data/spec/vagrant-openstack-provider/utils_spec.rb +128 -0
  112. data/spec/vagrant-openstack-provider/version_checker_spec.rb +39 -0
  113. data/stackrc +25 -0
  114. data/vagrant-openstack-provider-illuin.gemspec +34 -0
  115. metadata +362 -0
@@ -0,0 +1,498 @@
1
+ require 'vagrant'
2
+ require 'colorize'
3
+ require 'vagrant-openstack-provider/config/http'
4
+
5
+ module VagrantPlugins
6
+ module Openstack
7
+ class Config < Vagrant.plugin('2', :config)
8
+ # The API key to access Openstack.
9
+ #
10
+ attr_accessor :password
11
+
12
+ # The compute service url to access Openstack. If nil, it will read from hypermedia catalog form REST API
13
+ #
14
+ attr_accessor :openstack_compute_url
15
+
16
+ # The network service url to access Openstack. If nil, it will read from hypermedia catalog form REST API
17
+ #
18
+ attr_accessor :openstack_network_url
19
+
20
+ # The block storage service url to access Openstack. If nil, it will read from hypermedia catalog form REST API
21
+ #
22
+ attr_accessor :openstack_volume_url
23
+
24
+ # The orchestration service url to access Openstack. If nil, it will read from hypermedia catalog form REST API
25
+ #
26
+ attr_accessor :openstack_orchestration_url
27
+
28
+ # The image service url to access Openstack. If nil, it will read from hypermedia catalog form REST API
29
+ #
30
+ attr_accessor :openstack_image_url
31
+
32
+ # The authentication endpoint. This defaults to Openstack's global authentication endpoint.
33
+ attr_accessor :openstack_auth_url
34
+
35
+ # Openstack region
36
+ attr_accessor :region
37
+
38
+ # The flavor of server to launch, either the ID or name. This
39
+ # can also be a regular expression to partially match a name.
40
+ attr_accessor :flavor
41
+
42
+ # The name or ID of the image to use. This can also be a regular
43
+ # expression to partially match a name.
44
+ attr_accessor :image
45
+
46
+ # Volume to boot the vm from
47
+ #
48
+ attr_accessor :volume_boot
49
+
50
+ #
51
+ # The name of the openstack project on witch the vm will be created.
52
+ #
53
+ attr_accessor :tenant_name
54
+
55
+ #
56
+ # The name of the openstack project on witch the vm will be created, changed name in v3 identity API.
57
+ #
58
+ attr_accessor :project_name
59
+
60
+ # The name of the server. This defaults to the name of the machine
61
+ # defined by Vagrant (via `config.vm.define`), but can be overriden
62
+ # here.
63
+ attr_accessor :server_name
64
+
65
+ # The username to access Openstack.
66
+ #
67
+ # @return [String]
68
+ attr_accessor :username
69
+
70
+ # The domain name to access Openstack, this defaults to Default.
71
+ #
72
+ # @return [String]
73
+ attr_accessor :domain_name
74
+
75
+ # The name of the keypair to use.
76
+ #
77
+ # @return [String]
78
+ attr_accessor :keypair_name
79
+
80
+ # The SSH username to use with this OpenStack instance. This overrides
81
+ # the `config.ssh.username` variable.
82
+ #
83
+ # @return [String]
84
+ attr_accessor :ssh_username
85
+
86
+ # The SSH timeout use after server creation.
87
+ #
88
+ # Deprecated. Use config.vm.boot_timeout instead.
89
+ #
90
+ # @return [Integer]
91
+ attr_accessor :ssh_timeout
92
+
93
+ # Opt files/directories in to the rsync operation performed by this provider
94
+ #
95
+ # @deprecated Use standard Vagrant synced folders instead.
96
+ #
97
+ # @return [Array]
98
+ attr_accessor :rsync_includes
99
+
100
+ # The floating IP address from the IP pool which will be assigned to the instance.
101
+ #
102
+ # @return [String]
103
+ attr_accessor :floating_ip
104
+
105
+ # The floating IP pool from where new IPs will be allocated
106
+ #
107
+ # @return [String]
108
+ attr_accessor :floating_ip_pool
109
+
110
+ # if set to true, vagrant will always allocate floating ip instead of trying to reuse unassigned ones
111
+ # default to false
112
+ #
113
+ # @return [Boolean]
114
+ attr_accessor :floating_ip_pool_always_allocate
115
+
116
+ # Sync folder method. Can be either "rsync" or "none"
117
+ #
118
+ # @deprecated Use standard Vagrant synced folders instead.
119
+ #
120
+ # @return [String]
121
+ attr_accessor :sync_method
122
+
123
+ # Sync folder ignore files. A list of files containing exclude patterns to ignore in the rsync operation
124
+ # performed by this provider
125
+ #
126
+ # @deprecated Use standard Vagrant synced folders instead.
127
+ #
128
+ # @return [Array]
129
+ attr_accessor :rsync_ignore_files
130
+
131
+ # Network list the VM will be connected to
132
+ #
133
+ # @return [Array]
134
+ attr_accessor :networks
135
+
136
+ # Volumes list that will be attached to the VM
137
+ #
138
+ # @return [Array]
139
+ attr_accessor :volumes
140
+
141
+ # Stack that will be created and associated to the instances
142
+ #
143
+ # @return [Array]
144
+ attr_accessor :stacks
145
+
146
+ # Public key path to create OpenStack keypair
147
+ #
148
+ # @return [Array]
149
+ attr_accessor :public_key_path
150
+
151
+ # Availability Zone
152
+ #
153
+ # @return [String]
154
+ attr_accessor :availability_zone
155
+
156
+ # Pass hints to the OpenStack scheduler, e.g. { "cell": "some cell name" }
157
+ attr_accessor :scheduler_hints
158
+
159
+ # List of strings representing the security groups to apply.
160
+ # e.g. ['ssh', 'http']
161
+ #
162
+ # @return [Array[String]]
163
+ attr_accessor :security_groups
164
+
165
+ # User data to be sent to the newly created OpenStack instance. Use this
166
+ # e.g. to inject a script at boot time.
167
+ #
168
+ # @return [String]
169
+ attr_accessor :user_data
170
+
171
+ # A Hash of metadata that will be sent to the instance for configuration
172
+ #
173
+ # @return [Hash]
174
+ attr_accessor :metadata
175
+
176
+ # Flag to enable/disable all SSH actions (to use for instance on private networks)
177
+ #
178
+ # @return [Boolean]
179
+ attr_accessor :ssh_disabled
180
+
181
+ # Specify the endpoint_type to use : publicURL, adminURL, or internalURL (default is publicURL)
182
+ #
183
+ # @return [String]
184
+ attr_accessor :endpoint_type
185
+
186
+ # Specify the endpoint_type to use : publicL, admin, or internal (default is public)
187
+ #
188
+ # @return [String]
189
+ attr_accessor :interface_type
190
+
191
+ # Specify the authentication version to use : 2 or 3 (ddefault is 2()
192
+ #
193
+ # @return [String]
194
+ attr_accessor :identity_api_version
195
+
196
+ #
197
+ # @return [Integer]
198
+ attr_accessor :server_create_timeout
199
+
200
+ #
201
+ # @return [Integer]
202
+ attr_accessor :server_active_timeout
203
+
204
+ #
205
+ # @return [Integer]
206
+ attr_accessor :server_stop_timeout
207
+
208
+ #
209
+ # @return [Integer]
210
+ attr_accessor :server_delete_timeout
211
+
212
+ #
213
+ # @return [Integer]
214
+ attr_accessor :stack_create_timeout
215
+
216
+ #
217
+ # @return [Integer]
218
+ attr_accessor :stack_delete_timeout
219
+
220
+ #
221
+ # @return [Integer]
222
+ attr_accessor :floating_ip_assign_timeout
223
+
224
+ #
225
+ # @return [HttpConfig]
226
+ attr_accessor :http
227
+
228
+ #
229
+ # @return [Boolean]
230
+ attr_accessor :meta_args_support
231
+
232
+ # A switch for enabling the legacy synced folders implementation.
233
+ #
234
+ # This defaults to false, but is automatically set to true if any of the
235
+ # legacy synced folder options are used:
236
+ #
237
+ # - {#rsync_includes}
238
+ # - {#rsync_ignore_files}
239
+ # - {#sync_method}
240
+ #
241
+ # @deprecated Use standard Vagrant synced folders instead.
242
+ #
243
+ # @return [Boolean]
244
+ attr_accessor :use_legacy_synced_folders
245
+
246
+ # Specify the certificate to use.
247
+ #
248
+ # @return [String]
249
+ attr_accessor :ssl_ca_file
250
+
251
+ # Verify ssl peer certificate when connecting. Set to false (! unsecure) to disable
252
+ #
253
+ # @return [Boolean]
254
+ attr_accessor :ssl_verify_peer
255
+
256
+ def initialize
257
+ @password = UNSET_VALUE
258
+ @openstack_compute_url = UNSET_VALUE
259
+ @openstack_network_url = UNSET_VALUE
260
+ @openstack_volume_url = UNSET_VALUE
261
+ @openstack_orchestration_url = UNSET_VALUE
262
+ @openstack_image_url = UNSET_VALUE
263
+ @openstack_auth_url = UNSET_VALUE
264
+ @endpoint_type = UNSET_VALUE
265
+ @interface_type = UNSET_VALUE
266
+ @identity_api_version = UNSET_VALUE
267
+ @region = UNSET_VALUE
268
+ @flavor = UNSET_VALUE
269
+ @image = UNSET_VALUE
270
+ @volume_boot = UNSET_VALUE
271
+ @tenant_name = UNSET_VALUE
272
+ @server_name = UNSET_VALUE
273
+ @username = UNSET_VALUE
274
+ @rsync_includes = []
275
+ @rsync_ignore_files = []
276
+ @keypair_name = UNSET_VALUE
277
+ @ssh_username = UNSET_VALUE
278
+ @ssh_timeout = UNSET_VALUE
279
+ @floating_ip = UNSET_VALUE
280
+ @floating_ip_pool = []
281
+ @floating_ip_pool_always_allocate = UNSET_VALUE
282
+ @sync_method = UNSET_VALUE
283
+ @availability_zone = UNSET_VALUE
284
+ @networks = []
285
+ @stacks = []
286
+ @volumes = []
287
+ @public_key_path = UNSET_VALUE
288
+ @scheduler_hints = UNSET_VALUE
289
+ @security_groups = UNSET_VALUE
290
+ @user_data = UNSET_VALUE
291
+ @metadata = UNSET_VALUE
292
+ @ssh_disabled = UNSET_VALUE
293
+ @server_create_timeout = UNSET_VALUE
294
+ @server_active_timeout = UNSET_VALUE
295
+ @server_stop_timeout = UNSET_VALUE
296
+ @server_delete_timeout = UNSET_VALUE
297
+ @stack_create_timeout = UNSET_VALUE
298
+ @stack_delete_timeout = UNSET_VALUE
299
+ @floating_ip_assign_timeout = UNSET_VALUE
300
+ @meta_args_support = UNSET_VALUE
301
+ @http = HttpConfig.new
302
+ @use_legacy_synced_folders = UNSET_VALUE
303
+ @ssl_ca_file = UNSET_VALUE
304
+ @ssl_verify_peer = UNSET_VALUE
305
+ end
306
+
307
+ def merge(other)
308
+ result = self.class.new
309
+
310
+ # Set all of our instance variables on the new class
311
+ [self, other].each do |obj|
312
+ obj.instance_variables.each do |key|
313
+ # Ignore keys that start with a double underscore. This allows
314
+ # configuration classes to still hold around internal state
315
+ # that isn't propagated.
316
+ next if key.to_s.start_with?('@__')
317
+
318
+ # Let user inputs a string or an array for floating ip pool attribute
319
+ obj.floating_ip_pool = [obj.floating_ip_pool].flatten if key.eql?(:@floating_ip_pool) && !obj.floating_ip_pool.nil?
320
+
321
+ # Let user inputs a string or an array for networks attribute
322
+ obj.networks = [obj.networks].flatten if key.eql?(:@networks) && !obj.networks.nil?
323
+
324
+ # Don't set the value if it is the unset value, either.
325
+ value = obj.instance_variable_get(key)
326
+
327
+ if [:@networks, :@volumes, :@rsync_includes, :@rsync_ignore_files, :@floating_ip_pool, :@stacks].include? key
328
+ result.instance_variable_set(key, value) unless value.empty?
329
+ elsif [:@http].include? key
330
+ result.instance_variable_set(key, instance_variable_get(key).merge(other.instance_variable_get(key))) if value != UNSET_VALUE
331
+ else
332
+ result.instance_variable_set(key, value) if value != UNSET_VALUE
333
+ end
334
+ end
335
+ end
336
+
337
+ # Persist through the set of invalid methods
338
+ this_invalid = @__invalid_methods || Set.new
339
+ other_invalid = other.instance_variable_get(:"@__invalid_methods") || Set.new
340
+ result.instance_variable_set(:"@__invalid_methods", this_invalid + other_invalid)
341
+
342
+ result
343
+ end
344
+
345
+ # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
346
+ def finalize!
347
+ @password = nil if @password == UNSET_VALUE
348
+ @openstack_compute_url = nil if @openstack_compute_url == UNSET_VALUE
349
+ @openstack_network_url = nil if @openstack_network_url == UNSET_VALUE
350
+ @openstack_orchestration_url = nil if @openstack_orchestration_url == UNSET_VALUE
351
+ @openstack_volume_url = nil if @openstack_volume_url == UNSET_VALUE
352
+ @openstack_image_url = nil if @openstack_image_url == UNSET_VALUE
353
+ @openstack_auth_url = nil if @openstack_auth_url == UNSET_VALUE
354
+ @endpoint_type = 'publicURL' if @endpoint_type == UNSET_VALUE
355
+ @interface_type = 'public' if @interface_type == UNSET_VALUE
356
+ @identity_api_version = '2' if @identity_api_version == UNSET_VALUE
357
+ @region = nil if @region == UNSET_VALUE
358
+ @flavor = nil if @flavor == UNSET_VALUE
359
+ @image = nil if @image == UNSET_VALUE
360
+ @volume_boot = nil if @volume_boot == UNSET_VALUE
361
+ @tenant_name = nil if @tenant_name == UNSET_VALUE
362
+ @project_name = nil if @project_name == UNSET_VALUE
363
+ @server_name = nil if @server_name == UNSET_VALUE
364
+ @username = nil if @username == UNSET_VALUE
365
+ @domain_name = 'Default' if @domain_name == UNSET_VALUE
366
+ @floating_ip = nil if @floating_ip == UNSET_VALUE
367
+ @floating_ip_pool = nil if @floating_ip_pool == UNSET_VALUE
368
+ @floating_ip_pool_always_allocate = false if floating_ip_pool_always_allocate == UNSET_VALUE
369
+ @keypair_name = nil if @keypair_name == UNSET_VALUE
370
+ @public_key_path = nil if @public_key_path == UNSET_VALUE
371
+ @availability_zone = nil if @availability_zone == UNSET_VALUE
372
+ @scheduler_hints = nil if @scheduler_hints == UNSET_VALUE
373
+ @security_groups = nil if @security_groups == UNSET_VALUE
374
+ @user_data = nil if @user_data == UNSET_VALUE
375
+ @metadata = nil if @metadata == UNSET_VALUE
376
+ @ssh_disabled = false if @ssh_disabled == UNSET_VALUE
377
+
378
+ # The value of use_legacy_synced_folders is used by action chains
379
+ # to determine which synced folder implementation to run.
380
+ if @use_legacy_synced_folders == UNSET_VALUE
381
+ @use_legacy_synced_folders = !(
382
+ (@rsync_includes.nil? || @rsync_includes.empty?) &&
383
+ (@rsync_ignore_files.nil? || @rsync_ignore_files.empty?) &&
384
+ (@sync_method.nil? || @sync_method == UNSET_VALUE))
385
+ end
386
+
387
+ if @use_legacy_synced_folders
388
+ # Original defaults.
389
+ @rsync_includes = nil if @rsync_includes.empty?
390
+ @rsync_ignore_files = nil if @rsync_ignore_files.empty?
391
+ @sync_method = 'rsync' if @sync_method == UNSET_VALUE
392
+ else
393
+ # Disable all sync settings.
394
+ @rsync_includes = nil
395
+ @rsync_ignore_files = nil
396
+ @sync_method = nil
397
+ end
398
+
399
+ # The SSH values by default are nil, and the top-level config
400
+ # `config.ssh` and `config.vm.boot_timeout` values are used.
401
+ @ssh_username = nil if @ssh_username == UNSET_VALUE
402
+ @ssh_timeout = nil if @ssh_timeout == UNSET_VALUE
403
+
404
+ @server_create_timeout = 200 if @server_create_timeout == UNSET_VALUE
405
+ @server_active_timeout = 200 if @server_active_timeout == UNSET_VALUE
406
+ @server_stop_timeout = 200 if @server_stop_timeout == UNSET_VALUE
407
+ @server_delete_timeout = 200 if @server_delete_timeout == UNSET_VALUE
408
+ @stack_create_timeout = 200 if @stack_create_timeout == UNSET_VALUE
409
+ @stack_delete_timeout = 200 if @stack_delete_timeout == UNSET_VALUE
410
+ @floating_ip_assign_timeout = 200 if @floating_ip_assign_timeout == UNSET_VALUE
411
+ @meta_args_support = false if @meta_args_support == UNSET_VALUE
412
+ @networks = nil if @networks.empty?
413
+ @volumes = nil if @volumes.empty?
414
+ @stacks = nil if @stacks.empty?
415
+ @http.finalize!
416
+ @ssl_ca_file = nil if @ssl_ca_file == UNSET_VALUE
417
+ @ssl_verify_peer = true if @ssl_verify_peer == UNSET_VALUE
418
+ end
419
+ # rubocop:enable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
420
+
421
+ #
422
+ # @deprecated Use standard Vagrant synced folders instead.
423
+ def rsync_include(inc)
424
+ @rsync_includes << inc
425
+ end
426
+
427
+ def validate(machine)
428
+ errors = _detected_errors
429
+
430
+ errors << I18n.t('vagrant_openstack.config.password_required') if @password.nil? || @password.empty?
431
+ errors << I18n.t('vagrant_openstack.config.username_required') if @username.nil? || @username.empty?
432
+ errors << I18n.t('vagrant_openstack.config.invalid_api_version') unless %w(2 3).include?(@identity_api_version)
433
+
434
+ validate_api_version(errors)
435
+ validate_ssh_username(machine, errors)
436
+ validate_stack_config(errors)
437
+ validate_ssh_timeout(errors)
438
+
439
+ if machine.config.ssh.insert_key
440
+ if machine.config.ssh.private_key_path
441
+ puts I18n.t('vagrant_openstack.config.keypair_name_required').yellow unless @keypair_name || @public_key_path
442
+ else
443
+ errors << I18n.t('vagrant_openstack.config.private_key_missing') if @keypair_name || @public_key_path
444
+ end
445
+ end
446
+
447
+ {
448
+ openstack_compute_url: @openstack_compute_url,
449
+ openstack_network_url: @openstack_network_url,
450
+ openstack_volume_url: @openstack_volume_url,
451
+ openstack_orchestration_url: @openstack_orchestration_url,
452
+ openstack_image_url: @openstack_image_url,
453
+ openstack_auth_url: @openstack_auth_url
454
+ }.each_pair do |key, value|
455
+ errors << I18n.t('vagrant_openstack.config.invalid_uri', key: key, uri: value) unless value.nil? || valid_uri?(value)
456
+ end
457
+
458
+ { 'Openstack Provider' => errors }
459
+ end
460
+
461
+ private
462
+
463
+ def validate_api_version(errors)
464
+ if @identity_api_version == '2'
465
+ errors << I18n.t('vagrant_openstack.config.tenant_name_required') if @tenant_name.nil? || @tenant_name.empty?
466
+ errors << I18n.t('vagrant_openstack.config.invalid_endpoint_type') unless %w(publicURL adminURL internalURL).include?(@endpoint_type)
467
+ elsif @identity_api_version == '3'
468
+ errors << I18n.t('vagrant_openstack.config.domain_required') if @domain_name.nil? || @domain_name.empty?
469
+ errors << I18n.t('vagrant_openstack.config.project_name_required') if @project_name.nil? || @project_name.empty?
470
+ errors << I18n.t('vagrant_openstack.config.invalid_interface_type') unless %w(public admin internal).include?(@interface_type)
471
+ end
472
+ end
473
+
474
+ def validate_stack_config(errors)
475
+ @stacks.each do |stack|
476
+ errors << I18n.t('vagrant_openstack.config.invalid_stack') unless stack[:name] && stack[:template]
477
+ end unless @stacks.nil?
478
+ end
479
+
480
+ def validate_ssh_username(machine, errors)
481
+ puts I18n.t('vagrant_openstack.config.ssh_username_deprecated').yellow if @ssh_username
482
+ errors << I18n.t('vagrant_openstack.config.ssh_username_required') unless @ssh_username || machine.config.ssh.username
483
+ end
484
+
485
+ def validate_ssh_timeout(errors)
486
+ return if @ssh_timeout.nil? || @ssh_timeout == UNSET_VALUE
487
+ @ssh_timeout = Integer(@ssh_timeout) if @ssh_timeout.is_a? String
488
+ rescue ArgumentError
489
+ errors << I18n.t('vagrant_openstack.config.invalid_value_for_parameter', parameter: 'ssh_timeout', value: @ssh_timeout)
490
+ end
491
+
492
+ def valid_uri?(value)
493
+ uri = URI.parse value
494
+ uri.is_a?(URI::HTTP)
495
+ end
496
+ end
497
+ end
498
+ end