vagrant-openstack-provider 0.7.1 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -1
- data/Gemfile +1 -1
- data/functional_tests/Vagrantfile +1 -1
- data/lib/vagrant-openstack-provider/action.rb +23 -4
- data/lib/vagrant-openstack-provider/action/sync_folders.rb +10 -1
- data/lib/vagrant-openstack-provider/config.rb +12 -4
- data/lib/vagrant-openstack-provider/provider.rb +2 -2
- data/lib/vagrant-openstack-provider/version.rb +1 -1
- data/locales/en.yml +4 -0
- data/spec/vagrant-openstack-provider/action/sync_folders_spec.rb +1 -1
- metadata +21 -24
- data/lib/vagrant-openstack-provider/action/wait_accessible.rb +0 -61
- data/spec/vagrant-openstack-provider/action/wait_accessible_spec.rb +0 -67
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4dd7cf830eecfb15611665ed53da19db9cd5bab5
|
4
|
+
data.tar.gz: 1b5bce071291bc0af764f91933b839803ee3f4c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b95d4b1ccc79200bcd97f7a189e21768b214b3f50056d77ff53c83d7581b31c3d23a3e9d343f7023b37a31e8128a65cf6303c7315af3f3f00906286e634145c5
|
7
|
+
data.tar.gz: 2f071db27ddf020cb30cbf15bbcb7e11e0944dcf63572418c6fc3ce751d4080da54931172424fc88dc2aacf7fb7011ec8f6cedf17278ed7793e11f770d257e96
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,27 @@
|
|
1
|
-
# 0.7.
|
1
|
+
# 0.7.2 (May 1, 2016)
|
2
|
+
|
3
|
+
IMPROVEMENTS:
|
4
|
+
|
5
|
+
- Allow status and ssh to run without a lock #282
|
6
|
+
- Switch to standard WaitForCommunicator middleware #281
|
7
|
+
|
8
|
+
BUG FIXES:
|
9
|
+
|
10
|
+
- Run provisioner cleanup when destroying VMs #272
|
11
|
+
- Windows host provisioning using Winrm #264
|
12
|
+
- Use only provided ssh key and don't touch the known_hosts #259
|
13
|
+
- Fix hooks for provisioners #248, #249, #28
|
14
|
+
- Support standard option config.vm.boot_timeout #227
|
15
|
+
|
16
|
+
# 0.7.1 (February 19, 2016)
|
17
|
+
|
18
|
+
BUG FIXES:
|
19
|
+
|
20
|
+
- Fix dependency to make it work with Vagrant 1.8 #265, #266 , #268
|
21
|
+
- Fix heat stack create when multiple machines are declared #260
|
22
|
+
- Fix regression, vagrant provision was broken #240
|
23
|
+
|
24
|
+
# 0.7.0 (August 10, 2015)
|
2
25
|
|
3
26
|
FEATURES:
|
4
27
|
|
data/Gemfile
CHANGED
@@ -3,7 +3,7 @@ source 'https://rubygems.org'
|
|
3
3
|
gemspec
|
4
4
|
|
5
5
|
group :development do
|
6
|
-
gem 'vagrant', git: 'https://github.com/mitchellh/vagrant.git', tag: 'v1.
|
6
|
+
gem 'vagrant', git: 'https://github.com/mitchellh/vagrant.git', tag: 'v1.8.1'
|
7
7
|
gem 'appraisal', '1.0.0'
|
8
8
|
gem 'rubocop', '0.29.0', require: false
|
9
9
|
gem 'coveralls', require: false
|
@@ -4,6 +4,7 @@ Vagrant.configure('2') do |config|
|
|
4
4
|
|
5
5
|
config.vm.box = 'openstack'
|
6
6
|
config.vm.box_url = 'https://github.com/ggiamarchi/vagrant-openstack/raw/master/source/dummy.box'
|
7
|
+
config.vm.boot_timeout = ENV['OS_SSH_TIMEOUT'].to_i
|
7
8
|
|
8
9
|
config.ssh.private_key_path = ENV['OS_KEYPAIR_PRIVATE_KEY']
|
9
10
|
config.ssh.pty = true
|
@@ -16,7 +17,6 @@ Vagrant.configure('2') do |config|
|
|
16
17
|
os.openstack_compute_url = ENV['OS_COMPUTE_URL']
|
17
18
|
os.openstack_network_url = ENV['OS_NETWORK_URL']
|
18
19
|
os.tenant_name = ENV['OS_TENANT_NAME']
|
19
|
-
os.ssh_timeout = ENV['OS_SSH_TIMEOUT'].to_i
|
20
20
|
os.sync_method = ENV['OS_SYNC_METHOD']
|
21
21
|
os.flavor = ENV['OS_FLAVOR']
|
22
22
|
os.image = ENV['OS_IMAGE']
|
@@ -17,6 +17,7 @@ module VagrantPlugins
|
|
17
17
|
if env[:machine_state_id] == :not_created
|
18
18
|
b2.use Message, I18n.t('vagrant_openstack.not_created')
|
19
19
|
else
|
20
|
+
b2.use(ProvisionerCleanup, :before)
|
20
21
|
b2.use DeleteServer
|
21
22
|
b2.use DeleteStack
|
22
23
|
end
|
@@ -33,7 +34,11 @@ module VagrantPlugins
|
|
33
34
|
if env[:machine_state_id] == :not_created
|
34
35
|
b2.use Message, I18n.t('vagrant_openstack.not_created')
|
35
36
|
else
|
36
|
-
|
37
|
+
if env[:machine].provider_config.meta_args_support
|
38
|
+
b2.use ProvisionWrapper
|
39
|
+
else
|
40
|
+
b2.use Provision
|
41
|
+
end
|
37
42
|
b2.use SyncFolders
|
38
43
|
end
|
39
44
|
end
|
@@ -99,12 +104,27 @@ module VagrantPlugins
|
|
99
104
|
case env[:machine_state_id]
|
100
105
|
when :not_created
|
101
106
|
ssh_disabled = env[:machine].provider_config.ssh_disabled
|
102
|
-
|
107
|
+
unless ssh_disabled
|
108
|
+
if env[:machine].provider_config.meta_args_support
|
109
|
+
b2.use ProvisionWrapper
|
110
|
+
else
|
111
|
+
b2.use Provision
|
112
|
+
end
|
113
|
+
end
|
103
114
|
b2.use SyncFolders
|
104
115
|
b2.use CreateStack
|
105
116
|
b2.use CreateServer
|
106
117
|
b2.use Message, I18n.t('vagrant_openstack.ssh_disabled_provisioning') if ssh_disabled
|
107
|
-
|
118
|
+
unless ssh_disabled
|
119
|
+
# Handle legacy ssh_timeout option
|
120
|
+
timeout = env[:machine].provider_config.ssh_timeout
|
121
|
+
unless timeout.nil?
|
122
|
+
env[:machine].ui.warn I18n.t('vagrant_openstack.config.ssh_timeout_deprecated')
|
123
|
+
env[:machine].config.vm.boot_timeout = timeout
|
124
|
+
end
|
125
|
+
|
126
|
+
b2.use WaitForCommunicator
|
127
|
+
end
|
108
128
|
when :shutoff
|
109
129
|
b2.use StartServer
|
110
130
|
when :suspended
|
@@ -215,7 +235,6 @@ module VagrantPlugins
|
|
215
235
|
autoload :ProvisionWrapper, action_root.join('provision')
|
216
236
|
autoload :WaitForServerToStop, action_root.join('wait_stop')
|
217
237
|
autoload :WaitForServerToBeActive, action_root.join('wait_active')
|
218
|
-
autoload :WaitForServerToBeAccessible, action_root.join('wait_accessible')
|
219
238
|
|
220
239
|
private
|
221
240
|
|
@@ -82,6 +82,15 @@ module VagrantPlugins
|
|
82
82
|
incls << incl
|
83
83
|
end
|
84
84
|
|
85
|
+
# Create ssh params for rsync
|
86
|
+
# we need them as one string because rsync -e expects one string
|
87
|
+
ssh_params = [
|
88
|
+
"ssh -p #{ssh_info[:port]}",
|
89
|
+
'-o StrictHostKeyChecking=no',
|
90
|
+
'-o UserKnownHostsFile=/dev/null',
|
91
|
+
'-o IdentitiesOnly=yes',
|
92
|
+
"#{ssh_key_options(ssh_info)}"].join(' ')
|
93
|
+
|
85
94
|
# Rsync over to the guest path using the SSH info. add
|
86
95
|
# .hg/ and .git/ to exclude list as that isn't covered in
|
87
96
|
# --cvs-exclude
|
@@ -92,7 +101,7 @@ module VagrantPlugins
|
|
92
101
|
'--exclude', '.git/',
|
93
102
|
'--chmod', 'ugo=rwX',
|
94
103
|
*includes,
|
95
|
-
'-e',
|
104
|
+
'-e', ssh_params,
|
96
105
|
hostpath,
|
97
106
|
"#{ssh_info[:username]}@#{ssh_info[:host]}:#{guestpath}"]
|
98
107
|
command.compact!
|
@@ -73,8 +73,9 @@ module VagrantPlugins
|
|
73
73
|
# @return [String]
|
74
74
|
attr_accessor :ssh_username
|
75
75
|
|
76
|
-
# The SSH timeout use after server creation.
|
77
|
-
#
|
76
|
+
# The SSH timeout use after server creation.
|
77
|
+
#
|
78
|
+
# Deprecated. Use config.vm.boot_timeout instead.
|
78
79
|
#
|
79
80
|
# @return [Integer]
|
80
81
|
attr_accessor :ssh_timeout
|
@@ -194,6 +195,10 @@ module VagrantPlugins
|
|
194
195
|
# @return [HttpConfig]
|
195
196
|
attr_accessor :http
|
196
197
|
|
198
|
+
#
|
199
|
+
# @return [Boolean]
|
200
|
+
attr_accessor :meta_args_support
|
201
|
+
|
197
202
|
def initialize
|
198
203
|
@password = UNSET_VALUE
|
199
204
|
@openstack_compute_url = UNSET_VALUE
|
@@ -235,6 +240,7 @@ module VagrantPlugins
|
|
235
240
|
@server_delete_timeout = UNSET_VALUE
|
236
241
|
@stack_create_timeout = UNSET_VALUE
|
237
242
|
@stack_delete_timeout = UNSET_VALUE
|
243
|
+
@meta_args_support = UNSET_VALUE
|
238
244
|
@http = HttpConfig.new
|
239
245
|
end
|
240
246
|
|
@@ -309,15 +315,17 @@ module VagrantPlugins
|
|
309
315
|
@ssh_disabled = false if @ssh_disabled == UNSET_VALUE
|
310
316
|
|
311
317
|
# The SSH values by default are nil, and the top-level config
|
312
|
-
# `config.ssh` values are used.
|
318
|
+
# `config.ssh` and `config.vm.boot_timeout` values are used.
|
313
319
|
@ssh_username = nil if @ssh_username == UNSET_VALUE
|
314
|
-
@ssh_timeout =
|
320
|
+
@ssh_timeout = nil if @ssh_timeout == UNSET_VALUE
|
321
|
+
|
315
322
|
@server_create_timeout = 200 if @server_create_timeout == UNSET_VALUE
|
316
323
|
@server_active_timeout = 200 if @server_active_timeout == UNSET_VALUE
|
317
324
|
@server_stop_timeout = 200 if @server_stop_timeout == UNSET_VALUE
|
318
325
|
@server_delete_timeout = 200 if @server_delete_timeout == UNSET_VALUE
|
319
326
|
@stack_create_timeout = 200 if @stack_create_timeout == UNSET_VALUE
|
320
327
|
@stack_delete_timeout = 200 if @stack_delete_timeout == UNSET_VALUE
|
328
|
+
@meta_args_support = false if @meta_args_support == UNSET_VALUE
|
321
329
|
@networks = nil if @networks.empty?
|
322
330
|
@volumes = nil if @volumes.empty?
|
323
331
|
@stacks = nil if @stacks.empty?
|
@@ -22,7 +22,7 @@ module VagrantPlugins
|
|
22
22
|
# Run a custom action called "read_ssh_info" which does what it
|
23
23
|
# says and puts the resulting SSH info into the `:machine_ssh_info`
|
24
24
|
# key in the environment.
|
25
|
-
env = @machine.action('read_ssh_info')
|
25
|
+
env = @machine.action('read_ssh_info', lock: false)
|
26
26
|
env[:machine_ssh_info]
|
27
27
|
end
|
28
28
|
|
@@ -30,7 +30,7 @@ module VagrantPlugins
|
|
30
30
|
# Run a custom action we define called "read_state" which does
|
31
31
|
# what it says. It puts the state in the `:machine_state_id`
|
32
32
|
# key in the environment.
|
33
|
-
env = @machine.action('read_state')
|
33
|
+
env = @machine.action('read_state', lock: false)
|
34
34
|
|
35
35
|
state_id = env[:machine_state_id]
|
36
36
|
|
data/locales/en.yml
CHANGED
@@ -132,6 +132,10 @@ en:
|
|
132
132
|
standard vagrant configuration option `config.ssh.username` instead
|
133
133
|
ssh_username_required: |-
|
134
134
|
vagrant standard configuration option `ssh.username` is required
|
135
|
+
ssh_timeout_deprecated: |-
|
136
|
+
ssh_timeout provider config is deprecated for vagrant-openstack provider.
|
137
|
+
If you are using it, it will continue to work but we recommend switching
|
138
|
+
to the standard vagrant configuration option `config.vm.boot_timeout`.
|
135
139
|
invalid_value_for_parameter: |-
|
136
140
|
Invalid value '%{value}' for parameter '%{parameter}'
|
137
141
|
|
@@ -111,7 +111,7 @@ describe VagrantPlugins::Openstack::Action::SyncFolders do
|
|
111
111
|
'--chmod',
|
112
112
|
'ugo=rwX',
|
113
113
|
'-e',
|
114
|
-
"ssh -p 23 -o StrictHostKeyChecking=no -i '/tmp/key.pem' ",
|
114
|
+
"ssh -p 23 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -i '/tmp/key.pem' ",
|
115
115
|
'/home/john/vagrant/',
|
116
116
|
'user@1.2.3.4:/vagrant',
|
117
117
|
'--exclude-from',
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-openstack-provider
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guillaume Giamarchi
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-04-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -29,14 +29,14 @@ dependencies:
|
|
29
29
|
name: rest-client
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - ~>
|
32
|
+
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: 1.6.0
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - ~>
|
39
|
+
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: 1.6.0
|
42
42
|
- !ruby/object:Gem::Dependency
|
@@ -85,84 +85,84 @@ dependencies:
|
|
85
85
|
name: rake
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- -
|
88
|
+
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '0'
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- -
|
95
|
+
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: rspec
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
|
-
- - ~>
|
102
|
+
- - "~>"
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: 3.1.0
|
105
105
|
type: :development
|
106
106
|
prerelease: false
|
107
107
|
version_requirements: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
|
-
- - ~>
|
109
|
+
- - "~>"
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: 3.1.0
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
113
|
name: rspec-its
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
|
-
- - ~>
|
116
|
+
- - "~>"
|
117
117
|
- !ruby/object:Gem::Version
|
118
118
|
version: 1.0.1
|
119
119
|
type: :development
|
120
120
|
prerelease: false
|
121
121
|
version_requirements: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
|
-
- - ~>
|
123
|
+
- - "~>"
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: 1.0.1
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: rspec-expectations
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
|
-
- - ~>
|
130
|
+
- - "~>"
|
131
131
|
- !ruby/object:Gem::Version
|
132
132
|
version: 3.1.2
|
133
133
|
type: :development
|
134
134
|
prerelease: false
|
135
135
|
version_requirements: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
|
-
- - ~>
|
137
|
+
- - "~>"
|
138
138
|
- !ruby/object:Gem::Version
|
139
139
|
version: 3.1.2
|
140
140
|
- !ruby/object:Gem::Dependency
|
141
141
|
name: webmock
|
142
142
|
requirement: !ruby/object:Gem::Requirement
|
143
143
|
requirements:
|
144
|
-
- - ~>
|
144
|
+
- - "~>"
|
145
145
|
- !ruby/object:Gem::Version
|
146
146
|
version: 1.18.0
|
147
147
|
type: :development
|
148
148
|
prerelease: false
|
149
149
|
version_requirements: !ruby/object:Gem::Requirement
|
150
150
|
requirements:
|
151
|
-
- - ~>
|
151
|
+
- - "~>"
|
152
152
|
- !ruby/object:Gem::Version
|
153
153
|
version: 1.18.0
|
154
154
|
- !ruby/object:Gem::Dependency
|
155
155
|
name: fakefs
|
156
156
|
requirement: !ruby/object:Gem::Requirement
|
157
157
|
requirements:
|
158
|
-
- - ~>
|
158
|
+
- - "~>"
|
159
159
|
- !ruby/object:Gem::Version
|
160
160
|
version: 0.5.2
|
161
161
|
type: :development
|
162
162
|
prerelease: false
|
163
163
|
version_requirements: !ruby/object:Gem::Requirement
|
164
164
|
requirements:
|
165
|
-
- - ~>
|
165
|
+
- - "~>"
|
166
166
|
- !ruby/object:Gem::Version
|
167
167
|
version: 0.5.2
|
168
168
|
description: Enables Vagrant to manage machines in OpenStack Cloud.
|
@@ -173,8 +173,8 @@ executables: []
|
|
173
173
|
extensions: []
|
174
174
|
extra_rdoc_files: []
|
175
175
|
files:
|
176
|
-
- .gitignore
|
177
|
-
- .rubocop.yml
|
176
|
+
- ".gitignore"
|
177
|
+
- ".rubocop.yml"
|
178
178
|
- CHANGELOG.md
|
179
179
|
- Gemfile
|
180
180
|
- LICENSE
|
@@ -205,7 +205,6 @@ files:
|
|
205
205
|
- lib/vagrant-openstack-provider/action/stop_server.rb
|
206
206
|
- lib/vagrant-openstack-provider/action/suspend.rb
|
207
207
|
- lib/vagrant-openstack-provider/action/sync_folders.rb
|
208
|
-
- lib/vagrant-openstack-provider/action/wait_accessible.rb
|
209
208
|
- lib/vagrant-openstack-provider/action/wait_active.rb
|
210
209
|
- lib/vagrant-openstack-provider/action/wait_stop.rb
|
211
210
|
- lib/vagrant-openstack-provider/catalog/openstack_catalog.rb
|
@@ -256,7 +255,6 @@ files:
|
|
256
255
|
- spec/vagrant-openstack-provider/action/stop_server_spec.rb
|
257
256
|
- spec/vagrant-openstack-provider/action/suspend_server_spec.rb
|
258
257
|
- spec/vagrant-openstack-provider/action/sync_folders_spec.rb
|
259
|
-
- spec/vagrant-openstack-provider/action/wait_accessible_spec.rb
|
260
258
|
- spec/vagrant-openstack-provider/action/wait_active_spec.rb
|
261
259
|
- spec/vagrant-openstack-provider/action/wait_stop_spec.rb
|
262
260
|
- spec/vagrant-openstack-provider/action_spec.rb
|
@@ -293,17 +291,17 @@ require_paths:
|
|
293
291
|
- lib
|
294
292
|
required_ruby_version: !ruby/object:Gem::Requirement
|
295
293
|
requirements:
|
296
|
-
- -
|
294
|
+
- - ">="
|
297
295
|
- !ruby/object:Gem::Version
|
298
296
|
version: '0'
|
299
297
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
300
298
|
requirements:
|
301
|
-
- -
|
299
|
+
- - ">="
|
302
300
|
- !ruby/object:Gem::Version
|
303
301
|
version: '0'
|
304
302
|
requirements: []
|
305
303
|
rubyforge_project:
|
306
|
-
rubygems_version: 2.
|
304
|
+
rubygems_version: 2.4.5.1
|
307
305
|
signing_key:
|
308
306
|
specification_version: 4
|
309
307
|
summary: Enables Vagrant to manage machines in OpenStack Cloud.
|
@@ -322,7 +320,6 @@ test_files:
|
|
322
320
|
- spec/vagrant-openstack-provider/action/stop_server_spec.rb
|
323
321
|
- spec/vagrant-openstack-provider/action/suspend_server_spec.rb
|
324
322
|
- spec/vagrant-openstack-provider/action/sync_folders_spec.rb
|
325
|
-
- spec/vagrant-openstack-provider/action/wait_accessible_spec.rb
|
326
323
|
- spec/vagrant-openstack-provider/action/wait_active_spec.rb
|
327
324
|
- spec/vagrant-openstack-provider/action/wait_stop_spec.rb
|
328
325
|
- spec/vagrant-openstack-provider/action_spec.rb
|
@@ -1,61 +0,0 @@
|
|
1
|
-
require 'log4r'
|
2
|
-
|
3
|
-
module VagrantPlugins
|
4
|
-
module Openstack
|
5
|
-
module Action
|
6
|
-
class WaitForServerToBeAccessible < AbstractAction
|
7
|
-
def initialize(app, env, resolver = nil, ssh = nil)
|
8
|
-
@logger = Log4r::Logger.new('vagrant_openstack::action::wait_accessible')
|
9
|
-
@app = app
|
10
|
-
@ssh = ssh || Vagrant::Action::Builtin::SSHRun.new(app, env)
|
11
|
-
@resolver = resolver || VagrantPlugins::Openstack::ConfigResolver.new
|
12
|
-
end
|
13
|
-
|
14
|
-
def execute(env)
|
15
|
-
waiting_for_server_to_be_reachable(env)
|
16
|
-
@logger.info 'The server is ready'
|
17
|
-
env[:ui].info(I18n.t('vagrant_openstack.ready'))
|
18
|
-
@app.call(env)
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def waiting_for_server_to_be_reachable(env)
|
24
|
-
return if env[:interrupted]
|
25
|
-
ssh_timeout = env[:machine].provider_config.ssh_timeout
|
26
|
-
return if server_is_reachable?(env, ssh_timeout)
|
27
|
-
env[:ui].error(I18n.t('vagrant_openstack.timeout'))
|
28
|
-
fail Errors::SshUnavailable, host: @resolver.resolve_floating_ip(env), timeout: ssh_timeout
|
29
|
-
end
|
30
|
-
|
31
|
-
def server_is_reachable?(env, timeout)
|
32
|
-
start_time = Time.now
|
33
|
-
current_time = start_time
|
34
|
-
nb_retry = 0
|
35
|
-
|
36
|
-
while (current_time - start_time) <= timeout
|
37
|
-
@logger.debug "Checking if SSH port is open... Attempt number #{nb_retry}"
|
38
|
-
if nb_retry % 5 == 0
|
39
|
-
@logger.info 'Waiting for SSH to become available...'
|
40
|
-
env[:ui].info(I18n.t('vagrant_openstack.waiting_for_ssh'))
|
41
|
-
end
|
42
|
-
|
43
|
-
env[:ssh_run_command] = 'exit 0'
|
44
|
-
env[:ssh_opts] = {
|
45
|
-
extra_args: ['-o', 'BatchMode=yes']
|
46
|
-
}
|
47
|
-
@ssh.call(env)
|
48
|
-
return true if env[:ssh_run_exit_status] == 0
|
49
|
-
|
50
|
-
@logger.debug 'SSH not yet available... new retry in in 1 second'
|
51
|
-
nb_retry += 1
|
52
|
-
sleep 1
|
53
|
-
current_time = Time.now
|
54
|
-
end
|
55
|
-
|
56
|
-
false
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
require 'vagrant-openstack-provider/spec_helper'
|
2
|
-
|
3
|
-
describe VagrantPlugins::Openstack::Action::WaitForServerToBeAccessible do
|
4
|
-
let(:config) do
|
5
|
-
double('config')
|
6
|
-
end
|
7
|
-
|
8
|
-
let(:env) do
|
9
|
-
{}.tap do |env|
|
10
|
-
env[:ui] = double('ui')
|
11
|
-
env[:ui].stub(:info).with(anything)
|
12
|
-
env[:ui].stub(:error).with(anything)
|
13
|
-
env[:machine] = double('machine').tap do |m|
|
14
|
-
m.stub(:provider_config) { config }
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
let(:resolver) do
|
20
|
-
double('resolver').tap do |r|
|
21
|
-
r.stub(:resolve_floating_ip).with(anything) { '1.2.3.4' }
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
let(:ssh) do
|
26
|
-
double('shh')
|
27
|
-
end
|
28
|
-
|
29
|
-
let(:app) do
|
30
|
-
double('app').tap do |app|
|
31
|
-
app.stub(:call).with(anything)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
class SSHMock
|
36
|
-
def initialize(*exit_codes)
|
37
|
-
@times = 0
|
38
|
-
@exit_codes = exit_codes
|
39
|
-
end
|
40
|
-
|
41
|
-
def call(env)
|
42
|
-
env[:ssh_run_exit_status] = @exit_codes[@times]
|
43
|
-
@times += 1
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe 'call' do
|
48
|
-
context 'when server is not yet reachable' do
|
49
|
-
it 'retry until server is reachable' do
|
50
|
-
config.stub(:ssh_timeout) { 2 }
|
51
|
-
expect(app).to receive(:call)
|
52
|
-
|
53
|
-
@action = WaitForServerToBeAccessible.new(app, nil, resolver, SSHMock.new(1, 0))
|
54
|
-
@action.call(env)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
context 'when server is not yet reachable after timeout' do
|
58
|
-
it 'raise an error' do
|
59
|
-
config.stub(:ssh_timeout) { 1 }
|
60
|
-
expect(app).should_not_receive(:call)
|
61
|
-
|
62
|
-
@action = WaitForServerToBeAccessible.new(app, nil, resolver, SSHMock.new(1, 1))
|
63
|
-
expect { @action.call(env) }.to raise_error Errors::SshUnavailable
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|